Obtaining Node Position and Energy Dynamically in NS2.34

2,753 views
Skip to first unread message

thiru pathi

unread,
May 11, 2011, 3:52:02 AM5/11/11
to Network Simulator 2 (NS2)
I will be modifying the sample script simple-wireless.tcl found at ~/
ns-allinone-2.34/ns-2.34/tcl/ex and all my tasks in ns2 would be based
on AODV protocol.

1. In simple-wireless.tcl, change the routing protocol to AODV, enable
Energy model and set the initial energy value.

2. In the node configuration set the EnergyModel, Initial Energy
value, power spent in receiving mode,transmit mode,idle mode and sleep
mode.

3. Now we will move to the backend code(c++). Our edits would be
performed only in aodv.cc and aodv.h.

4. In aodv.h,first include the following header file that contains the
procedures/functions needed to access node postion,energy and several
other functions.

#include <mobilenode.h>


You will find class AODV, something like the one shown below.

5. In that, declare the following variables in “protected” scope.



* History management
*/

double PerHopTime(tprp_rt_entry *rt);


nsaddr_t index; // IP Address of this
node
u_int32_t seqno; // Sequence Number
int bid; // Broadcast ID
public:
double xpos ;
double ypos;
double zpos ;
double iEnergy;
MobileNode *iNode;


With that, no more work to be done in aodv.h. What we have actually
done here is to declare the variables that we will using in aodv.cc to
record a nodes position and energy.

6. In aodv.cc, we will initialize the variables that we have just
declared in aodv.h. This we do in the AODV “constructor“(invoked only
once during node creation).



xpos = 0.0;
ypos = 0.0;
zpos = 0.0;
MobileNode *iNode;
iEnergy = 1000.0;

7. Next, we include the code to access the functions in mobilenode.h,
that fetch the nodes current position and energy.



/*
Packet Transmission Routines
*/

void
TPRP::forward(tprp_rt_entry *rt, Packet *p, double delay) {
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);

iNode = (MobileNode *) (Node::get_node_by_address (index) );
xpos = iNode->X();
ypos = iNode->Y();
iEnergy = iNode->energy_model()->energy();
printf("at Time (%.6f), Posotion of %d is X =%.4f and Y =%.4f
\n",CURRENT_TIME,index,xpos,ypos);
printf("at Time (%.6f): Updated Energy for node %d is Energy %.4f
\n",CURRENT_TIME,index,iEnergy);

fprintf(stderr,"\nPosotion of is X =%.4f and Y =%.4f \n",xpos,ypos);
fprintf(stderr,"Updated Energy for node is Energy %.4f
\n",iEnergy--);

fprintf(stderr,"N (%.6f): Routing agent is initialized for node %d
\n", CURRENT_TIME, index);

//fprintf(stderr, "\nNODE: \t %i\t %i\t %i\t %i\t %i\t %.4lf\t %d
\n",rt->rt_dst, rt->rt_nexthop, rt->rt_hops, rt->rt_seqno, rt-
>rt_expire, rt->rt_flags);



I have included that code AODV::forward() function, so that the nodes
position and energy are printed each time it forwards a packet. Where
and When you want them to be printed is your choice. Alternatively,
you may have the code included in the function of your choice and have
the output redirected to a file.

8. Thats all! All we have to do now is to run simple-wireless.tcl
$ns simple-wireless.tcl

madhav kumar

unread,
Feb 20, 2013, 7:13:05 AM2/20/13
to ns-u...@googlegroups.com
hi i done as per the above steps..., 

now while i am running a tcl file with AODV it is giving a segmentation fault..., error...,

n can u plz tell me how to write in tcl file to print the node position and energy 
for ex: position of node 1 is: x:____ y:_____
energy of node 1 is: ___________
.
.
.
.

madhav kumar

unread,
Feb 20, 2013, 7:16:42 AM2/20/13
to ns-u...@googlegroups.com
plz reply me its urgent...,

hassan fadaie

unread,
Mar 15, 2013, 10:58:13 AM3/15/13
to ns-u...@googlegroups.com
use mobilenode.h

madhav kumar

unread,
Mar 15, 2013, 2:58:06 PM3/15/13
to ns-u...@googlegroups.com
actually i am fresher i am not getting how to write the ttcl sccript for getting teh node position and energy...,

can u plz help me
if u have any code plz mail me .. plz...,
madhav...@gmail.com
--with regards
Madhava
m. 91 9491616162

Sanjeev K. Prasad

unread,
Jul 31, 2013, 1:09:02 PM7/31/13
to ns-u...@googlegroups.com
when I am running this code, It gives segmentation fault.

pls tell me what is the problem?

rohit patil

unread,
Feb 10, 2015, 3:11:03 AM2/10/15
to ns-u...@googlegroups.com
i have done whatever you have told here, still it throws an error at assigning values to variable iNode as multiple markers at the line
 thank you.... 

Foram Patel

unread,
May 2, 2015, 1:21:30 AM5/2/15
to ns-u...@googlegroups.com
Hello,
I have done all this steps. But when I am running tcl file it gives segmentation dump error. Please help

knudfl

unread,
May 2, 2015, 4:31:22 AM5/2/15
to ns-u...@googlegroups.com
@Foram Patel ,   Hi.

All the default scripts with the name "wireless***.tcl will usually cause 'Segmentation fault', when edited to AODV.

?  Did you remember recompiling ns2 with the changes ? 
?  And save the new executable 'ns' to a new name :
$ cd ns-2.3x/ && cp ns ns-aodv && sudo copy ns-aodv /usr/local/bin/
.... All (AODV) simulations can then be run with $ ns-aodv file.tcl

AODV files (wireless) not causing 'Segmentation fault' are : ns2.3x/tcl/ex/wpan/wpan_demo*.tcl

-

Anamika Garg

unread,
Sep 7, 2015, 3:43:12 AM9/7/15
to Network Simulator 2 (NS2)
Hello all,
I have setup energy model and it is working fine but i want that when node energy less than perticular threshold then AODV select path of that node whose energy is higher than that threshold value.

Please give me code its really very important for me. 

hepzi prakash

unread,
Mar 26, 2016, 12:32:37 PM3/26/16
to Network Simulator 2 (NS2)
do you have that code mam, that below threshold energy in route path, the src node selects alternative path?

Deachan Choskit

unread,
Apr 25, 2016, 4:35:02 AM4/25/16
to Network Simulator 2 (NS2)
Sir @Thirupatti
i am using ns2.35. As you have mentioned in your second step that we need to enable the Energy model , but in ns2.35 i didnot find the Energy Model in the simple-wireless.tcl. In ns2.35 is it not available or what?

paras narkhede

unread,
May 12, 2016, 3:24:00 AM5/12/16
to Network Simulator 2 (NS2)
i want to calculate the energy of entire path so how to do that?

Arief Hidayat

unread,
Aug 14, 2018, 1:33:48 AM8/14/18
to Network Simulator 2 (NS2)

Hi everyone
anyone can help me
i have get  issue when i compile tcl as below :
set val(chan)           Channel/WirelessChannel    ;# channel type
set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)          Phy/WirelessPhy            ;# network interface type

set val(mac)            Mac/802_11                 ;# MAC type
set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set val(ll)             LL                         ;# link layer type
set val(ant)            Antenna/OmniAntenna        ;# antenna model
set val(ifqlen)         100                         ;# max packet in ifq
set val(nn)             12                         ;# number of mobilenodes
set val(rp)             AODV                       ;# routing protocol
set val(x)              500                        ;# X dimension of topography
set val(y)              400                        ;# Y dimension of topography
set val(stop)           150                        ;# time of simulation end
set val(energymodel)    EnergyModel     ;
#set opt(energymodel)    RadioModel     ;
set opt(radiomodel)        RadioModel     ;
set val(initialenergy)  100            ;# Initial energy in Joules
#set opt(logenergy)      "on"           ;# log energy every 150 seconds


set ns          [new Simulator]
set tracefd       [open testAODV.tr w]
set windowVsTime2 [open win.tr w]
set namtrace      [open testAODV.nam w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)


set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

#
#  Create nn mobilenodes [$val(nn)] and attach them to the channel.
#

        $ns node-config -adhocRouting $val(rp) \
             -llType $val(ll) \
             -macType $val(mac) \
             -ifqType $val(ifq) \
             -ifqLen $val(ifqlen) \
             -antType $val(ant) \
             -propType $val(prop) \
             -phyType $val(netif) \
             -channelType $val(chan) \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace ON \
             -macTrace OFF \
             -movementTrace ON
             -energyModel $val(energymodel) \
         -initalEnergy $val(initialenergy)\
         -idlePower 1.0 \
         -rxPower 1.0 \
         -txPower 1.0 \
             -sleepPower 0.001 \
             -transitionPower 0.2 \
             -transitionTime 0.005 \


the message error is :
arief-pc@ubuntu:~/Documents/movementnode$ ns aodv.tcl
num_nodes is set 12
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
invalid command name "-energyModel"
    while executing
"-energyModel $val(energymodel) \
         -initalEnergy $val(initialenergy)\
         -idlePower 1.0 \
         -rxPower 1.0 \
         -txPower 1.0 \
           ..."
    (file "aodv.tcl" line 59)

knudfl

unread,
Aug 14, 2018, 3:57:23 AM8/14/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

Check for typos ....
...  Missing back-slash ( \ ) in line 58
             -movementTrace ON

must be
             -movementTrace ON \


Arief Hidayat

unread,
Aug 14, 2018, 4:59:50 AM8/14/18
to Network Simulator 2 (NS2)
hi knudlf
i have changed that but stiill error, the error message as below :

arief-pc@ubuntu:~/Documents/movementnode$ ns aodv.tcl

num_nodes is set 12
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Agent/AODV::gw_discovery

    see tcl-object.tcl in tclcl for info about this warning.

INITIALIZE THE LIST xListHead
can't read "initialEnergy_": no such variable
    while executing
"new $energyModel_ $node  $initialEnergy_ $l1 $l2"
    invoked from within
"if [info exists energyModel_] {
if  [info exists level1_] {
set l1 $level1_
} else {
set l1 0.5
}
if  [info exists level2_] {
set l2 $level2_
} else {..."
    (procedure "_o3" line 115)
    (Simulator create-wireless-node line 115)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns node"
    ("for" body line 2)
    invoked from within
"for {set i 0} {$i < $val(nn) } { incr i } {
        set node_($i) [$ns node]
        $node_($i) set X_ [ expr 10+round(rand()*480) ]
        $node_($i..."
    (file "aodv.tcl" line 71)
arief-pc@ubuntu:~/Documents/movementnode$

knudfl

unread,
Aug 14, 2018, 6:53:29 AM8/14/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

»» (file "aodv.tcl" line 71) «« :  Please show the complete script.tcl, line 71 is unknown.

You can attach your code, not as aodv.tcl :  Already several files with that name.
I.e. a new file must have a new unique file name, e.g.  Arief-energy.tcl .

 

Arief Hidayat

unread,
Aug 14, 2018, 7:28:59 AM8/14/18
to Network Simulator 2 (NS2)

hi knudlf
my code in attach.
i want to ask about energy model in https://www.isi.edu/nsnam/ns/doc/node225.html, where do i add energy model class?is there in aodv.cc,is not it?
arief-energy.tcl

knudfl

unread,
Aug 14, 2018, 9:55:26 AM8/14/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

... is not about adding C++ code, but about the existing code.
EnergyModel is present in all versions of ns2. See attachments.
( EnergyModel → mac/ and mobile/ ).

About your errors : Seems you are trying to add EnergyModel to a basic simulation.

I made an example:
Added some aodv-Soumia.tcl code to your file → new file = Arief-energy-2.tcl
Arief-energy-2.tcl
ns235-EnergyModel.txt
ns226-EnergyModel.txt

Arief Hidayat

unread,
Aug 16, 2018, 4:06:51 AM8/16/18
to Network Simulator 2 (NS2)
Hi Knudlf
when i run Arief-energy-2.tcl. it get error, the error message as below
arief-pc@ubuntu:~/Documents/movementnode$ ns Arief-energy-2.tcl
*************************************************
     Proactive gateway discovery
*************************************************


No gateway discovery method chosen! Add the following line in your Tcl file:
    Agent/AODV set gw_discovery <0 or 1 or 2>

knudfl

unread,
Aug 16, 2018, 6:17:34 AM8/16/18
to Network Simulator 2 (NS2)
$ ns235-64-orig Arief-energy-2.tcl
num_nodes
is set 12

warning
: Please use -channel as shown in tcl/ex/wireless-mitf.
tcl
INITIALIZE THE LIST xListHead
channel
.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_
= 1.5,  distCST_ = 550.0
SORTING LISTS
...DONE!
awk
: awk: fatal: awk: fatal: can't open source file `delay.awk' for reading (No such file or directory)can't open source file `throughput.awk' for reading (No such file or directory)
fatal
:
can
't open source file `pdr.awk' for reading (No such file or directory)
... Files created: testAODV.nam, 5.8MB,  testAODV.tr 19.4MB, win.tr 357.7kB .

? Which files are you using for throughput.awk and pdr.awk ? Please attach.
( throughput.awk is not the best choice if it's any default file. Besides that, several files with that name.) https://drive.google.com/drive/folders/1rU_MFAEl1GCLMTJPLR3zbxPxkQQHkQ7T

Your errors : May be you are not using an ns2 friendly OS ?
Please specify :  OS name and version.    ?32 or 64 bits OS ?

Arief Hidayat

unread,
Aug 16, 2018, 10:10:20 AM8/16/18
to Network Simulator 2 (NS2)
hi knudlf
i try twice, i get same error;
My version ubuntu and gcc as below
arief-pc@ubuntu:~/Documents/movementnode$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.4' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)

knudfl

unread,
Aug 16, 2018, 5:17:12 PM8/16/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

Please read my posts carefully, and notice that I am using $ ns235-64-orig Arief-energy-2.tcl
... Not $ ns235-aodv+      !

Some EnergyModel examples can run with the `ns235-aodv+´ executable, others not.

My setup is attached.


On Thursday, August 16, 2018 at 4:10:20 PM UTC+2, Arief Hidayat wrote:
hi knudlf
usr.local.bin-08.18.txt

Arief Hidayat

unread,
Aug 16, 2018, 10:13:07 PM8/16/18
to Network Simulator 2 (NS2)
Hi knudlf
i has executed $ ns235-aodv+ but not it not working as below
arief-pc@ubuntu:~/Documents/movementnode$ ns235-aodv+  Arief-energy-2.tcl

Arief Hidayat

unread,
Aug 17, 2018, 5:57:53 AM8/17/18
to Network Simulator 2 (NS2)
hi knudlf
what is the solution for segmentation fault (core dumped)?
the problem when i run Arief-energy-2.tcl, so nam not execute.
at Time (70.169225), Posotion of 3 is X =158.0000 and Y =34.0000
at Time (70.169225): Updated Energy for node 3 is Energy 367.3961
at Time (70.169225), Posotion of 1 is X =177.0000 and Y =221.0000
at Time (70.169225): Updated Energy for node 1 is Energy 360.9732
at Time (70.169225), Posotion of 11 is X =118.0000 and Y =246.0000
at Time (70.169225): Updated Energy for node 11 is Energy 368.7025
at Time (70.170797), Posotion of 2 is X =291.0000 and Y =114.0000
at Time (70.170797): Updated Energy for node 2 is Energy 359.8834
at Time (70.172744), Posotion of 2 is X =291.0000 and Y =114.0000
at Time (70.172744): Updated Energy for node 2 is Energy 359.8822
at Time (70.173714), Posotion of 8 is X =490.0000 and Y =176.0000
at Time (70.173714): Updated Energy for node 8 is Energy 367.4922
at Time (70.176000), Posotion of 7 is X =79.0000 and Y =331.0000
at Time (70.176000): Updated Energy for node 7 is Energy 366.9825
at Time (70.182650), Posotion of 8 is X =490.0000 and Y =176.0000
at Time (70.182650): Updated Energy for node 8 is Energy 367.4875
at Time (70.182857), Posotion of 8 is X =490.0000 and Y =176.0000
at Time (70.182857): Updated Energy for node 8 is Energy 367.4875
Segmentation fault (core dumped)
arief-pc@ubuntu:~/Documents/movementnode$

knudfl

unread,
Aug 17, 2018, 2:10:40 PM8/17/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

The command is missing. Should be like $ ns-orig Arief-energy-2.tcl
I.e. assume /usr/local/bin/ns-orig  or a similar new name for a stock "ns" (ns235-orig)

Arief Hidayat

unread,
Aug 17, 2018, 8:06:41 PM8/17/18
to Network Simulator 2 (NS2)

Hi knudlf
i has tried ns-orig and  ns235-orig but it not working
arief-pc@ubuntu:~/Documents/movementnode$ ns-orig Arief-energy-2.tcl
ns-orig: command not found
arief-pc@ubuntu:~/Documents/movementnode$ ns235-orig Arief-energy-2.tcl
ns235-orig: command not found

in addition to try Arief-Energy-2.tcl, i execute aodv18.tcl in https://www.isi.edu/nsnam/ns/tutorial/index.html, it's not working, do i must add gateaway discovery method?

arief-pc@ubuntu:~/Downloads$ ns aodv18.tcl

knudfl

unread,
Aug 18, 2018, 6:31:46 AM8/18/18
to Network Simulator 2 (NS2)
@Arief Hidayat ,  Hi.

»» tried ns-orig and  ns235-orig but it not working «« :
All those executable´s in /usr/local/bin/  https://drive.google.com/file/d/1Z17kBoKgwELm3IfgWm7maHBwLqIKtax5/view?usp=sharing  must of course be created before you can use any of them.


Setup multiple ns-allinone-2.35/
/home/name/ns2/a/ns-allinone-2.35/
/home/name/ns2/b/ns-allinone-2.35/
/home/name/ns2/c/ns-allinone-2.35/
/home/name/ns2/d/ns-allinone-2.35/
( I have more than 200 ns2 on one OS ... one ns2 for each patch https://drive.google.com/drive/folders/0B7S255p3kFXNZ2lWZDBRSW40Q00?usp=sharing  )

Arief Hidayat

unread,
Aug 18, 2018, 6:42:40 AM8/18/18
to Network Simulator 2 (NS2)
hi Mr Knudlf
i has added ns-orig but it not working because No gateway discovery method chosen! Add the following line in your Tcl file:
    Agent/AODV set gw_discovery <0 or 1 or 2>, must the gateaway be added?because i has added AODV+__ns235.patch, other program like 2paires -b.tcl, Clustering-moc_v1_idsAODV.tcl must be added gateaway discovery.

help me sir because i'm beginner using ns2



$ ns-orig Clustering-moc_v1__idsAODV.tcl
num_nodes is set 15
Starting Simulation...
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead


*************************************************
     Proactive gateway discovery
*************************************************


No gateway discovery method chosen! Add the following line in your Tcl file:
    Agent/AODV set gw_discovery <0 or 1 or 2>


knudfl

unread,
Aug 18, 2018, 11:17:59 AM8/18/18
to Network Simulator 2 (NS2)
@Arief Hidayat

»» added ns-orig but it not working «« : 
You will need another ns-2.35 for that. An ns-2.35 patched with aodv+ won't do.
....  So did you build a new ns-allinone-2.35 ?    Or ?

About  "ns-orig Clustering-moc_v1__idsAODV.tcl" :
Please read the file ....
set val(rp)     idsAODV                     ;# routing protocol
set val(brp)    blackholeAODV
I.e. all  idsAODV examples are supposed to be run with an executable patched with :
blackholeaodv2013-ns235_1.patch  idsAODV-2-for-blackhole2013-patched_ns235.patch

Please try to understand why I have "100" different ns-allinone-2 installed at the same time.
New added protocols can conflict with each other.  So a lot of separate ns-allinone-2 are required  https://drive.google.com/file/d/1Z17kBoKgwELm3IfgWm7maHBwLqIKtax5/view?usp=sharing
Message has been deleted
Message has been deleted
Message has been deleted

Arief Hidayat

unread,
Aug 23, 2018, 10:18:45 AM8/23/18
to Network Simulator 2 (NS2)
hi everyone
i followed instructor and  had edited aodv.cc according in http://slogix.in/how-to-select-an-energy-based-path-in-aodv-routing-protocol-using-ns2#Source-code but i run that, i get the problem, as below
aodv/aodv.cc: In member function ‘void AODV::sendPacket(Packet*, aodv_rt_entry*, double)’:
aodv/aodv.cc:91:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(ih->daddr() == IP_BROADCAST)
                     ^
aodv/aodv.cc: In constructor ‘AODV::AODV(nsaddr_t)’:
aodv/aodv.cc:201:2: error: ‘iEnergy’ was not declared in this scope
  iEnergy = 0.0;
  ^
aodv/aodv.cc:204:2: error: ‘iNode1’ was not declared in this scope
  iNode1 = (MobileNode *) (Node::get_node_by_address(index));
  ^
aodv/aodv.cc:206:2: error: ‘residual_energy’ was not declared in this scope
  residual_energy = iNode1->energy_model()->energy();
  ^
aodv/aodv.cc:208:39: error: ‘packet’ was not declared in this scope
  if (residual_energy > 35.0) {forward(packet);}
                                       ^
aodv/aodv.cc:209:16: error: ‘packet’ was not declared in this scope
  else {discard(packet);
                ^
aodv/aodv.cc:209:22: error: ‘discard’ was not declared in this scope
  else {discard(packet);
                      ^
aodv/aodv.cc:200:14: warning: unused variable ‘iNode’ [-Wunused-variable]
  MobileNode *iNode;
              ^
aodv/aodv.cc: In member function ‘void AODV::recvError(Packet*)’:
aodv/aodv.cc:1048:45: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
      while(pkt = ifqueue->filter(ih->saddr())) {
                                             ^
make: *** [aodv/aodv.o] Error 1
Ns make failed!
anyone can help me please?

Arief Hidayat

unread,
Sep 3, 2018, 4:54:10 AM9/3/18
to Network Simulator 2 (NS2)
Hi everyone
anyone can help me
i get the problem (can't read "initialEnergy_": no such variable ) when i execute my tcl. i don't know solve that
        $node_($i) set..."
    (file "ex-movement-node-1.tcl" line 75)
ex-movement-node-1.tcl

Arief Hidayat

unread,
Oct 29, 2018, 3:41:10 AM10/29/18
to Network Simulator 2 (NS2)
hi knudlf
i has followed the instructor based on https://getch.wordpress.com/2011/02/08/obtaining-node-position-and-energy-dynamically-in-ns2/, when i run the program, printf("at Time (%.6f), Position of %d is X: %.4f and Y : %.4f \n", CURRENT_TIME, index, xpos, ypos);
printf("at Time (%.6f), Update Energy for Node %d is Energy %.4f  \n", CURRENT_TIME, index, iEnergy);
these not appear, like as below :
10 - arpresolve
2 - arpresolve
2 - arpresolve
8 - arpresolve
0 - arpresolve
5 - arpresolve
2 - arpresolve
0 - arpresolve
5 - arpresolve
5 - arpresolve
2 - arpresolve
10 - arpresolve
10 - arpresolve
2 - arpresolve
2 - arpresolve
10 - arpresolve
5 - arpresolve
10 - arpresolve
10 - arpresolve
5 - arpresolve
5 - arpresolve
10 - arpresolve
10 - arpresolve
10 - arpresolve
0 - arpresolve
0 - arpresolve
10 - arpresolve
10 - arpresolve
awk: cannot open throughput.awk (No such file or directory)
 can you help me?
aodv.cc
aodv.h

knudfl

unread,
Oct 29, 2018, 8:19:53 AM10/29/18
to Network Simulator 2 (NS2)
@

»» awk: cannot open throughput.awk «« :  Which simulation is it about ?
»» when i run the program «« :  Unknown program.
Errors / question make no sense when the simulation command is missing.

My test :
$ ns235-aodv-rtable-WP-64 WP-aodv-rtable.tcl
... The files aodv.nam  326.0kB, aodv.tr 1.4MB, rtable.txt 8.6kB are created.

aodv-print-rtable-WP_ns235.patch
rtable.txt
WP-aodv-rtable.tcl

Soorya

unread,
Jul 8, 2019, 7:41:27 PM7/8/19
to Network Simulator 2 (NS2)
How to get the energy of a path in aodv?
Reply all
Reply to author
Forward
0 new messages