This is a comparison between two old TCP variants: TCP Tahoe and TCP Reno, using the ns-3 simulator.
Over the years, many TCP variants have been developed, each trying to improve the performance of the predecessor, given the right conditions. Most of them have become highly sophisticated. Still, it can be interesting to look at two of the first TCP variants: TCP Tahoe and TCP Reno and see the basic components of any TCP variant.
TCP Tahoe is the first TCP variant to consider the issue of congestion. It's mechanism is very simple and can be easily understood. This makes it a good starting point to understand how TCP works. It uses
- slow start: it doubles the congestion window every RTT.
- congestion avoidance: it increases the congestion window by 1 every RTT.
- fast retransmit: it detects packet loss by checking if the next packet is received.
TCP Reno is the first TCP variant to be standardized. It is a newer TCP variant than TCP Tahoe and uses a more complex mechanism to handle congestion. Apart from the slow start and congestion avoidance mechanisms, it uses:
- fast recovery: it recovers from packet loss by halving the congestion window instead of going straight in the slow start phase.
The simulation uses the ns-3 simulator, and has been developed and tested with the version 3.37.
First, make sure you have already completed all the step required for the installation of the simulator shown here.
The directory structure should look something like this:
.
└── ns-allinone-3.37/
└── ns-3.37/
├── ns3
├── examples/
├── src/
├── scratch/
└── ...
Move to the scratch
folder and clone the repository:
cd ns-allinone-3.37/ns-3.37/scratch
git clone [email protected]:TendTo/ns3-Tahoe-vs-Reno.git
Lastly, move back to the ns-3.37
folder and build the simulation:
cd ..
./ns3 run "p2p-project --PrintHelp"
The simulation is highly configurable. The following options are available:
Usage: ./ns3 run "p2p-project [options]"
Program Options:
--n_tcp_tahoe: Number of Tcp Tahoe nodes [1]
--n_tcp_reno: Number of Tcp Reno nodes [1]
--s_buf_size: Sender buffer size (bytes) [131072]
--r_buf_size: Receiver buffer size (bytes) [131072]
--cwnd: Initial congestion window (segments) [1]
--ssthresh: Initial slow start threshold (segments) [65535]
--mtu: Size of IP packets to send (bytes) [1500]
--sack: Enable SACK [true]
--nagle: Enable Nagle algorithm [false]
--error_p: Packet error rate [0]
--s_bandwidth: Sender link bandwidth [10Mbps]
--s_delay: Sender link delay [40ms]
--r_bandwidth: Receiver link bandwidth [10Mbps]
--r_delay: Receiver link delay [40ms]
--tcp_queue_size: TCP queue size (packets) [25]
--run: Run id [0]
--duration: Duration of the simulation (s) [3]
--max_mbytes_to_send: Maximum number of megabytes to send (MB) [0]
--prefix_file_name: Prefix file name [P2P-project]
--graph_output: The type of image to output: png, svg [png]
--ascii_tracing: Enable ASCII tracing [false]
--pcap_tracing: Enable Pcap tracing [false]
General Arguments:
--PrintGlobals: Print the list of globals.
--PrintGroups: Print the list of groups.
--PrintGroup=[group]: Print all TypeIds of group.
--PrintTypeIds: Print all TypeIds.
--PrintAttributes=[typeid]: Print all attributes of typeid.
--PrintVersion: Print the ns-3 version.
--PrintHelp: Print this help message.
The following are some example usages of the simulation with the output graphs.
./ns3 run "p2p-project --n_tcp_tahoe=1 --n_tcp_reno=0 --error_p=0.001 --run=0 --duration=10"
flowchart LR
r{{router}}
n0[Node 0\nTCP Tahoe]
i((Receiver))
r <--Random loss--> i
n0 <----> r
./ns3 run "p2p-project --n_tcp_tahoe=0 --n_tcp_reno=1 --error_p=0.001 --run=0 --duration=10"
flowchart LR
r{{router}}
n0[Node 0\nTCP Reno]
i((Receiver))
r <--Random loss--> i
n0 <----> r
./ns3 run "p2p-project --n_tcp_tahoe=1 --n_tcp_reno=1 --error_p=0.002 --run=1 --duration=10"
flowchart LR
r{{router}}
n0[Node 0\nTCP Tahoe]
n1[Node 1\nTCP Reno]
i((Receiver))
r <--Random loss--> i
n0 <----> r
n1 <----> r
./ns3 run "p2p-project --n_tcp_tahoe=2 --n_tcp_reno=2 --run=0 --duration=10"
flowchart LR
r{{router}}
n0[Node 0\nTCP Tahoe]
n1[Node 1\nTCP Tahoe]
n2[Node 2\nTCP Reno]
n3[Node 3\nTCP Reno]
i((Receiver))
r <----> i
n0 <----> r
n1 <----> r
n2 <----> r
n3 <----> r
TCP Tahoe and TCP Reno are very similar. The main difference is that TCP Reno uses a fast retransmit mechanism to detect packet loss and a fast recovery mechanism to recover from packet loss and follows up with a fast recovery phase.
This means that, in most cases, TCP Reno outperforms TCP Tahoe.