LinuxQuestions.org
Help answer threads with 0 replies.
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 03-20-2018, 03:55 AM   #1
suhaib sheikh
LQ Newbie
 
Registered: Feb 2018
Posts: 7

Rep: Reputation: Disabled
ns2 gives an error message when i try to use an energy model in my tcl script.


Hello ,
I am new to ns2.

i am trying to calculate energy consumed by nodes in a network during simulation in ns2 ,the energy model i use is given below :

set val(energymodel) EnergyModel ;
set val(initialenergy) 100 ;# Initial energy
set val(x) 1200
set val(y) 1200
-energyModel $val(energymodel)
-initialEnergy $val(initialenergy)\
-movementTrace ON \
-idlePower 720e-6 \
-rxPower 5.28e-4 \
-txPower 10.032e-3 \
-sleepPower 1.2e-9 \

when i run the tcl file ,it throws an error message
"warning: please use -channel as shown in tcl/ex/wireless-mitf.tcl
invalid command name"-energyModel"
while executing
"-energyModel $val(energymodel)"
(file "script-olsr-sa2copy.tcl" line 129)

Kindly help.

Last edited by suhaib sheikh; 03-20-2018 at 03:57 AM.
 
Old 03-20-2018, 05:50 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
file "script-olsr-sa2copy.tcl" line 129
Well, we can only guess what's in line 129, but possibly node creation.

It may be easier to edit an EnergyModel ex to OLSR : set val(rp) OLSR
.... and add OLSR "configurations" : Ex 1.
Code:
# Simulator Instance Creation
set ns	[new Simulator]

# ======================================================================
# control OLSR behaviour from this script -
# commented lines are not needed because
# those are default values
#
Agent/OLSR set use_mac_    true
#Agent/OLSR set debug_      false
#Agent/OLSR set willingness 3
#Agent/OLSR set hello_ival_ 2
#Agent/OLSR set tc_ival_    5
# ======================================================================
... or Ex 2.
Code:
# Simulator Instance Creation
set ns	[new Simulator]

# ======================================================================
# Routing protocol configuration: OLSR
# ======================================================================
# OLSR RFC
set options(HELLO_INTERVAL_) 2.0;
set options(REFRESH_INTERVAL_) 2.0;
set options(TC_INTERVAL_) 5.0;
set options(WILLINGNESS_) 3; 
set options(OLSR_NEIGHB_HOLD_TIME_) 6.0;
set options(OLSR_TOP_HOLD_TIME_) 15.0;
set options(OLSR_DUP_HOLD_TIME_) 30;
set options(OLSR_MID_HOLD_TIME_) 15.0;

Agent/OLSR set use_mac_    true
Agent/OLSR set debug_      false
Agent/OLSR set willingness $options(WILLINGNESS_)
Agent/OLSR set hello_ival_ $options(HELLO_INTERVAL_)
Agent/OLSR set tc_ival_    $options(TC_INTERVAL_)
Agent/OLSR set mid_ival_   $options(REFRESH_INTERVAL_) 
Agent/OLSR set OLSR_NEIGHB_HOLD_TIME $options(OLSR_NEIGHB_HOLD_TIME_)
Agent/OLSR set OLSR_TOP_HOLD_TIME $options(OLSR_TOP_HOLD_TIME_)
Agent/OLSR set OLSR_DUP_HOLD_TIME $options(OLSR_DUP_HOLD_TIME_)
Agent/OLSR set OLSR_MID_HOLD_TIME $options(OLSR_MID_HOLD_TIME_)
# ======================================================================

# control OLSR behaviour from this script -
# commented lines are not needed because
# those are default values
#
Agent/OLSR set use_mac_    true
#Agent/OLSR set debug_      false
#Agent/OLSR set willingness 3
#Agent/OLSR set hello_ival_ 2
#Agent/OLSR set tc_ival_    5
Ex 1. OLSR-Soumia.tcl https://www.dropbox.com/s/wta5iy0o9e...oumia.tcl?dl=0
Ex 2. 2OLSR-Soumia.tcl https://www.dropbox.com/s/3m19v31mn4...oumia.tcl?dl=0

EnergyModel-examples-3.tar.gz
https://drive.google.com/file/d/1LMw...ew?usp=sharing

-

Last edited by knudfl; 03-20-2018 at 05:55 AM.
 
Old 03-20-2018, 08:17 AM   #3
suhaib sheikh
LQ Newbie
 
Registered: Feb 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
sir, am really sorry but i am not able to understand what you are trying to explain to me .
i tried the example scripts , but couldn't understand much .

Guess , i would need more of your help.
 
Old 03-20-2018, 09:28 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #3.

Please explain in details, what it is you don't understand.

"More help" : It is difficult to add EnergyModel to OLSR simulation examples. EDIT : See post #7.
It's easy to add OLSR protocol and OLSR definitions to EnergyModel examples.
That's why I showed how to add OLSR to a "basic" aodv EnergyModel example.
And by the way, we don't know your file ``script-olsr-sa2copy.tcl´´.
If you want anything done with 'script-olsr-sa2copy.tcl', please attach the file as script-olsr-sa2copy.tcl.txt : I.e. text files require suffix .txt to attach.

.. Attachments: That's the 'paper clip tool' in the 'Advanced Editor'.
Quote:
i tried the example scripts
Did try out the ~20 energy examples and the two OLSR examples ?

-

Last edited by knudfl; 03-20-2018 at 04:39 PM.
 
Old 03-20-2018, 10:01 AM   #5
suhaib sheikh
LQ Newbie
 
Registered: Feb 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
Sorry again.
I'l try to be more precise.
i have attached my .tcl script and the .awk file which i am using .Actually i want that when i run the tcl script, in the output , i should get the energy consumed by the network .i guess the code for energy model is missing in the script(which i have attached), so i tried to add the previously mentioned code (for energy model) in the script.but i got the error message . now i dont know what exactly is going wrong , is their a problem with the code or.awk file ?

i just read the examples you had previosly shared , but couldnt understand much. i am totally new to ns2.
Attached Files
File Type: txt script-olsr-sa .txt (13.2 KB, 39 views)
File Type: txt metrics.awk.txt (4.7 KB, 23 views)
 
Old 03-20-2018, 10:06 AM   #6
suhaib sheikh
LQ Newbie
 
Registered: Feb 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
Mentioned below is the energy model , that i am using.

set val(energymodel) EnergyModel ;
set val(initialenergy) 100 ;# Initial energy
set val(x) 1200
set val(y) 1200
-energyModel $val(energymodel)
-initialEnergy $val(initialenergy)\
-movementTrace ON \
-idlePower 720e-6 \
-rxPower 5.28e-4 \
-txPower 10.032e-3 \
-sleepPower 1.2e-9 \
 
Old 03-20-2018, 04:38 PM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #5, #6.

This time I had no issues adding EnergyModel (post #6) to the file.tcl: script-olsr-sa.tcl ...
. Uploaded as "Energymodel_script-olsr-sa.tcl"
. https://www.dropbox.com/s/ynku0jvxy2...sr-sa.tcl?dl=0
Code:
$ ns235-olsr-64 Energymodel_script-olsr-sa.tcl
... The files simulation.nam 6.4MB, wtrace.tr 35.4MB are created.
Text output is ~10,470 lines https://www.dropbox.com/s/5a7u2upthm...l_out.txt?dl=0
$ nam simulation.nam & : A perfect animation.
...

Your "metrics.awk" seems to fit olsr trace files perfect. Better than other scripts!
Code:
$ awk -f metrics.awk wtrace.tr 

--------METRICS-----------

Total Packets Sent              :       10512
Total Packets Received          :       5968
Total Packets Dropped           :       4691
Total Packets Forwarded         :       8844
Packet Delivery Ratio           :       56.77%
The total hop counts are        :       21565
Average Hop Count               :       3 hops
Routing Overhead                :       0
Normalized Routing Load         :       0.0000
Througphut of the network(KBps) :       2.9840
Average End to End Delay        :0.668054854 ms
Total Energy Consumed           :499000.532647
Protocol Energy Consumption     :99.800107
OLSR simulation examples : umolsr-examples-2Jun.17.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing
All ~2500 examples https://drive.google.com/drive/folde...Ws?usp=sharing

~200 analyzing scripts https://drive.google.com/file/d/1D_X...ew?usp=sharing
... Overview https://drive.google.com/file/d/1TEz...ew?usp=sharing
Top 25 scripts https://drive.google.com/file/d/1t9a...ew?usp=sharing

-

Last edited by knudfl; 03-20-2018 at 04:56 PM.
 
Old 03-20-2018, 11:50 PM   #8
suhaib sheikh
LQ Newbie
 
Registered: Feb 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
sorry sir to bother to again ,
i have some concerns here , i made the changes as you suggested,it didn't work,but when i copy pasted your edited script and made a new file , it worked ?


second, i made the same changes in some other scripts,they again show the same error message on my system.

warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
invalid command name "-energyModel"
while executing
"-energyModel $val(energymodel) \
-initialEnergy $val(initialenergy)\
-movementTrace ON \
-idlePower ..."
(file "script-olsr-sa2copy.tcl" line 129).


idont know if i am doing anything wrong or there is a problem with my olsr installation.

Last edited by suhaib sheikh; 03-21-2018 at 01:10 AM.
 
Old 03-21-2018, 04:46 AM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #8.
Quote:
when i copy pasted your edited script and made a new file , it worked
Why not download from https://www.dropbox.com/s/ynku0jvxy2...sr-sa.tcl?dl=0

Your errors : You may have some hidden characters in your files.
(Those hidden / invisible (and forbidden) characters can origin from a html file, or from Windows© / a Windows© application.)

Please be aware that the original {script-olsr-etx.tcl, script-olsr-md.tcl, script-olsr-ml.tcl, script-olsr.tcl} https://github.com/wevertoncordeiro/olsr-ns2 ... also are included in umolsr-examples-2Jun.17.tar.gz .

Quote:
invalid command name "-energyModel"
See post #2 : "node creation", line 129 → made impossible by other errors.
Solution: Download 'Energymodel_script-olsr-sa.tcl' and watch my edits.

-
 
  


Reply

Tags
energy model, ns2, olsr


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 reset the node energy after some treatment in NS2 TCL ? Hataki_Kakachi Linux - Software 3 05-03-2019 04:06 PM
Problems in energy model ns2 hbenlabbes Linux - Software 1 12-11-2015 06:32 AM
implementation of energy model in NS2 ali_it Programming 3 07-07-2015 11:43 AM
Trace for energy Model in ns2.31 ines8989 Linux - Networking 5 01-30-2014 11:13 AM

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

All times are GMT -5. The time now is 09:17 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