将mit-μAMPS的ns扩展代码(LEACH)移植到ns-2.33

转自:http://blog.sina.com.cn/s/blog_62a594f70100ff1b.html

+++++++++++++++++++++++++++++++++++++++++++++++++++

㈠新建文件夹leach,将mit.tar.gz放在其中


tar xvfz mit.tar.gz

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


㈡复制文件

 

①将leach/mit整个目录复制到ns-allinone-2.33/ns-2.33中


②将leach/mac目录下的

mac-sensor.cc, mac-sensor.h, mac-sensor-timers.cc, mac-sensor-timers.h

四个文件复制到ns-allinone-2.33/ns-2.33/mac中


③将leach/tcl/mobility目录下的四个文件复制到ns-allinone-2.33/ns-2.33/tcl/mobility中


④将ns-allinone- 2.33/ns-2.33/tcl/ex目录下的wireless.tcl重命名为wireless_1.tcl,再将leach/tcl/ex目录下的 wireless.tcl复制到ns-allinone-2.33/ns-2.33/tcl/ex中


⑤将leach目录下的test,leach_test,package_up三个文件复制到ns-allinone-2.33/ ns-2.33中

----------------------------------------------------------------------------------------------
㈢修改文件


①需要修改的文件有:

ns-allinone-2.33/ns-2.33/apps/app.cc,app.h

ns-allinone-2.33/ns-2.33/trace/cmu-trace.cc,cmu-trace.h
ns-allinone-2.33/ns-2.33/common/mobilenode.cc,packet.cc,packet.h

ns-allinone-2.33/ns-2.33/macannel.cc,ll.h,mac.cc,phy.cc,phy.h,wireless-phy.cc,wireless-phy.h


②修改方法:

对于leach目录下相应的文件(即刚才未复制的文件),将代码中以“#ifdef MIT_uAMPS”开始,并以“#endif”结束的部分复制到以上文件对应的位置


③特殊情况


ns-allinone-2.33/ns-2.33/common/packet.h中大约185行,根据其他变量的格式将代码更改为

#ifdef MIT_uAMPS

static const packet_t PT_RCA = 61;

#endif

并将最后一个枚举值改为62


ns-allinone-2.33/ns-2.33/mac/wireless-phy.h,给类WirelessPhy添加public变量,大约105行

#ifdef MIT_uAMPS

MobileNode * node_;
#endif


ns-allinone-2.33/ns-2.33/mac/wireless-phy.h,对于Antenna *ant_;和Propagation *propagation_;之间的那部分代码,应将其置于public声明的最后(private之前), 即Propagation变量必须保持为public


ns-allinone-2.33/ns-2.33/mac/wireless-phy.cc(大约234行),wireless-phyExt.cc (大约132行),将代码中的

node_ = (Node *)obj;

改为
#ifdef MIT_uAMPS

node_ = (MobileNode *)obj;

#else

node_ = (Node *)obj;

#endif


④修改ns-allinone-2.33/ns-2.33/mit/uAMPS/ns-leach.tcl

将set dst_ $mac_dsc改为set dsc_addr $mac_dsc


⑤修改ns-allinone-2.33/ns-2.33目录下的Makefile文件


在DEFINE行的最后添加-DMIT_uAMPS 在INCLUDE行的中间添加-I./mit/rca -I./mit/uAMPS /

 

在代码gaf/gaf.o /之前添加

mit/rca/energy.o mit/rca/rcagent.o /
mit/rca/rca-ll.o mit/rca/resource.o /

mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPSagent.o /

----------------------------------------------------------------------------------------------
㈣编译

make clean make

----------------------------------------------------------------------------------------------
㈤给.bashrc添加环境变量

export RCA_LIBRARY=/安装目录/ns-allinone-2.33/ns-2.33/mit/rca

export uAMPS_LIBRARY=/安装目录/ns-allinone-2.33/ns-2.3/mit/uAMPS

----------------------------------------------------------------------------------------------
㈥修改ns-allinone-2.33/ns-2.33/test

交换最后两行顺序

----------------------------------------------------------------------------------------------
㈦测试是否安装成功

sh test
如成功,ns-allinone-2.33/ns-2.33/mit/leach_sims/leach.err内容应为

INITIALIZE THE LIST xListHead SORTING LISTS ...DONE!

 

你可能感兴趣的:(扩展,include,library,makefile,DST,sorting)