A custom Reliable User Datagram Protocol (RUDP) implemented in Python from scratch. This project was developed to provide TCP-like reliable data transfer services over inherently unreliable standard UDP sockets during te course of Computer Communication Networks at Tongji University. The project was completed in Spring Semester 2024-2025
The repository includes two distinct Automatic Repeat reQuest (ARQ) reliability mechanisms to compare their efficiency in bulk data transfers under simulated network loss.
The custom RUDP stack implements several core transport-layer functionalities:
- Custom Packet Structure: Binary packet packing/unpacking using Python's
structmodule (Sequence Numbers, Acknowledgment Numbers, Flags, Checksum). - Connection Management: TCP-style 3-way handshake (SYN, SYN-ACK, ACK) for connection establishment and graceful termination (FIN/ACK).
- Data Integrity: 16-bit one's complement checksum validation to detect data corruption.
- Timeout & Retransmission: Dynamic timer management to recover from dropped packets or lost acknowledgments.
- Packet Loss Simulation: Built-in logic to artificially drop packets and test protocol resilience.
- Stop-and-Wait: A fundamental ARQ protocol where the sender transmits one segment at a time and waits for an explicit ACK before proceeding.
- Go-Back-N (Sliding Window): An advanced pipelined protocol allowing up to N unacknowledged packets in flight, utilizing cumulative ACKs to drastically improve channel utilization.
The protocols were benchmarked by transferring a ~97 KB text file ("The Little Prince") over localhost, with a simulated packet loss probability of 10% (0.1) and a payload size of 1024 bytes.
| Metric | Stop-and-Wait RUDP | Go-Back-N RUDP (Window = 4) |
|---|---|---|
| Total Duration | 21.11 seconds | 0.013 seconds |
| Effective Throughput | 36.84 Kbps | 63.82 Mbps |
Conclusion: The Go-Back-N implementation outperformed the Stop-and-Wait approach by orders of magnitude. By keeping the "network pipe" full and avoiding the Round-Trip Time (RTT) idle penalty for every single packet, the sliding window protocol successfully mitigates the severe performance limits of Stop-and-Wait, efficiently handling timeouts and retransmissions.
src/: Contains the Python source code for both the sender and receiver modules (sender_sliding_windows.py,receiver_stop_and_wait.py, etc.).docs/: Contains the detailed technical report discussing the architectural choices, packet header design, and performance evaluation.
- Clone the repository.
- Open two separate terminal windows.
- Start the receiver first:
python src/receiver_sliding_windows.py
- Start the sender to initiate the 3-way handshake and the file transfer:
python src/sender_sliding_windows.py
(Note: Ensure you have a sample text file in the working directory to be transmitted).