一、下载gpsr协议源码,在~/ns-allinone-2.35/ns-2.35下解压,得到gpsr文件夹。
源码地址:点击打开链接
7个为协议实现文件:
gpsr_packet.h : definition of packets of different type used by this implementaion
gpsr_neighbor.h : definition of the neighbor list of each node used by this gpsr implementation including the planaring procedure (both GG and RNG)
gpsr_neighbor.cc : the implementation of the neighbor list class
gpsr.h : the definition of functions of GPSR routing agent of this implementation
gpsr.cc : the implementation of the GPSR routing agent
gpsr_sinklist.h: definition used for scenarios with multiple sinks
gpsr_sinklist.cc: implementation of gpsr_sinklist.cc
以上4个文件为仿真所需文件
gpsr.tcl : the node and agent creation functions used by simultion configuration in wireless-gpsr.tcl
wireless-gpsr.tcl : the simulation configuration
grid-deploy10x10.tcl : 100 nodes in a 200x200 meter area
cbr100.tcl : node 99 sends cbr traffic on UDP to node 0
二、修改packet.h
进入~/ns-allinone-2.35/ns-2.35/common文件夹, 打开packet.h文件,增加一行:
static const packet_t PT_GPSR = 73
关键代码如图:
static const packet_t PT_GPSR = 73;
// insert new packet types here
static packet_t PT_NTYPE = 74; // This MUST be the LAST one
三、修改trace/cmu-trace.cc
进入~/ns-allinone-2.35/ns-2.35/trace,打开cmu-trace.cc文件。
在65行左右增加一行:
#include <gpsr/gpsr_packet.h>
关键代码如图:
#include <mdart/mdart_function.h>
#include <gpsr/gpsr_packet.h>
#include <cmu-trace.h>
在void CMUTrace::format(Packet *p, const char *why){}中第1460行左右增加2行:
case PT_GPSR:
break;
关键代码如图:
case PT_PING:
break;
case PT_GPSR:
break;
default:
四、修改priqueue.cc
进入~/ns-allinone-2.35/ns-2.35/queue文件夹, 打开priqueue.cc文件。
在void PriQueue::rece(Packet *p, Handler *h){}中第95行附近增加一行:
case PT_GPSR:
关键代码如图:
case PT_AOMDV:
case PT_GPSR:
case PT_MDART:
五、修改ns-packet.tcl
在~/ns-allinone-2.35/ns-2.35/tcl/lib文件夹, 打开ns-packet.tcl文件。
在set protolist{}中174行附近加入一行
GPSR
关键代码如图:
Diffusion # diffusion/diffusion.cc
GPSR
IMEP # Internet MANET Encapsulation Protocol, for ad-hoc networks
六、修改Makefile
在~/ns-allinone-2.35/ns-2.35,打开Makefile
在OBJ_CC = 的最后加入
gpsr/gpsr_neighbor.o gpsr/gpsr_sinklist.o gpsr/gpsr.o \
关键代码如图:
wpan/p802_15_4trace.o wpan/p802_15_4transac.o \
apps/pbc.o \
gpsr/gpsr_neighbor.o gpsr/gpsr_sinklist.o gpsr/gpsr.o \
$(OBJ_STL)
注意:每个【.o】后均有一个空格,包括最后一个【gpsr.o】
如果需要加入调试信息,则在CCOPT = -Wall 加上 -g, 如下:
CCOPT = -g -Wall
七、重新编译
cd ~/ns-allinone-2.35/ns-2.35/common
touch packet.cc
cd ..
make clean
make
八、 运行仿真
进入~/ns-allinone-2.35/ns-2.35/gpsr文件夹,运行:
ns wireless_gpsr.tcl
有疑问可参看源码包中的readme。
原创文章,转载请注明!
分享到:
相关推荐
基于ns2的gpsr协议源代码,其中包括两个版本,keliu版加普通版
gpsr路由协议c++实现,添加了除了距离因素以外的链路质量因素作为选路判据。
NS2 中植入GPSR模型,并且把自己遇到的一些问题总结了一下。
gpsr协议包
这个是在ns2里嵌入了gpsr路由协议后,利用gpsr协议仿真的无线网络的例子。下载的gpsr有一些错误,是在更正了之后才引入的这个协议,并且运行了一下,没有问题
ns 2.35平台上移值gpsr协议代码
能够成功添加到ns2中的贪婪周边无状态路由协议(GPSR)源码
已修改过的gpsr协议,无需再更改,直接放入NS2文件夹下然后修改NS2的内容即可。
NS2中可用的GPSR路由协议修改版,加上了目的节点位置刷新
gpsr和location-service里的内容不用修改。适合于ns-3.26及以下版本。
自组织车联网中GPSR路由协议的研究进展.pdf
GPSR路由matlab实现,模拟仿真了路由算法的各种性能指标,若有不足请批评指正。
至广大无线传感器网络开发爱好者: GPSR是基于地理位置的路由,它的主要优点是它是stateless的,即每个节点只需要知道节点本身和它邻居的位置信息,即可做出路径选择,而不需要维护其它的状态,这使得它非常...
GPSR路由协议的NS2源代码,很健全,可以直接用
基于粒子群算法的车载自组网GPSR协议优化.pdf
KeLiu版本GPSR路由协议源码,应用在NS2仿真平台
gpsr在ns2仿真平台上的仿真,包含协议源码
NS-3 这是一个NS-3项目,旨在模拟Adhoc路由协议。
柯学习ns2快速入门手册,进如下载,能有效帮助那些初入门的同学学习!