# Creating event scheduler set ns [new Simulator] # make it easy to put output in different files set outprefix out # setup traces $ns trace-all [open $outprefix.tr w] set nf [open $outprefix.nam w] $ns namtrace-all $nf # turn on extra tcp tracing for nam Agent/TCP set nam_tracevar_ true # Create the topology # # n0 --- n1 --- n2 --- n3 # set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] # Creating the links # All with bandwidth 10Mb, delay 10ms, and DropTail queue # Except the bottleneck link with bw 1Mb, delay 30ms, and DropTail queue $ns duplex-link $n0 $n1 10Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 30ms DropTail $ns duplex-link $n2 $n3 10Mb 10ms DropTail # # tell nam how to arrange the nodes # $ns duplex-link-op $n0 $n1 orient left-up $ns duplex-link-op $n1 $n2 orient left $ns duplex-link-op $n2 $n3 orient left-down # Create a TCP Reno connection from node 0 to node 3 # with a sink that will ack every packet set tcpsrc [new Agent/TCP/Reno] set tcpsnk [new Agent/TCPSink] $ns attach-agent $n0 $tcpsrc $ns attach-agent $n3 $tcpsnk $ns connect $tcpsrc $tcpsnk # Create an FTP source, attach it to the TCP agent set ftp [new Application/FTP] $ftp attach-agent $tcpsrc # # create and add an error model # set em [new ErrorModel/List] # drop a particular packet (packets are numbered from 0) $em droplist {100} $ns lossmodel $em $n1 $n2 # schedule the ftp source to send some data starting at a specific time. $ns at 1.0 "$ftp produce 8" $ns at 15.0 "finish" proc finish {} { global ns nf outprefix $ns flush-trace close $nf puts "Filtering ..." exec tclsh ~csci551/ns-allinone-2.1b8a/nam/bin/namfilter.tcl $outprefix.nam puts "running nam..." exec ~csci551/ns-allinone-2.1b8a/nam/nam $outprefix.nam & exit 0 } $ns run