LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-14-2017, 11:28 PM   #1
khanhcn
LQ Newbie
 
Registered: Sep 2017
Posts: 8

Rep: Reputation: Disabled
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

Last edited by khanhcn; 09-15-2017 at 07:27 PM.
 
Old 09-15-2017, 11:41 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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

-

Last edited by knudfl; 09-15-2017 at 11:44 AM.
 
1 members found this post helpful.
Old 09-15-2017, 12:03 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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 



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

Last edited by knudfl; 09-15-2017 at 12:05 PM.
 
Old 09-18-2017, 10:42 PM   #4
khanhcn
LQ Newbie
 
Registered: Sep 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
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.
 
Old 11-07-2017, 01:15 AM   #5
khanhcn
LQ Newbie
 
Registered: Sep 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
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,
 
Old 11-07-2017, 04:22 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.
 
  


Reply

Tags
ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find Residual Energy of the nodes in ns2 khanhcn Linux - Newbie 1 09-15-2017 07:21 AM
To find Residual Energy of nodes in OLSR protocol-NS-2.35 shelja.fet@mriu.edu.in Linux - Newbie 3 07-21-2016 07:43 AM
How to find residual a residual energy of a node in wireless network in ns2 pon Linux - Newbie 0 08-31-2014 10:44 AM
LEACH on ns2. Anyone know how to obtain residual network energy? linuxUser123linux Linux - Software 1 07-13-2013 04:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration