0
我想在NS2中使用AODV協議進行IEEE 802.15.4模擬。我正在從節點0發送一個30字節的數據包到節點1.從發送方開始,數據包將與添加的標題一起傳輸。但是,在接收端,MAC層丟棄路由層頭,但AGT層沒有丟棄MAC層頭。我發送30字節的數據包,但收到50字節的數據包。我在劇本中做錯了什麼?我試圖用AODV模擬IEEE 802.11的代碼,並且它完美地工作。IEEE 802.15.4模擬的NS2中的AODV數據包大小
我附上完整的TCL腳本和跟蹤文件線包0
TCL腳本
#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/Shadowing ;# radio-propagation model
set val(netif) Phy/WirelessPhy/802_15_4 ;# network interface type
set val(mac) Mac/802_15_4 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(stop) 2 ;# time of simulation end
##################################################################
#===================================
Antenna/OmniAntenna set Gt_ 1 ;#Transmit antenna gain
Antenna/OmniAntenna set Gr_ 1 ;#Receive antenna gain
Phy/WirelessPhy set L_ 1.0 ;#System Loss Factor
Phy/WirelessPhy set freq_ 2.4e9 ;#channel
Phy/WirelessPhy set bandwidth_ 0.25Mb ;#Data Rate
###############Simulation experiment # 3 ################################################
Phy/WirelessPhy set Pt_ 0.00050118723363 ;#in W for Transmit Power -3dBm IEEE 802.15.4 standard
Phy/WirelessPhy set RXThresh_ 3.1622776602e-12 ;#Receive Power Threshold -85dBm IEEE 802.15.4
Phy/WirelessPhy set CSThresh_ 1.5848931925e-12 ;#Carrier Sense Power -88dBm
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open outAODV.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open outAODV.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
# first set values of shadowing model
Propagation/Shadowing set pathlossExp 2.9 ;# path loss exponent
Propagation/Shadowing set std_db 8.0 ;# shadowing deviation (dB)
Propagation/Shadowing set dist0 1.0 ;# reference distance (m)
Propagation/Shadowing set seed 10 ;# seed for RNG
#===================================
# Nodes Definition
#===================================
set n0 [$ns node] ;#considered as a sink
$n0 set X_ 60
$n0 set Y_ 60
$n0 set Z_ 0.0
$ns initial_node_pos $n0 15
set n1 [$ns node] ;# Source 1 measured PDR /throughput/Delay varying diatance
$n1 set X_ 90
$n1 set Y_ 60
$n1 set Z_ 0.0
$ns initial_node_pos $n1 15
# Start Coordinate/Normal Nodes
$ns at 0.0 "$n0 NodeLabel \"PAN Coor\""
$ns at 0.0 "$n0 sscs startCTPANCoord"
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set null0 [new Agent/Null]
$ns attach-agent $n0 $null0
#===================================
# Applications Definition CBR1
#===================================
#Setup a CBR Application over UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
$ns connect $udp1 $null0
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 30
$cbr1 set interval_ .1
$ns at 1.0 "$cbr1 start"
$ns at 1.5 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
輸出跟蹤文件(包0只)
s 1.000000000 _1_ AGT --- 0 cbr 30 [0 0 0 0] ------- [1:0 0:0 32 0] [0] 0 0
r 1.000000000 _1_ RTR --- 0 cbr 30 [0 0 0 0] ------- [1:0 0:0 32 0] [0] 0 0
s 1.000000000 _1_ RTR --- 0 AODV 48 [0 0 0 0] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
s 1.000665000 _1_ MAC --- 0 AODV 55 [0 ffffffff 1 800] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
r 1.003257100 _0_ MAC --- 0 AODV 48 [0 ffffffff 1 800] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
r 1.003282100 _0_ RTR --- 0 AODV 48 [0 ffffffff 1 800] ------- [1:255 -1:255 30 0] [0x2 1 1 [0 0] [1 4]] (REQUEST)
s 1.003282100 _0_ RTR --- 0 AODV 44 [0 0 0 0] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
s 1.004352000 _0_ MAC --- 0 ARP 35 [0 ffffffff 0 806] ------- [REQUEST 0/0 0/1]
r 1.006304100 _1_ MAC --- 0 ARP 28 [0 ffffffff 0 806] ------- [REQUEST 0/0 0/1]
s 1.006629100 _1_ MAC --- 0 ARP 35 [0 0 1 806] ------- [REPLY 1/1 0/0]
s 1.008192000 _0_ MAC --- 0 ACK 5 [0 1 0 0]
r 1.008544100 _1_ MAC --- 0 ACK 5 [0 1 0 0]
r 1.009184000 _0_ MAC --- 0 ARP 28 [0 0 1 806] ------- [REPLY 1/1 0/0]
s 1.012032000 _0_ MAC --- 0 AODV 51 [0 1 0 800] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
s 1.014048100 _1_ MAC --- 0 ACK 5 [0 0 1 0]
r 1.014400200 _0_ MAC --- 0 ACK 5 [0 0 1 0]
r 1.015040100 _1_ MAC --- 0 AODV 44 [0 1 0 800] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
r 1.015065100 _1_ RTR --- 0 AODV 44 [0 1 0 800] ------- [0:255 1:255 30 1] [0x4 1 [0 4] 10.000000] (REPLY)
s 1.015065100 _1_ RTR --- 0 cbr 50 [0 0 0 0] ------- [1:0 0:0 30 0] [0] 0 0
s 1.017650100 _1_ MAC --- 0 cbr 57 [0 0 1 800] ------- [1:0 0:0 30 0] [0] 0 0
s 1.020032000 _0_ MAC --- 0 ACK 5 [0 1 0 0]
r 1.020384100 _1_ MAC --- 0 ACK 5 [0 1 0 0]
r 1.021024000 _0_ MAC --- 0 cbr 50 [0 0 1 800] ------- [1:0 0:0 30 0] [0] 1 0
r 1.021049000 _0_ AGT --- 0 cbr 50 [0 0 1 800] ------- [1:0 0:0 30 0] [0] 1 0