Having experimented a bit with TCP over MANETs in ns-2, I’ve made some learning points. I try to distillate these below.
Firstly, ns-2 has both one-way and two-way implementations of TCP to be employed. The two-way TCP only implements the Reno congestion avoidance algorithm, but on the other hand provides full establishment and tear-down procedures. The one-way TCP with a TCP sink as the destination can be used with several congestion avoidance implementations. Among these are Tahoe, Reno, Newreno, Vegas and Linux. I have experimented mostly with Tahoe, Reno and Newreno. Tahoe is the first implementation of TCP’s congestion control. The difference between Tahoe and Reno is that Reno implements fast retransmit and recovery upon receiving three duplicate ACKs. The difference between Reno and Newreno is that Newreno allows new retransmissions during the fast recovery phase, to keep the transmit window full.
TCP can be used by the FTP agent as follows:
set tcp(0) [new Agent/TCP/Newreno]
set sink(0) [new Agent/TCPSink]
set ftp(0) [new Application/FTP]
$ns_ attach-agent $node_(0) $tcp(0)
$ns_ attach-agent $node_(1) $sink(0)
$ns_ connect $tcp(0) $sink(0)
$ftp(0) set packetSize_ 1024
$ftp(0) set random_ 1
$ftp(0) attach-agent $tcp(0)
$ns_ at $opt(ftpstart) "$ftp(0) start"
Note that the default receiver window is set at 20 packets, which can limit the throughput if the path has long transmission delay. The window can be set like this:
Agent/TCP set window_ 200 ;# max bound on window size
If flow control is unwanted, the window size can be set very high. However, if it is set too high, the default value of 20 will be used. Be aware!
Another discovery is that, using a propagation model with bit errors, link layer notification may render the recovery improvements of Reno and Newreno unused in case no other paths to the destination exist. When the link is taken down because of LLN, the (proactive) routing protocol must reestablish a symmetrical link. In the meantime, TCP retransmissions are denied because of a lack of route, with the consequence that fast recovery is botched.