Nathan H
Nathan H

Reputation: 11

NS2 TCL Script Simulating Wireless LAN

I am attempting to simulate a wireless LAN environment in NS2. I am currently running Ubuntu 15.10 on a virtual machine working with NS2 version 2.35. I am required to used this specific OS. My script gives this error:

--- 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

Upvotes: 1

Views: 95

Answers (0)

Related Questions