LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find Residual Energy of the nodes in ns2 (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-residual-energy-of-the-nodes-in-ns2-4175613838/)

khanhcn 09-14-2017 11:28 PM

How to find Residual Energy of the nodes in ns2
 
Hi all,

I am writing a tcl script for WSN in NS-2. In my script, I want to summary residual energy of each nodes in trace file .tr

I have googled some sites, but i does not works. I have seen also some thread in this forum but answer is not clear.

http://slogix.in/how-to-find-residua...e-nodes-in-ns2

https://ns2research.wordpress.com/20...rgy-of-a-node/

I followed second link, declare in aodv.h and add code into aodv.cc

Code:

double AODV::get_energy(nsaddr_t addr);
Code:

double AODV::get_energy(nsaddr_t addr)
{
Node* thisnode = Node::get_node_by_address(addr);
double energy ;
energy = thisnode->energy_model()->energy();
return energy;
}

In tcl scrip, I also declare EnergyModel. However, I don't know how to call this function in tcl script

Code:

$ns node-config  -energyModel "EnergyModel" \
                  -initialEnergy 3.4 \
                  -txPower 0.33 \
                  -rxPower 0.1 \
                  -idlePower 0.05 \
                  -sleepPower 0.03 \

Code:

set energy [new Agent/AODV] ???
Thanks,
Khanh CN

knudfl 09-15-2017 11:41 AM

Welcome to LQ.

Simulation examples, energy model : EnergyModel-examples.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing

Example : $ ns aodv-Soumia.tcl → The trace file is simple.tr 25.9MB.

Lines with ``energy´´ in simple.tr :
$ grep energy simple.tr >> Energy.txt

Energy : $ awk -f energy-tes.awk simple.tr
The ~140 awk scripts https://drive.google.com/file/d/0B7S...ew?usp=sharing


About "double OLSR::get_energy(nsaddr_t addr);" (for OLSR.cc ?)
Probably of no use, unless you are using the OLSR protocol : umolsr-ns235_v1.0-2014.patch
https://drive.google.com/file/d/0B7S...ew?usp=sharing

All patches https://drive.google.com/drive/folde...00?usp=sharing

All ~2500 examples https://drive.google.com/drive/folde...Ws?usp=sharing

-

knudfl 09-15-2017 12:03 PM

Analyzing tool for energy, etc. : APP-Tool
https://github.com/WiNG-NITK/APP-Tool
.... See README.md

The result from simple.tr :
Code:

Average Residual Energy
Average residual energy                  :461.045223

---------------------
Residual Energy for particular node
Residual energy of node 0 is : 955.677067



---------------------


khanhcn 09-18-2017 10:42 PM

Quote:

Originally Posted by knudfl (Post 5759158)
Welcome to LQ.

Simulation examples, energy model : EnergyModel-examples.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing

Example : $ ns aodv-Soumia.tcl → The trace file is simple.tr 25.9MB.

Lines with ``energy´´ in simple.tr :
$ grep energy simple.tr >> Energy.txt

Energy : $ awk -f energy-tes.awk simple.tr
The ~140 awk scripts https://drive.google.com/file/d/0B7S...ew?usp=sharing

-

It is OK. Thank you very much.

khanhcn 11-07-2017 01:15 AM

Quote:

Originally Posted by knudfl (Post 5759158)
Welcome to LQ.

Simulation examples, energy model : EnergyModel-examples.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing

Example : $ ns aodv-Soumia.tcl → The trace file is simple.tr 25.9MB.

Lines with ``energy´´ in simple.tr :
$ grep energy simple.tr >> Energy.txt

Energy : $ awk -f energy-tes.awk simple.tr
The ~140 awk scripts https://drive.google.com/file/d/0B7S...ew?usp=sharing

https://drive.google.com/file/d/0B7S...ew?usp=sharing

All patches https://drive.google.com/drive/folde...00?usp=sharing

All ~2500 examples https://drive.google.com/drive/folde...Ws?usp=sharing

-

Hi @knudfl, one more question.

Which is exactly .awk file to be used to analysis Packet Delivery Ratio after complete simulation.

Regards,

knudfl 11-07-2017 04:22 AM

Re #5 : Please do not quote entire posts. A "one word reference" will do.

Packet Delivery Ratio : Usually PDR.awk → also included in "Top 20 scripts"
https://drive.google.com/file/d/0B7S...ew?usp=sharing
.... mostly awk scripts from APP-Tool.


All times are GMT -5. The time now is 06:16 PM.