Search This Blog

Random Early Detection (RED) in NS-2 - TCL - Part 1

Labels: ,

Reactions: 


Random Early Detection (RED) proposed by S. Floyd and V. Jacobson in 1993 is one of the widely deployed Active Queue Management (AQM) mechanisms. The performance of RED highly depends on the appropriate setting of atleast four parameters namely:

1. Minimum threshold
2. Maximum threshold
3. Exponential weighted moving average constant
4. Maximum drop probability

Setting appropriate values for these parameters is considered as a challenging issue and hence in 1999 S. Floyd proposed Gentle variant of RED. Later in 2001, S. Floyd proposed Adaptive RED which automatically sets all these parameters based on the network conditions.

In NS-2, the default RED which is active is Gentle RED + RED with automatic settings. To simulate the Original RED proposed in 1993 by S. Floyd (because still there are several researchers who aim to address the parameter sensitivity of Original RED), following commands must be used in the TCL Script before configuring a router with RED queue:

Queue/RED set thresh_ 5
Queue/RED set maxthresh_ 15
Queue/RED set q_weight_ 0.001
Queue/RED set bytes_ false
Queue/RED set queue_in_bytes_ false
Queue/RED set gentle_ false
Queue/RED set mean_pktsize_ 1000

Note that the values used in the above commands are taken from the Original paper of RED (See References). You need to change them as per your requirements!

thresh_ = minimum threshold

maxthresh_ = maximum threshold

q_weight_ = exponential weighted moving average constant

bytes_ and queue_in_bytes_ = indicate calculations of average queue size in bytes. Setting them to false indicates average queue size will be calculated in packets (not in bytes).

gentle_ = Gentle RED mode. Setting it false indicates Gentle mode is OFF

mean_pktsize_ = average size of a packet arriving at the router

Setting RED in Wired Networks:

Sample command is:

$ns duplex-link $n0 $n2 10Mb 10ms RED

Setting RED in Wireless Networks:

Sample command is:

set val(ifq)    Queue/RED

Gentle RED Settings in NS-2:

To enable Gentle RED option, the only change required is:

Queue/RED set gentle_ true

Rest all commands and syntax for Gentle RED are exactly same as mentioned above for Original RED.

Hope it helps.

Regards,
Mohit P. Tahiliani

References: S. Floyd and V. Jacobson, "Random Early Detection Gateways for Congestion Avoidance", IEEE/ACM Transactions on Networking, 1, 397-413.

Related Blogs:
1. Nonlinear RED (NLRED) patch for NS-2
2. Refined Adaptive RED (Re-ARED or RARED) patch for NS-2
3. TCL Script Generator
4. TCL Script Generator centered on NSG

Comments (25)

sir please help me........
I m doing my dissertation in ns2.
I have implemented dccp in ns 2.34 and did my project in wired networks.
now my dissertation topic is"DCCP for manets".
sir i m not able to draw the topology for manets.
i had replaced tcp by dccp agent.
the error it is giving is:

Created Files
num_nodes is set 3
Configuring Nodes
INITIALIZE THE LIST xListHead


*** stack smashing detected ***: ns terminated

Sir,does it means ns2.35 has the default script for adaptive-red? and are the way to setting adaptive-red as same as with setting gentle-red?? thanks..

@Mintu - See the following link to design MANETs topology:

140.116.164.80/~smallko/ns2/adhoc_routing.htm

@Charysa - Yes, ns-2 has default script for adaptive RED. You just need to include the following command:

Queue/RED set adaptive_ 1

Hope it helps.

Regards,
Mohit P. Tahiliani

Hi, Mr.Tahiliani,, I'm doing my final project using NS2 and really stuck there..
I want to using Adaptive RED for my prpject, I want to ask how to build wireless topology in ns2? I got the tcl script for wireless from http://www.isi.edu/nsnam/ns/tutorial/nsscript5.html#second , but it can't be running ..Can u help me Sir??
Thank you..

@Charysa - ARED does not work with wireless topology. This is because it requires automatic setting of a few parameters and those parameters are obtained from the "link" object. "Link" object does not exist for wireless networks and hence you end up getting "Segmentation Fault".

You need to manually set the values of those parameters to avoid getting this error.

Hope it helps.

Regards,
Mohit P. Tahiliani

how to set the values of those paramaters manually Sir? and what parameters? can you explain it more detail Sir? Please I need your help Sir, thank you..

Hi I want to implement an XOR relation between the packets which received by the intermediate nodes, but I don't know how I do it?? can anybody help me plzz :)

Sir,
I want to change RED algorithm and want to compare results with RED and modified RED so how i can make new .cc file and configure in ns2.35 help me

Sir,
I want to compare RED with CHOKe, but i don't know how to implementation CHOKe's parameter in NS2.35 at unicast topology. Help me for my problem sir. Thank You

Helloo.
This is regarding the previous post on implementing RED in wireless scenarios. YOu have asked to put the set val(ifq) Queue/RED and insert these parameters in the TCL script.
Queue/RED set thresh_ 5
Queue/RED set maxthresh_ 15
Queue/RED set q_weight_ 0.001
Queue/RED set cur_max_p_ 0.5
Queue/RED set bytes_ false
Queue/RED set queue_in_bytes_ false
Queue/RED set gentle_ false
Queue/RED set mean_pktsize_ 1000

But my question is where exactly should I insert these lines in the TCL script? I just inserted these lines as you asked and made that parameter to be true. But the problem is that, when i run the simulation i can see the nodes moving and all, but i dont see any traffic between the nodes. Why is this? Can you please help me on this.
Thanks

hello sir plz tell me how to use awk and tcl file for generating graphs and for generating throughput.

Hi sir, myself Naresh working on ns2 projects. How to implement AODV routing protocol for red algorithm in wireless network.............................

@Charysa - I am replying very late to this question but might be useful for some other readers. You need to manually set the bandwidth in red.cc because in wireless networks there is no link object and hence, bandwidth cannot be retrieved from the link object in ns-2.

@Ali - You can fetch the contents of the packet and do that operation. However, note that packets in ns-2 are dummy packets and do not contain any other information apart from the headers.

@Chandni - You need not create a new .cc file. Instead, make changes in red.cc itself. Once the changes are done - recompile ns-2 by using following commands:

./configure
make clean
make
make install

@Wahyu - CHOKe patch is available for ns-2 but for quite an older version. You need to manually apply it in ns-2.35.

@Kasun - You need to analyze the trace file to calculate the amount of traffic on a particular node.

@Raveena - Refer to the post named "Xgraph and AWK Scripts in NS-2" which is available in this blog itself.

@Naresh - Just use the following two lines in your wireless TCL Script

set val(rp) AODV
set val(ifq) Queue/RED

Hope it helps.

Regards,
Mohit P. Tahiliani

while implementing RED with AODV over VANET it reflects "Core Dump" error while execution. What's he solution?

Hey got the solution for using ARED with wireless topology. Tested with aodv 5 10 20 30 & 40 nodes.

Paste below text in tcl file.

set adaptive_ 1
Queue/RED set thresh_ 5
Queue/RED set maxthresh_ 15
Queue/RED set q_weight_ 0.001
Queue/RED set cur_max_p_ 0.5
Queue/RED set bytes_ false
Queue/RED set queue_in_bytes_ false
Queue/RED set gentle_ false
Queue/RED set mean_pktsize_ 1000

Do not know is the logic correct. But do not reflect any errors while simulation.
Hope it may be helpful.
regards

'm getting throughput as zero while executing awk script in wireless simulation...pls suggest me sir, wat to do

Sir can u plz share the .tcl file to compare RED, ARED and RARED protocol?
I am trying to compare their packet drop rate.

please send me the tcl script for using RED queue in IFQ in wireless simulation.

Thanks.

Hello sir,

I wanted to set time delay at destination node for evaluating cost function in AODV but i couldnt find any code through which i can make delay at destination.

Thanks..

sir am doing project on ATCP fo WMN will u help by mailing event detection mechanism or any links that give help on wmn and congestion

Sir I want to create an energy efficient AODV routing protocol can u help me plz its very urgent

hello sir,
I want to make Link state aware Geographic opportunistic routing protocol for Vanet. can we make direct awk script without making protocol?

@Krima - AWK is used for analyzing the trace files whereas your protocol must be written in C++. Both are different things.

First you must code your protocol in C++. Then run it in a scenario which is designed in TCL and then AWK can be used to extract values from the generated trace file.

Hope it helps.

Regards,
Mohit P. Tahiliani

I Tried with wireless RED implementation that two lines
but i am getting like this


set ns [new Simulator]
set topo [new Topography]

channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!
Floating point exception (core dumped)

hello sir,

do you have tcl example for wireless RED? because mine always get segmentation fault...

I am still having problem if I want to implement this on more than 5 nodes

thank you

Guest Book...!!!