Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Stanford University CS 321 Information Processing in Sensor Networks
Sensors Network SimulatorsSensors Network Simulators
Qing Fang10/14/05
Sensing Networking
Computation
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.
Stanford University CS 321 Information Processing in Sensor Networks
Outline
Network simulation 1-2-3
NS-2
TOSSIM
NS-2 vs. TOSSIM
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
Stanford University CS 321 Information Processing in Sensor Networks
Developing Protocols
The distributed world view
Event-driven programming
Use of timers
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
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)
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
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
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
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
Stanford University CS 321 Information Processing in Sensor Networks
OTcl and C++: The Duality
��� ����
������� ����
�������� ����
���������������� ����
��
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
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.
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
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.
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
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.
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
Stanford University CS 321 Information Processing in Sensor Networks
A Multihop Routing Example
Stanford University CS 321 Information Processing in Sensor Networks
TOSSIM Architecture
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.
Stanford University CS 321 Information Processing in Sensor Networks
A TinyViz Example – Setting ADC values
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.
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
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.
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
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.
Stanford University CS 321 Information Processing in Sensor Networks
More Detailed Questions?
Talk to the TA �
Stanford University CS 321 Information Processing in Sensor Networks
The End
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();
}