To read this article in Scribd go <here>
For an alternative method to obtain a nodes position, go <here>
Happy to meet you in another interesting task in NS2!
This time we will “dynamically” calculate a nodes position and remaining energy.This post is based on the valuable tips mentioned <here> by Elmurod Talipov.
Now to the task…
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.
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).
7. Next, we include the code to access the functions in mobilenode.h, that fetch the nodes current position and energy.
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
and the output would be something like this:
If you find any discrepancies in this post, please feel free to drop me a mail at micman.manoj@gmail.com. By doing so, You would be saving the valuable time of many researchers.
Pingback: Finding Node Position,Velocity and Speed in NS2.34 « tutorMicman
Hi manoj,
Could you please help me on finding the waiting time of a wireless node.
i am creating a new routing protocol for my final year B.Tech project and would request you to help me.
hi can u do the same in opnet
canu do same for me in DSDV protocal
Sorry Bro!
I can’t do your homework!
I am not familiar with Opnet brother!
Sir,
I need a tcl script to find the residual energy of nodes after they transfer the packets in AODV i tried the above procedure i got error in the energymodel..can you plz help me to make out this…and one more issue is that I am using xgraph 12.1 and I need to rescale x axis value to have integers and no decimals since x axis is number of nodes..can you please help me to make out this..thanks in advance.
hello sir,how to put different initial energy levels to different nodes……………pls give suggest me a solution……..
hi,
Can u plz tell me how to add delay on wireless node
sir,
can you tell me how to do local repair in AODV using hand off approach??
for this where i should edit plz suggest me sir
Salam & Hello
how we can redirect the out put on a file ??
I need the value of received signal strength Pr and the position of node every x second on separately trace file
please help,
hi friends..
pls help and save me
i am abhi …now i am doing my b.tech project …i want code for DYNAMIC ROUTING WITH SECURITY CONSIDERATIONS…. Any one have code pls reply once..
i want implemented in NS2 TOOL by using TCL language
Sir, Can u give me the complete code for simulating zigbee in ns 2.34
i want ns2 tcl code for aodv & aomdv protocol using TCP
Hi, Manoj
Could u give me some help on how to extract the current node’s own speed. Not just print on screen. Because I want to each node be able to know its speed, position in my Agent’s C++ code.
Appreciated
Dsheng
hi friends,
i am sambit, doing my m tech project on cooperative caching in manet. but i face some problems like
how to make dynamic clustering among the nodes in manet
how to spread data items inside manet
how to call a c++ procedure from tcl script etc
can any one help me in this regard.
my mail id : sambitmshr2@gmail.com
thanks
hi Manoj
i am facing some problems running this code.
firstly in the node config part in the tcl file, the energyModel on line 94 and idlePower on line 98 are being considered as “invalid command names”.
secondly when i comment them i am not getting the defined output (which mean at least the POSITION) in the simple.tr file.
Kindly help asap
Regards
Great article… Thank you for your help!
Hello sir,can u tell me how to make an active node become passive?
hi manoj,
how to obtain next hop of a node in aodv(ns2),using god object?if not possible using god then how else?
hi,
I want a single node’s position. How i have to add the condition in the above program.Can u plz tell that condition.
Jeru
Hello;
i tried to execute this exapmle without success.
I did not get the informations in the terminal.
shoul i do make et make install for ns-2 after modifying the aodv.cc and adodv.h?
i get also en erro ‘invalid command name” when i add node-config -idlPower??
Any help please ???????
thanks in advance for your help.*
siwar
Hi BeroOo and everyone else
can anyone of you please tell me how this code is running at their end?
do we need to put some changes in it or what else
Thanks and Regards
Hello Manoj Sir,
can I do the same changes in ns-2.31 version… can you please help me sir, what do I need to modify additionally…
Thanks & Regards,
Divya Ganesh
Yes, there are some little changes on the code to work.. Contact me on my e-mail if you want more help.
I want to know what r the companies(like IBM, HCL….ect..) using NS2 for testing or developing or some other purpose….
plzzz tell me……..
can u send this obtaining node position and energy for the DSR routing protocol
can u send this obtaining node position and energy for the DSR protocol
I don’t think any company is using NS2 for its services/production!
We are doing our B.Tech main project on the topic:load balancing-An Approach Based on Clustering in Manet.We are planning to do this in NS2.We are completely new to this topic.And would like to know the details on the following:
1.how to create nodes dynamically using cbrp
2.selecting clusterheads
hello.. monoj sir.. i successfully added above modification but i dont get printed value at my terminal window.. please do reply
hi ,
am not getting node ‘s position and energy……
am just getting SORTING LISTS DONE…
NS EXISTING…..
please help me in sorting out this…
hello
will u please tell me how a node can go in sleep mode and come back to its real state, using AODV protocol in ns2.35
how to replicate data items in mobile nodes using ns2
can we assign different energy value for different nodes ?????????????????? in ns2
then how?????????? plz……….help me
on the last code ?? what does mean (index)
it’s not declared ??? How can we declare it
thank you so much
can u suggest me how can i track a mobile node.Please reply
how to find energy level on node
Hi All,
I do not get the output as the terminal. Can anyone explain how to get the output. please …
Hi Everyone this is Jyoti from TechnoZonk.
We can develop any kind of simulation based on NS2.
NS2 Project Developers and NS2 Training In India. Having 14+ years experience in Networking, Linux and Network Simulator over 7+ years. First time Professional Ns2 Reserch projects development done by us and delivered more than 300 projects around India . Also trained more than 2000 students in ns2. Having strong knowledge to bring new domain and create strong professionals for the same.
Contact us :9920118169
for more info or email us on rungtajyoti@yahoo.co.in
Sir,
Could u please tell how to print the signal strength of a particular node in ns2. I have already printed the pr value by copying the print statement from propagation.cc to tworayground.cc. now plwase help me to print pr for a particular node sir…
hello sir….can you tell me if we want to change power level on certain condition how we can do it.
Thank you for sharing this it works
Hi,
Thanks for your code.. tried the same.. i am getting segmentation fault.. I am very new to ns2.. Can you please tell me how to debug?
can u tell me how nodes can be made as task
which energy is max at nodes? kinetic or potential.
hi manoj
I’m mitra n i’m so happy to finad ur blog it’s so handy.
thank u so much 4 ur awesome code, i’ve run itand it does work very well
but i want to do the exact same thing in my tcl file
i mean finding the current mobile node position in tcl code
will u please help me out with it.
i appreciate any help.
how to compile ns2,34 after adding energy and position details to get position and energy.
will this piece of code work on ns2.28? I have tried it, but it hasn’t. What can be the possible alterations?
what about DSR protocol??
how to compare particular node with current index value
for example to compare 5 node with index value
how to change code in aodv.cc file
Hi,
i want to print transmission energy and reception energy with node ID of whenever packet is sent and receive. I can print the transmission and receive energy whenever this operation is performed in wireless-phy.cc but unable to print the node ID. I’ll be grateful if anyone can guide how to print node ID in wireless-phy.cc.
Regards,
Najma
hi manoj could you please write an article to print current load of node dynamically.
i did all changes above mentioned. and when i execute make i am getting below error error: invalid use of incomplete type ‘class MobileNode’
ypos=iNode->Y();
please help me
can u tell me how to disable a node on particular time
hi!
I try to run simple-wireless.tcl follow your conduct but I see a error :
invalid comman -energyModel
so can you help me ?
can you help me to finding HCTT protocol for solving boundry problems in custers?
i implement this code to get the energy of node, make command was successful with out errors but when i compile tcl file it gives me segmentation fault. please can any one help me why this error and how to fix it???
pls, i need tcl script for simulating 10, 20, 30, 40 and 50 nodes simultaneously