Skip to content

thierry-gx/rudp-python-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reliable UDP (RUDP) Protocol Implementation

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.

Core Features

The custom RUDP stack implements several core transport-layer functionalities:

  • Custom Packet Structure: Binary packet packing/unpacking using Python's struct module (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.

Implemented ARQ Protocols

  1. Stop-and-Wait: A fundamental ARQ protocol where the sender transmits one segment at a time and waits for an explicit ACK before proceeding.
  2. 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.

Performance Analysis & Results

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.

Repository Structure

  • 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.

How to Run

  1. Clone the repository.
  2. Open two separate terminal windows.
  3. Start the receiver first:
    python src/receiver_sliding_windows.py
  4. 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).

About

Python implementation of a Reliable User Datagram Protocol (RUDP) over standard UDP sockets, featuring Stop-and-Wait and Go-Back-N (Sliding Window) ARQ mechanisms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages