NS2下运行Leach协议 “./test" 后警告处理方法

系统:linux mint 17

软件:NS-2.34

参考链接:http://blog.sina.com.cn/s/blog_3c680f810100bnl3.html

如果出现如下错误:

num_nodes is set 3
node-config
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
create-wireless-node
DSDV
warning: no class variable Phy/WirelessPhy::alive_
        see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
INITIALIZE THE LIST xListHead
create-wireless-node
DSDV
warning: no class variable Phy/WirelessPhy::alive_
        see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
$
create-wireless-node
DSDV
warning: no class variable Phy/WirelessPhy::alive_
        see tcl-object.tcl in tclcl for info about this warning.
warning: no class variable Phy/WirelessPhy::Efriss_amp_
warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_
warning: no class variable Phy/WirelessPhy::EXcvr_
warning: no class variable Phy/WirelessPhy::sleep_
warning: no class variable Phy/WirelessPhy::ss_
warning: no class variable Phy/WirelessPhy::dist_
Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 89.8
SORTING LISTS ...DONE!
NS EXITING...

 

需要对照/home/yourname/ns-allinone-2.34/ns-2.34/mac/wireless-phy.cc

修改/home/yourname/ns-allinone-2.34/ns-2.34/tcl/lib/ns-default.tcl

添加代码如下(红色部分,大概在765行):

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0  

Phy/WirelessPhy set alive_ 1
Phy/WirelessPhy set Efriss_amp_ 100*1e-12
Phy/WirelessPhy set Etwo_ray_amp_ 0.013*1e-12
Phy/WirelessPhy set EXcvr_ 50*1e-9
Phy/WirelessPhy set sleep_ 0
Phy/WirelessPhy set ss_ 1
Phy/WirelessPhy set dist_ 0

后面数字的值来自于/home/yourname/ns-allinone-2.34/ns-2.34/mac/wireless-phy.cc文件,大概在95行左右

注意:set后面设置变量值的时候数字和星号之间不能有空格

然后执行:

sudo make clean

sudo make

./test

显示如下结果:

num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 28.4
SORTING LISTS ...DONE!
NS EXITING...
执行成功

posted on 2015-04-03 09:38  ysu_shunfu  阅读(338)  评论(0)    收藏  举报

导航