how (not) to simulate wireless networks with ns brad karp [email protected] university college...

48
How (not) to Simulate Wireless Networks with ns Brad Karp [email protected] University College London ns Workshop MSR Cambridge 9 th December, 2005

Upload: jase-stopper

Post on 01-Apr-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

How (not) to SimulateWireless Networks with ns

Brad [email protected]

University College London

ns WorkshopMSR Cambridge

9th December, 2005

Page 2: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

2

Outline

• 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 simulation’s pitfalls: GPSR

ns overview material largely borrowed:ns Manual (Chapter 16)Padma Haldar’s tutorial (11/2002)

Page 3: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

3

History of ns Wireless Support

• David Johnson’s 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 today’s talk): Mobile IP, Directed Diffusion, satellite links, &c.

Page 4: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

4

ns 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

Page 5: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

5

Wireless Example:Ad 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

Page 6: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

6

An Example – Step 1

# Define Global Variables# create simulatorset ns [new Simulator]

# create flat topology in 670m x 670m areaset topo [new Topography] $topo load_flatgrid 500 500

Page 7: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

7

An Example – Step 2

# Define wireless ns trace

# ns trace

set tracefd [open simple.tr w]

$ns trace-all $tracefd

Page 8: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

8

GOD (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 <no of mnodes>]• $god set-dist <from> <to> <#hops>

Page 9: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

9

Example –Step 3

• Create godset god [create-god 2]$ns at 900.00 “$god setdist 1 2 1”

• Create wireless channelset thechan [new

Channel/WirelessChannel]

Page 10: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

10

An 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

Page 11: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

11

An Example – Step 5# Use “for” loop to create 3 nodes:

for {set i 0} {$i < 2} {incr i} {

set node($i) [$ns node]

# disable random motion

$node($i) random-motion 0

}

Page 12: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

12

MobileNode Movement

• Node position defined in 3D• Today, z axis not used

$node set X_ <x1>$node set Y_ <y1>$node set Z_ <z1>$node at <time> setdest <newx> <newy> <speed>

• Lots of these events over a simulation; manual generation tedious…

Page 13: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

13

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

Page 14: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

14

Scenario Generator: Movement

• setdest: MobileNode movement generatorsetdest -n <num_of_nodes> -p setdest -n <num_of_nodes> -p pausetime -M <maxspeed> -t pausetime -M <maxspeed> -t <simtime> -x <maxx> -y <maxy><simtime> -x <maxx> -y <maxy>

Source: ns-2/indep-utils/cmu-scen-ns-2/indep-utils/cmu-scen-gen/setdest/gen/setdest/

Page 15: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

15

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

Page 16: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

16

Scenario Generator: Traffic• Generating traffic pattern files

– CBR/TCP trafficns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate (pkt/s)]seed] [-mc connections] [-rate rate (pkt/s)]

– CBR trafficCBR trafficns cbrgen.tcl –type cbr –nn 20 –seed 1 –mc 8 ns cbrgen.tcl –type cbr –nn 20 –seed 1 –mc 8 -rate 4-rate 4– TCP trafficns cbrgen.tcl –type tcp -nn 15 -seed 0 –mc 6ns cbrgen.tcl –type tcp -nn 15 -seed 0 –mc 6Default 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/ns-2/indep-utils/cmu-scen-gen/

Page 17: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

17

A 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"…….

Page 18: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

18

An Example – Step 6

# Define node movement model source <movement-scenario-files>

# Define traffic modelsource <traffic-scenario-files>

Page 19: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

19

An Example – Step 7

# Tell ns the simulation stop time $ns at 200.0 “$ns halt”

# Start your simulation $ns run

Page 20: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

20

Energy Extension

• Makes MobileNode energy-aware• Enable by adding options:$ns_ node-config \

–energyModel EnergyModel

-initialEnergy100.0

-txPower 0.6

-rxPower 0.2

Page 21: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

21

Outline

• 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 simulation’s pitfalls: GPSR

Page 22: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

22

Wireless 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

Page 23: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

23

Portrait of A Mobile Node

Node

ARP

Propagation and antenna models MobileNode

LL

MAC

PHY

LL

CHANNEL

LL

MAC

PHY

Classifier: Forwarding

Agent: Protocol EntityNode Entry

LL: Link layer object

IFQ: Interface queue

MAC: Mac object

PHY: Net interface

protocolagent

routingagent

addrclassifier

portclassifier

255

IFQIFQ

defaulttarget_

Radio propagation/antenna models

Prop/ant

Page 24: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

24

Mobile 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

Page 25: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

25

Mobile 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

Page 26: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

26

Mobile 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

Page 27: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

27

Mobile 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

Page 28: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

28

Wireless Channel

• Duplicate packets to all mobile nodes attached to the channel except the sender

• It is the receiver’s responsibility to decide if it will accept the packet– Collision is handled at individual

receiver– O(N2) computation!

Page 29: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

29

Wireless 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

Page 30: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

30

Outline

• 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 simulation’s pitfalls: GPSR

Page 31: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

31

Simulation 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

Page 32: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

32

Simulation as Way to Kill Area

• Simulators don’t 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 it’s HARD)

Page 33: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

33

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

Page 34: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

34

Things Not to Investigate Using ns

• Realistic loss behavior (interference, multi-path fading, …)

Bro

ad

cast

Packet

Delivery

Pro

bab

ilit

y

Node Pair

Roofnet measurements [SIGCOMM 2004]

Page 35: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

35

Not in ns (cont’d)

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

Page 36: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

36

When to Roll Your Own Simulator

• GPSR greedy-only simulator– properties of node density, not of fine-

grained radio propagation– ~250 lines of C, a morning’s work– far faster than ns will ever be

• Simple visualization– GPSR topology visualizer

• find connected components• show planar subgraphs• animate forwarding

Page 37: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

37

Outline

• 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 simulation’s pitfalls: GPSR

Page 38: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

38

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, [AT&T 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

Scalability: tiny state per router; low routing protocol overhead; approximates shortest paths; high delivery success rate

Greedy Perimeter Stateless Routing (GPSR)

Page 39: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

39

Greedy Forwarding

• Nodes learn immediate neighbors’ positions from beaconing/piggybacking on data packets

• Locally optimal, greedy next hop choice:– Neighbor geographically nearest destination

Dx

y

Page 40: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

40

Greedy Forwarding Failure

Greedy forwarding not always possible! Consider:D

x

zv

void

w y

How can we circumnavigate voids?…based only on one-hop

neighborhood?

Page 41: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

41

Well-known graph traversal: right-hand ruleRequires only neighbors’ positions

Void Traversal: The Right-hand Rule

x

y zDoesn’t work when edges in graph cross one another!

Page 42: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

42

Planarized Graphs: Example

200 nodes, placed uniformly at random on 2000-by-2000-meter region; 250-meter radio range

Full Graph GG Subgraph RNG Subgraph

Page 43: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

43

Packet Delivery Success Rate(50, 200; Dense)

Page 44: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

44

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

Page 45: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

45

50-Node Testbed, Soda Hall

GAME OVEROnly 68.2% of node pairs connected!!

What’s going on here?!

Page 46: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

46

Planar, but Partitioned

Output of GPSR’s Distributed GG

(arrows denote unidirectional links)

Absorption, reflection (multi-path), interference, antenna orientation differences, &c., lead to non-uniform radio ranges.RNG and GG partition graphs when radio ranges not uniform!Solution: entirely new protocol, CLDP, for removing crossing edges [NSDI 2005]. Provably correct on all connected graphs.

Page 47: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

47

Key Lessons and Conclusion

• Understand your algorithm’s correctness assumptions

• Does the simulator model these properties accurately, or at least pessimistically?

• Fading, interference, loss rate particular pitfalls

• No substitute for building—even moreso than for Internet congestion control, as propagation too complex to model accurately

Page 48: How (not) to Simulate Wireless Networks with ns Brad Karp bkarp@cs.ucl.ac.uk University College London ns Workshop MSR Cambridge 9 th December, 2005

48

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