如何在ns2中实现aodv协议

时间:2015-04-23 22:15:16

标签: c++ protocols ns2

这是我的文件AODV.tcl的一部分在ns2中AODV实现的例子我需要在这个实现中使用aodv.c和aodv.h的问题我不知道怎么做?我需要使用aodv.c文件中的所有函数,我不知道该怎么做?请帮助和谢谢。

my code:
set ns [new Simulator]
set namfile [open AODV_final.nam w]
set Time [open time.tr w]
...
global TN
set TN 2
set god_ [create-god $TN]
$ns node-config -adhocRouting AODV \
         -llType LL \
     -macType Mac/802_11\
     -ifqLen 50 \
     -ifqType Queue/DropTail/PriQueue \
     -antType Antenna/OmniAntenna \
     -propType Propagation/TwoRayGround \
     -phyType Phy/WirelessPhy \
     -channel [new Channel/WirelessChannel] \
     -topoInstance $topography \
     -agentTrace ON \
     -routerTrace ON \
     -macTrace ON \
             -movementTrace ON

     set x1 150
     set y1 150
     ...
for {set j1 0} {$j1 < $TN} {incr j1 20} {
incr x1 0
incr y1 150
$node($j1) set X_ $x1
$node($j1) set Y_ $y1
$node($j1) set Z_ 0
$node($j1) color "green"
$ns at 0.000000 "$node($j1) setdest $x1 $y1 0.00"

}
...
$ns at 10.000000 "$node(0) setdest 160 450 75"
$ns connect $Tcp(0) $TcpSink(1)
$ns at 0.020000 "$Ftp(0) start"
$ns at 590.000000 "$Ftp(0) stop"
...
proc finish {} {
global ns namfile  
$ns flush-trace
close $namfile
exit 0
}
$ns at 10.000000 "finish"
$ns run

1 个答案:

答案 0 :(得分:0)

“aodv.c”:ns2文件名是aodv.cc。

`ns2'以这种方式工作:C ++和tcl / lib / **文件中的所有函数都被编译成可执行文件“ns”。在仿真时,使用以下文件:/ usr / local / bin / ns,ns-allinone-2.3x / {bin / tcsh8,lib / / }。

实际上可以删除所有其他文件:您可以在任意位置放置模拟示例。

AODV示例:aodv_ex_04.2015.tar.gz

https://drive.google.com/file/d/0B7S255p3kFXNZFlsVXhpcHZ2NFE/view?usp=sharing

相关问题