A lightweight user-space TCP protocol implementation built on top of UDP, featuring handshake, timeout retransmission, sliding window flow control, reliable in-order delivery, congestion control, fast retransmit, multi-connection support, and a high-level socket-like API.
| Feature | Description |
|---|---|
| 3-way handshake | SYN / SYN+ACK / ACK connection establishment |
| 4-way termination | Full-duplex connection teardown |
| Dynamic RTO | Jacobson/Karels algorithm (RFC 6298) |
| Sliding window | Sender and receiver side flow control |
| Reliable delivery | In-order reassembly with out-of-order buffering |
| Congestion control | TCP Reno: slow start + AIMD |
| Fast retransmit | 3 duplicate ACKs triggers immediate retransmission |
| Multi-connection | Reactor pattern with epoll |
| High-level API | BSD-socket-like ReliableSocket wrapper |
For detailed protocol design and implementation notes, see Design.md.
- CMake ≥ 3.14
- g++ ≥ 9.0
- Linux / WSL environment
./build.sh./clean.shAll binaries are generated in ./build/. Switch to that directory before running any demo program.
Server:
ReliableSocket sock;
sock.listen(9000);
sock.accept();
auto data = sock.recv();
sock.close();Client:
ReliableSocket sock;
sock.connect("127.0.0.1", 9000);
sock.send(data);
sock.close();// sender side
send_file(connection, udp, "./path/to/file");
// receiver side
recv_file(connection, udp, "./path/to/output");Tested on loopback interface with tc netem network emulation. File size: 1.5 MB.
| Delay | Loss | Throughput | Time |
|---|---|---|---|
| 10ms | 0% | 10.64 Mbps | 1180ms |
| 10ms | 1% | 1.26 Mbps | 10001ms |
| 10ms | 5% | 0.80 Mbps | 15795ms |
| 50ms | 0% | 6.95 Mbps | 1808ms |
| 50ms | 1% | 0.64 Mbps | 19767ms |
| 50ms | 5% | 0.21 Mbps | 58844ms |
| 100ms | 0% | 3.59 Mbps | 3499ms |
| 100ms | 1% | 1.49 Mbps | 8429ms |
| 100ms | 5% | 0.18 Mbps | 69153ms |
To reproduce:
sudo bash scripts/run_stress_test.sh
python3 scripts/analyze_results.pySee the step-by-step guide: Wireshark Tutorial
- Name: Linfeng Zhang
- Email: linfengzh01@gmail.com
- School: UCSD — Computer Science and Engineering (Computer Engineering)
- Interests: System programming, networking, and backend infrastructure
