set ns [new Simulator] set totalTime 20.0 set bottleQueueSize 17 #Define a 'finish' procedure proc finish {} { global ns f close $f exec xgraph out.tr -geometry 400x800 & exit 0 } set host0 [$ns node] set host1 [$ns node] set host2 [$ns node] $ns simplex-link $host0 $host1 1MB 0.01s DropTail $ns simplex-link $host1 $host2 100kB 0.01s DropTail $ns simplex-link $host2 $host0 1MB 0.01s DropTail set bottleQ [[$ns link $host1 $host2] queue] $bottleQ set limit_ $bottleQueueSize set tcp [new Agent/TCP] $tcp set packetSize_ 1000 set sink [new Agent/TCPSink] $ns attach-agent $host0 $tcp $ns attach-agent $host2 $sink $ns connect $sink $tcp set ftp [new Application/FTP] $ftp attach-agent $tcp set f [open out.tr w] #Define a procedure that periodically records the congestion window size proc record {} { global f tcp ns totalTime set time [expr $totalTime/600.0] #set w to the congestion window size set w [$tcp set cwnd_] set now [$ns now] puts $f "$now $w" #Re-schedule the procedure $ns at [expr $now+$time] "record" } $ns at 0.0 "$ftp start" $ns at 0.0 "record" $ns at $totalTime "$ftp stop" $ns at [expr $totalTime + 1.5] "finish" $ns run