This repository contains implementations of the following network protocols as part of a programming assignment:
- RDT 2.2 (NAK-Free Reliable Data Transfer) Protocol
- RDT 3.0 (Reliable Data Transfer Over a Lousy Channel) Protocol
- TCP Tahoe Congestion Control Mechanism
- TCP Reno Congestion Control Mechanism
These implementations are written in Python and aim to simulate the specified protocols with configurable parameters, logging, and (where applicable) visualization.
- Overview
- Implementation Details
- Files
- Usage
- Parameters
- Testing
- Deliverables
- Report
- Contributing
- License
This project fulfills the requirements of a programming assignment focusing on reliable data transfer (RDT) and TCP congestion control protocols. Each implementation includes:
- Packet structures with sequence numbers, payloads, and checksums.
- Unreliable channel simulations with configurable error and loss rates.
- Finite State Machines (FSMs) for sender and receiver behavior.
- Timer mechanisms for retransmissions (RDT 3.0).
- Logging of state transitions, packet handling, and (for TCP) congestion window evolution.
- Optional visualization of TCP congestion window behavior.
- RDT 2.2: A stop-and-wait protocol that handles bit errors with ACKs, retransmitting on duplicate ACKs.
- RDT 3.0: Extends RDT 2.2 with packet loss handling and a timer-based retransmission mechanism.
- TCP Tahoe: Simulates congestion control with slow start, congestion avoidance, and a reset to 1 MSS on loss.
- TCP Reno: Adds fast recovery to TCP Tahoe, adjusting cwnd on triple duplicate ACKs.
All implementations use Python for simplicity and include logging for debugging and analysis.
rdt_2.2.py: Implementation of RDT 2.2 protocol.rdt_3.0.py: Implementation of RDT 3.0 protocol.tcp_tahoe.py: Simulation of TCP Tahoe congestion control.tcp_reno.py: Simulation of TCP Reno congestion control.README.md: This file.report.pdf: A 2-3 page report (to be added) detailing the implementation, parameter choices, and sample outputs.
-
Prerequisites:
- Python 3.x
- For TCP implementations, install matplotlib:
pip install matplotlib
-
Running the Code:
- Navigate to the directory containing the script (e.g.,
rdt_3.0.py). - Run
python rdt_3.0.pyin the terminal. - Follow prompts to input messages (type "done" to finish).
- Navigate to the directory containing the script (e.g.,
-
TCP Visualization:
- Run
python tcp_tahoe.pyorpython tcp_reno.pyto see a plot of the congestion window.
- Run
- RDT 2.2 and 3.0:
error_rate: Probability of bit corruption (default 0.2 for RDT 3.0, adjustable inNetworkChannel).loss_rate: Probability of packet loss (default 0.1 for RDT 3.0, not applicable in RDT 2.2).- Timer duration: 2 seconds in RDT 3.0 (adjustable in
time.sleep()).
- TCP Tahoe and Reno:
mss: Maximum Segment Size (default 1).initial_ssthresh: Initial slow start threshold (default 8).max_rtt: Maximum simulation rounds (default 50).loss_interval: Interval for loss events (default 15 or 8 to match graphs).
Modify these values in the main() function of each script.
- Test RDT protocols by inputting multiple messages and varying
error_rateandloss_rateto observe retransmissions and error handling. - Test TCP protocols by adjusting
loss_intervaland observing the saw-tooth pattern in the generated plots. - Sample outputs are logged to the console; graphical results are displayed for TCP simulations.
- Source code files (
rdt_2.2.py,rdt_3.0.py,tcp_tahoe.py,tcp_reno.py). - A
report.pdfincluding:- Description of each implementation.
- Rationale for parameter choices (e.g., error rates, timer duration).
- Sample console outputs and graphical results for TCP.
The report is a 2-3 page PDF document detailing:
- Implementation approach for each protocol.
- Parameter selections and their impact.
- Sample logs and plots (e.g., TCP Tahoe/Reno saw-tooth behavior).
- Observations from testing under various error and loss conditions.