我在NS2.35中使用AODV路由協議運行一些簡單的模擬。但是,在某些情況下,我注意到,當我運行足夠長的模擬時,AODV REQUEST和REPLY消息不會被髮送出去並填充節點隊列。NS2:AODV路由消息卡在隊列中
在下面的.tcl示例中,我有3個節點生成要發送給PAN協調器的CBR流量。然而,在某些情況下,路由請求和回覆在節點2處於IFQ級別時不斷丟棄。
此外,如以下跟蹤代碼段所示,在仿真結束時(時間= 10000),節點2的IFQ填充了REQUESTS,儘管模擬結束時有足夠的時間來清空隊列。
s 9353.439721046 _2_ RTR --- 0 AODV 48 [0 ffffffff 1 800] ------- [2:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
D 9353.439746046 _2_ IFQ --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 3 0] [0x2 2 20 [0 105] [3 42]] (REQUEST)
s 9353.441744607 _3_ MAC --- 0 AODV 55 [0 ffffffff 3 800] ------- [3:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
r 9353.444336620 _2_ MAC --- 0 AODV 48 [0 ffffffff 3 800] ------- [3:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
r 9353.444336633 _1_ MAC --- 0 AODV 48 [0 ffffffff 3 800] ------- [3:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
r 9353.444361620 _2_ RTR --- 0 AODV 48 [0 ffffffff 3 800] ------- [3:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
r 9353.444361633 _1_ RTR --- 0 AODV 48 [0 ffffffff 3 800] ------- [3:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 2 0] [0x2 2 37 [0 149] [1 76]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 3 0] [0x2 2 30 [0 139] [3 62]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 4 0] [0x2 2 36 [0 143] [1 74]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 30 0] [0x2 1 103 [0 49] [2 208]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 2 0] [0x2 2 35 [0 143] [1 72]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 30 0] [0x2 1 102 [0 49] [2 206]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 30 0] [0x2 1 101 [0 49] [2 204]] (REQUEST)
D 10000.000000000 _2_ IFQ END 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 30 0] [0x2 1 100 [0 49] [2 202]] (REQUEST)
任何想法是怎麼回事?
更新: 顯然,在某些時候REQUEST消息在RTR水平產生但不被髮送出去,然後流量被丟棄,因爲節點沒有得到及時路由應答。這裏是展示本一絲例如:
s 2417.739768850 _2_ AGT --- 23 cbr 70 [0 0 0 0] ------- [2:0 0:1 32 0] [7] 0 0
r 2417.739768850 _2_ RTR --- 23 cbr 70 [0 0 0 0] ------- [2:0 0:1 32 0] [7] 0 0
s 2417.739768850 _2_ RTR --- 0 AODV 48 [0 0 0 0] ------- [2:255 -1:255 30 0] [0x2 1 16 [0 49] [2 34]] (REQUEST)
s 2418.500000000 _2_ RTR --- 0 AODV 48 [0 0 0 0] ------- [2:255 -1:255 30 0] [0x2 1 17 [0 49] [2 36]] (REQUEST)
s 2419.500000000 _2_ RTR --- 0 AODV 48 [0 0 0 0] ------- [2:255 -1:255 30 0] [0x2 1 18 [0 49] [2 38]] (REQUEST)
s 2421.000000000 _2_ RTR --- 0 AODV 48 [0 0 0 0] ------- [2:255 -1:255 30 0] [0x2 1 19 [0 49] [2 40]] (REQUEST)
D 2423.000000000 _2_ RTR NRTE 23 cbr 90 [0 0 0 0] ------- [2:0 0:1 30 0] [7] 0 0
注意的是,在我遇到這個問題的所有例子,產生CBR消息每一次,以前的路徑已經過期,新的路線已被發現。我認爲這可能會導致一個錯誤的地方。
TCL file:
set tr .tr
set nam .nam
set fname [file rootname $argv0]
# Parameters Settings
set val(chan) Channel/WirelessChannel ;# Channel Model: Wireless
set val(prop) Propagation/TwoRayGround ;# Propragation Model: Shadowing (Shadowing/TwoRayGround/FreeSpace)
set val(netif) Phy/WirelessPhy/802_15_4
set val(mac) Mac/802_15_4
set val(ifq) Queue/DropTail/PriQueue ;# Queue Model: Drop at Tail
set val(ll) LL ;# Link Layer Model
set val(ant) Antenna/OmniAntenna ;# Antenna Model
set val(ifqlen) 64 ;# Max Number of Queue
set val(nn) 4 ;# Number of Nodes
set val(rp) AODV ;# Routing Protocol: AODV (DSR/ZBR/AOMDV/AODV)
set val(x) 0 ;# Center Position of nam
set val(y) 0
set val(tr) $fname$tr ;# Tracing File
set val(nam) $fname$nam ;# Nam File
set val(traffic) cbr ;# Data Flow: cbr (cbr/poisson/ftp)
set val(trInterval) 0.01 ;# Time Interval between Packets
set val(startInterval) 0.5 ;# Start Time
set stopTime 10000 ;# Stop Time
# For model 'TwoRayGround'
set dist(5m) 7.69113e-06
set dist(9m) 2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(10m)
Phy/WirelessPhy set RXThresh_ $dist(10m)
# Input
proc getCmdArgu {argc argv} {
global val
for {set i 0} {$i < $argc} {incr i} {
set arg [lindex $argv $i]
if {[string range $arg 0 0] != "-"} continue
set name [string range $arg 1 end]
set val($name) [lindex $argv [expr $i+1]]
}
}
getCmdArgu $argc $argv
# Initial Global Variables
set ns_ [new Simulator]
set tracefd [open ./$val(tr) w]
# $ns_ use-newtrace
$ns_ trace-all $tracefd
# Topology Configuration
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
# Node Configuration
$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1_
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}
#########################################################
# Topology Input
for {set i 0} {$i < $val(nn)} {incr i} {
$node_($i) set X_ [expr 4*$i]
$node_($i) set Y_ 0
$node_($i) set Z_ 0
}
# Start Coordinate/Normal Nodes
$ns_ at 0.0 "$node_(0) NodeLabel \"PAN Coor\""
$ns_ at 0.0 "$node_(0) sscs startPANCoord 0"
for {set i 1} {$i < $val(nn)} {incr i} {
$ns_ at [expr $i*($val(startInterval))] "$node_($i) sscs startDevice"
}
#########################################################
# Setup UDP and CBR
proc cbrtraffic { src dst interval starttime } {
global ns_ node_
set udp_($src) [new Agent/UDP]
eval $ns_ attach-agent \$node_($src) \$udp_($src)
set null_($dst) [new Agent/Null]
eval $ns_ attach-agent \$node_($dst) \$null_($dst)
set cbr_($src) [new Application/Traffic/CBR]
eval \$cbr_($src) set packetSize_ 70
eval \$cbr_($src) set rate_ 250kb
eval \$cbr_($src) set interval_ $interval
eval \$cbr_($src) set random_ 1
#eval \$cbr_($src) set maxpkts_ 1000
eval \$cbr_($src) attach-agent \$udp_($src)
eval $ns_ connect \$udp_($src) \$null_($dst)
$ns_ at $starttime "$cbr_($src) start"
$ns_ at 9500 "$cbr_($src) stop"
}
# ACK
if {$val(rp) == "ZBR"} {
# 0=No ACK; 1=ACK at failure (default); 2=ACK at success/failure
Mac/802_15_4 wpanCmd callBack 2;
}
if { ("$val(traffic)" == "cbr") || ("$val(traffic)" == "poisson") } {
puts "\nTraffic: $val(traffic)"
puts [format "Acknowledgement for data: %s" [Mac/802_15_4 wpanCmd ack4data off]]
#########################################################
# Set Traffic
for {set i 1} {$i < $val(nn)} {incr i} {
cbrtraffic $i 0 300 [expr 20+200*$i]
}
#########################################################
}
# Reset of Nodes
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $stopTime "$node_($i) reset";
}
# Stop Simulation
$ns_ at $stopTime "stop"
$ns_ at $stopTime "puts \"\nNS EXITING...\n\""
$ns_ at $stopTime "$ns_ halt"
# Stop Function
proc stop {} {
global ns_ tracefd starttime val env
$ns_ flush-trace
close $tracefd
set hasDISPLAY 0
foreach index [array names env] {
#puts "$index: $env($index)"
if { ("$index" == "DISPLAY") && ("$env($index)" != "") } {
set hasDISPLAY 1
}
}
}
# Start Simulation
puts "\nStarting Simulation..."
$ns_ run