Analize queue using nam and monitoring queue

Analize queue among 3 nodes : node0, node1,node2. Queue dropping will be happen at node0 and node1. because it need 0.8Mb/s to send packet from node0 to node1, but duplex-link between node0 and node1 only 0.5Mb/s and only 0.1Mb/s between node1 and node2.

———————-
monq.tcl
———————–

#Packet drop at node0 and node1
set ns [new Simulator]

$ns color 1 Blue

set nf [open example2.nam w]
$ns namtrace-all $nf

#finish procedure
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam example2.nam &
exit 0
}

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

#link1,2 bandwidth 1Mb, delay 10ms, DropTail queue
$ns duplex-link $n0 $n1 0.5Mb 10ms DropTail
$ns duplex-link $n1 $n2 0.1Mb 10ms DropTail

$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right

#Monitoring Queue
$ns duplex-link-op $n1 $n2 queuePos 0.5
$ns duplex-link-op $n0 $n1 queuePos 0.5

#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0

#Create a CBR traffic source abd attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

$udp0 set class_ 1

#Create Null agent which acts as traffic sink and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $n2 $null0

#Connect agent UDP and agent NULL
$ns connect $udp0 $null0

#sample the q every 1 sec between n0 and n2. store the trace in qm1.out
set qm [$ns monitor-queue $n0 $n1 [open qm1.out w] 1]; # 1 = every 1 sec
[$ns link $n0 $n1] queue-sample-timeout; # [$ns link $n0 $n1] start-tracing
#sample the q every 1 sec between n1 and n2. store the trace in qm2.out
set qm [$ns monitor-queue $n1 $n2 [open qm2.out w] 1];
[$ns link $n1 $n2] queue-sample-timeout; # [$ns link $n1 $n2] start-tracing

#define what time CBR start and when to stop sending data
$ns at 0.5 “$cbr0 start”
$ns at 4.0 “$cbr0 stop”

#Finish time
$ns at 5.0 “finish”

$ns run

——————————-

result in qm1.out :

0 0 1 0 0 0 0 0 0 0 0
1 0 1 4686.9999999999927 9.3739999999999917 100 63 0 50000 31500 0
2 0 1 23900.000000000713 47.800000000001447 301 188 64 150500 94000 32000
3 0 1 24312.500000002081 48.625000000004214 501 313 139 250500 156500 69500
4 0 1 24312.500000003482 48.625000000006985 701 438 214 350500 219000 107000

result in qm2.out :

0 1 2 0 0 0 0 0 0 0 0
1 1 2 5807.99999999999 11.615999999999985 61 13 0 30500 6500 0
2 1 2 24496.999999999982 48.994000000000064 186 38 99 93000 19000 49500
3 1 2 24499.999999999985 49.000000000000057 311 63 199 155500 31500 99500
4 1 2 24499.999999999982 49.000000000000064 436 88 299 218000 44000 149500

Trace Format :

Time, From, To, qsizeB, qsizeP, arrivedP, departedP, droppedP, arrivedB, departedB, droppedB
where *B is number in Bytes, and *P is numbers in Packets.

Monitoring using nam :

Hancurkan Kemalasan – Hancurkan Kebodohan

May 2, 2008
Taipei City
High Speed Network Lab

Udin Harun

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: