我不能運行這個模擬:無線模擬問題
set pairs [lindex $argv 0]
# ====================================
# Define options
# ====================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# 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) $pairs ;# pair of mobilenodes
set val(rp) DSDV ;# routing protocol
# ======================================
# Main Program
# ======================================
#
# Initialize Global Variables
#
set ns [new Simulator]
set tracefd [open wl.tr w]
$ns use-newtrace
$ns trace-all $tracefd
# set up topography object
set topo [new Topography]
#1000x1000m terrain
$topo load_flatgrid 1000 1000
#
# Create General Operations Director
#
set god_ [ create-god $val(nn) ]
Mac/802_11 set RTSThreshold_ 3000
#
# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# configure node
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF
for {set i 0} {$i < [expr {2*$val(nn)}] } {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;# disable random motion
}
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
set rng [new RNG]
$rng seed 0
set unit 10.0;
set even_x 50.0;
set even_y 50.0;
set odd_x 50.0;
set odd_y 0.0;
for {set i 0} { $i < [expr {2*$val(nn)}] } {incr i} {
set residue [expr {$i%2}];
#puts $residue
set rand [expr [$rng uniform 0 1] + [ns-random 0] % 100];
if { $residue ==0 } {
$node_($i) set X_ [expr {$even_x + $rand}];
$node_($i) set Y_ [expr {$even_y }]
$node_($i) set Z_ 0.0;
} else {
$node_($i) set X_ [expr {$odd_x + $rand}];
$node_($i) set Y_ [expr {$odd_y}];
$node_($i) set Z_ 0.0;
}
}
for {set i 0} { $i < $val(nn) } {incr i} {
set null_($i) [new Agent/Null]
$ns attach-agent $node_([expr {($i*2)+1}]) $null_($i)
set udp_($i) [new Agent/UDP]
$ns attach-agent $node_([expr {2*$i}]) $udp_($i)
set cbr_($i) [new Application/Traffic/CBR]
$cbr_($i) set packetSize_ 1440
$udp_($i) set packetSize_ 1440
$cbr_($i) set rate_ 500k
$cbr_($i) attach-agent $udp_($i)
$ns connect $udp_($i) $null_($i)
}
for {set i 0} {$i < $val(nn)} {incr i} {
$ns at 0.0 "$cbr_($i) start"
$ns at 120.0 "$cbr_($i) stop"
}
$ns at 120.0 "$ns halt"
$ns run
$ns flush-trace
close $tracefd
puts "Starting Simulation..."
$ns run
我得到這個錯誤 可以在任何一個請幫助我!
MAC_802_11: accessing MAC cache_ array out of range (src 33, dst 32, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 33, dst 32, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 33, dst 32, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 32, dst 33, size 20)!
[suppressing additional MAC cache_ warnings]
你確定你知道你在做什麼嗎?你能夠理解每一行代碼,它的目的是什麼? – asprin
@asprin親愛的阿斯匹林!我只是想運行這個模擬,並學會了它,我得到了這個錯誤,當我搜索時沒有任何東西,你能向我解釋一下嗎? – Arash
根據猜測(基於_reading_日誌消息),某些數組需要增加大小,或者需要告訴某個數組起初不是那麼大。我真的不知道ns2 - 網絡根本不是我的領域 - 所以我不能說如何做到這一點,但看着代碼(並沒有看到一個明顯的'20')我是猜測有一些默認值不適用於您的配置。 –