Sunday 22 November 2015

How to define nodes,links and queues?

      To create a node

1 set n0 [ns node]
2 set n2 [ns node]

In the above we created a node that is pointed by a variable n0. While referring the node in the script we use $n0. Similarly we create another node n2.

To create a link

Now we will set a link between the two nodes.

1    $ns duplex-link $n0 $n2 10Mb 10ms DropTail

So we are creating a bi-directional link between n0 and n2 with a capacity of 10Mb/sec and a propagation delay of 10ms.

To create a queue

In NS an output queue of a node is implemented as a part of a link whose input is that node to handle the overflow at the queue. But if the buffer capacity of the output queue is exceeded then the last packet arrived is dropped and here we will use a 'DropTail' option. Many other options such as RED(Random Early Discard) mechanism, FQ(Fair Queuing), DRR(Deficit Round Robin), SFQ(Stochastic Fair Queuing) are available.

So now we will define the buffer capacity of the queue related to the above link

1    #Set queue size of the link
2    $ns queue-limit $n0 $n2 20

so, if we summarize the above three things we get

01    #create nodes
02    
03    set n0 [$ns node]
04    set n1 [$ns node]
05    set n2 [$ns node]
06    set n3 [$ns node]
07    set n4 [$ns node]
08    set n5 [$ns node]
09    
10    #create links between the nodes
11    
12    $ns duplex-link $n0 $n2 10Mb 10ms DropTail
13    $ns duplex-link $n1 $n2 10Mb 10ms DropTail
14    $ns simplex-link $n2 $n3 0.3Mb 100ms DropTail
15    $ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
16    $ns duplex-link $n0 $n2 0.5Mb 40ms DropTail
17    $ns duplex-link $n0 $n2 0.5Mb 40ms DropTail
18    
19    #set queue-size of the link (n2-n3) to 20
20    $ns queue-limit $n2 $n3 20


No comments:

Post a Comment