NS2:AODV路由消息卡在队列中

时间:2017-03-08 19:59:43

标签: c++ simulator ns2

我正在使用AODV路由协议在NS2.35中运行一些简单的模拟。但是,在某些情况下,我注意到,当我长时间运行模拟时,AODV REQUEST和REPLY消息不会被发送出去并填满节点队列。

在下面的.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

1 个答案:

答案 0 :(得分:0)

对于可能遇到此问题的其他人:

这似乎是由来自mac-layer的CCA引起的,其中一系列不幸的事件可能导致blocked_类中的PriQueue变量陷入1。

Phy802_15_4::CCAHandler的{​​{1}}中,替换

p802_15_4phy.cc

CCAReportH.start(4/getRate('s'));

'修复'此问题。这使CCA成为当务之急。显然,没有实时的CCA会导致这个错误。 如果有人找到更好的解决方案,请告诉我。

相关问题