ns2 gives an error message when i try to use an energy model in my tcl script.
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
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
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 .
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
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 ?
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.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.