https://github.com/shojiyao12/tcp_congestion_control_simulation
A TCP Congestion Control Simulator in Python that models the behavior of Slow Start, Congestion Avoidance, Timeout, and Fast Retransmit. The program randomly introduces packet loss and congestion events to visualize how the Congestion Window (cwnd) changes dynamically over time.
https://github.com/shojiyao12/tcp_congestion_control_simulation
congestion-avoidance networking python slow-start tcp-congestion-control timeouts
Last synced: 7 months ago
JSON representation
A TCP Congestion Control Simulator in Python that models the behavior of Slow Start, Congestion Avoidance, Timeout, and Fast Retransmit. The program randomly introduces packet loss and congestion events to visualize how the Congestion Window (cwnd) changes dynamically over time.
- Host: GitHub
- URL: https://github.com/shojiyao12/tcp_congestion_control_simulation
- Owner: Shojiyao12
- Created: 2025-03-14T06:48:05.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-14T06:56:27.000Z (7 months ago)
- Last Synced: 2025-03-14T07:32:43.450Z (7 months ago)
- Topics: congestion-avoidance, networking, python, slow-start, tcp-congestion-control, timeouts
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TCP Congestion Control Simulation
This project simulates **TCP Congestion Control** mechanisms, illustrating how the **Congestion Window (cwnd)** changes over time in response to network events such as **timeouts, fast retransmissions, slow start, and congestion avoidance**.
## Quickstart Guide
### Running the Simulation
1. Copy all the contents from this repository.
2. Open a terminal and navigate to the folder containing `congestion.py`.
3. Run the program using:
```bash
python congestion.py
```
4. The simulation will:
- Print log entries showing **cwnd** changes due to different congestion control mechanisms.
- Plot a graph showing how **cwnd** evolves over **Round Trip Times (RTTs)**.## Core Concepts
- **Slow Start**: Doubles `cwnd` until it reaches `ssthresh`.
- **Congestion Avoidance**: Increases `cwnd` linearly after `ssthresh` is reached.
- **Timeouts**: Drops `cwnd` to `1` and updates `ssthresh`.
- **Fast Retransmit**: Quickly reduces `cwnd` but avoids a full restart.## Preview of Simulation Output
### **Log Output Example**
```bash
Slow start at RTT 0: cwnd=2, ssthresh=16
Slow start at RTT 1: cwnd=4, ssthresh=16
Congestion avoidance at RTT 5: cwnd=17, ssthresh=16
Timeout at RTT 10: cwnd=1, ssthresh=8
...
```### **Graph Example**
The simulation generates a graph plotting `cwnd` over **RTTs**, illustrating how congestion control operates dynamically.
## Notes:
- The probability of **timeouts** and **fast retransmits** is configurable within the script.
- The initial `ssthresh` value can be modified to observe different behaviors.
- The model follows the fundamental principles of **TCP Tahoe & Reno** congestion control.## Future Enhancements
- Implement **Selective Acknowledgments (SACK)** for a more advanced simulation.
- Add real-world **network trace integration**.
- Extend support for **TCP Cubic**.