set MASK 0 set NUM 1 set END 100.0 set END_FILE 100.1 if { [lindex $argv 0] == "setmask" } { set MASK 1 puts stderr "Ignoring port nos of sources" } set ns [new Simulator] #NUM sender! for {set i 0} {$i < $NUM} {incr i} { set s($i) [$ns node] } set r0 [$ns node] set g0 [$ns node] set f [open out.$NUM.tr w] $ns simplex-link $g0 $r0 1.0Mb 0.1ms DropTail $ns simplex-link $r0 $g0 1.0Mb 0.1ms DropTail $ns duplex-link $s(0) $g0 500.0Mb 20.0ms DropTail # trace the bottleneck queue $ns trace-queue $g0 $r0 $f Simulator instproc get-link { node1 node2 } { $self instvar link_ set id1 [$node1 id] set id2 [$node2 id] return $link_($id1:$id2) } # create NUM TCP sources : for {set i 0} {$i < $NUM} {incr i} { set tcp($i) [new Agent/TCP] $ns attach-agent $s($i) $tcp($i) set ftp($i) [new Application/FTP] $ftp($i) attach-agent $tcp($i) } # create NUM receiver for {set i 0} {$i < $NUM} {incr i} { set sink($i) [new Agent/TCPSink] $ns attach-agent $r0 $sink($i) } for {set i 0} {$i < $NUM} {incr i} { $ns connect $tcp($i) $sink($i) } for {set i 0} {$i < $NUM} {incr i} { $ns at 0.0 "$ftp($i) start" } for {set i 0} {$i < $NUM} {incr i} { $ns at $END "$ftp($i) stop" } $ns at $END_FILE "close $f;finish $NUM" proc finish {NUM} { puts "processing output ..." exec awk { { n[$9]=$9; \ if ($1=="-") r[$9]++; \ if ($1=="+") s[$9]++; \ if ($1=="d") d[$9]++ \ } END \ { printf ("Flow#\t#sent\t#recvd\t#drop\t%%recvd\n"); \ for (i in n) \ printf ("%1.1f\t%d\t%d\t%d\t%f\n",n[i],s[i],r[i],d[i],r[i]*1.0/s[i])\ } } out.$NUM.tr > out exec sort -n out > out.sort exec cat out.sort & exit 0 } $ns run