Professional Documents
Culture Documents
SEE Online Letter
SEE Online Letter
set tf [open p1.tr w] ; #open trace file p1.tr using a pointer tf which points to
trace file in writable mode
$ns trace-all $tf ; #main class object ns linked with trace file object tf to
dump all outputs in trace file
set nf [open p1.nam w] ; #open nam file p1.nam in writable mode using
pointer nf
$ns namtrace-all $nf ; #main class object ns linked with nam file object nf to
dump animation outputs
$ns set queue-limit $n0 $n2 10 ;#Assigning Queuesize between the nodes no
and n2 as 10
$ns set queue-limit $n1 $n2 10 ;#Assigning Queuesize between the nodes n1
and n2 as 10
$ns set queue-limit $n2 $n3 5 ;#Assigning Queuesize between the nodes n2
and n3 as 5
$ns attach-agent $n0 $udp0 ;#Attaching agents to respective nodes i.e udp
0 to n0
$ns attach-agent $n1 $udp1 ;#n1 to udp 1
$ns attach-agent $n2 $null ;#n2 to destination null
$ns attach-agent $n3 $null ;#n3 to destination null
$cbr0 attach-agent $udp0 ;# attach traffic agents cbr0 and cbr1 to udp0 and
udp1
$cbr1 attach-agent $udp1
$cbr0 set packetSize_ 512 ;#assigning values of packet size and time interval packet size
is 512 bytes and interval is 0.001s
$cbr0 set interval_ 0.001
$cbr1 set packetSize_ 512
$cbr1 set interval_ 0.005
$ns at 0.0 "$cbr0 start" ;#Setting time for start and stop the packet
transmission.at 0s no will start
$ns at 10.0 "$cbr0 stop" ;#at 10s n0 will stop transmission
$ns at 2.0 "$cbr1 start" ;#at 2 sn1 will start
$ns at 12.0 "$cbr1 stop" ;#at 12 s n2 will stop tramsmission
$ns at 13.0 "finish" ;#finish simulation
$ns run