Search This Blog

Revised: Adding Multiple Interface Support in NS-2

Labels: , , ,


After designing the patch provided in my previous blog "Adding Multiple Interface Support in NS-2", I tried to design an example tcl script (with reference to Chapter 6 in the document prepared by Ramon Aguero Calvo and Jesus Perez Campo) to verify the working of the patch.

I found few errors and later found there was a problem with file. I have corrected the error and the modified patch can be found on the link given below:


Following are the steps to be followed to apply above given patch to ns-2.33:

1. Download ns-allinone-2.33.tar.gz

2. Download multi-interface.patch

3. Unzip ns-allinone-2.33.tar.gz. You will get a folder named ns-allinone-2.33.

4. Paste the downloaded multi-interface.patch in this folder.

5. Give the following command:

    patch -p1 < multi-interface(ns-2.33).patch

6. Then give ./install

If you have already installed copy of ns-allinone-2.33 then follow the below given steps to apply multi-interface patch.

1. Paste the downloaded multi-interface.patch in ns-allinone-2.33 folder.

2. Give the following command:

    patch -p1 < multi-interface(ns-2.33).patch

3. Go in ns-allinone-2.33/ns-2.33 directory.

4. Give the following commands:


    make clean


    make install

You are done with it!

Example TCL scripts to verify the working of the patch can be found on the link given below:

Multi-Interface TC...

Kindly Note: The tcl scripts having "mesh" word in their name are the scripts designed with multiple interfaces. Others are designed with single interfaces. To verify the working of multiple interfaces, two awk scripts are also provided in the folder.

A tcl script named im3pmanual.tcl is a tcl script wherein nodes have different number of interfaces assigned to them whereas in other tcl scripts designed with multiple interface are designed such that all the nodes in the network have equal number of interfaces.

If you encounter any problem in downloading the patch from the link given above, please follow this link:

If you encounter any problem in downloading example tcl scripts, please follow this link:

Hope it helps.

Mohit P. Tahiliani

Related Blogs: 

Modified DSDV for Multiple Interface Support in NS-2

Comments (32)

Dear Mohit P. Tahiliani
Thanks alot for your usefull patch.
It works good.
I sent you an email about this patch wich describe my problem completely and I am waiting for your guides.
Thanks in advance.

Dear Mohit P. Tahiliani
thank u for this help. but i am getting one problem. whenever i am setting different channel to the node few cases i get segmentation fault. can u tell me the reason.
here i am giving one example--
$ns_ change-numifs 3
for {set i 0} {$i < 100} {incr i} {
$ns_ add-channel 0 $chan_(0)
$ns_ add-channel 1 $chan_(1)
$ns_ add-channel 2 $chan_(2)
set node_($i) [$ns_ node]
$node_($i) random-motion 0

$ns_ change-numifs 1
for {set i 100} {$i < $val(nn)} {incr i} {
set f [expr $i-100]
set in [expr $f%3]
$ns_ add-channel 0 $chan_($in)
set node_($i) [$ns_ node]
$node_($i) random-motion 0
i am using 300 node where 0 to 99 node has 3 channel and other 200 node few has chan 0 few has chan 1 and few has chan 2. the mode function is for this distribution. plz reply me quickly.
thanks in advance

Hi Mohit,
Can this patch be applied to ns-allinone-2.34 as well?


hello sir,thanku very much
i used it in my project,very useful to me ,

Hello sir...
Can u tell me where i get multi channel patch for ns-2.34..??
Please help me...

please help me to download tcl script for Multiple Interface support

dear Mohit,

i am not able to download the patch file. When ever i download the file i am getting esnips.exe

Please help me to download the patch file

@Nimms - I have not yet designed that.

@Shiva - You may try downloading now. All links have been checked last week.

Hope it helps.

Mohit P. Tahiliani

hello sir ,
Is any patch der for VANET.where to get the patch??

hello sir,
i installed multi interface patch for ns-2.33.where should i see the change..

@Rama - There is no need of separate patch for VANETs. The same patch works for all.

@Priya - You can see the changes in all the files which are patched. The list of such files when you run the patch command.

Hope it helps.

Mohit P. Tahiliani

Hello sir,

how to calculate congestion level in AODV?

please help me...

best regard

@Khozaimi - Search for "IFQ" in the 5th column of the trace file which is generated by running the TCL Script. This indicates that the packet has been dropped because of congestion. "Packet drops due to congestion" is one metric by which you can find out the congestion level. Alternatively, you can also use link utilization to do the same.

Hope it helps.

Mohit P. Tahiliani

hello sir
is this revised patch only for AODV protocol?

im using ZRP protocol
and its not fix anything i think
can you explain to me please sir?
thank you

is this patch will work for ns2.35

hello sir,
I am a student of S.I.T Tumkur, sir can u send me the exectuing ns-2 code for Adding Interface with model graphs and output.........please sir fast.......

Thank you so much for this patch.

I have a small problem after trying it, the command "node" is not passed to the c code of AODV. I mean command method doesn't receive "node" command and the index of the node is not assigned probably


Dear Sir,

I added multi-channel support in ns2 according to "Adding multiple interface support in ns2" tutorial. Then I found this website.
I am currently having problem for multi-channel support for mobile node. It works fine for static node. The problem is as follows.
Program received signal SIGSEGV, Segmentation fault.
0x000000000069f926 in MobileNode::X (this=0x18dc1) at common/
619 return X_;

I would like to know why this problem happens.

I also would like to know the problem you found in and its solution.

I am looking forward to your reply.

Thank you.
Best Regards,

Hi sir,

i m doing project in VANET using VADD protocol .

Please guide...


prashant; hi to add the building in ns-32 , the patch is MLS, OR other , please send the link of this patch..

is this patch works in ns2.34 ?

Dear Sir,
I have installed multi interface patch for ns-2.33 ..
Everything works fine! But whenever i am setting different channel to the node some times i get segmentation fault (or one of: MAC_802_11: accessing MAC cache_ array out of range, core dumped, received signal SIGSEGV in MobileNode::X () () )
here i am giving one example--

set chan_(0) [new $val(chan)]
set chan_(1) [new $val(chan)]
set chan_(2) [new $val(chan)]

$ns_ change-numifs 2
$ns_ add-channel 0 $chan_(0)
$ns_ add-channel 1 $chan_(1)

set node_(0) [$ns_ node]
$node_(0) random-motion 0

set node_(1) [$ns_ node]
$node_(1) random-motion 0

set node_(2) [$ns_ node]
$node_(2) random-motion 0

$ns_ change-numifs 2
$ns_ add-channel 0 $chan_(0)
$ns_ add-channel 1 $chan_(2)

set node_(3) [$ns_ node]
$node_(3) random-motion 0

I am looking forward to your reply.

Thanks in advance

how to install multiple ns-2 versions on ubuntu 12.04

Hey Mohit.
I was wondering if this patch would work with the latest version of NS (ie. 2.35). If not, could you please suggest another alternative because adding the patch to 2.33 involves lots of inconsistencies. Furthermore, its a headaches trying to figure out how to make this work. I'm currently working on something very important and I need multiple interfaces to go ahead. So, a quick, speedy reply would be very much appreciated and I would be so very grateful. Thanks in advamce.

Hi Sir,
i m implementing LEACH protocol by using AODV protocol. I wanna to check the number of packets received and dropped. How can i do it. Plz help me. I m really very thakful to u.

sir when i m implementing the script..following error is there....plz help me out
(_o3 cmd line 1)
invoked from within
"_o3 cmd change-numifs 3"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o3" line 2)
(SplitObject unknown line 2)
invoked from within
"$ns_ change-numifs $val(ni)"
(file "im3pmesh.tcl" line 48)

Hello Sir,
I Want to implement cluster in aodv...
sir, can you pls give me an idea for that..
i am really confused with how to elect cluster head and how to manage cluster based on battery power.


will this work for ns2.29?

Hi Sir,
How can we obtain number of interface in c++ part ? Thank you.

Good Day Sir,
I have the multi interface functionality to NS-2.35, I want to send traffic received from one interface to the other (2nd) Interface.
Can you please guide me what is the exact plan of action.

As far as I think,I'll need to do some changes in the Protocol file, e.g. AODV.*

Waiting for your response.
Warm Regards,

Dear sir,
I need multiple interface support fot ns 2.35. Is it possible to extend NS2.35 to support multiple communication?

Thanks in advance

I have a question regarding dmux_->recv(p,0); in
It seems that it is never getting executed. Then, how data packets are received by the destination?

Waiting for your reply,