# Lab1 C # Set up below network topology. # # 0 # \ # \ # 2------3 # / # / # 1 # # create event scheduler set ns [new Simulator] # setup color mapping $ns color 0 blue $ns color 1 red # create nodes set n0 [$ns node] # # fill in code here... # # enable tracing set f [open out.tr w] $ns trace-all $f set nf [open out.nam w] $ns namtrace-all $nf $ns duplex-link $n0 $n2 5Mb 2ms DropTail $ns duplex-link $n1 $n2 5Mb 2ms DropTail # # fill in code here... # # topology layout $ns duplex-link-op $n0 $n2 orient right-up $ns duplex-link-op $n1 $n2 orient right-down $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n2 $n3 queuePos 0.5 # enable variable tracing for TCP Agent/TCP set nam_tracevar_ true # create TCP traffic set tcp [new Agent/TCP] #set tcp [new Agent/TCP/Reno] #set tcp [new Agent/TCP/Newreno] $tcp set class_ 0 set sink [new Agent/TCPSink] # # fill in here # # Equivelant of # set tcp [$ns create-connection TCP $n0 TCPSink $n3 0] # add FTP traffic set ftp [new Application/FTP] $ftp attach-agent $tcp #setup UDP set udp [new Agent/UDP] $udp set class_ 1 $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null # # fill in here # # add CBR traffic set cbr [new Application/Traffic/CBR] # # fill in here # $cbr attach-agent $udp #start and stop traffic # # fill in code here # $ns at 2.0 "finish" proc finish {} { global ns f nf $ns flush-trace close $f close $nf # nam graph tracing filtering puts "Filtering ..." exec tclsh ../sample/namfilter.tcl out.nam # run animation puts "running nam..." exec nam out.nam & exit 0 } $ns run