set opt(tr) out set opt(namtr) "lantest.nam" set opt(ll) LL set opt(ifq) Queue/DropTail set opt(mac) Mac/Csma/Cd set opt(chan) Channel set opt(tcp) TCP/Reno set opt(sink) TCPSink set opt(app) FTP #Create a simulator object set ns [new Simulator] #Open the nam trace file set nf [open $opt(namtr) w] $ns namtrace-all $nf #open trace file set tracefile [open $opt(tr) w] $ns trace-all $tracefile #Define a 'finish' procedure proc finish {} { global ns nf tracefile opt $ns flush-trace #Close the trace file close $nf close $tracefile #Execute nam on the trace file exec nam $opt(namtr) & exit 0 } for {set i 0} {$i < 2} {incr i} { set node($i) [$ns node] lappend nodelist $node($i) } #$ns newLan $nodelist $opt(bw) $opt(delay) $opt(ll) $opt(ifq) $opt(mac) $opt(chan) $ns make-lan "$node(0) $node(1)" 2Mb 10ms set tcp0 [new Agent/TCP] $ns attach-agent $node(0) $tcp0 set sink [new Agent/TCPSink] $ns attach-agent $node(1) $sink $ns connect $tcp0 $sink #set tcp0 [$ns create-connection TCP/Reno $node(0) TCPSink $node(1) 0] set ftp0 [new Source/FTP] $ftp0 attach $tcp0 #set ftp0 [$tcp0 attach-app FTP] $ns at 0.0 "$ftp0 start" $ns at 5.0 "finish" $ns run