模拟无线局域网的 NS2 TCL 脚本

NS2 TCL Script Simulating Wireless LAN

提问人:Nathan H 提问时间:11/4/2023 最后编辑:Donal FellowsNathan H 更新时间:11/4/2023 访问量:36

问:

我正在尝试在 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
TCL NS2

评论

0赞 Knud Larsen 11/4/2023
术语“linkCreated”或“set linkCreated”在 ns2 中不存在。....无线局域网:ns-2.35/tcl/ex/wireless-scripts/ .....所有 WLAN ex、wlan-ex-1.tar.gz drive.google.com/file/d/1yjp3Yy0TOIa3ZHlHHWVvu9mM5fLLcOmi/...
0赞 Knud Larsen 11/4/2023
提示 stackoverflow.com/questions/76131288/...
1赞 Colin Macleod 11/4/2023
@KnudLarsen - 我不知道 ns2,但很明显 linkCreated 在这里只是用作标志数组,以避免对 .所以它只是数据,不需要在 ns2 中具有任何预定义的含义。$ns duplex-link ...
1赞 Donal Fellows 11/4/2023
这并不能解决你的问题......但是从 up 而不是 up 循环将简化事情并消除对数组的需求。$j$i0linkCreated
0赞 Knud Larsen 11/4/2023
编辑“Nathan H wlan ex”、NathanH-wlan-ex.tar.gz drive.google.com/file/d/1E0sx2IodVCaRpEMFHV0LM91AZ93l7uPK/...

答: 暂无答案