This is a TCP implementation based on RFC 793 https://www.rfc-editor.org/rfc/rfc793.html
In one terminal, run the server script:
./run.shThe server will start and listen for TCP connections on the tun0 interface.

In another terminal, set up tshark to view the network handshake and TCP metrics:
sudo tshark -i tun0This will capture and display all network packets on the tun0 interface, allowing you to see the TCP handshake and communication details.

in another terminal You can test the server with either of these approaches:
echo "foo" | nc 192.168.0.2 8000Expected output:
hello from rust-tcp!
This sends "foo" to the server, which reads it and closes the connection immediately.
nc 192.168.0.2 8000Then type messages interactively:
read
write to me
ok good job
- Option 1: Sends a single message. The server reads it and stops immediately. This results in minimal packet exchange.
Follow this learning path to understand the implementation:
-
RFC 1180 - TCP/IP Protocol Suite Tutorial (Overview)
- https://datatracker.ietf.org/doc/html/rfc1180?hl=en-US
- Start here for a high-level understanding of TCP/IP concepts
-
YouTube: TCP Trace Files & Packet Analysis (Video)
- https://youtu.be/xdQ9sgpkrX8?si=gzkFGBdGDD7ZlaTm
- Learn how to read TCP traces, understand handshakes, and track packet flow between client and server
-
YouTube: TCP Deep Dive (Video)
- https://youtu.be/rmFX1V49K8U?si=eZzkhkJYzu3nWxxK
- Reinforces key terminologies and packet movement concepts
RFC 793 - Transmission Control Protocol ⭐ MAIN REFERENCE
- https://www.rfc-editor.org/rfc/rfc793.html
- The primary specification for this implementation
- Essential reading for understanding the code architecture
-
RFC 791 - Internet Protocol (Optional)
- https://www.rfc-editor.org/rfc/rfc791.html
- Provides context on the IP layer that TCP operates over
-
YouTube: TCP Retransmission (Advanced)
- https://youtu.be/NdvWI6RH1eo?si=eU5co2Itd41YWbpH
- Deep dive into retransmission mechanisms and timeout handling