[ns] Wireless 802.11 network simulation problem

Filkon filkon at seznam.cz
Wed Dec 9 10:51:33 PST 2009


Hi.
I have to simulate a network 802.11. There should be two stations
connected to one access point. My source code is:

proc set_options {nn} {
global val
# 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
type
set val(ifq)            Queue/DropTail           ;# 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)               $nn               ;# number of mobile nodes
set val(rp)            DumbAgent           ;# routing protocol
set val(x)              60                   ;# X dimension of topography
set val(y)            60                   ;# Y dimension of topography
set val(stop)           50               ;# time of simulation end
set val(trfile)        vys.w        ;# trace file
set val(namfile)    vys.nam        ;# nam file
set val(endtime)    10        ;# end of simulation
}

proc init {} {
      global opt tracefile namtrace val topo chan_1_ ns
      global node_
#DSSS (IEEE802.11b)
   Mac/802_11 set SlotTime_          0.000020        ;# 20us
   Mac/802_11 set SIFS_              0.000010        ;# 10us
   Mac/802_11 set PreambleLength_    144             ;# 144 bit
   Mac/802_11 set PLCPHeaderLength_  48              ;# 48 bits
   Mac/802_11 set PLCPDataRate_      1.0e6           ;# 1Mbps
   Mac/802_11 set dataRate_          11.0e6          ;# 11Mbps
   Mac/802_11 set basicRate_         1.0e6           ;# 1Mbps
   Mac/802_11 set RTSThreshold_      3000         ;# Disable RTS/CTS
# frequency is 2.4 GHz
   Phy/WirelessPhy set freq_          2.4e+9

#Phy/WirelessPhy set CSThresh_ 10.00e-12
#Phy/WirelessPhy set RXThresh_ 10.00e-11
#Phy/WirelessPhy set Pt_ 0.3
#Phy/WirelessPhy set Pt_ 7.214e-6


# Main Program
set ns [new Simulator]
set tracefile [open $val(trfile) w]
set namtrace [open $val(namfile) w]

$ns trace-all $tracefile
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
#$ns use-newtrace

# Set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

# Create god (node)
create-god $val(nn)

# Create channel
set chan_1_ [new $val(chan)]

# Configure the wireless nodes
    $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) \
            -topoInstance $topo \
            -agentTrace ON \
            -routerTrace OFF \
            -macTrace ON \
            -movementTrace OFF \
            -channel $chan_1_

for {set i 0} {$i < $val(nn)} {incr i} {
    set node_($i) [$ns node]
    $node_($i) random-motion 0               ;# disable random motion
    #  set node_($i) [$node_($i) getMac 0]
    set mac_($i) [$node_($i) getMac 0]
    $mac_($i) set RTSThreshold_ 3000
}


#Set node_(0) as the AP

set AP_ADDR1 [$mac_(0) id]
$mac_(0) ap $AP_ADDR1
$mac_(0) ScanType PASSIVE
#$node_(0) set BeaconInterval_ 0.2
$node_(0) set X_ 1.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$ns at 0.0 "$node_(0) label AP"


$ns at 0.1 "$mac_(1) ScanType ACTIVE"
$ns at 0.1 "$mac_(2) ScanType ACTIVE"
#$ns at 0.1 "$mac_(3) ScanType ACTIVE"
$node_(2) set X_ 10.0
$node_(2) set Y_ 15.0
$node_(2) set Z_ 0.0

$node_(1) set X_ 45.0
$node_(1) set Y_ 40.0
$node_(1) set Z_ 0.0

#$node_(3) set X_ 150.0
#$node_(3) set Y_ 110.0
#$node_(3) set Z_ 1.0


# Define node initial position in nam
for {set i 0} {$i < $val(nn)} {incr i} {
    # 1 defines the node size for name
    $ns initial_node_pos $node_($i) 20
}

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn)} {incr i} {
    $ns at $val(endtime) "$node_($i) reset";
}


# ending nam and the simulation
$ns at $val(endtime) "$ns nam-end-wireless $val(endtime)"
$ns at $val(endtime) "stop"
$ns at $val(endtime).01 "puts \"end simulation\" ; $ns halt"
}


proc stop {} {
    global ns tracefile namtrace
    $ns flush-trace
    close $tracefile
    close $namtrace
    exec nam vys.nam &
    exit 0
}

proc start {arg} {
global ns
set_options $arg
init
puts "Starting Simulation..."
$ns run
}

global argv arg0
   start 3
  #start $argv


But when I run this simulation, I get some error "No APs in range". I
think there is a problem with AP signal power, because if I look at
trace file, authorized is only one station (node_(2)). Do you see a
mistake? I've tried everything, but with no success. Thanks for your answer.



More information about the Ns-users mailing list