31
Stanford University CS 321 Information Processing in Sensor Networks Sensors Network Simulators Sensors Network Simulators Qing Fang 10/14/05 Sensing Networking Computation

Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Sensors Network SimulatorsSensors Network Simulators

Qing Fang10/14/05

Sensing Networking

Computation

Page 2: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

This Talk

Not on how to run various network simulatorsInstead…

What differentiates various simulatorsBrief structures of the major simulators and their design considerations

Goal: understand what simulations can really achieve and which simulator to choose for your purpose. Pointers to how to get started.

Page 3: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Outline

Network simulation 1-2-3

NS-2

TOSSIM

NS-2 vs. TOSSIM

Page 4: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

When a network simulator is needed?

If it’s necessary to include the networking behaviors (multiple access control, flow control, etc.) to make your point. And You care about performance metrics, such as: packet loss, delay, etc. in an event-driven distributed environment.

User

System

Physical Layer

Data Link

Network

Transport

Network Stack

Threads

Address Space

Drivers

Files

Application

Application

Routers

Page 5: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Developing Protocols

The distributed world view

Event-driven programming

Use of timers

Page 6: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Choosing a Simulator

Accuracy – expressiveness

Scalability – simple, only keep minimal fidelity to observe critical phenomena

How much learning involved vs. how much time you have

Page 7: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Simulators for Sensornet Research

NS-2: the de facto general network simulator (Multiple institutions funded by DARPAR, NSF).

TOSSIM: the TinyOS mote simulator (Berkeley).

SensorSim: built on top of ns-2 for WINS platform. No longer supported (UCLA).

EmStar: a flexible environment for transitioning between simulation and deployment for iPAQ-class sensors (UCLA)

TOSSF: limited documentation, looks promising (Dartmouth)

Page 8: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

NS-2 vs. TOSSIM

1. The predominant network simulator

2. Simulates networks at the packet level

3. Allows a wide range of heterogeneous network configurations. Built-in propagation models.

4. Simulates networking stacks from the physical layer all the way to the transport layer

1. A TinyOS simulator that provides a network model

2. Simulates at the bit level3. External radio models4. Component oriented

modeling after TinyOS5. Better GUI

Page 9: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

NS-2

Wired and WirelessSize : (Current release adds around 10%)

100K lines of C++70K lines of OTcl30K lines of test suites20K lines of documentation

Page 10: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

NS Architecture

Completely follow the OSF layered architecture

Object-oriented (C++, OTcl)

Scalability + ExtensibilityControl/primitive separationSplit Otcl/C++ object

Modular approachFine-grained object compositionHigh reusability

Page 11: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

C++ and Otcl Separation

C++ for computation

OTcl for control (programmable simulator)Periodic or triggered action

�Compromise between composibility and speed

Learning and debugging

Page 12: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

OTcl and C++: The Duality

��� ����

������� ����

�������� ����

���������������� ����

��

Page 13: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

NS2 Disadvantages

Does not work well for large topologies(more than 300 nodes), but there is a work around for that when nodes are immobile

Large memory footprint100 nodes 23MB1000 nodes 412 MB

Page 14: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

To Use NS2…Don’t worry about Otcl. Its easy..

Forget about Nam traces (slow, ugly, hard to see useful info anyway). Write your own visualization program if you want to impress others.

The online documentation is quite resourceful.

Get started as soon as possible….

Adding new protocols by simply adding new subclasses of agent at the appropriate places. Some internal changes might be necessary.

Page 15: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Basics to Learn

Write the configuration file in Otcl (plenty of examples on-line).

How files are structured (read the manual and poke around in the ns directory).

How to add a protocol:the agent class the packet.h file the void recv ( Packet * pkt, Handler* h) function in C++ the Otcl interface (the int command(int argc, const char*const*argc)) to its C++ function

Page 16: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

My Own Experience with NS-2

Layered structure, easy to understand its logic flows

Once understand how they interact and how the files are structured (a steep initial learning curve), easy to hack.

The built-in routing algorithms could be buggy.

Page 17: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Scalability: able to handle large networks

Completeness: capture complete system behavior

Fidelity: capture behavior at a fine-grain

Bridging: the gap between algorithms and implementation

Goals of TOSSIM

Page 18: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

The Radio Model

Radio models external to TOSSIM

Models network as a directed graph of bit error probabilities, which can be changed at runtime.

Allows asymmetric links.

Page 19: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

TOS Application = Graph of Components

RFM

Radio byte

Radio Packet

UART

Serial Packet

ADC

Temp photo

Active Messages

clocksbit

byte

pack

et

Route map router sensor appln

appl

icat

ion

HW

SWExample: ad hoc, multi-hop routing of photo sensor readings

Graph of cooperatingstate machines on shared stack

Page 20: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

A Multihop Routing Example

Page 21: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

TOSSIM Architecture

Page 22: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Communication Services

Allows PC applications (TCP/IP etc) to drive, monitor, debug simulation.

TinyViz a java-based GUI allowing simulations to be visualized, analyzed and controlled.

TinyViz engine manage the event/command interface between user plugins to TOSSIM.

Page 23: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

A TinyViz Example – Setting ADC values

Page 24: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Programming TOSSIM

Write your own component (or modify the existing ones), assemble your application.

Write your own plugins (states you want to observe or control) if needed.

Comparatively easy to learn if you are not new to event-driven programming.

Page 25: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

Things Can Make TOSSIM More Appealing

CPU modeling : run-instantly model

Energy modeling

Supporting heterogeneous platforms

Page 26: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

TOSSIM Summary

The same code can be used both for simulation and testbed deployment.Fine-grained simulation, scalable to thousands of nodes (claimed).Does not address energy profiling. Applicable only on TinyOS platform.

Page 27: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

NS-2 vs. TOSSIM - A Recap

1. The predominant network simulator

2. Simulates networks at the packet level

3. Allows a wide range of heterogeneous network configurations. Built-in propagation models.

4. Simulates networking stacks from the physical layer all the way to the transport layer

1. A TinyOS simulator that provides a network model

2. Simulates at the bit level3. External radio models4. Component oriented

modeling after TinyOS5. Better GUI6. Comparatively easier to

learn

Page 28: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

After All …Why do we need simulations in the first place?

Controlled , Reproducible testing environmentCost-effective, alternative to real deploymentMeans to explore and improve design space while factoring into uncertainties (system, environment, etc.)

So, be clear what you want, i.e. at what level of details you want your simulation to be.

Then, design sensible scenarios and be specific in reporting how you made comparisons.

Page 29: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

More Detailed Questions?

Talk to the TA �

Page 30: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

The End

Page 31: Sensors Network Simulatorsgraphics.stanford.edu/.../Lectures/qing-CS321-NetSim.pdfHow files are structured (read the manual and poke around in the ns directory). How to add a protocol:

Stanford University CS 321 Information Processing in Sensor Networks

ComponentsModules

provide code that implements one or more interfaces and internal behavior

Configurationslink together components to yield new component

Interfacelogically related set of commands and events

StdControl.nc

interface StdControl {

command result_t init();

command result_t start();

command result_t stop();

}

Clock.nc

interface Clock {

command result_t setRate(char interval, char scale);

event result_t fire();

}