Master the fundamental concepts of tcp/ip from scratch through this focused micro-challenge.
Once TCP is established, data flows as a reliable byte stream. Each byte gets a sequence number. For example, sending 100 bytes starting at SEQ 1000 means the receiver ACKs with 1100 (the next expected byte).
1000, 100 bytes of payload11001100, next 100 bytes1200If segments arrive out of order (SEQ 1200 before 1100), the receiver buffers the gap and waits. Duplicate ACKs for the last in-order byte (three in a row) trigger fast retransmit.
A TCP segment is header (20+ bytes) plus payload up to MSS. On Ethernet, MSS is typically 1460 bytes (1500 MTU minus 20-byte IP header minus 20-byte TCP header). The sender cannot exceed the receiver's advertised window.
This task asks you to simulate data transfer with printed SEQ/ACK pairs. The Linux kernel's tcp_sock struct maintains this same bookkeeping per connection, and Wireshark's "Follow TCP Stream" reconstructs it from captured segments. Production stalls from Nagle's algorithm interacting with delayed ACKs trace directly back to misunderstanding this sequence-number accounting on port 80 and other TCP services.
Implement a simulation of TCP data transfer with sequence numbers and ACKs.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github