Simulating TCP congestion control algorithms with ns-3 and visualizing the result with matplotlib.
| 日本語(Qiita) | haltaro |
I assume Linux system. You have to install:
Hereinafter, I assume ns-3.26 is installed in ~/ns-3.26/source/ns-3.26/.
Based on ns-3 implementation(~/ns-3.26/source/ns-3.26/src/internet/model/tcp-socket-base.cc), I assume the congestion states shown below:

Based on ns-3 implementation, I assume the congestion control algorithms shown below:
| Algorithm | TypeId |
source |
|---|---|---|
| NewReno | TcpNewReno |
tcp-congestion-ops.cc |
| HighSpeed | TcpHighSpeed |
tcp-highspeed.cc |
| Hybla | TcpHybla |
tcp-hybla.cc |
| Westwood | TcpWestwood |
tcp-westwood.cc |
| Westwood+ | TcpWestwoodPlus |
tcp-westwood.cc |
| Vegas | TcpVegas |
tcp-vegas.cc |
| Scalable | TcpScalable |
tcp-scalable.cc |
| Veno | TcpVeno |
tcp-veno.cc |
| Bic | TcpBic |
tcp-bic.cc |
| YeAH | TcpYeah |
tcp-yeah.cc |
| Illinois | TcpIllinois |
tcp-illinois.cc |
| H-TCP | TcpHtcp |
tcp-htcp.cc |
Make a new directry ~/ns-3.26/source/ns-3.26/data
Add compare-tcp-algorithms.sh and plottcpalgo.py to ~/ns-3.26/source/ns-3.26/
Add execute permission to compare-tcp-algorithms.sh and plottcpalgo.py
Add my-tcp-variants-comparison.cc to ~/ns-3.26/source/ns-3.26/scratch
Compile my-tcp-variants-comparison.cc by the command below:
$ cd ~ns-3.26/source/ns-3.26/
$ ./waf
compare-tcp-algorithms.shShell script to run ns-3 and call plottcpalgo.py.
my-tcp-variants-comparison.ccns-3 scenario script to simulate TCP congestion control. It’s based on tcp-variants-comparison.cc. I added tracing targets: ACK and congestion state.
plottcpalgo.pyPython script to manipulate and visualize data.
get_data(): Gets and manipulates data.plot_cwnd_ack_rtt_each_algorithm(): Plot cwnd, ACK, and RTT of each algorithm. It saves twelve data/Tcp{algorithm}{duration}-cwnd-ack-rtt.pngs.plot_cwnd_all_algorihtms(): Plot cwnd and ssthresh of all algorithms. It saves data/TcpAll{duration}-cwnd.png.Just run compare-tcp-algorithms.sh.
$ cd ~/ns-3.26/source/ns-3.26
$ ./compare-tcp-algorithms.sh

X-axis is time [s], and Y-axis is cwnd [segment]. The digit lines are cwnd, dotted lines are ssthresh. Colors are corresponding to congestion states: blue is OPNE, yellow is RECOVERY, and red is LOSS.












compare-tcp-algorithms and plottcpalgo.py: MITmy-tcp-variants-comparison.cc: GNU GPLv2