Hacker News new | past | comments | ask | show | jobs | submit login
Implementing TCP in Rust (github.com/ghvstcode)
136 points by mooreds on Nov 9, 2023 | hide | past | favorite | 27 comments



I only read the README so far but I'm not sure if the author realizes that the RFC793 being repeatedly referred to has been obsoleted by RFC9293. I encourage people needing a reference to TCP to start with RFC9293 instead. This is the updated specification that brings together changes from a number of previous RFCs.


It's based on the videos from Jon Gjengset from 4 years ago and he used RFC793. RFC9293 has a publish date of August 2022


[flagged]


While I agree with you in most other cases I've seen (this happens a lot), parent wasn't necessarily ragging on the dev, just adding a useful note. I found it helpful, as I wasn't aware there was an updated specification.


Is it a case of one just being monstrously easier? Like how everyone makes an HTTP1.1 server but never a higher version.


9293 takes 953 and incorporates the errata (20 of them) and 6 other RFCS, so in that sense it's easier since you don't have to check elsewhere for bugs or updates.

953 is 85 pages. 9293 is also 85 pages (with 13 pages of appendix), although they switched to a proportional font for the PDF so there's probably more text.


HTTP1.1 was the standard for decades (1990-2015, technically still extant). People usually just "stop there" because it's what the majority of browsers and devices were targeted to support and does "just enough" of what they're seeking.

Of course you would make an HTTP/2 server, if you were looking for active push support and the like.


Also, HTTP/1 is amazingly simple compared to HTTP/2.

I can write you an HTTP/1 server in bash in an hour or two.


no, HTTP/1.1 was RFC 2068, then RFC 2616, now most recently RFC 7231. it's still the same protocol, but with updates and clarifications from over the years.


This was going to be a statement in support, read the classics / rfc793. Priors being you should definitely implement http from the RFC a la 199x, and:

I assumed rfc793 was shorter than 9293; false. 9293 is significantly shorter.

9293 also has a lot of implementation notes from the past.. many years of folks that have done this.

So yeah, 9293. Seems like a solid rec.


Ah yes, the classics. The Illiad, the Odyssey and of course RFC793.


There was nothing backhanded about that, that was useful relevant information.


Should my shit ever make it to HN, I would be happy for it to get scrutinized by people smarter than me, even for basic stuff. The HN crowd is mostly polite in its criticisms and acknowledges good work. That is, unless you write something like a Rust web framework that's full in unsafes and claim it to be the fastest...


You seem like the type to take criticisms well.


There is also the Rust TCP/IP stack https://github.com/smoltcp-rs/smoltcp which is not mentioned as reference (and it's probably more useful to have a look there than querying ChatGPT).


ICYMI but https://datatracker.ietf.org/doc/html/rfc9293 may be a better place to start in 2023.


Oh nice. Just today I started watching Jon Gjengset's video implementing TCP in Rust https://youtu.be/bzja9fQWzdA?si=Gh4s8FHpk9vBVEwZ


There needs to be a statue built for this man. My understanding of Rust and low level computing has become oceanic due this man's hours of videos and books.


This is a great initiative to help people understand how TCP works.

But an "implementing TCP in <an easy, readable language such as Python>" would be so much better IMHO. Rust is good, but not as readable pseudo-code to understand a concept.


As someone who programs both Python and Rust I found the Rust version very clear. And I would not use Python for this kind of programming.


This is something similar: https://implement-dns.wizardzines.com/



Also https://tokio.rs/tokio/tutorial has something similar


Can you please add proper error messages, because this is the main problem I have with all networking related issues: I don't get any error messages, just a dead connection.


The TCP RFC (circa 1974) has an example API with more meaningful error messages than the BSD socket (circa 1982) API.


Break that glass with Wireshark/tcpdump behind it.


Thanks for sharing. I look forward to going through this content.


At certain point, I tends to avoid this kind of tutorial because if you understand both topic well there is no reason why you need to learn implementing X in Y.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: