Wednesday, February 14, 2024

QUEUE TYPE

 

Queue Management is defined as the algorithm that manages the length of the packet queues by dropping packets when necessary. 

Passive Queue Management: In Passive Queue Management the packet drop occurs only when the buffer gets full. Ex: Drop Tail.
Active Queue Management: Active Queue Management employs preventive packet drops. It provides an implicit feedback mechanism to notify senders of the onset of congestion. Arriving packets are randomly dropped. Ex: RED.



Droptail: In Droptail, the router accepts and forwards all the packets that arrive as long as its buffer space is available for the incoming packets. If a packet arrives and the queue is full, the incoming packet will be dropped. The sender eventually detects the packet lost and shrinks its sending window. Drop-tail queues have a tendency to penalize bursty flows, and to cause global synchronization between flows.

RED: RED is a type of active queue management technique used for congestion avoidance. RED monitors the average queue size and drops (or marks when used in conjunction with ECN) packets based on statistical probabilities. If the buffer is almost empty, all incoming packets are accepted. As the queue grows, the probability for dropping an incoming packet grows too. When the buffer is full, the probability has reached 1 and all incoming packets are dropped


REM: REM is an active queue management scheme that measures congestion not by performance measure such as loss or delay, but by quantity. REM can achieve high utilization, small queue length, and low buffer overflow probability. Many works have used control theory to provide the stable condition of REM without considering the feedback delay. In case of (Random Exponential Marking) REM, the key idea is to decouple congestion measure from performance measure (loss, queue length or delay).

Fair Queuing In fair queuing every flow gets the bandwidth propositional to its demand. The main goal of fair queuing is to allocate resources fairly to keep separate queue for each flow currently flowing via a router. Every queue gets equal bandwidth when the packets are in same size and non-empty queue follows a round robin fashion like FIFO. But if the packets are in different size the flow of large size packets gets more bandwidth than small size packets and these problems are overcome by weighted fair queuing algorithm, etc. Maintaining a separate queue for each flow requires a gateway or router to map from source to destination address pair for the related queue on a per packet basis. 


Stochastic Fair Queuing Stochastic Fair Queuing uses a hash algorithm to divide the traffic over a limited number of queues. Due to the hashing in SFQ multiple sessions might end up into the same bucket. SFQ changes its hashing algorithm so that any two colliding sessions will only work for a small number of seconds. Stochastic Fair Queuing algorithm is the best algorithm among all algorithms in case of providing satisfactory bandwidth to the legitimate users (TCP and UDP) in network. It is called Stochastic due to the reason that it does not actually assign a queue for every session; it has an algorithm which divides traffic over a restricted number of queues using a hashing algorithm.SFQ assigns a pretty large number of FIFO queues. Stochastic Fair Queuing (SFQ) ensures fair access to network resources and prevents a busty flow from consuming more than its fair share.SFQ has a minimum average loss ratio and maximum throughput compared to RED. 

DIFFERENT COLOR NODE

 

Add the following two lines to your CBR agent definitions.

$udp0 set class_ 1
$udp1 set class_ 2


$ns color 1 Blue
$ns color 2 Red

This code allows you to set different colors for each flow id.

Nam snap shot

LARGE TOPOLOGY

 

for {set i 0} {$i < 7} {incr i} {
  set n($i) [$ns node]
}


for {set i 0} {$i < 7} {incr i} {
  $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail
}

Nam snap shot

TOPOLOGY

 


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

The following piece of Tcl code creates three duplex links between the nodes.

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

You can save and start the script now. You might notice that the topology looks a bit awkward in nam. You can hit the 're-layout' button to make it look better, but it would be nice to have some more control over the layout. Add the next three lines to your Tcl script and start it again.

$ns duplex-link-op $n0 $n2 orient right-down      
$ns duplex-link-op $n1 $n2 orient right-up 
$ns duplex-link-op $n2 $n3 orient right 

You will probably understand what this code does when you look at the topology in the nam window now. It should look like the picture below.

Nam snap shot

DUPLEX LINK

 $ns duplex-link node1 node2 bandwidth delay queue-type



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

A new node object is created with the command '$ns node'. The above code creates two nodes and assigns them to the handles 'n0' and 'n1'.

The next line connects the two nodes.

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

This line tells the simulator object to connect the nodes n0 and n1 with a duplex link with the bandwidth 1Megabit, a delay of 10ms and a DropTail queue.

NODE CREATION

#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

$ns color 1 blue: is to set color of the packets for a flow specified by the flow id (fid). 


$n3 shape "square"
$n3 color "black"

$n0 shape "square"
$n0 color "blue"

PACKET TRACING

 




UDP

 #Setup a UDP connection

set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null
$udp set fid_ 2

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false

TCP

1. #Setup a TCP connection(ftp)

set tcp [new Agent/TCP]
$tcp set class_ 3
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set fid_ 1

#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP


2.#Setup a TCP connection(cbr)

Introduction to ns2

 1.Network protocol stack written in C++

 2.Tcl (Tool Command Language) used for

specifying scenarios and events.


3. Simulates both wired and wireless networks.


4.Ns, the simulator itself

 5.Nam, the network animator--Nam editor: GUI interface to generate ns scripts


NAM (NETWORK ANIMATOR)

-> PROVIDES A VISUAL INTERPRETATION OF THE NETWORK CREATED

-> CONTROLS PLAY,FAST FORWARD,REWIND,PAUSE

X-GRAPH

->INTERACTIVE PLOTTING,GRAPHING ANIMATED AND DERIVATIVES

->SIZE 800x400