zrp_ns2_code
所属分类:Linux/Unix编程
开发工具:tcl/tk
文件大小:330KB
下载次数:306
上传日期:2009-05-04 11:39:34
上 传 者:
youzp
说明: 区域路由协议(ZRP),只能在ns2.1b9环境下运行,其他都不可以。
(Zone Routing Protocol (ZRP), the environment can only be run under ns2.1b9 other can not.)
文件列表:
ns-allinone-2.1b9 (0, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9 (0, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp (0, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\zrp.h (7979, 2002-11-04)
ns-allinone-2.1b9\ns-2.1b9\zrp\zrp_table.h (5483, 2002-11-04)
ns-allinone-2.1b9\ns-2.1b9\zrp\zrp.cc (80715, 2002-11-04)
ns-allinone-2.1b9\ns-2.1b9\zrp\zrp_table.cc (13615, 2002-11-04)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles (0, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\cmu-trace.cc (26557, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\cmu-trace.h (4826, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\ns-agent.tcl (5510, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\ns-default.tcl (36153, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\ns-lib.tcl (55621, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\ns-packet.tcl (7541, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\packet.h (16856, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\otherfiles\ns2-zrp.patch (6714, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo (0, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo1_rad2.tcl (7515, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo1_rad3.tcl (7515, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo2_rad2.tcl (7601, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo2_rad3.tcl (7601, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo3_rad2.tcl (7620, 2002-11-27)
ns-allinone-2.1b9\ns-2.1b9\zrp\demo\demo3_rad3.tcl (7620, 2002-11-27)
ZRP November 2002
Assumptions:
- we will be installing version ns-2.1b9 allinone in your home
directory (not ns-2.1b9a or any other version, these are not
guaranteed to work as of this writing)
- if you want to install somewhere else, make sure you untar
both ns2 and zrp while in the same directory. The zrp tarball
assumes the directory structure of ns-2 is in place. See
further note on untarring under installing ZRP2002 below.
I. Get ns-2
- download ns-allinone-2.1b9.tar.gz to your home directory
- type "tar xzvf ns-allinone-2.1b9.tar.gz" to untar archive
- type "cd ns-allinone-2.1b9" to enter the top directory
- type "./install" to install, compiling may take up to
twenty minutes
- edit your ~/.bashrc, add following lines
#NS2 specifics
export PATH=$HOME/ns-allinone-2.1b9/bin:$HOME/ns-allinone-2.1b9/ns-2.1b9/zrp:$PATH
export LD_LIBRARY_PATH=$HOME/ns-allinone-2.1b9/otcl-1.0a7:/ns2/ns-allinone-2.1b8a/lib
export LD_LIBRARY_PATH=$HOME/ns-allinone-2.1b9/otcl-1.0a8:/ns2/ns-allinone-2.1b9/lib
export TCL_LIBRARY=$HOME/ns-allinone-2.1b9/tcl8.3.2/library
export TCLSH=$HOME/ns-allinone-2.1b9/bin/tclsh8.3
- re-login in that terminal window to make sure settings
changes are implemented type "set" to see a listing, check if
the above paths are in your environment.
II. Install ZRP2002
- Download zrp2002.tar.gz from the contributed module section
of the ns-2 site to your home directory.
- type "tar xzvf zrp2002.tgz" to untar zrp archive, the code
is automatically inserted in the right places in the directory
tree (if you untarred zrp2002.tgz before ns2, you need to
untar zrp2002.tgz again to make sure the zrp archived files
over-write the corresponding ns2 code)
- edit Makefile at ns-allinone-2.1b9/ns-2.1b9/Makefile, and at
line 209 (after "dsdv/dsdv.o dsdv/rtable.o queue/rtqueue.o \")
insert the zrp code objects:
dsdv/dsdv.o dsdv/rtable.o queue/rtqueue.o \
zrp/zrp.o zrp/zrp_table.o \
routing/rttable.o \
Make sure there is a tab (the keystroke, not the word "tab")
at the beginning of the line.
- Now we need to modify some ns2 code. The files in the
directory "zrp/otherfiles" are the files that will be changed.
You can change them using the patch method (recommended for
any version of ns2 "close" to ns-2.1b9) or just edit these
files manually to make the changes. (hint: if you want to find
out the difference between two files, use "diff file1 file2")
by patching:
% cd ~/ns-allinone-2.1b9 # (the patch has to be run from here)
% patch -p1 < ns-2.1b9/zrp/otherfiles/ns2-zrp.patch
- now type:
% cd ~/ns-allinone-2.1b9/ns-2.1b9
% touch common/* tcl/lib/* trace/*
to make sure we re-compile newly added code. (for some reason
this wasn't always enough, I had to actually either touch a
file individually by name or edit the file and add a space
anywhere in the file to force the Makefile to re-compile that
file, especially the files trace/cmu-trace.*)
- type "make -k" within the "~/ns-allinone-2.1b9/ns-2.1b9/"
directory, the ns-2 code should re-compile
- if no errors (there might be some warnings), then run the
demo script:
% ns ~/ns-allinone-2.1b9/ns-2.1b9/zrp/demo/demo3_rad3.tcl
num_nodes is set 23
_ 0_ [0.000000] | Node 0 was created. ! Neighbor Table: empty ! LinkTable: empty ! Routes empty Periph[]
_ 1_ [0.000000] | Node 1 was created. ! Neighbor Table: empty ! LinkTable: empty ! Routes empty Periph[]
_ 2_ [0.000000] | Node 2 was created. ! Neighbor Table: empty ! LinkTable: empty ! Routes empty Periph[]
. . . . . . .
_ 1_ [100.007170] | Got IARP_Data packet orig=10 dest=9 ( >>> forwarding to next hop 2 ! Neighbor Table: 0 2 ! LinkTable: 10=11 0=1 5=6 20=10 22#20 0=22 4=5 2=1 3=2 3=4 ! Routes [2 1 ] [0 1 ] [3 2 1 ] [22 0 1 ] [4 3 2 1 ] Periph[4 ]
_ 2_ [100.008868] | Got IARP_Data packet orig=10 dest=9 ( >>> forwarding to next hop 3 ! Neighbor Table: 3 1 ! LinkTable: 10=11 5=6 1#2 7=21 20=10 22#20 0=22 7=6 4=5 0=1 3=2 7=8 3=4 ! Routes [3 2 ] [4 3 2 ] [5 4 3 2 ] Periph[5 ]
III. Adding a new parameter
For a parameter that takes no arguments: For example, the
command "suspend" sets a flag "suspend_flag_" to be TRUE so
that when pkt_send() is called, this flag is tested before the
packet is sent. The packet is dropped if the node is
suspended.
1. Edit the zrp.cc file and find the command() method.
2. Look for the "suspend" command
3. Edit the command to perform some action for being called from
Tcl.
4. Always make sure the command() method returns a TCL_OK for a
normal condition, or Tcl will give an error.
For a parameter that takes one argument, the command name is
compared with argv[1], and the argument is given by argv[2].
To convert to an integer, call this way:
abc = atoi(argv[2]);
The beacon_period command is a good example of how to do it.
Now to call the function from a Tcl script, here is a Tcl
snippet for our two examples:
set r_(2) [$node_(2) set ragent_] # gets a pointer to route agent
$ns_ at 12.0 "$r_(2) suspend" # send suspend command to ragent at time=12 sec
$ns_ at 0.4 "$r_(2) beacon_period 7.0" # change beacon period to 7 at time=0.4 sec
近期下载者:
相关文件:
收藏者: