Advertisement

Implementing TCP in Rust (part 1)

Implementing TCP in Rust (part 1) In this stream, we started implementing the ubiquitous TCP protocol that underlies much of the traffic on the internet! In particular, we followed RFC 793 — — which describes the original protocol, with the goal of being able to set up and tear down a connection with a "real" TCP stack at the other end (netcat in particular). We're writing it using a user-space networking interface (see and the Rust bindings at

We got decently far, and are now able to both establish an incoming TCP connection (i.e., perform the TCP three-way handshake) and terminate the connection cleanly. You can find the current code at There's still a long way to go though, as we still need to add support for data segments, retransmissions, and timers; so that's what we'll cover in the next stream! Eventually, we will also want to implement RFC 1122 — — which lays out a number of further enhancements that must be made in order to interoperate nicely on the internet. This is also discussed in RFC 7414: which we're also aiming to support.

You can see the live version with comments at

rust,live-coding,tcp,internet,protocols,

Post a Comment

0 Comments