Title: How (not) to Simulate Wireless Networks with ns
1How (not) to SimulateWireless Networks with ns
- Brad Karp
- bkarp_at_cs.ucl.ac.uk
- University College London
ns Workshop MSR Cambridge 9th December, 2005
2Outline
- Overview of ns wireless functionality
- History
- Simple example
- MobileNode configuration
- Controlling mobility
- Defining traffic workloads
- MobileNode architecture
- Trace file format
- Role of simulation in wireless research
- Case study of simulations pitfalls GPSR
3History of ns Wireless Support
- David Johnsons Monarch group at CMU
- Free-space, two-ray ground reflection channel
model - 802.11 MAC layer
- Random waypoint mobility model
- ARP
- Ad hoc routing Dynamic Source Routing (DSR),
TORA, - c.
- Other major supported protocols and links
(outside scope of todays talk) Mobile IP,
Directed Diffusion, satellite links, c.
4ns Wireless Architecture
- MobileNode at core of mobility support
- MobileNodes can move in a given topology,
receive/transmit signals to/from wireless
channels - Wireless network stack consists of LL, ARP, MAC,
IFQ, c. - Allows simulations of multi-hop ad hoc networks,
wireless LANs, sensor networks etc
5 Wireless ExampleAd hoc Routing
- Scenario
- 2 mobile nodes
- moving within 500m x 500m flat topology
- using DSDV ad hoc routing protocol
- Random Waypoint mobility model
- TCP traffic
- Examples
- ns-2/ns-tutorial/examples/simple-wireless.tcl
- ns-2/tcl/ex/wireless-demo-csci694.tcl
6An Example Step 1
Define Global Variables create simulator set
ns new Simulator create flat topology in
670m x 670m area set topo new Topography topo
load_flatgrid 500 500
7An Example Step 2
Define wireless ns trace ns trace set tracefd
open simple.tr w ns trace-all tracefd
8GOD (General Operations Director)
- Stores all-pairs Dijkstra shortest path lengths
- Allows comparison of path length with optimal
- Automatically generated, contained in scenario
file - set god create-god ltno of mnodesgt
- god set-dist ltfromgt lttogt lthopsgt
9Example Step 3
- Create god
- set god create-god 2
- ns at 900.00 god setdist 1 2 1
- Create wireless channel
- set thechan new Channel/WirelessChannel
10An Example Step 4
Define how a mobile node is configured ns
node-config \ -adhocRouting DSDV \ -llType LL
\ -macType Mac/802_11 \ -ifqLen 50 \ -ifqType
Queue/DropTail/PriQueue \ -antType
Antenna/OmniAntenna \ -propType
Propagation/TwoRayGround \ -phyType
Phy/WirelessPhy \ -channel thechan
\ -topoInstance topo -agentTrace ON
\ -routerTrace OFF \ -macTrace OFF
\ -movementTrace OFF
11An Example Step 5
- Use for loop to create 3 nodes
- for set i 0 i lt 2 incr i
- set node(i) ns node
- disable random motion
- node(i) random-motion 0
-
12MobileNode Movement
- Node position defined in 3D
- Today, z axis not used
- node set X_ ltx1gt
- node set Y_ lty1gt
- node set Z_ ltz1gt
- node at lttimegt setdest ltnewxgt ltnewygt ltspeedgt
- Lots of these events over a simulation manual
generation tedious
13Random Waypoint Model
- Place nodes uniformly at random
- Node moves to uniformly randomly chosen
destination, at velocity chosen uniformly at
random - Between move events, node stays put for pause
time - Meant to mimic user behavior move, work, move
14Scenario Generator Movement
- setdest MobileNode movement generator
- setdest -n ltnum_of_nodesgt -p pausetime -M
ltmaxspeedgt -t ltsimtimegt -x ltmaxxgt -y ltmaxygt - Source ns-2/indep-utils/cmu-scen-gen/setdest/
15Example setdest Output
- node_(2) set Z_ 0.000000000000
- node_(2) set Y_ 199.373306816804
- node_(2) set X_ 591.256560093833
- node_(1) set Z_ 0.000000000000
- node_(1) set Y_ 345.357731779204
- node_(1) set X_ 257.046298323157
- node_(0) set Z_ 0.000000000000
- node_(0) set Y_ 239.438009831261
- node_(0) set X_ 83.364418416244
- god_ set-dist 0 1 1
- ns_ at 50.000000000000 "node_(2) setdest
369.463244915743 170.519203111152 3.371785899154" - ns_ at 51.000000000000 "node_(1) setdest
221.826585497093 80.855495003839 14.909259208114" - ns_ at 33.000000000000 "node_(0) setdest
89.663708107313 283.494644426442 19.153832288917"
16Scenario Generator Traffic
- Generating traffic pattern files
- CBR/TCP traffic
- ns cbrgen.tcl -type cbrtcp -nn nodes -seed
seed -mc connections -rate rate (pkt/s) - CBR traffic
- ns cbrgen.tcl type cbr nn 20 seed 1 mc 8
- -rate 4
- TCP traffic
- ns cbrgen.tcl type tcp -nn 15 -seed 0 mc 6
- Default packet size 512 bytes, hardwired in
script! - Start time uniform in 0, 180 s, hardwired in
script! - To evaluate routing, which traffic type would you
use? - Source ns-2/indep-utils/cmu-scen-gen/
17A Traffic Scenario
- set udp_(0) new Agent/UDP
- ns_ attach-agent node_(0) udp_(0)
- set null_(0) new Agent/Null
- ns_ attach-agent node_(2) null_(0)
- set cbr_(0) new Application/Traffic/CBR
- cbr_(0) set packetSize_ 512
- cbr_(0) set interval_ 4.0
- cbr_(0) set random_ 1
- cbr_(0) set maxpkts_ 10000
- cbr_(0) attach-agent udp_(0)
- ns_ connect udp_(0) null_(0)
- ns_ at 127.93667922166023 "cbr_(0) start"
- .
18An Example Step 6
Define node movement model source
ltmovement-scenario-filesgt Define traffic
model source lttraffic-scenario-filesgt
19An Example Step 7
Tell ns the simulation stop time ns at 200.0
ns halt Start your simulation ns run
20Energy Extension
- Makes MobileNode energy-aware
- Enable by adding options
- ns_ node-config \
- energyModel EnergyModel
- -initialEnergy 100.0
- -txPower 0.6
- -rxPower 0.2
21Outline
- Overview of ns wireless functionality
- History
- Simple example
- MobileNode configuration
- Controlling mobility
- Defining traffic workloads
- MobileNode architecture
- Trace file format
- Role of simulation in wireless research
- Case study of simulations pitfalls GPSR
22Wireless Internals
- MobileNode
- Basic entity with address and port de-muxes,
routing agent, c. - Stack of network components, including IFQ, LL,
MAC, NetIF, radio propagation model, c. - Wireless channel
23Portrait of A Mobile Node
port classifier
Node
protocol agent
255
routing agent
addr classifier
defaulttarget_
ARP
LL
LL
LL
IFQ
IFQ
MAC
MAC
Propagation and antenna models
PHY
PHY
MobileNode
CHANNEL
Radio propagation/ antenna models
Prop/ant
24Mobile Node Components
- Classifiers
- defaulttarget_ points to routing agent object
- 255 is the port id assigned for rtagent_
- Routing agent
- Ad hoc routing protocol, e.g., AODV, DSDV, DSR
or directed diffusion -
25Mobile Node Components
- Link Layer
- Same as LAN, but with a separate ARP module
- Looks up IP-to-MAC mappings using ARP
- ARP
- Resolves IP address to hardware (MAC) address
- Broadcasts ARP query
- Interface queue (IFQ)
- Gives priority to routing protocol packets
- Has packet filtering (search and remove) capacity
26Mobile Node Components
- MAC
- 802.11
- IEEE RTS/CTS/DATA/ACK for unicast
- Sends DATA directly for broadcast
- Network interface (PHY)
- Used by MobileNode to access channel
- Stamps outgoing packets with meta-data
- Interface with radio/antenna models
27Mobile Node Components
- Radio Propagation Model
- Friss-space model attenuation at near distance
- Two-ray ground reflection model attenuation at
far distance - Shadowing model probabilistic
- Antenna
- Omni-directional, unity-gain
28Wireless Channel
- Duplicate packets to all mobile nodes attached to
the channel except the sender - It is the receivers responsibility to decide if
it will accept the packet - Collision is handled at individual receiver
- O(N2) computation!
29Wireless Trace Support
- CMU trace format differs from standard ns trace
format! - Configurable tracing
- MAC (very voluminous!)
- Router forwarding
- Agent events
- Movement events
- Format described in detail in ns manual
- When in doubt, no substitute for reading the
code! - Shortest path lengths logged per pkt rx (cost
in-core?) - New wireless trace format
- appears not to be in wide use yet
- same information, formatted differently
30Outline
- Overview of ns wireless functionality
- History
- Simple example
- MobileNode configuration
- Controlling mobility
- Defining traffic workloads
- MobileNode architecture
- Trace file format
- Role of simulation in wireless research
- Case study of simulations pitfalls GPSR
31Simulation as Way to Enable Area
- Ad hoc routing huge system deployment/debugging
cost - 1998 Broch et al. paper a watershed for ad hoc
routing first even comparison of wide field of
protocols - CMU ns wireless extensions the basis of most ad
hoc networking research for next 5 years
32Simulation as Way to Kill Area
- Simulators dont evaluate motivation!
- Why are 500 laptops in a gymnasium not simply
connecting to base stations? - The founding of MobiHoc
- cf. the founding of SIGMETRICS
- The founding of MobiSys
- Secret tip building a real system dramatically
increases chances of acceptance! (because its
HARD)
33Things to Investigate Using ns
- Coarse notion of capacity
- Coarse notion of effect of mobility
- Fine-grained behavior of your routing (or other
hop-by-hop) protocol - Only place you can easily have centralized view!
34Things Not to Investigate Using ns
- Realistic loss behavior (interference, multi-path
fading, )
Roofnet measurements SIGCOMM 2004
Broadcast Packet Delivery Probability
Node Pair
35Not in ns (contd)
- Realistic topology information
- Roofnet finding RTS/CTS useless in outdoor
network! - Hidden terminal problem still mainstay of
undergraduate networking courses everywhere - GPSR free space ns simulation debacle (more
later) - Fine-grained mobility behavior
- Random Waypoint corresponds little to reality
- GPSR density anomaly (more later)
36When to Roll Your Own Simulator
- GPSR greedy-only simulator
- properties of node density, not of fine-grained
radio propagation - 250 lines of C, a mornings work
- far faster than ns will ever be
- Simple visualization
- GPSR topology visualizer
- find connected components
- show planar subgraphs
- animate forwarding
37Outline
- Overview of ns wireless functionality
- History
- Simple example
- MobileNode configuration
- Controlling mobility
- Defining traffic workloads
- MobileNode architecture
- Trace file format
- Role of simulation in wireless research
- Case study of simulations pitfalls GPSR
38Greedy Perimeter Stateless Routing (GPSR)
- Central idea Machines can know their geographic
locations. - Route using geography. MobiCom 2000
- Packet destination field location of destination
- Nodes all know own positions, e.g.,
- by GPS (outdoors)
- by surveyed position (for non-mobile nodes)
- by short-range localization (indoors, ATT Camb,
1997, Priyantha et al., 2000) - c.
- Two forwarding algorithms
- Greedy mode simply chooses closest neighbor to
destination - Perimeter mode recovers when no closer next hop
available, by routing on planar subgraph of full
network graph
39Greedy Forwarding
- Nodes learn immediate neighbors positions from
beaconing/piggybacking on data packets - Locally optimal, greedy next hop choice
- Neighbor geographically nearest destination
D
x
y
40Greedy Forwarding Failure
- Greedy forwarding not always possible! Consider
D
z
v
void
y
w
x
41Void Traversal The Right-hand Rule
- Well-known graph traversal right-hand rule
- Requires only neighbors positions
z
y
x
42Planarized Graphs Example
- 200 nodes, placed uniformly at random on
2000-by-2000-meter region 250-meter radio range
Full Graph
GG Subgraph
RNG Subgraph
43Packet Delivery Success Rate(50, 200 Dense)
44GPSR Making it Real
- We implemented full GPSR for Berkeley mote
sensors NSDI 2005 - 3750 lines of nesC code
- also includes simple link thresholding, ARQ
- Deployed on Mica 2 dot mote testbeds
- 23-node, 50-node subsets of 100-node network in
office building (Soda Hall office walls 433
MHz) - 40-node network in office building (Intel
Research Berkeley cubicles 900 MHz) - Delivery success workload 50 packets between all
node pairs, serially
4550-Node Testbed, Soda Hall
46Planar, but Partitioned
Output of GPSRs Distributed GG (arrows denote
unidirectional links)
47Key Lessons and Conclusion
- Understand your algorithms correctness
assumptions - Does the simulator model these properties
accurately, or at least pessimistically? - Fading, interference, loss rate particular
pitfalls - No substitute for buildingeven moreso than for
Internet congestion control, as propagation too
complex to model accurately
48UCL A Tradition of Great Networking Research in
London
- Hiring junior and senior networking faculty
- Application deadline
- 5th January, 2006
- Details at http//www.cs.ucl.ac.uk/
- Why UCL?
- Research sdr, rat, Landmark Routing, NAT, XORP,
TFRC, XCP, GPSR, CLDP, GHT, Autograph, Polygraph,
- Students (Paul Francis, Mark Handley, Jon
Crowcroft, ) - LONDON