Date post: | 21-Nov-2015 |
Category: |
Documents |
Upload: | ayie-heriansyah |
View: | 32 times |
Download: | 3 times |
Network Network Simulator:Simulator:
802.11 WLAN802.11 WLAN
Daniele Messina, Ilenia Tinnirello
Wireless SimulationsWireless Simulations A mobile node consists of several network components including:
Link Layer Interface Queue MAC PHY
Other parameters need to be defined: radio propagation model type of ad-hoc routing type of antenna
Daniele Messina, Ilenia Tinnirello
type of antenna
set val(chan) Channel/WirelessChannel ;# channel typeset val(prop) Propagation/TwoRayGround ;# radio-propagation
modelset val(ant) Antenna/OmniAntenna ;# Antenna typeset val(ll) LL ;# Link layer typeset val(ifq) Queue/DropTail/PriQueue ;# Interface queue typeset val(ifqlen) 50 ;# max packet in ifqset val(netif) Phy/WirelessPhy ;# network interface typeset val(mac) Mac/802_11 ;# MAC typeset val(rp) DSDV ;# ad-hoc routing
protocol set val(nn) 2 ;# number of mobilenodes
Wireless Node StructureWireless Node Structure
Node
ARPLLLLLL
Classifier: Forwarding
Agent: Protocol Entity
Node Entry
LL: Link layer object
protocolagent
routingagent
addrclassifier
portclassifier
255
defaulttarget_
Daniele Messina, Ilenia Tinnirello
ARP
Propagation and antenna models
MobileNode
LL
MAC
PHY
LL
CHANNEL
LL
MAC
PHY
LL: Link layer object
IFQ: Interface queue
MAC: Mac object
PHY: Net interface
IFQIFQ
Radio propagation/antenna models
Prop/ant
Wireless SimulationsWireless Simulations
We need a topology object that keeps track of movements of mobilenodes within the topological boundary.
set topo [new Topography]
Mobilenodes move within a topology of 500mX500m. We provide the topography object with x and y
Daniele Messina, Ilenia Tinnirello
Mobilenodes move within a topology of 500mX500m. We provide the topography object with x and y coordinates of the boundary, (x=500, y=500) :
$topo load_flatgrid 500 500#file:simple-wireless.tcl
Wireless SimulationsWireless Simulations
Next we create the object God, as follows:
create-god $val(nn)
God (General Operations Director) stores:
the total number of mobilenodes
Daniele Messina, Ilenia Tinnirello
the total number of mobilenodes
a table of shortest number of hops required to reach from one node to another.
the next hop information is normally loaded into god object from movement pattern files.
Wireless SimulationsWireless Simulations
We need to configure nodes:
# $ns_ node-config -addressingType flat or hierarchical or expanded
# -adhocRouting DSDV or DSR or TORA# -llType LL# -macType Mac/802_11# -propType "Propagation/TwoRayGround"# -ifqType "Queue/DropTail/PriQueue"# -ifqLen 50# -phyType "Phy/WirelessPhy"
Daniele Messina, Ilenia Tinnirello
# -phyType "Phy/WirelessPhy"# -antType "Antenna/OmniAntenna"# -channelType "Channel/WirelessChannel"# -topoInstance $topo# -energyModel "EnergyModel"# -initialEnergy (in Joules)# -rxPower (in W)# -txPower (in W)# -agentTrace ON or OFF# -routerTrace ON or OFF# -macTrace ON or OFF# -movementTrace ON or OFF
Wireless simulationsWireless simulations
# Create nodes:for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node ]$node_($i) random-motion 0;# disable random motion
}
# Provide initial (X,Y,Z) co-ordinates for node_(0)
Daniele Messina, Ilenia Tinnirello
# Provide initial (X,Y,Z) co-ordinates for node_(0) and node_(1)
$node_(0) set X_ 5.0$node_(0) set Y_ 2.0$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0$node_(1) set Y_ 385.0$node_(1) set Z_ 0.0
Wireless SimulationsWireless Simulations
# Produce some node movements ## Node_(1) starts to move towards node_(0)# command: $node setdest $ns_ at 50.0 "$node_(1) setdest 25.0 20.0 15.0"$ns_ at 10.0 "$node_(0) setdest 20.0 18.0 1.0"
Daniele Messina, Ilenia Tinnirello
# Node_(1) then starts to move away from node_(0)$ns_ at 100.0 "$node_(1) setdest 490.0 480.0 15.0"
Wireless SimulationsWireless Simulations
# Tell nodes when the simulation ends#for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 150.0 "$node_($i) reset";}$ns_ at 150.0001 "stop"$ns_ at 150.0002 "puts \"NS EXITING...\" ; $ns_ halt"
Daniele Messina, Ilenia Tinnirello
$ns_ at 150.0002 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {global ns_ tracefdclose $tracefd
}
puts "Starting Simulation..."$ns_ run
Wireless TraceWireless Trace
[65536:0 16777984:0 31 16777984] [1 0] 2 0
r 160.093884945 _6_ RTR --- 5 tcp 1492 [a2 4 6 800] -------
MAC
NETWORK TRANSPORT
Daniele Messina, Ilenia Tinnirello
TCP packet received by routing agent of node 6 at time 160.09...UID: 5size: 1492Mac Layer fields: time src_addr dst_addr type (800: IP, 806: ARP) Network Layer fields: src_addr dst_addr TTL next_hop_addr Transport Layer fields: seq_no ack_no no_of_fwds opt_no_of_fwds
New Wireless Trace FormatNew Wireless Trace Format
enabled by the command
$ns use-newtraceavailable only for wireless simulations
adds:
coordinates log
Daniele Messina, Ilenia Tinnirello
coordinates log
energy log
reason code for the event
flow id
duration at PHY layer
Wireless Nam TraceWireless Nam Trace
Enabling nam trace for wireless simulation:
set namtrace [open wireless1-out.nam w]$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
Daniele Messina, Ilenia Tinnirello
Note: We are able to see only MAC Layer packet
exchanges
#file:wireless1.tcl
Creating scenario files for Creating scenario files for mobility simulationsmobility simulations
To create the scenario, run
cd /indep-utils/cmu-scen-gen/setdest
Daniele Messina, Ilenia Tinnirello
./setdest [-v version of setdest] [-n num_of_nodes] [-p pausetime] [-s maxspeed] [-t simtime] [-x maxx] [-y maxy]> [outdir/movement-file]
Wireless Channel and MACWireless Channel and MAC
Duplicate packets to all mobile nods attached to channel
except the source
Each receiver is responsible to decide if it can receive the
packet
Each receiver evaluates the received power Pr on the
basis of the Propagation Model
Antenna: Unit Gain Omni-directional
Daniele Messina, Ilenia Tinnirello
Antenna: Unit Gain Omni-directional
Fee Space, TwpRayground, Shadowing
If Pr > Pthreshold, the packet is received
N1 N2 N3
CHANNEL_1
N4
CHANNEL_2
N4 cannot hear N1, N2 and N3
PHY Layer ParametersPHY Layer Parameters
Transmission Power: set by default at 0.2818W
(corresponding to a coverage range of 250m)
Phy/WirelessPhy set Pt_ 0.2818
Capture threshold: indicates the power ratio over which a
collision results in the reception of the strongest packet
Daniele Messina, Ilenia Tinnirello
Phy/WirelessPhy set CPThresh_ 10.0
Carrier Sense and Reception thresholds: indicate the
power threshold over which a packet is sensed or
correctly received
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Transmission/Interference/CS RangeTransmission/Interference/CS Range
TX
Daniele Messina, Ilenia Tinnirello
TX
Correct reception (if no collision)
Incorrect reception
TX detected, but no reception
No Interference from TX
MAC Layer ParametersMAC Layer Parameters
Contention Parameters: minimum and
maximum contention windows, backoff slot,
SIFS (DIFS=SIFS+2*backoff slot)
Mac/802_11 set CWMin_ 31
Mac/802_11 set CWMax_ 1023
Daniele Messina, Ilenia Tinnirello
Mac/802_11 set CWMax_ 1023
Mac/802_11 set SlotTime_ 0.000020
Mac/802_11 set SIFS_ 0.000010
RTS Threshold (over which the 4way
handshake is used)
Mac/802_11 set RTSThreshold_ 0
MAC Layer ParametersMAC Layer Parameters
Data Rate: rate at which data frames are sent
over the wireless medium (default: 1 Mbps)
Although only some rates are standardized, in principle each
configuration is possible
Daniele Messina, Ilenia Tinnirello
configuration is possible
MAC/802_11 set dataRate_ 11.0e6
Basic Rate: rate at which ACK, RTS/CTS
frames are sent over the wireless medium
(default: 1 Mbps, usually: 2 Mbps)
MAC/802_11 set basicRate 2.0e6
Energy modelEnergy model
The energy model represents level of energy in a mobile host.
The energy model in a node has an initial value which is the level of energy the node has at the beginning of the simulation. This is known as initialEnergy.
Daniele Messina, Ilenia Tinnirello
It also has a given energy usage for every packet it transmits and receives, for idle and sleep states and for transitions (txPower, rxPower, idlePower, sleepPower, transitionPower)
Energy modelEnergy model
When the energy level at the node goes down to zero, no more packets can be received or transmitted by the node
OTcl interface: $ns_ node-config...
-energyModel $opt(energymodel) \ #EnergyModel
Daniele Messina, Ilenia Tinnirello
-energyModel $opt(energymodel) \ #EnergyModel-idlePower 1.0 \ #watts-rxPower 1.0 \ #watts-txPower 2.0 \ #watts-sleepPower 0.001 \ #watts-transitionPower 0.2 \ #watts-transitionTime 0.005 \ #seconds-initialEnergy $opt(initialenergy) #joules
Energy modelEnergy model
Examples:
/tcl/ex/wireless-newnode-energy.tcl
http://www.isi.edu/ilense/software/smac/MyTest.tcl
Trace:
[energy 979.917000 ei 20.074 es 0.000 et 0.003 er 0.006]
Daniele Messina, Ilenia Tinnirello
[energy 979.917000 ei 20.074 es 0.000 et 0.003 er 0.006]
energy: total remaining energy
ei: energy consumption in IDLE state
es: energy consumption in SLEEP state
et: energy consumed in transmitting packets
er: energy consumed in receiving packets
Wireless Script StructureWireless Script Structure
# parameters and options# parameters and optionsset ns [new Simulator]set ns [new Simulator]# [Turn on tracing]# [Turn on tracing]# create # create MobileNodeMobileNode object (PHY to layer 3 object (PHY to layer 3
configured) configured) # Create topology# Create topology
Daniele Messina, Ilenia Tinnirello
# Create topology# Create topology# create mobility# create mobility# Create Layer 4 and above# Create Layer 4 and above# # -- UDP/TCP agentsUDP/TCP agents# # -- application and/or setup traffic sourcesapplication and/or setup traffic sources# Post# Post--processing proceduresprocessing procedures# Start simulation# Start simulation
SingleSingle--hop hop
Simulation ScenarioSimulation Scenario
Daniele Messina, Ilenia Tinnirello
See ex4.tcl..
ExerciseExercise
Run the script ex4.tcl for different number
of contending stations.
1. How does the throughput change?
2. What happens by activating the
Daniele Messina, Ilenia Tinnirello
What happens by activating the
RTS/CTS mechanism?
3. What happens if we reduce the
CWmin/CWmax values?
MultiMulti--hop hop
Simulation ScenarioSimulation Scenario
240m
8 11
13 14
11
Daniele Messina, Ilenia Tinnirello
4 7
8 11
2 3
See ex5.tcl..
ExerciseExercise
Run the script ex5.tcl for different number
of contending stations.
1. How does the throughput change?
2. Which traffic flows are active in the
Daniele Messina, Ilenia Tinnirello
Which traffic flows are active in the
network?
3. What happens by activating RTS/CTS?
4. What happens by reducing the node
distance?