Menu

Building TCP From Scratch (1/6): Why bother when TCP exists?
📰

Building TCP From Scratch (1/6): Why bother when TCP exists?

DEV Community·Bhavesh Ghanchi·6 months ago
#60l2k7BO
#networking#java#systems#code#loss
Reading 0:00
15s threshold

What does the word "retransmit" actually mean? I thought I knew. I'd taken the networking class. I'd read the chapter. I could draw the slow-start curve on a whiteboard. Then I tried to write it and discovered I had no idea.

This is a series about rebuilding TCP from scratch in Java, and the parts of it I only understood after the code actually ran.

What I built

LEAP (Loss-aware End-to-end Acknowledged Protocol) is a TCP-style reliable transport I built from scratch on top of UDP. About 1,900 lines of Java. It has sequence numbers, cumulative ACKs, a sliding window, fast retransmit on three duplicate ACKs, adaptive RTO in the style of RFC 6298, slow start and AIMD congestion control with an ssthresh floor, and end-to-end SHA-256 integrity verification on every transfer.

There's a CLI:

./bin/leap receive --port 4040 --output /tmp/in ./bin/leap send myfile.bin --to localhost:4040

Enter fullscreen mode

Exit fullscreen mode

And a benchmark harness that sweeps file size × loss rate × trial across LEAP and…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.