NS-2.35中添加gpsr
来源:互联网 发布:南京软件 外包公司 编辑:程序博客网 时间:2024/04/29 10:03
文的内容转载自:http://blog.sina.com.cn/s/blog_6735526a0101fkha.html。中间按照自己做的过程进行了一些修改。我按照前面链接上的方法做了,还是出了一些错误。后边我会陆续把怎么解决问题的贴上来。
gpsr协议为Ke liu写的协议
步骤一:/ns-allinone-2.35/ns-2.35下新建gpsr文件夹,然后将文件:gpsr.cc,gpsr.h, gpsr.tcl, gpsr_neighbor.cc, gpsr_neighbor.h, gpsr_packet.h,gpsr_sinklist.cc, gpsr_sinklist.h,wireless-gpsr.tcl全部复制到新建的gpsr文件夹下。
步骤二:修改NS中与mflood协议相关的文件
(1)/ns-allinone-2.35/ns-2.35/common/packet.h
gpsr协议定义的分组类型为:GPSR,需要将该分组类型添加到packet.h文件中。该添加过程需要做两处改动:
其一,修改packet_t的类型。在PT_NTYPE之前加入PT_MFLOOD。如下面下滑线的代码是新加入的内容。添加自定义的分组类型是必须保证PT_NTYPE为最后一个。
2.35中为了使得新加动态库中可以动态定义新的分组,预定义的分组类型通过static const来实现。
typedef unsigned int packet_t;
……
// insert new packet types here
static const packet_t PT_MFLOOD = 73; //
static const packet_t PT_GPSR = 74; //
static packet_t PT_NTYPE = 75; // This MUST be the LAST one<---这行注意改一下
static const packet_t PT_MFLOOD = 73; //
static const packet_t PT_GPSR = 74; //
static packet_t PT_NTYPE = 75; // This MUST be the LAST one<---这行注意改一下
其二,在class p_info { }下的static void initName()中加入对应分组类型PT_GPSR的字符串:name [PT_GPSR]="GPSR"。
name_[PT_DCCP_CLOSEREQ]="DCCP_CloseReq";
name_[PT_DCCP_RESET]="DCCP_Reset";
name_[PT_MFLOOD]="MFlood";
name_[PT_GPSR]="GPSR";
name_[PT_NTYPE]= "undefined";
name_[PT_NTYPE]= "undefined";
(2)/ns-allinone-2.35/ns-2.35/trace/cmu-trace.cc:
其一,头文件中添加:#include <gpsr/gpsr_packet.h>
其二,添加下划线中的代码
void CMUTrace::format(Packet* p, const char *why)
{
hdr_cmn *ch = HDR_CMN(p);
……
switch(ch->ptype()) {
case PT_MAC:
……
switch(ch->ptype()) {
case PT_AODV:
format_aodv(p, offset);
break;
……
case PT_DIFF:
break;
case PT_GPSR:
break;
case PT_GAF:
case PT_PING:
break;
default:
……
}
}
}
(3)/ns-allinone-2.35/ns-2.35/queue/priqueue.cc:
void
PriQueue::recv(Packet *p, Handler *h)
{
struct hdr_cmn *ch = HDR_CMN(p);
if(Prefer_Routing_Protocols) {
switch(ch->ptype()) {
case PT_DSR:
case PT_MESSAGE:
case PT_TORA:
case PT_AODV:
case PT_AOMDV:
case PT_GPSR:
case PT_MFLOOD:
case PT_MDART:
recvHighPriority(p, h);
break;
default:
Queue::recv(p, h);
}
}
else {
Queue::recv(p, h);
}
}
void CMUTrace::format(Packet* p, const char *why)
{
hdr_cmn *ch = HDR_CMN(p);
……
switch(ch->ptype()) {
case PT_MAC:
……
switch(ch->ptype()) {
case PT_AODV:
format_aodv(p, offset);
break;
……
case PT_DIFF:
break;
case PT_GPSR:
break;
case PT_GAF:
case PT_PING:
break;
default:
……
}
}
}
(3)/ns-allinone-2.35/ns-2.35/queue/priqueue.cc:
void
PriQueue::recv(Packet *p, Handler *h)
{
struct hdr_cmn *ch = HDR_CMN(p);
if(Prefer_Routing_Protocols) {
switch(ch->ptype()) {
case PT_DSR:
case PT_MESSAGE:
case PT_TORA:
case PT_AODV:
case PT_AOMDV:
case PT_GPSR:
case PT_MFLOOD:
case PT_MDART:
recvHighPriority(p, h);
break;
default:
Queue::recv(p, h);
}
}
else {
Queue::recv(p, h);
}
}
(4)/ns-allinone-2.35/ns-2.35/tcl/lib/ns-packet.tcl:
set protolist {
# Common:
......
# Mobility, Ad-Hoc Networks, Sensor Nets:
MFlood #add by qfy for mflood protocol, 2015/12/04
GPSR #add by qfy for GPSR protocol, 2015/12/07
AODV # routing protocol for ad-hoc networks
Diffusion # diffusion/diffusion.cc
IMEP # Internet MANET
......
}
(5)/ns-allinone-2.35/ns-2.35/tcl/lib/ns-lib.tcl:
Simulator instproc create-wireless-node args {
......
switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self create-aodv-agent $node]
}
......
OMNIMCAST {
eval $node addr $args
set ragent [$self create-omnimcast-agent $node]
}
MFlood {
set ragent [$self create-mflood-agent $node]
}
GPSR {
set ragent [$self create-gpsr-agent $node]
}
......
}
}
}
Simulator instproc create-wireless-node args {
......
switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self create-aodv-agent $node]
}
......
OMNIMCAST {
eval $node addr $args
set ragent [$self create-omnimcast-agent $node]
}
MFlood {
set ragent [$self create-mflood-agent $node]
}
GPSR {
set ragent [$self create-gpsr-agent $node]
}
......
}
}
}
添加下划线中的内容。
Simulator instproc create-puma-agent { node } {
# Create PUMA routing agent
set ragent [new Agent/PUMA [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-mflood-agent { node } {
set ragent [new Agent/MFlood [$node id]]
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-gpsr-agent { node } {
set ragent [new Agent/GPSR [$node id]]
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-mdart-agent { node } {
# Create M-DART routing agent
set ragent [new Agent/MDART [$node node-addr]]
$self at 0.0 "$ragent start" ;# start BEACON/HELLO Messages
$node set ragent_ $ragent
return $ragent
}
# Create PUMA routing agent
set ragent [new Agent/PUMA [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-mflood-agent { node } {
set ragent [new Agent/MFlood [$node id]]
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-gpsr-agent { node } {
set ragent [new Agent/GPSR [$node id]]
$node set ragent_ $ragent
return $ragent
}
Simulator instproc create-mdart-agent { node } {
# Create M-DART routing agent
set ragent [new Agent/MDART [$node node-addr]]
$self at 0.0 "$ragent start" ;# start BEACON/HELLO Messages
$node set ragent_ $ragent
return $ragent
}
(6)/ns-allinone-2.35/ns-2.35/Makefile:(sudo gedit Makefile)
OBJ_CC = \
measure/mudp.o measure/mudpsink.o \
tools/random.o tools/rng.o tools/ranvar.o common/misc.o common/timer-handler.o \
......
wpan/p802_15_4trace.o wpan/p802_15_4transac.o \
apps/pbc.o \
mflood/mflood.o mflood/mflood-seqtable.o \
gpsr/gpsr_neighbor.o \
gpsr/gpsr_sinklist.o \
gpsr/gpsr.o \
$(OBJ_STL)
OBJ_CC = \
measure/mudp.o measure/mudpsink.o \
tools/random.o tools/rng.o tools/ranvar.o common/misc.o common/timer-handler.o \
......
wpan/p802_15_4trace.o wpan/p802_15_4transac.o \
apps/pbc.o \
mflood/mflood.o mflood/mflood-seqtable.o \
gpsr/gpsr_neighbor.o \
gpsr/gpsr_sinklist.o \
gpsr/gpsr.o \
$(OBJ_STL)
步骤三:重新编译NS2
cd /ns-allinone-2.35/ns-2.35/common
sudo touch packet.cc
cd ..
make clean
make
sudo make install
最后运行测试文件:wireless-gpsr.tcl。终端显示如下:
num_nodes is set 100
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
GPSR configuration file
INITIALIZE THE LIST xListHead
Loading connection pattern...
Loading scenario file...
Load complete...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 129.2
SORTING LISTS ...DONE!
NS EXITING...
make中出现下面的提示,并不是错误,可以不理会。我现在也没弄明白是什么意思。
make[1]: Leaving directory `/home/XXX/ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
sudo make install
最后运行测试文件:wireless-gpsr.tcl。终端显示如下:
num_nodes is set 100
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
GPSR configuration file
INITIALIZE THE LIST xListHead
Loading connection pattern...
Loading scenario file...
Load complete...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 129.2
SORTING LISTS ...DONE!
NS EXITING...
make中出现下面的提示,并不是错误,可以不理会。我现在也没弄明白是什么意思。
make[1]: Leaving directory `/home/XXX/ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
0 0
- NS-2.35中添加gpsr
- ns 2.35中移值gpsr协议(KeLiu版)
- NS2中添加GPSR(KeLiu)协议
- NS-2.35添加MFlood协议
- 【NS2】NS2.35成功添加GPSR协议
- 在NS中添加一个新协议的步骤
- 在ns-3中添加自己编写的模块
- 如何在NS-2中添加协议[转载]
- 在NS中添加自己编写新协议的步骤
- ns-2与TCP拥塞模拟 之五 ns-2中添加核心模块-TCPAgent子类
- ns-2与TCP拥塞模拟 之五 ns-2中添加核心模块-TCPAgent子类
- 如何在NS-2 AODV协议中添加一种新的数据包类型
- 添加自己编写的模块到ns-3中出现undefined reference to问题的解决
- 如何在NS-2 AODV协议中添加一种新的数据包类型[转载]
- 【NS2】向ns中添加新的协议(ping协议)
- NS
- [翻译]NS下添加新协议
- NS中使用的语言
- Which three statements are correct about temporary tables? (Choose three.) A. Indexes and views can
- Android利用Fiddler进行网络数据抓包
- DOM事件详解(二)
- 战五渣系列之三(6个命令)
- Windows + IDEA + SBT 打造Spark源码阅读环境
- NS-2.35中添加gpsr
- 浅谈线程
- Cocos2dx下的selector对比!
- 构建基于Nginx的web服务器
- iOS navigationbar 的一些自定义设置
- JS调用OC方法(1)
- 如何验证PDF文档中的数字签名
- Eclipse 用Hibernate Tools 生成 .hbm cfg.xml等文件
- javascript学习笔记之Call()和Apply()