提问人:Nathan H 提问时间:11/4/2023 最后编辑:Donal FellowsNathan H 更新时间:11/4/2023 访问量:36
模拟无线局域网的 NS2 TCL 脚本
NS2 TCL Script Simulating Wireless LAN
问:
我正在尝试在 NS2 中模拟无线局域网环境。我目前在使用 NS2 版本 2.35 的虚拟机上运行 Ubuntu 15.10。我需要使用这个特定的操作系统。我的脚本给出了这个错误:
--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o13: no target for slot 4294967295
_o13 type: Classifier/Hash/Dest
content dump:
classifier _o13
0 offset
0 shift
2147483647 mask
1 slots
slot 0: _o21433 (Classifier/Port)
-1 default
---------- Finished standard no-slot{} default handler ----------
# Define the simulation scenario
set numNodes 60
# Create a new simulation object
set ns [new Simulator]
# Set channel type
set val(chan) [new Channel/WirelessChannel]
# Create nodes
for {set i 0} {$i < $numNodes} {incr i} {
set node($i) [$ns node]
}
$ns node-config -adhocRouting ON \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channel $val(chan) \
-topoInstance $ns \
# Create bi-directional links between nodes without duplicate links
array set linkCreated {}
for {set i 0} {$i < $numNodes} {incr i} {
for {set j 0} {$j < $numNodes} {incr j} {
if {$i != $j && ![info exists linkCreated($i,$j)] && ![info exists linkCreated($j,$i)]} {
$ns duplex-link $node($i) $node($j) 10Mb 2ms DropTail
set linkCreated($i,$j) 1
set linkCreated($j,$i) 1
}
}
}
# Traffic generation: nodes send packets to each other
set udp [new Agent/UDP]
$ns attach-agent $node(0) $udp
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 1000
$cbr set rate_ 1Mbps
$cbr set random_ false
# Schedule traffic generation
$ns at 1.0 "$cbr start"
$ns at 100.0 "$cbr stop"
# Define simulation end time and finish procedure
$ns at 100.0 "finish"
# Procedure to finish the simulation, close trace files, and open Nam file on completion
proc finish {} {
global ns
$ns flush-trace
$ns nam-end-wireless output.nam
exit 0
}
# Run the simulation
$ns run
答: 暂无答案
上一个:滤除具有相同时钟属性的引脚
评论
$ns duplex-link ...
$j
$i
0
linkCreated