Showing posts with label queue. Show all posts
Showing posts with label queue. Show all posts

Oct 16, 2006

Developing new queue management

Ilyes Gouta ilyes.gouta at gmail.com
Sat Apr 29 14:06:11 PDT 2006

Hi,

You have to create the necessary TCL binding within your new C++ code
too. That binding will be used later by your simulation scripts.

In the C++ part, you'll have to add a class like this:

static class NewQueueClass : public TclClass
{
public:
NewQueueClass () : TclClass("Queue/NewQueue") {}
TclObject* create(int, const char*const*)
{
return (new NewQueue);
}
} class_new_queue;

And then in the simulation script:

$ns node-config option1 option2 option3 -ifqType Queue/NewQueue
This will tell NS to use your new queue for the newly created nodes.

Hope it helps,
Ilyes Gouta.


On 4/29/06, Eduardo J. Ortega wrote:
Hi:
I tried this, recompiled ok, but my sims won't run no matter what my code is.
i thought maybe my code was wrong, so i decided to copy droptail.{cc,h} to
fifo.{c,h} and change class names to FIFO, then add fifo.o to makefile and
recompiile. It compiled, but again, sims won't run when i try to use fifo
instead of droptail.

Any clues?


On Saturday 29 April 2006 11:11, you wrote:
Hi,

Have a look into the ~/ns-2.x/queue directory. You'll find all sorts
of implementations for different active queues. This include RED, RIO,
PRIO, JOBS, etc.

Implementing a new queue is rather easy actually, you'll have to
inherit from Queue and implement the enque() and deque() methods. This
is really it! Don't forget to add you source code to NS's makefile to
get it compiled.

Regards,
Ilyes Gouta.


On 4/29/06, Eduardo J. Ortega wrote:
hey there:

Anyone knows how to code new queue algorithms into NS? (for example, choke)? Thanks.

--
Eduardo J. Ortega - Linux user #222873
"No fake - I'm a big fan of konqueror, and I use it for everything." --
Linus Torvalds



tags :

Feb 4, 2006

Monitor_queue Trace

To monitor a queue between two nodes, command monitor-queue can be used.

$ns monitor-queue
This sets up a monitor that keeps track of average queue length of the queue on the link between nodes and . The default value of sampleinterval is 0.1.

Eg.

set monitor [$ns monitor-queue $S $D [open qm.out w] 0.1]

Trace format :

0.69999999999999996 0 1 0.0 0.0 12 12 0 5178 5178 0
Time, From, To, qsizeB, qsizeP, arrivedP, departedP, droppedP, arrivedB, departedB, droppedB

where *B is number in Bytes, and *P is numbers in Packets.

Jan 27, 2006

Exercise 4 - Simulation of a M/D/1 queue

Consider a simple network composed of only two nodes (S and D), and one link connecting them. The link connecting the two nodes has a speed of 1Mbps, a propagation delay of 100 ms, and a DropTail buffer at its input of very large size.

$ns duplex-link $S $D 1Mb 100ms DropTail
$ns queue-limit $S $D 10000


We run on node S a Poisson source of traffic. The destination of the packets being node D. Let lamda be the intensity of the Poisson traffic in terms of packets/s. Take lamda = 1200 packets/s and set the packet size of the Poisson source to a fixed value 100 bytes.

Write the code of a simulation of this scenario, then run the simulation for 1000 seconds. The Poisson source can be created as follows:

set udp [new Agent/UDP]
$ns attach-agent $S $udp
set null [new Agent/Null]
$ns attach-agent $D $null
$ns connect $udp $null
set poisson [new Application/Traffic/Poisson]
$poisson attach-agent $udp
$ns at 0 "$poisson start"


Don’t forget the ns run !

Verify the load of the queue. What is the expected load? You get the load from the simulation by computing the total number of packets that leave the queue, then by dividing it by the total number of packets that would leave the queue if the link was busy all time. Use the queue monitor object to obtain the total number of packets that leave the queue.

set monitor [$ns monitor-queue $S $D stdout]

We focus on the computation of the average queue length. Compute theoretically this average value. Recall that the average queue length in a M/G/1 queue is equal to


This average queue length includes the packet in the server (physically, the packet being transmitted). The Queue-Monitor object gives the number of packets waiting in the queue, without counting the packet in the server. You will notice that there is a difference P between the theoretical value and the measured value. P is the average number of packets occupying the server of the queue.

Now validate this average value using your simulation. You need to write a function that samples the queue length many times during the simulation, then you compute the average over all the samples you obtain.

proc queueLength {sum number}{
global ns monitor
set time 0.1
set len [$monitor set pkts_]
set now [$ns now]
set sum [expr $sum+$len]
set number [expr $number+1]
puts "[expr 1.0*$sum/$number]"
$ns at [expr $now+$time] "queueLength $sum $number"}
$ns at 0 "queueLength 0 0"


As a final exercise on this scenario, write in a file the queue size in packets (on two columns, the first one for time, the second one for queue size), and plot this queue size versus time using gnuplot.

*** for generation of random inter-arrival time and packet sizes

such example can be used :

set lambda 30.0
set mu 33.0
set InterArrivalTime [new RandomVariable/Exponential]
$InterArrivalTime set avg_ [expr 1/$lambda]
set pktSize [new RandomVariable/Exponential]
$pktSize set avg_ [expr 100000.0/(8*$mu)]