What a home-made TCP stack in Python teaches
Summary
Julia Evans implements parts of TCP in Python and makes sequence numbers, acknowledgements, retransmissions and states experimentally visible. The experiment uses Python and Linux. Scapy helps with creating and reading packets.
Ideas
- Raw packets allow your own transport logic in user space.
- Sequence numbers order bytes rather than individual packets.
- Acknowledgements report the next expected range of bytes.
- Packet loss requires timers and retransmission.
Insights
- Protocols become understandable through your own minimal implementations.
- Reliability arises over an unreliable network through state.
- Kernel abstractions hide complexity that diagnosis sometimes needs.
Facts
- The kernel TCP stack has to be bypassed for test connections.
Recommendations
- Only experiment on isolated networks.
- Analyse packets in parallel with tcpdump or Wireshark.
References
Links to the original source and the Web Archive open in a new tab.