# # test_a.tcl # $xIdx: test_b.tcl,v 1.2 2002/04/20 04:26:06 johnh Exp $ # proc usage {} { puts "Identify the PRIMARY reason limiting the bandwidth of" puts "the tcp connection between nodes Left and Right." } # # create the topology # proc make_topology {} { global ns global node_left node_right # nodes set node_left [$ns node] set node_b1 [$ns node] set node_b2 [$ns node] set node_right [$ns node] # links $ns duplex-link $node_left $node_b1 2Mbps 10ms DropTail $ns duplex-link $node_b1 $node_b2 1Mbps 40ms DropTail $ns duplex-link $node_b2 $node_right 2Mbps 10ms DropTail # nam hacking $node_left shape hexagon $node_left label Left $node_right shape hexagon $node_right label Right # orient the nodes relative to each other # # 19-Apr-02: don't do this currently because of a bug in nam # that breaks with absolute positioning :-( # # $ns duplex-link-op $node_left $node_b1 orient right # $ns duplex-link-op $node_b1 $node_b2 orient right # $ns duplex-link-op $node_b2 $node_right orient right } # # create the traffic # proc make_traffic {} { global ns global node_left node_right # make the source set tcp_left [new Agent/TCP/Reno] $ns attach-agent $node_left $tcp_left # set its flow id $tcp_left set fid_ 1 # sink set tcp_sink_right [new Agent/TCPSink] $ns attach-agent $node_right $tcp_sink_right # hook the source and sink $ns connect $tcp_left $tcp_sink_right # app over the source set ftp_left [new Application/FTP] $ftp_left attach-agent $tcp_left # start the traffic (send 200 pkts) $ns at 1 "$ftp_left produce 200" $ns at 10 "$ftp_left stop" } # # set up tracing # proc make_tracing {prefix} { global ns global tr_file nam_file set tr_file [open $prefix.tr w] $ns trace-all $tr_file set nam_file [open $prefix.nam w] $ns namtrace-all $nam_file } # # called to end the simulation # proc finish {progname} { global ns global tr_file nam_file $ns flush-trace close $tr_file close $nam_file puts "Done with simulation." puts "You may now look at the output trace files $progname.tr and $progname.nam" exit 0 } proc main {} { # get the current script name without .tcl global argv0 regexp -expanded -nocase {^(.*)\.tcl$} $argv0 dummy progname usage global ns set ns [new Simulator] make_tracing $progname make_topology make_traffic $ns at 11 "finish $progname" $ns run } main exit 0