SlideShare une entreprise Scribd logo
1  sur  107
Télécharger pour lire hors ligne
Experimentation with ns-3
                               Mathieu Lacage
                         mathieu.lacage@sophia.inria.fr
                                        INRIA


                 Trilogy Summer School, 27th august 2009




Mathieu Lacage (INRIA)          Experimentation with ns-3   Trilogy’2009   1 / 95
Goals of this tutorial


 • Understand the goals of the ns-3 project
 • Learn what has been done to achieve these goals
 • Identify future work directions




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   2 / 95
Tutorial schedule


 1   14h00-15h00: Introduction
 2   15h00-16h00: The ns-3 architecture
 3   16h00-17h00: The ns-3 object model




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   3 / 95
Part I

                         Introduction




Mathieu Lacage (INRIA)    Experimentation with ns-3   Trilogy’2009   4 / 95
Outline

Simulation considered harmful


Why not reuse an existing simulator ?


What is so special about ns-3 ?


What we learned along the way




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   5 / 95
Outline

Simulation considered harmful


Why not reuse an existing simulator ?


What is so special about ns-3 ?


What we learned along the way




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   6 / 95
Recent history (1995-2005)

 • ns-2 became the main choice for research usage. Search of
    ACM Digital Library papers citing simulation, 2001-04:
                            ns-2        OPNET                 QualNet/Glomosim
      ≥ layer 4           123 (75%)    30 (18%)                    11 (7%)
      = layer 3           186 (70%)    48 (18%)                   31 (12%)
      ≤ layer 2           114 (43%)    96 (36%)                   55 (21%)
 • Funding for ns-2 development dropped in the early 2000’s




 Mathieu Lacage (INRIA)           Experimentation with ns-3                Trilogy’2009   7 / 95
What is wrong about ns-2 ?
 • Split object model (OTcl and C++) and use of Tcl:
     • Doesn’t scale well
     • Makes it difficult for students
 • Large amount of abstraction at the network layer and below
    leads to big discontinuities when transitioning from simulation to
    experiment
 • Accretion of unmaintained and incompatible models
 • Lack of support for creating methodologically sound simulations
 • Lack of, and outdated, documentation
 • In ns-2, validation really means regression: no documented
    validation of the models, outside of TCP



 Mathieu Lacage (INRIA)    Experimentation with ns-3        Trilogy’2009   8 / 95
Overheard on e2e-interest
mailing list

September 2005 archives of the e2e-interest mailing list:
  • “...Tragedy of the Commons...”
  • “...around 50% of the papers appeared to be... bogus...”
  • “Who has ever validated NS2 code?”
  • “To be honest, I’m still not sure whether I will use a simulation in
     a paper.”
  • “...I will have a hard time accepting or advocating the use of
     NS-2 or any other simulation tool”



  Mathieu Lacage (INRIA)    Experimentation with ns-3        Trilogy’2009   9 / 95
A recurring misconception

 • Using ns-2 is actively harmful




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   10 / 95
A recurring misconception

 • Using ns-2 is actively harmful



 • Simulation is ns-2




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   10 / 95
A recurring misconception

  • Using ns-2 is actively harmful



  • Simulation is ns-2



Thus, simulation is actively harmful




  Mathieu Lacage (INRIA)    Experimentation with ns-3   Trilogy’2009   10 / 95
Back in 2000’s, the rise of
testbeds
 • Hardware costs going down
 • OS virtualization going up
 • Development of control and management software




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   11 / 95
Back in 2000’s, the rise of
testbeds
  • Hardware costs going down
  • OS virtualization going up
  • Development of control and management software

Result:
  • Emulab: http://www.emulab.net
  • ORBIT: http://www.orbit-lab.org
  • Planetlab: http://planet-lab.org
  • ModelNet: https://modelnet.sysnet.ucsd.edu
  • ...


  Mathieu Lacage (INRIA)     Experimentation with ns-3   Trilogy’2009   11 / 95
Why do we need simulation at
all ?

 • Simulation models are not validated
 • Simulation model implementations not verified
 • No need for validation and verification in testbeds




 Mathieu Lacage (INRIA)   Experimentation with ns-3     Trilogy’2009   12 / 95
Why do we need simulation at
all ?

  • Simulation models are not validated
  • Simulation model implementations not verified
  • No need for validation and verification in testbeds

However, there are lots of good things about simulation:
  • Reproducibility
  • Easier to setup, deploy, instrument
  • Investigate non-existent systems
  • Scalability



  Mathieu Lacage (INRIA)   Experimentation with ns-3       Trilogy’2009   12 / 95
But, really, we need both !

We want to get the best from both worlds:
  • Simulators: reproducibility, debuggability, ease of setup
  • Testbeds: realism
We want an integrated experimentation environment:
 • Use each tool separately:
         • Parameter space exploration with simulations
         • More realism with testbeds
  • Use both tools together:
      • Simulator for elements of the topology to scale
      • Testbed for other elements to get realism




  Mathieu Lacage (INRIA)      Experimentation with ns-3    Trilogy’2009   13 / 95
Summary

We need simulations:
  • Easier to use, debug, reproduce than testbeds
  • Not constrained by existing hardware/software
We need a special simulator:
  • Improves model validation
  • Improves model implementation verification
  • Allow users to move back and forth between simulation and
     testbeds




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   14 / 95
Outline

Simulation considered harmful


Why not reuse an existing simulator ?


What is so special about ns-3 ?


What we learned along the way




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   15 / 95
Starting from ns-2
The biggest reason to start from ns-2 is:
  • A large existing userbase
  • A large set of existing models
But, we need to address many issues:
  • Most existing models lack validation, verification, maintenance
  • Bi-language system (C++/tcl) makes debugging complex:
    removing it would mean dropping backward compatibility
  • Core packet data-structure:
         • Inappropriate for emulation
         • Fragmentation unsupported
Re-engineering ns-2 to fix all these issues would make it a new
different simulator: we would lose our existing userbase.


  Mathieu Lacage (INRIA)      Experimentation with ns-3   Trilogy’2009   16 / 95
Proprietary simulators

There are many of them (google for network simulator):
  • Opnet
  • QualNet
  • Shunra
  • etc.
But:
  • Terms of use
  • Very costly for industrial partners or publicly-funded research
       which cannot get education licenses.




  Mathieu Lacage (INRIA)     Experimentation with ns-3     Trilogy’2009   17 / 95
Omnetpp


 • It was not clear in 2005 it would still be alive in 2009
 • Major worries over the bi-language architecture: learning curve,
    debugging, etc.
 • Software structure did not seem to lend itself to the realism we
    sought.




 Mathieu Lacage (INRIA)    Experimentation with ns-3          Trilogy’2009   18 / 95
Not Invented Here



Yes, we did fall prey to that syndrome too:
we thought we could do it better than the others




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   19 / 95
Outline

Simulation considered harmful


Why not reuse an existing simulator ?


What is so special about ns-3 ?


What we learned along the way




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   20 / 95
Good debuggability


C++-only simulations: no need to debug two languages at the same
time
  • ns-3 is a library written in C++
  • Simulation programs are C++ executables
  • Bindings in Python for python simulations




  Mathieu Lacage (INRIA)    Experimentation with ns-3   Trilogy’2009   21 / 95
Long term project lifetime

A open source community:
   • An open license (GPLv2)
   • All design and implementation discussions in the open on
     mailing-lists (even flame wars)
   • Everyone can (should) become a maintainer
This is critical to allow:
   • The project to scale to many models
   • The project to last beyond initial seed funding
   • Model/implementations reviews in the open:
     Given enough eyeballs, all bugs are shallow



  Mathieu Lacage (INRIA)     Experimentation with ns-3   Trilogy’2009   22 / 95
Low cost of model validation

Make models close to the real world:
  • Models are less abstract: easier to validate
  • Makes it easy to perform direct execution of real code
  • Emulation is native and robust against changes in models
How ?
  • Real IP addresses
  • Multiple interfaces per node
  • Bsd-like sockets
  • Packets contain real network bytes




  Mathieu Lacage (INRIA)   Experimentation with ns-3     Trilogy’2009   23 / 95
A usecase: NSC
 Architecture
                                                                                                   liblinux2.6.14.so
                                                                                                        libfreebsd5.3.so
       NSC TCP
       NSC TCP                                                                                 Socket API
        NSC TCP
        model
         model                                                                         Network
                                                                                       Network
          model
                                                       send packet                     Stack
                                                                                       StackTCP

                                                                             Cradle (shared Virtualised
                                                                             Cradle (sharedlib)
                                                                                             lib)
                                                                                             Virtualised Virtualised
                                                                                                       Resources
                                                                                                        Resources
                                                                                              IP         Resources

                                                                             Simulation API

   Network
   simulator                                                                                       Network Stack
   (ns-2)                                              connect,
                                                       send,                                       Cradle (shared lib)
                                                       packet received,
                                                       timer, read




       © THE UNIVERSITY OF WAIKATO • TE WHARE WANANGA O WAIKATO                                                            5




 Mathieu Lacage (INRIA)                                                   Experimentation with ns-3                            Trilogy’2009   24 / 95
NSC implementation

 • Globalizer: per-process kernel source code and add indirection
   to all global variable declarations and accesses
 • Glue: per-kernel (and per-kernel-version) glue to provide kernel
   APIs for kernel code:
        • kmalloc: memory allocation
        • NetDevice integration
        • Socket integration
 • Provides glue for:
     • linux 2.6.18, 2.6.26, 2.6.28
     • FreeBSD 5
     • lwip 1.3
     • OpenBSD 3




 Mathieu Lacage (INRIA)      Experimentation with ns-3   Trilogy’2009   25 / 95
NSC accuracy
 Accuracy
 ●Have shown NSC to be very accurate – able to produce
 packet traces that are almost identical to traces measured
 from a test network




       © THE UNIVERSITY OF WAIKATO • TE WHARE WANANGA O WAIKATO                               6




 Mathieu Lacage (INRIA)                                           Experimentation with ns-3       Trilogy’2009   26 / 95
Summary

ns-3 has a strong focus on realism:
  • Makes models closer to the real world: easier to validate
  • Allows direct code execution: no model validation
  • Allows robust emulation for large-scale and mixed experiments
ns-3 also cares about good software engineering:
  • Single-language architecture is more robust in the long term
  • Open source community ensures long lifetime to the project




  Mathieu Lacage (INRIA)   Experimentation with ns-3     Trilogy’2009   27 / 95
Outline

Simulation considered harmful


Why not reuse an existing simulator ?


What is so special about ns-3 ?


What we learned along the way




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   28 / 95
Things You Should Never Do

It’s an old axiom of software engineering:
Don’t rewrite from scratch, ever.


We did not really start from scratch:
  • Stole code and concepts from GTNetS (applications)
  • Stole code and concepts from yans (wifi)
  • Stole code and concepts from ns-2 (olsr, error models)
Even then, it took us 2 years to get to a useful state




  Mathieu Lacage (INRIA)    Experimentation with ns-3    Trilogy’2009   29 / 95
Building an open source
community is hard
It’s a lot of work to attract contributors and keep them: they want to
have fun, they want to have impact on the project:
    • Never flame people on mailing-lists:
         • Always answer questions kindly, point out manuals and FAQ
         • Don’t answer provocative statements
         • English is not the native language of most users
  • We need to do the boring work (release management, bug
     tracking, server maintenance)
  • No discussion behind closed doors: increases communication
     cost
  • It’s a meritocracy: those who contribute the most should have
     power to decide for the project

  Mathieu Lacage (INRIA)     Experimentation with ns-3       Trilogy’2009   30 / 95
Need for integrated statistical
tools

Initially, we thought we could:
  • Allow users to easily instrument the system
  • Delegate analysis to third-party tools such as R
It does not work that way though:
  • Lack of methodology documentation
  • Fancy statistical tools are too complex for most users
Future work: integrate tools to automatically measure and improve
confidence intervals on simulation output



  Mathieu Lacage (INRIA)    Experimentation with ns-3        Trilogy’2009   31 / 95
Need for a high-level
experimentation environment
ns-3 provides low-level functionality:
  • Tap devices
  • Realtime simulation core
But we want to allow easy switching and mixing of simulation and
testbeds. We need higher-level abstractions for:
  • Experiment description (topology, application traffic)
  • Experiment configuration
  • Tracing configuration
  • Deployment automation
Work towards this is underway with NEPI (ROADS’09: NEPI: Using
Independent Simulators, Emulators, and Testbeds for Easy
Experimentation)
  Mathieu Lacage (INRIA)    Experimentation with ns-3       Trilogy’2009   32 / 95
Need for more direct code
execution I
Integrate normal POSIX network applications in the simulator:
  • No source code modifications
  • Easy to debug (great network application development platform
     !)
Needs:
  • Globalization: global variables must be virtualized for each
     instance of the application running in the simulator
  • Filesystem virtualization: each application needs a separate
     filesystem (to get different configuration and log files for
     example)
  • Socket library: need a complete implementation of sockets in
     the simulator, including all the crazy ioctls
  Mathieu Lacage (INRIA)     Experimentation with ns-3      Trilogy’2009   33 / 95
Need for more direct code
execution II

Status:
  • Running demonstrations with ping, traceroute
  • Simple socket applications can run: a couple of threads, select,
     tcp server/client
  • Larger applications using fancy socket ioctls don’t work very well
     yet




  Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   34 / 95
Part II

                         The ns-3 architecture




Mathieu Lacage (INRIA)         Experimentation with ns-3   Trilogy’2009   35 / 95
Outline


Introduction


Fundamental network model structure


Topology construction




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   36 / 95
Outline


Introduction


Fundamental network model structure


Topology construction




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   37 / 95
Environment setup

Install all needed tools:
Ubuntu
sudo apt-get install build-essential g++ python mercurial

Windows
  • cygwin
  • python
  • mercurial




  Mathieu Lacage (INRIA)      Experimentation with ns-3     Trilogy’2009   38 / 95
Getting ns-3

Availability (linux, osx, cygwin, mingw):
  • Released tarballs: http://www.nsnam.org/releases
  • Development version: http://code.nsnam.org/ns-3-dev


The development version is usually stable: a lot of people use it for
daily work:

hg clone http://code.nsnam.org/ns-3-dev




  Mathieu Lacage (INRIA)     Experimentation with ns-3     Trilogy’2009   39 / 95
Running ns-3


Use waf to build it (similar to make):

./waf
./waf shell
./build/debug/examples/csma-broadcast




  Mathieu Lacage (INRIA)     Experimentation with ns-3   Trilogy’2009   40 / 95
Exploring the source code
Node
NetDevice
                                                                                        High-level wrappers
Address types
                                                                                        No smart pointers
Queues
                                                                                        Aimed at scripting
Socket
Ipv4                                              helper


                              routing          internet-stack          devices       MobilityModels
                                                                                     (static, random walk,
                                        node                       mobility          etc.)
Events
Scheduler
Time arithmetic                 simulator                       common


                                                   core
                                                                                            Packets
                                                                                            Packet tags
                                                                                            Packet headers
        Smart pointers                                            Callbacks                 Pcap file writing
        Dynamic type system                                       Tracing
        Attributes                                                Logging
                                                                  Random Variables




   Mathieu Lacage (INRIA)                         Experimentation with ns-3                          Trilogy’2009   41 / 95
A typical simulation
  • Create a bunch of C++ objects
  • Configure and interconnect them
  • Each object creates events with Simulator::Schedule
  • Call Simulator::Run to execute all events

A (fictional) simulation
Node *a = new Node ();
Node *b = new Node ();
Link *link = new Link (a,b);
Simulator::Schedule (Seconds (0.5),          // in 0.5s from now
                     &Node::StartCbr, a,      // call StartCbr on ’a’
                     "100bytes", "0.2ms", b); // pass these arguments
Simulator::Run ();

  Mathieu Lacage (INRIA)     Experimentation with ns-3        Trilogy’2009   42 / 95
Outline


Introduction


Fundamental network model structure


Topology construction




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   43 / 95
The basic model
           Application                                    Application
         Application                                    Application
                             Socket-like
                             API




           Protocol                                      Protocol
            Stack                                         Stack




           NetDevice                                     NetDevice
          NetDevice                                     NetDevice


Node                                           Node

                            Channel
                           Channel




  Mathieu Lacage (INRIA)    Experimentation with ns-3                   Trilogy’2009   44 / 95
The fundamental objects

 • Node: the motherboard of a computer with RAM, CPU, and, IO
    interfaces
 • Application: a packet generator and consumer which can run on
    a Node and talk to a set of network stacks
 • Socket: the interface between an application and a network
    stack
 • NetDevice: a network card which can be plugged in an IO
    interface of a Node
 • Channel: a physical connector between a set of NetDevice
    objects



 Mathieu Lacage (INRIA)   Experimentation with ns-3    Trilogy’2009   45 / 95
Important remark

NetDevices are strongly bound to Channels of a matching type:

         WifiNetDevice                       WifiNetDevice                     CsmaNetDevice




  WifiNetDevice              WifiChannel                               CsmaChannel




             WifiNetDevice                             CsmaNetDevice                 CsmaNetDevice




  Mathieu Lacage (INRIA)                   Experimentation with ns-3                                 Trilogy’2009   46 / 95
Existing models


 • Network stacks: arp, ipv4, icmpv4, udp, tcp (ipv6 under review)
 • Devices: wifi, csma, point-to-point, bridge
 • Error models and queues
 • Applications: udp echo, on/off, sink
 • Mobility models: random walk, etc.
 • Routing: olsr, static global




 Mathieu Lacage (INRIA)    Experimentation with ns-3    Trilogy’2009   47 / 95
For example, the wifi models


 • New model, written from 802.11 specification
 • Accurate model of the MAC
 • DCF, beacon generation, probing, association
 • A set of rate control algorithms (ARF, ideal, AARF, Minstrel, etc.)
 • Not-so-slow models of the 802.11a PHY




 Mathieu Lacage (INRIA)   Experimentation with ns-3       Trilogy’2009   48 / 95
Development of wifi models

New contributions from many developers:
  • University of Florence: 802.11n, EDCA, frame aggregation,
     block ack
  • Russian Academy of Sciences: 802.11s, HWMP routing protocol
  • Boeing: 802.11b channel models, validation
  • Deutsche Telekom Laboratories: PHY modelization, validation
  • Karlsruhe Institute of Technology: PHY modelization (Rayleigh,
     Nakagami)




  Mathieu Lacage (INRIA)   Experimentation with ns-3    Trilogy’2009   49 / 95
Summary


 • Core models are based on well-known abstractions: sockets,
    devices, etc.




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   50 / 95
Summary


 • Core models are based on well-known abstractions: sockets,
    devices, etc.
 • An active community of contributors




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   50 / 95
Outline


Introduction


Fundamental network model structure


Topology construction




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   51 / 95
The Helper/Container API
We want to:
  • Make it easy to build topologies with repeating patterns
  • Make the topology description more high-level (and less
     verbose) to make it easier to read and understand
The idea is simple:
  • Sets of objects are stored in Containers
  • One operation is encoded in a Helper object and applies on a
     Container
Helper operations:
  • Are not generic: different helpers provide different operations
  • Do not try to allow code reuse: just try to minimize the amount of
     code written
  • Provide syntactical sugar: make the code easier to read

  Mathieu Lacage (INRIA)   Experimentation with ns-3       Trilogy’2009   52 / 95
Typical containers and helpers
Example containers:
  • NodeContainer
  • NetDeviceContainer
  • Ipv4AddressContainer
Example helper classes:
  • InternetStackHelper
  • WifiHelper
  • MobilityHelper
  • OlsrHelper
  • etc. Each model provides a helper class



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   53 / 95
Create a couple of nodes


NodeContainer csmaNodes;                  Create empty node container
csmaNodes.Create (2);                     Create two nodes
NodeContainer wifiNodes;                   Create empty node container
wifiNodes.Add (csmaNodes.Get (1));         Add existing node to it
wifiNodes.Create (3);                      And then create some more nodes




   Mathieu Lacage (INRIA)   Experimentation with ns-3         Trilogy’2009   54 / 95
Then, the csma network


NetDeviceContainer csmaDevices;                  Create empty device container
CsmaHelper csma;                                 Create csma helper
csma.SetChannelAttribute ("DataRate",            Set data rate
        StringValue ("5Mbps"));
csma.SetChannelAttribute ("Delay",               Set delay
        StringValue ("2ms"));
csmaDevices = csma.Install (csmaNodes);          Create csma devices and
                                                 channel




   Mathieu Lacage (INRIA)    Experimentation with ns-3             Trilogy’2009   55 / 95
And a couple of wifi interfaces

Finally, setup the wifi channel:
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());

And create adhoc devices on this channel:
NetDeviceContainer wifiDevices;
WifiHelper wifi = WifiHelper::Default ();
wifiDevices = wifi.Install (wifiPhy, wifiNodes);




   Mathieu Lacage (INRIA)        Experimentation with ns-3            Trilogy’2009   56 / 95
Comparison with low-level
version


Fire up editor for tutorial-helper.cc and tutorial-lowlevel.cc




  Mathieu Lacage (INRIA)      Experimentation with ns-3          Trilogy’2009   57 / 95
Summary


 • It’s always possible to create objects by hand, interconnect and
    configure them




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   58 / 95
Summary


 • It’s always possible to create objects by hand, interconnect and
    configure them
 • But it can be easier to reuse the for loops encapsulated in
    Helper classes




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   58 / 95
Summary


 • It’s always possible to create objects by hand, interconnect and
    configure them
 • But it can be easier to reuse the for loops encapsulated in
    Helper classes
 • Helper classes make scripts less cluttered and easier to read
    and modify




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   58 / 95
Part III

                         The ns-3 object model




Mathieu Lacage (INRIA)         Experimentation with ns-3   Trilogy’2009   59 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   60 / 95
It’s easy to build a network
simulator

It’s just a matter of:
   • Provide an event scheduler
   • Implement a couple of models to create and consume events
But it’s much harder to build a network simulator which:
   • Allows models to be reusable independently
   • Ensures API coherence between models
   • Automates common tasks (tracing, configuration)




  Mathieu Lacage (INRIA)   Experimentation with ns-3       Trilogy’2009   61 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   62 / 95
Why are objects so
complicated to create ?

We do:
 Ptr<Node> node0 = CreateObject<Node> ();
Why not:

 Node *node0 = new Node ();
Or:
 Node node0 = Node ();




  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   63 / 95
Templates: the Nasty Brackets

 • Contain a list of type arguments
 • Parameterize a class or function from input type
 • In ns-3, used for:
      • Standard Template Library
      • Syntactical sugar for low-level facilities
 • Saves a lot of typing
 • No portability/compiler support problem
 • Sometimes painful to decipher error messages.




 Mathieu Lacage (INRIA)    Experimentation with ns-3   Trilogy’2009   64 / 95
Memory Management
It is hard in C++:
  • No garbage collector
  • Easy to forget to delete an object
  • Pointer cycles
  • Ensure coherency and uniformity
So, we use:
  • Reference counting: track number of pointers to an object
     (Ref+Unref)
  • Smart pointers: Ptr<>, Create<> and, CreateObject<>
  • Sometimes, explicit Dispose to break cycles



  Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   65 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   66 / 95
Where is my MobileNode ?
Ptr<Node> node = CreateObject<Node> ();
Ptr<MobilityModel> mobility = CreateObject<...> ();
node->AggregateObject (mobility);

  •   Some nodes need an IPv4 stack, a position, an energy model.
  •   Some nodes need just two out of three.
  •   Others need other unknown features.
  •   The obvious solution: add everything to the Node base class:
         • The class will grow uncontrollably over time
         • Everyone will need to patch the class
         • Slowly, every piece of code will depend on every other piece of
            code (cannot reuse anything without dragging in everything)
         • A maintenance nightmare...
  • A better solution:
      • Separate functionality belongs to separate classes
      • Objects can be aggregated at runtime to obtain extra functionality
  Mathieu Lacage (INRIA)       Experimentation with ns-3        Trilogy’2009   67 / 95
Object aggregation
Node                  MobilityModel
                                             • A circular singly linked-list
                                             • AggregateObject is a constant-time
                                                operation
                                             • GetObject is a O(n) operation
                                             • Aggregate contains only one object
Node           MobilityModel
                                                of each type

                                                           Ipv4




        Ipv4                                    Node              MobilityModel




  Mathieu Lacage (INRIA)              Experimentation with ns-3                   Trilogy’2009   68 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   69 / 95
The traditional approach
In C++, if you want to call methods on an object, you need a pointer
to this object. To get a pointer, you need to:
   • keep local copies of pointers to every object you create
   • walk pointer chains to get access to objects created within other
     objects
For example, in ns-3, you could do this:

Ptr<NetDevice> dev = NodeList::Get (5)->GetDevice (0);
Ptr<WifiNetDevice> wifi = dev->GetObject<WifiNetDevice> ();
Ptr<WifiPhy> phy = dev->GetPhy ();
phy->SetAttribute ("TxGain", ...);
phy->ConnectTraceSource (...);
It’s not fun to do...

  Mathieu Lacage (INRIA)    Experimentation with ns-3      Trilogy’2009   70 / 95
Use a namespace string !
Set an attribute:
Config::SetAttribute ("/NodeList/5/DeviceList/0/Phy/TxGain",
            StringValue ("10"));
Connect a trace sink to a trace source:
Config::Connect ("/NodeList/5/DeviceList/0/Phy/TxGain",
         MakeCallback (&LocalSink));
Just get a pointer:

Config::MatchContainer match;
match = Config::LookupMatches ("/NodeList/5/DeviceList/0/Phy/");
Ptr<WifiPhy> phy = match.Get (0)->GetObject<WifiPhy> ();


  Mathieu Lacage (INRIA)    Experimentation with ns-3         Trilogy’2009   71 / 95
The object namespace I

Object namespace strings represent a path through a set of object
pointers:
   NodeListPriv                           Node


  /NodeList/[0-n]                    /DeviceList/[0-n]




     PointToPointNetDevice                       CsmaNetDevice


 /DataRate          /InterframeGap      /SendEnable        /FrameSize



For example, /NodeList/x/DeviceList/y/InterframeGap represents the
InterframeGap attribute of the device number y in node number x.



   Mathieu Lacage (INRIA)                                Experimentation with ns-3   Trilogy’2009   72 / 95
The object namespace II

Navigating the attributes using paths:
  • /NodeList/[3-5]|8|[0-1]: matches nodes index 0, 1, 3, 4, 5, 8
  • /NodeList/*: matches all nodes
  • /NodeList/3/$ns3::Ipv4: matches object of type ns3::Ipv4
     aggregated to node number 3
  • /NodeList/3/DeviceList/*/$ns3::CsmaNetDevice: matches all
     devices of type ns3::CsmaNetDevice within node number 3
  • /NodeList/3/DeviceList/0/RemoteStationManager: matches the
     object pointed to by attribute RemoteStationManager in device 0
     in node 3.



  Mathieu Lacage (INRIA)   Experimentation with ns-3        Trilogy’2009   73 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   74 / 95
Traditionally, in C++
   • Export attributes as part of a class’s public API
   • Use static variables for defaults
For example:
class MyModel {
public:
 MyModel () : m_foo (m_defaultFoo) {}
 void SetFoo (int foo) {m_foo = foo;}
 int GetFoo (void) {return m_foo}
 static void SetDefaultFoo (int foo) {m_defaultFoo = foo;}
 static int GetDefaultFoo (void) {return m_defaultFoo;}
private:
 int m_foo;
 static int m_defaultFoo = 10;
};


   Mathieu Lacage (INRIA)          Experimentation with ns-3   Trilogy’2009   75 / 95
In ns-3, done automatically I

   • Set a default value:

Config::SetDefaultValue ("ns3::WifiPhy::TxGain", StringValue ("10"));

   • Set a value on a specific object:

phy->SetAttribute ("TxGain", StringValue ("10"));

   • Set a value from the command-line –ns3::WifiPhy::TxGain=10:

CommandLine cmd;
cmd.Parse (argc, argv);




   Mathieu Lacage (INRIA)          Experimentation with ns-3          Trilogy’2009   76 / 95
In ns-3, done automatically II

   • Load, Change, and Save all values from and to a raw text or xml
      file with or without a GUI:
GtkConfigStore config;
config.ConfigureDefaults ();
...
config.ConfigureAttributes ();

   • Set a value with an environment variable
      NS_ATTRIBUTE_DEFAULT=ns3::WifiPhy::TxGain=10




   Mathieu Lacage (INRIA)      Experimentation with ns-3   Trilogy’2009   77 / 95
Graphical navigation




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   78 / 95
Doxygen documentation




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   79 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   80 / 95
Tracing requirements

 • Tracing is a structured form of simulation output
 • Example (from ns-2):
   + 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610
   - 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610
   r 1.84471 2 1 cbr 210 ------- 1 3.0 1.0 195 600
   r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602
   + 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611
 • Problem: tracing needs vary widely
        • Would like to change tracing output format without editing the core
        • Would like to support multiple output formats




 Mathieu Lacage (INRIA)       Experimentation with ns-3         Trilogy’2009   81 / 95
Tracing overview


 • Simulator provides a set of pre-configured trace sources
     • Users may edit the core to add their own
 • Users provide trace sinks and attach to the trace source
     • Simulator core provides a few examples for common cases
 • Multiple trace sources can connect to a trace sink




 Mathieu Lacage (INRIA)   Experimentation with ns-3     Trilogy’2009   82 / 95
The ns-3 tracing model
Decouple trace sources from trace sinks:




            Source                                                  Source




   Source                  Sink                Sink                          Source




            Source                                                  Source



   Unchanging               Configurable by user                    Unchanging




Benefit: Customizable trace sinks

  Mathieu Lacage (INRIA)                Experimentation with ns-3                     Trilogy’2009   83 / 95
Ns-3 trace sources
 • Various trace sources (e.g., packet receptions, state machine
    transitions) are plumbed through the system
 • Organized with the rest of the attribute system




 Mathieu Lacage (INRIA)   Experimentation with ns-3     Trilogy’2009   84 / 95
Multiple levels of tracing


 • High-level: use a helper to hook a predefined trace sink to a
    trace source and generate simple tracing output (ascii, pcap)
 • Mid-level: hook a special trace sink to an existing trace source to
    generate adhoc tracing
 • Low-level: add a new trace source and connect it to a special
    trace sink




 Mathieu Lacage (INRIA)   Experimentation with ns-3       Trilogy’2009   85 / 95
High-level tracing


   • Use predefined trace sinks in helpers
   • All helpers provide ascii and pcap trace sinks

CsmaHelper::EnablePcap ("filename", nodeid, deviceid);
std::ofstream os;
os.open ("filename.tr");
CsmaHelper::EnableAscii (os, nodeid, deviceid);




   Mathieu Lacage (INRIA)         Experimentation with ns-3   Trilogy’2009   86 / 95
Mid-level tracing

   • Provide a new trace sink
   • Use attribute/trace namespace to connect trace sink and source

void
DevTxTrace (std::string context,
         Ptr<const Packet> p, Mac48Address address)
{
  std::cout << " TX to=" << address << " p: " << *p << std::endl;
}
Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx",
            MakeCallback (&DevTxTrace));




   Mathieu Lacage (INRIA)           Experimentation with ns-3       Trilogy’2009   87 / 95
Pcap output
The trace sink:
static void PcapSnifferEvent (Ptr<PcapWriter> writer,
                  Ptr<const Packet> packet)
{
  writer->WritePacket (packet);
}
Prepare the pcap output:
oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
Ptr<PcapWriter> pcap = ::ns3::Create<PcapWriter> ();
pcap->Open (oss.str ());
pcap->WriteWifiHeader ();
Finally, connect the trace sink to the trace source:
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid;
oss << "/$ns3::WifiNetDevice/Phy/PromiscSniffer";
Config::ConnectWithoutContext (oss.str (),
          MakeBoundCallback (&PcapSnifferEvent, pcap));
   Mathieu Lacage (INRIA)          Experimentation with ns-3     Trilogy’2009   88 / 95
Outline

A coherent memory management scheme

Maximizing model reuse

Getting the right object

A uniform configuration system

Controlling trace output format

The underlying type metadata database



  Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   89 / 95
The ns-3 type system
  • The aggregation mechanism needs information about the type
     of objects at runtime
  • The attribute mechanism needs information about the attributes
     supported by a specific object
  • The tracing mechanism needs information about the trace
     sources supported by a specific object
All this information is stored in ns3::TypeId:
  • The parent type
  • The name of the type
  • The list of attributes (their name, their type, etc.)
  • The list of trace sources (their name, their type, etc.)


  Mathieu Lacage (INRIA)     Experimentation with ns-3         Trilogy’2009   90 / 95
The ns-3 type system
It is not very complicated to use:
    • Derive from the ns3::Object base class
    • Define a GetTypeId static method:

class Foo : public Object {
public:
 static TypeId GetTypeId (void);
};
  • Define the features of your object:

 static TypeId tid = TypeId ("ns3::Foo")
  .SetParent<Object> ()
  .AddAttribute ("Name", "Help", ...)
  .AddTraceSource ("Name", "Help", ...);
 return tid;
  • call NS_OBJECT_ENSURE_REGISTERED
  Mathieu Lacage (INRIA)     Experimentation with ns-3   Trilogy’2009   91 / 95
Summary


 • Memory management is uniform and simple




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   92 / 95
Summary


 • Memory management is uniform and simple
 • Dynamic aggregation makes models easier to reuse




 Mathieu Lacage (INRIA)   Experimentation with ns-3   Trilogy’2009   92 / 95
Summary


 • Memory management is uniform and simple
 • Dynamic aggregation makes models easier to reuse
 • Path strings allow access to every object in a simulation




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   92 / 95
Summary


 • Memory management is uniform and simple
 • Dynamic aggregation makes models easier to reuse
 • Path strings allow access to every object in a simulation
 • Attributes allow powerful and uniform configuration




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   92 / 95
Summary


 • Memory management is uniform and simple
 • Dynamic aggregation makes models easier to reuse
 • Path strings allow access to every object in a simulation
 • Attributes allow powerful and uniform configuration
 • Trace sources allow arbitrary output file formats




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   92 / 95
Summary


 • Memory management is uniform and simple
 • Dynamic aggregation makes models easier to reuse
 • Path strings allow access to every object in a simulation
 • Attributes allow powerful and uniform configuration
 • Trace sources allow arbitrary output file formats




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   92 / 95
Summary

 • Simulation is a key component of network research
     • Debuggability
     • Reproducibility
     • Parameter exploration
     • No dependency on existing hardware/software
 • ns-3 has a strong focus on realism:
     • Makes models closer to the real world: easier to validate
     • Allows direct code execution: no model validation
     • Allows robust emulation for large-scale and mixed experiments
 • ns-3 also cares about good software engineering:
     • Single-language architecture is more robust in the long term
     • Open source community ensures long lifetime to the project




 Mathieu Lacage (INRIA)   Experimentation with ns-3        Trilogy’2009   93 / 95
Resources

 • Web site: http://www.nsnam.org
 • Developer mailing list:
    http://mailman.isi.edu/mailman/listinfo/ns-developers
 • User mailing list: http://groups.google.com/group/ns-3-users
 • IRC: #ns-3 at irc.freenode.net
 • Tutorial: http://www.nsnam.org/docs/tutorial/tutorial.html
 • Code server: http://code.nsnam.org
 • Wiki: http://www.nsnam.org/wiki/index.php/Main_Page




 Mathieu Lacage (INRIA)      Experimentation with ns-3          Trilogy’2009   94 / 95
Acknowledgments


 • Many slides stolen from other’s presentations and tutorials
 • Many contributors to the ns-3 codebase (developers, testers)
 • Google summer of code students (2008,2009)




 Mathieu Lacage (INRIA)   Experimentation with ns-3      Trilogy’2009   95 / 95

Contenu connexe

Tendances

Cloud RAN and Evolution to 5G
Cloud RAN and Evolution to 5GCloud RAN and Evolution to 5G
Cloud RAN and Evolution to 5GSmall Cell Forum
 
Network time protocol
Network time protocolNetwork time protocol
Network time protocolMohd Amir
 
CCNA ppt Day 1
CCNA ppt Day 1CCNA ppt Day 1
CCNA ppt Day 1VISHNU N
 
Subentting, Supernetting and VLSM presentation
Subentting, Supernetting and VLSM presentationSubentting, Supernetting and VLSM presentation
Subentting, Supernetting and VLSM presentationZakaria Hossain
 
Network address translation
Network address translationNetwork address translation
Network address translationVarsha Honde
 
Network Address Translation (NAT)
Network Address Translation (NAT)Network Address Translation (NAT)
Network Address Translation (NAT)Joud Khattab
 
Introduction to OpenFlow
Introduction to OpenFlowIntroduction to OpenFlow
Introduction to OpenFlowJoel W. King
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11Shreejan Acharya
 
VLAN Trunking Protocol
VLAN Trunking ProtocolVLAN Trunking Protocol
VLAN Trunking ProtocolNetwax Lab
 
Deployment Models of Cloud Computing.pptx
Deployment Models of Cloud Computing.pptxDeployment Models of Cloud Computing.pptx
Deployment Models of Cloud Computing.pptxJaya Silwal
 
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) KHNOG
 

Tendances (20)

Cloud RAN and Evolution to 5G
Cloud RAN and Evolution to 5GCloud RAN and Evolution to 5G
Cloud RAN and Evolution to 5G
 
IP Multicasting
IP MulticastingIP Multicasting
IP Multicasting
 
Ns3
Ns3Ns3
Ns3
 
Network time protocol
Network time protocolNetwork time protocol
Network time protocol
 
CCNA ppt Day 1
CCNA ppt Day 1CCNA ppt Day 1
CCNA ppt Day 1
 
Subentting, Supernetting and VLSM presentation
Subentting, Supernetting and VLSM presentationSubentting, Supernetting and VLSM presentation
Subentting, Supernetting and VLSM presentation
 
MPLS Presentation
MPLS PresentationMPLS Presentation
MPLS Presentation
 
Network virtualization
Network virtualizationNetwork virtualization
Network virtualization
 
Network address translation
Network address translationNetwork address translation
Network address translation
 
Network Address Translation (NAT)
Network Address Translation (NAT)Network Address Translation (NAT)
Network Address Translation (NAT)
 
Introduction to OpenFlow
Introduction to OpenFlowIntroduction to OpenFlow
Introduction to OpenFlow
 
IGMP
IGMPIGMP
IGMP
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11
 
Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 
VLAN Trunking Protocol
VLAN Trunking ProtocolVLAN Trunking Protocol
VLAN Trunking Protocol
 
Deployment Models of Cloud Computing.pptx
Deployment Models of Cloud Computing.pptxDeployment Models of Cloud Computing.pptx
Deployment Models of Cloud Computing.pptx
 
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD)
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
6LoWPAN: An Open IoT Networking Protocol
6LoWPAN: An Open IoT Networking Protocol6LoWPAN: An Open IoT Networking Protocol
6LoWPAN: An Open IoT Networking Protocol
 

En vedette

1 session installation
1 session installation1 session installation
1 session installationRahul Hada
 
Fundamental of Shell Programming
Fundamental of Shell ProgrammingFundamental of Shell Programming
Fundamental of Shell ProgrammingRahul Hada
 
Socio-technical System
Socio-technical SystemSocio-technical System
Socio-technical SystemRahul Hada
 
ns-3: History and Future
ns-3: History and Futurens-3: History and Future
ns-3: History and Futuremathieu_lacage
 
Network Simulation NS3
Network Simulation NS3Network Simulation NS3
Network Simulation NS3baddi youssef
 
Evaluation of mininet WiFi integration via ns-3
Evaluation of mininet WiFi integration via ns-3Evaluation of mininet WiFi integration via ns-3
Evaluation of mininet WiFi integration via ns-3Farzaneh Pakzad
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using JavaRahul Hada
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorialcode453
 
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...chrisbailey000
 
IEEE NS2 & NS3 PROJECT TITLE 2015-16
IEEE NS2 & NS3  PROJECT TITLE 2015-16IEEE NS2 & NS3  PROJECT TITLE 2015-16
IEEE NS2 & NS3 PROJECT TITLE 2015-16Spiro Vellore
 
Script login form php
Script login form phpScript login form php
Script login form phpHanief Rpl
 
Final Year Project Report Example
Final Year Project Report ExampleFinal Year Project Report Example
Final Year Project Report ExampleMuhd Mu'izuddin
 
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]Source Code Halaman Web Radio Stremaing [RAMEN RADIO]
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]Rizki Ogawa
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with phpJoe Ferguson
 
Integrated Optical Wireless Network For Next Generation Wireless Systems
Integrated Optical Wireless Network For Next Generation Wireless SystemsIntegrated Optical Wireless Network For Next Generation Wireless Systems
Integrated Optical Wireless Network For Next Generation Wireless SystemsCSCJournals
 

En vedette (20)

1 session installation
1 session installation1 session installation
1 session installation
 
Fundamental of Shell Programming
Fundamental of Shell ProgrammingFundamental of Shell Programming
Fundamental of Shell Programming
 
Socio-technical System
Socio-technical SystemSocio-technical System
Socio-technical System
 
ns-3: History and Future
ns-3: History and Futurens-3: History and Future
ns-3: History and Future
 
Network Simulation NS3
Network Simulation NS3Network Simulation NS3
Network Simulation NS3
 
Ns2
Ns2Ns2
Ns2
 
Evaluation of mininet WiFi integration via ns-3
Evaluation of mininet WiFi integration via ns-3Evaluation of mininet WiFi integration via ns-3
Evaluation of mininet WiFi integration via ns-3
 
Inheritance
InheritanceInheritance
Inheritance
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using Java
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
 
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
 
Ph.D. Defense
Ph.D. DefensePh.D. Defense
Ph.D. Defense
 
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...
Measuring and Comparing the Reliability of the Structured Walkthrough Evaluat...
 
IEEE NS2 & NS3 PROJECT TITLE 2015-16
IEEE NS2 & NS3  PROJECT TITLE 2015-16IEEE NS2 & NS3  PROJECT TITLE 2015-16
IEEE NS2 & NS3 PROJECT TITLE 2015-16
 
Script login form php
Script login form phpScript login form php
Script login form php
 
Final Year Project Report Example
Final Year Project Report ExampleFinal Year Project Report Example
Final Year Project Report Example
 
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]Source Code Halaman Web Radio Stremaing [RAMEN RADIO]
Source Code Halaman Web Radio Stremaing [RAMEN RADIO]
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with php
 
Integrated Optical Wireless Network For Next Generation Wireless Systems
Integrated Optical Wireless Network For Next Generation Wireless SystemsIntegrated Optical Wireless Network For Next Generation Wireless Systems
Integrated Optical Wireless Network For Next Generation Wireless Systems
 
Making web forms using php
Making web forms using phpMaking web forms using php
Making web forms using php
 

Similaire à ns-3 Tutorial

Paper9250 implementation of an i pv6 stack for ns-3
Paper9250 implementation of an i pv6 stack for ns-3Paper9250 implementation of an i pv6 stack for ns-3
Paper9250 implementation of an i pv6 stack for ns-3Suhail Ahmed Chandio
 
Simulations on Computer Network An Improved Study in the Simulator Methodolog...
Simulations on Computer Network An Improved Study in the Simulator Methodolog...Simulations on Computer Network An Improved Study in the Simulator Methodolog...
Simulations on Computer Network An Improved Study in the Simulator Methodolog...YogeshIJTSRD
 
Netw200 final joshua_brown
Netw200 final joshua_brownNetw200 final joshua_brown
Netw200 final joshua_brownJoshuaBrown233
 
Ecet 375 Education Specialist-snaptutorial.com
Ecet 375 Education Specialist-snaptutorial.comEcet 375 Education Specialist-snaptutorial.com
Ecet 375 Education Specialist-snaptutorial.comrobertlesew62
 
Ecet 375 Education Redefined - snaptutorial.com
Ecet 375     Education Redefined - snaptutorial.comEcet 375     Education Redefined - snaptutorial.com
Ecet 375 Education Redefined - snaptutorial.comDavisMurphyC86
 
ECET 375 Effective Communication/tutorialrank.com
 ECET 375 Effective Communication/tutorialrank.com ECET 375 Effective Communication/tutorialrank.com
ECET 375 Effective Communication/tutorialrank.comjonhson203
 
NoC simulators presentation
NoC simulators presentationNoC simulators presentation
NoC simulators presentationHossam Hassan
 
ECET 375 Invent Yourself/newtonhelp.com
ECET 375 Invent Yourself/newtonhelp.comECET 375 Invent Yourself/newtonhelp.com
ECET 375 Invent Yourself/newtonhelp.comlechenau125
 
Performance comparision 1307.4129
Performance comparision 1307.4129Performance comparision 1307.4129
Performance comparision 1307.4129Pratik Joshi
 
How to hack cryptographic protocols with Formal Methods
How to hack cryptographic protocols with Formal MethodsHow to hack cryptographic protocols with Formal Methods
How to hack cryptographic protocols with Formal MethodsOfer Rivlin, CISSP
 
Verilog Ams Used In Top Down Methodology For Wireless Integrated Circuits
Verilog Ams Used In Top Down Methodology For Wireless Integrated CircuitsVerilog Ams Used In Top Down Methodology For Wireless Integrated Circuits
Verilog Ams Used In Top Down Methodology For Wireless Integrated CircuitsRégis SANTONJA
 
Network Analyzer and Report Generation Tool for NS-2 using TCL Script
Network Analyzer and Report Generation Tool for NS-2 using TCL ScriptNetwork Analyzer and Report Generation Tool for NS-2 using TCL Script
Network Analyzer and Report Generation Tool for NS-2 using TCL ScriptIRJET Journal
 
Grid is Dead ? Nimrod on the Cloud
Grid is Dead ? Nimrod on the CloudGrid is Dead ? Nimrod on the Cloud
Grid is Dead ? Nimrod on the CloudAdianto Wibisono
 
Spring sim 2010-riley
Spring sim 2010-rileySpring sim 2010-riley
Spring sim 2010-rileySopna Sumāto
 
ECET 375 Entire Course NEW
ECET 375 Entire Course NEWECET 375 Entire Course NEW
ECET 375 Entire Course NEWshyamuopuop
 
Legion - AI Runtime Platform
Legion -  AI Runtime PlatformLegion -  AI Runtime Platform
Legion - AI Runtime PlatformAlexey Kharlamov
 
ECET 375 Success Begins/Newtonhelp.com
ECET 375 Success Begins/Newtonhelp.comECET 375 Success Begins/Newtonhelp.com
ECET 375 Success Begins/Newtonhelp.comledlang1
 

Similaire à ns-3 Tutorial (20)

Dc project 1
Dc project 1Dc project 1
Dc project 1
 
Paper9250 implementation of an i pv6 stack for ns-3
Paper9250 implementation of an i pv6 stack for ns-3Paper9250 implementation of an i pv6 stack for ns-3
Paper9250 implementation of an i pv6 stack for ns-3
 
Simulations on Computer Network An Improved Study in the Simulator Methodolog...
Simulations on Computer Network An Improved Study in the Simulator Methodolog...Simulations on Computer Network An Improved Study in the Simulator Methodolog...
Simulations on Computer Network An Improved Study in the Simulator Methodolog...
 
Netw200 final joshua_brown
Netw200 final joshua_brownNetw200 final joshua_brown
Netw200 final joshua_brown
 
Ecet 375 Education Specialist-snaptutorial.com
Ecet 375 Education Specialist-snaptutorial.comEcet 375 Education Specialist-snaptutorial.com
Ecet 375 Education Specialist-snaptutorial.com
 
Ecet 375 Education Redefined - snaptutorial.com
Ecet 375     Education Redefined - snaptutorial.comEcet 375     Education Redefined - snaptutorial.com
Ecet 375 Education Redefined - snaptutorial.com
 
ECET 375 Effective Communication/tutorialrank.com
 ECET 375 Effective Communication/tutorialrank.com ECET 375 Effective Communication/tutorialrank.com
ECET 375 Effective Communication/tutorialrank.com
 
NoC simulators presentation
NoC simulators presentationNoC simulators presentation
NoC simulators presentation
 
ECET 375 Invent Yourself/newtonhelp.com
ECET 375 Invent Yourself/newtonhelp.comECET 375 Invent Yourself/newtonhelp.com
ECET 375 Invent Yourself/newtonhelp.com
 
Performance comparision 1307.4129
Performance comparision 1307.4129Performance comparision 1307.4129
Performance comparision 1307.4129
 
How to hack cryptographic protocols with Formal Methods
How to hack cryptographic protocols with Formal MethodsHow to hack cryptographic protocols with Formal Methods
How to hack cryptographic protocols with Formal Methods
 
Verilog Ams Used In Top Down Methodology For Wireless Integrated Circuits
Verilog Ams Used In Top Down Methodology For Wireless Integrated CircuitsVerilog Ams Used In Top Down Methodology For Wireless Integrated Circuits
Verilog Ams Used In Top Down Methodology For Wireless Integrated Circuits
 
Network Analyzer and Report Generation Tool for NS-2 using TCL Script
Network Analyzer and Report Generation Tool for NS-2 using TCL ScriptNetwork Analyzer and Report Generation Tool for NS-2 using TCL Script
Network Analyzer and Report Generation Tool for NS-2 using TCL Script
 
Grid is Dead ? Nimrod on the Cloud
Grid is Dead ? Nimrod on the CloudGrid is Dead ? Nimrod on the Cloud
Grid is Dead ? Nimrod on the Cloud
 
Spring sim 2010-riley
Spring sim 2010-rileySpring sim 2010-riley
Spring sim 2010-riley
 
Delay Tolerant Streaming Services, Thomas Plagemann, UiO
Delay Tolerant Streaming Services, Thomas Plagemann, UiODelay Tolerant Streaming Services, Thomas Plagemann, UiO
Delay Tolerant Streaming Services, Thomas Plagemann, UiO
 
ECET 375 Entire Course NEW
ECET 375 Entire Course NEWECET 375 Entire Course NEW
ECET 375 Entire Course NEW
 
Legion - AI Runtime Platform
Legion -  AI Runtime PlatformLegion -  AI Runtime Platform
Legion - AI Runtime Platform
 
ECET 375 Success Begins/Newtonhelp.com
ECET 375 Success Begins/Newtonhelp.comECET 375 Success Begins/Newtonhelp.com
ECET 375 Success Begins/Newtonhelp.com
 
An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4
 

Dernier

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Dernier (20)

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

ns-3 Tutorial

  • 1. Experimentation with ns-3 Mathieu Lacage mathieu.lacage@sophia.inria.fr INRIA Trilogy Summer School, 27th august 2009 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 1 / 95
  • 2. Goals of this tutorial • Understand the goals of the ns-3 project • Learn what has been done to achieve these goals • Identify future work directions Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 2 / 95
  • 3. Tutorial schedule 1 14h00-15h00: Introduction 2 15h00-16h00: The ns-3 architecture 3 16h00-17h00: The ns-3 object model Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 3 / 95
  • 4. Part I Introduction Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 4 / 95
  • 5. Outline Simulation considered harmful Why not reuse an existing simulator ? What is so special about ns-3 ? What we learned along the way Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 5 / 95
  • 6. Outline Simulation considered harmful Why not reuse an existing simulator ? What is so special about ns-3 ? What we learned along the way Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 6 / 95
  • 7. Recent history (1995-2005) • ns-2 became the main choice for research usage. Search of ACM Digital Library papers citing simulation, 2001-04: ns-2 OPNET QualNet/Glomosim ≥ layer 4 123 (75%) 30 (18%) 11 (7%) = layer 3 186 (70%) 48 (18%) 31 (12%) ≤ layer 2 114 (43%) 96 (36%) 55 (21%) • Funding for ns-2 development dropped in the early 2000’s Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 7 / 95
  • 8. What is wrong about ns-2 ? • Split object model (OTcl and C++) and use of Tcl: • Doesn’t scale well • Makes it difficult for students • Large amount of abstraction at the network layer and below leads to big discontinuities when transitioning from simulation to experiment • Accretion of unmaintained and incompatible models • Lack of support for creating methodologically sound simulations • Lack of, and outdated, documentation • In ns-2, validation really means regression: no documented validation of the models, outside of TCP Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 8 / 95
  • 9. Overheard on e2e-interest mailing list September 2005 archives of the e2e-interest mailing list: • “...Tragedy of the Commons...” • “...around 50% of the papers appeared to be... bogus...” • “Who has ever validated NS2 code?” • “To be honest, I’m still not sure whether I will use a simulation in a paper.” • “...I will have a hard time accepting or advocating the use of NS-2 or any other simulation tool” Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 9 / 95
  • 10. A recurring misconception • Using ns-2 is actively harmful Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 10 / 95
  • 11. A recurring misconception • Using ns-2 is actively harmful • Simulation is ns-2 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 10 / 95
  • 12. A recurring misconception • Using ns-2 is actively harmful • Simulation is ns-2 Thus, simulation is actively harmful Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 10 / 95
  • 13. Back in 2000’s, the rise of testbeds • Hardware costs going down • OS virtualization going up • Development of control and management software Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 11 / 95
  • 14. Back in 2000’s, the rise of testbeds • Hardware costs going down • OS virtualization going up • Development of control and management software Result: • Emulab: http://www.emulab.net • ORBIT: http://www.orbit-lab.org • Planetlab: http://planet-lab.org • ModelNet: https://modelnet.sysnet.ucsd.edu • ... Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 11 / 95
  • 15. Why do we need simulation at all ? • Simulation models are not validated • Simulation model implementations not verified • No need for validation and verification in testbeds Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 12 / 95
  • 16. Why do we need simulation at all ? • Simulation models are not validated • Simulation model implementations not verified • No need for validation and verification in testbeds However, there are lots of good things about simulation: • Reproducibility • Easier to setup, deploy, instrument • Investigate non-existent systems • Scalability Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 12 / 95
  • 17. But, really, we need both ! We want to get the best from both worlds: • Simulators: reproducibility, debuggability, ease of setup • Testbeds: realism We want an integrated experimentation environment: • Use each tool separately: • Parameter space exploration with simulations • More realism with testbeds • Use both tools together: • Simulator for elements of the topology to scale • Testbed for other elements to get realism Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 13 / 95
  • 18. Summary We need simulations: • Easier to use, debug, reproduce than testbeds • Not constrained by existing hardware/software We need a special simulator: • Improves model validation • Improves model implementation verification • Allow users to move back and forth between simulation and testbeds Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 14 / 95
  • 19. Outline Simulation considered harmful Why not reuse an existing simulator ? What is so special about ns-3 ? What we learned along the way Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 15 / 95
  • 20. Starting from ns-2 The biggest reason to start from ns-2 is: • A large existing userbase • A large set of existing models But, we need to address many issues: • Most existing models lack validation, verification, maintenance • Bi-language system (C++/tcl) makes debugging complex: removing it would mean dropping backward compatibility • Core packet data-structure: • Inappropriate for emulation • Fragmentation unsupported Re-engineering ns-2 to fix all these issues would make it a new different simulator: we would lose our existing userbase. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 16 / 95
  • 21. Proprietary simulators There are many of them (google for network simulator): • Opnet • QualNet • Shunra • etc. But: • Terms of use • Very costly for industrial partners or publicly-funded research which cannot get education licenses. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 17 / 95
  • 22. Omnetpp • It was not clear in 2005 it would still be alive in 2009 • Major worries over the bi-language architecture: learning curve, debugging, etc. • Software structure did not seem to lend itself to the realism we sought. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 18 / 95
  • 23. Not Invented Here Yes, we did fall prey to that syndrome too: we thought we could do it better than the others Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 19 / 95
  • 24. Outline Simulation considered harmful Why not reuse an existing simulator ? What is so special about ns-3 ? What we learned along the way Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 20 / 95
  • 25. Good debuggability C++-only simulations: no need to debug two languages at the same time • ns-3 is a library written in C++ • Simulation programs are C++ executables • Bindings in Python for python simulations Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 21 / 95
  • 26. Long term project lifetime A open source community: • An open license (GPLv2) • All design and implementation discussions in the open on mailing-lists (even flame wars) • Everyone can (should) become a maintainer This is critical to allow: • The project to scale to many models • The project to last beyond initial seed funding • Model/implementations reviews in the open: Given enough eyeballs, all bugs are shallow Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 22 / 95
  • 27. Low cost of model validation Make models close to the real world: • Models are less abstract: easier to validate • Makes it easy to perform direct execution of real code • Emulation is native and robust against changes in models How ? • Real IP addresses • Multiple interfaces per node • Bsd-like sockets • Packets contain real network bytes Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 23 / 95
  • 28. A usecase: NSC Architecture liblinux2.6.14.so libfreebsd5.3.so NSC TCP NSC TCP Socket API NSC TCP model model Network Network model send packet Stack StackTCP Cradle (shared Virtualised Cradle (sharedlib) lib) Virtualised Virtualised Resources Resources IP Resources Simulation API Network simulator Network Stack (ns-2) connect, send, Cradle (shared lib) packet received, timer, read © THE UNIVERSITY OF WAIKATO • TE WHARE WANANGA O WAIKATO 5 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 24 / 95
  • 29. NSC implementation • Globalizer: per-process kernel source code and add indirection to all global variable declarations and accesses • Glue: per-kernel (and per-kernel-version) glue to provide kernel APIs for kernel code: • kmalloc: memory allocation • NetDevice integration • Socket integration • Provides glue for: • linux 2.6.18, 2.6.26, 2.6.28 • FreeBSD 5 • lwip 1.3 • OpenBSD 3 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 25 / 95
  • 30. NSC accuracy Accuracy ●Have shown NSC to be very accurate – able to produce packet traces that are almost identical to traces measured from a test network © THE UNIVERSITY OF WAIKATO • TE WHARE WANANGA O WAIKATO 6 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 26 / 95
  • 31. Summary ns-3 has a strong focus on realism: • Makes models closer to the real world: easier to validate • Allows direct code execution: no model validation • Allows robust emulation for large-scale and mixed experiments ns-3 also cares about good software engineering: • Single-language architecture is more robust in the long term • Open source community ensures long lifetime to the project Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 27 / 95
  • 32. Outline Simulation considered harmful Why not reuse an existing simulator ? What is so special about ns-3 ? What we learned along the way Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 28 / 95
  • 33. Things You Should Never Do It’s an old axiom of software engineering: Don’t rewrite from scratch, ever. We did not really start from scratch: • Stole code and concepts from GTNetS (applications) • Stole code and concepts from yans (wifi) • Stole code and concepts from ns-2 (olsr, error models) Even then, it took us 2 years to get to a useful state Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 29 / 95
  • 34. Building an open source community is hard It’s a lot of work to attract contributors and keep them: they want to have fun, they want to have impact on the project: • Never flame people on mailing-lists: • Always answer questions kindly, point out manuals and FAQ • Don’t answer provocative statements • English is not the native language of most users • We need to do the boring work (release management, bug tracking, server maintenance) • No discussion behind closed doors: increases communication cost • It’s a meritocracy: those who contribute the most should have power to decide for the project Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 30 / 95
  • 35. Need for integrated statistical tools Initially, we thought we could: • Allow users to easily instrument the system • Delegate analysis to third-party tools such as R It does not work that way though: • Lack of methodology documentation • Fancy statistical tools are too complex for most users Future work: integrate tools to automatically measure and improve confidence intervals on simulation output Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 31 / 95
  • 36. Need for a high-level experimentation environment ns-3 provides low-level functionality: • Tap devices • Realtime simulation core But we want to allow easy switching and mixing of simulation and testbeds. We need higher-level abstractions for: • Experiment description (topology, application traffic) • Experiment configuration • Tracing configuration • Deployment automation Work towards this is underway with NEPI (ROADS’09: NEPI: Using Independent Simulators, Emulators, and Testbeds for Easy Experimentation) Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 32 / 95
  • 37. Need for more direct code execution I Integrate normal POSIX network applications in the simulator: • No source code modifications • Easy to debug (great network application development platform !) Needs: • Globalization: global variables must be virtualized for each instance of the application running in the simulator • Filesystem virtualization: each application needs a separate filesystem (to get different configuration and log files for example) • Socket library: need a complete implementation of sockets in the simulator, including all the crazy ioctls Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 33 / 95
  • 38. Need for more direct code execution II Status: • Running demonstrations with ping, traceroute • Simple socket applications can run: a couple of threads, select, tcp server/client • Larger applications using fancy socket ioctls don’t work very well yet Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 34 / 95
  • 39. Part II The ns-3 architecture Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 35 / 95
  • 40. Outline Introduction Fundamental network model structure Topology construction Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 36 / 95
  • 41. Outline Introduction Fundamental network model structure Topology construction Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 37 / 95
  • 42. Environment setup Install all needed tools: Ubuntu sudo apt-get install build-essential g++ python mercurial Windows • cygwin • python • mercurial Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 38 / 95
  • 43. Getting ns-3 Availability (linux, osx, cygwin, mingw): • Released tarballs: http://www.nsnam.org/releases • Development version: http://code.nsnam.org/ns-3-dev The development version is usually stable: a lot of people use it for daily work: hg clone http://code.nsnam.org/ns-3-dev Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 39 / 95
  • 44. Running ns-3 Use waf to build it (similar to make): ./waf ./waf shell ./build/debug/examples/csma-broadcast Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 40 / 95
  • 45. Exploring the source code Node NetDevice High-level wrappers Address types No smart pointers Queues Aimed at scripting Socket Ipv4 helper routing internet-stack devices MobilityModels (static, random walk, node mobility etc.) Events Scheduler Time arithmetic simulator common core Packets Packet tags Packet headers Smart pointers Callbacks Pcap file writing Dynamic type system Tracing Attributes Logging Random Variables Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 41 / 95
  • 46. A typical simulation • Create a bunch of C++ objects • Configure and interconnect them • Each object creates events with Simulator::Schedule • Call Simulator::Run to execute all events A (fictional) simulation Node *a = new Node (); Node *b = new Node (); Link *link = new Link (a,b); Simulator::Schedule (Seconds (0.5), // in 0.5s from now &Node::StartCbr, a, // call StartCbr on ’a’ "100bytes", "0.2ms", b); // pass these arguments Simulator::Run (); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 42 / 95
  • 47. Outline Introduction Fundamental network model structure Topology construction Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 43 / 95
  • 48. The basic model Application Application Application Application Socket-like API Protocol Protocol Stack Stack NetDevice NetDevice NetDevice NetDevice Node Node Channel Channel Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 44 / 95
  • 49. The fundamental objects • Node: the motherboard of a computer with RAM, CPU, and, IO interfaces • Application: a packet generator and consumer which can run on a Node and talk to a set of network stacks • Socket: the interface between an application and a network stack • NetDevice: a network card which can be plugged in an IO interface of a Node • Channel: a physical connector between a set of NetDevice objects Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 45 / 95
  • 50. Important remark NetDevices are strongly bound to Channels of a matching type: WifiNetDevice WifiNetDevice CsmaNetDevice WifiNetDevice WifiChannel CsmaChannel WifiNetDevice CsmaNetDevice CsmaNetDevice Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 46 / 95
  • 51. Existing models • Network stacks: arp, ipv4, icmpv4, udp, tcp (ipv6 under review) • Devices: wifi, csma, point-to-point, bridge • Error models and queues • Applications: udp echo, on/off, sink • Mobility models: random walk, etc. • Routing: olsr, static global Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 47 / 95
  • 52. For example, the wifi models • New model, written from 802.11 specification • Accurate model of the MAC • DCF, beacon generation, probing, association • A set of rate control algorithms (ARF, ideal, AARF, Minstrel, etc.) • Not-so-slow models of the 802.11a PHY Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 48 / 95
  • 53. Development of wifi models New contributions from many developers: • University of Florence: 802.11n, EDCA, frame aggregation, block ack • Russian Academy of Sciences: 802.11s, HWMP routing protocol • Boeing: 802.11b channel models, validation • Deutsche Telekom Laboratories: PHY modelization, validation • Karlsruhe Institute of Technology: PHY modelization (Rayleigh, Nakagami) Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 49 / 95
  • 54. Summary • Core models are based on well-known abstractions: sockets, devices, etc. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 50 / 95
  • 55. Summary • Core models are based on well-known abstractions: sockets, devices, etc. • An active community of contributors Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 50 / 95
  • 56. Outline Introduction Fundamental network model structure Topology construction Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 51 / 95
  • 57. The Helper/Container API We want to: • Make it easy to build topologies with repeating patterns • Make the topology description more high-level (and less verbose) to make it easier to read and understand The idea is simple: • Sets of objects are stored in Containers • One operation is encoded in a Helper object and applies on a Container Helper operations: • Are not generic: different helpers provide different operations • Do not try to allow code reuse: just try to minimize the amount of code written • Provide syntactical sugar: make the code easier to read Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 52 / 95
  • 58. Typical containers and helpers Example containers: • NodeContainer • NetDeviceContainer • Ipv4AddressContainer Example helper classes: • InternetStackHelper • WifiHelper • MobilityHelper • OlsrHelper • etc. Each model provides a helper class Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 53 / 95
  • 59. Create a couple of nodes NodeContainer csmaNodes; Create empty node container csmaNodes.Create (2); Create two nodes NodeContainer wifiNodes; Create empty node container wifiNodes.Add (csmaNodes.Get (1)); Add existing node to it wifiNodes.Create (3); And then create some more nodes Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 54 / 95
  • 60. Then, the csma network NetDeviceContainer csmaDevices; Create empty device container CsmaHelper csma; Create csma helper csma.SetChannelAttribute ("DataRate", Set data rate StringValue ("5Mbps")); csma.SetChannelAttribute ("Delay", Set delay StringValue ("2ms")); csmaDevices = csma.Install (csmaNodes); Create csma devices and channel Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 55 / 95
  • 61. And a couple of wifi interfaces Finally, setup the wifi channel: YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); And create adhoc devices on this channel: NetDeviceContainer wifiDevices; WifiHelper wifi = WifiHelper::Default (); wifiDevices = wifi.Install (wifiPhy, wifiNodes); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 56 / 95
  • 62. Comparison with low-level version Fire up editor for tutorial-helper.cc and tutorial-lowlevel.cc Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 57 / 95
  • 63. Summary • It’s always possible to create objects by hand, interconnect and configure them Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 58 / 95
  • 64. Summary • It’s always possible to create objects by hand, interconnect and configure them • But it can be easier to reuse the for loops encapsulated in Helper classes Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 58 / 95
  • 65. Summary • It’s always possible to create objects by hand, interconnect and configure them • But it can be easier to reuse the for loops encapsulated in Helper classes • Helper classes make scripts less cluttered and easier to read and modify Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 58 / 95
  • 66. Part III The ns-3 object model Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 59 / 95
  • 67. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 60 / 95
  • 68. It’s easy to build a network simulator It’s just a matter of: • Provide an event scheduler • Implement a couple of models to create and consume events But it’s much harder to build a network simulator which: • Allows models to be reusable independently • Ensures API coherence between models • Automates common tasks (tracing, configuration) Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 61 / 95
  • 69. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 62 / 95
  • 70. Why are objects so complicated to create ? We do: Ptr<Node> node0 = CreateObject<Node> (); Why not: Node *node0 = new Node (); Or: Node node0 = Node (); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 63 / 95
  • 71. Templates: the Nasty Brackets • Contain a list of type arguments • Parameterize a class or function from input type • In ns-3, used for: • Standard Template Library • Syntactical sugar for low-level facilities • Saves a lot of typing • No portability/compiler support problem • Sometimes painful to decipher error messages. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 64 / 95
  • 72. Memory Management It is hard in C++: • No garbage collector • Easy to forget to delete an object • Pointer cycles • Ensure coherency and uniformity So, we use: • Reference counting: track number of pointers to an object (Ref+Unref) • Smart pointers: Ptr<>, Create<> and, CreateObject<> • Sometimes, explicit Dispose to break cycles Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 65 / 95
  • 73. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 66 / 95
  • 74. Where is my MobileNode ? Ptr<Node> node = CreateObject<Node> (); Ptr<MobilityModel> mobility = CreateObject<...> (); node->AggregateObject (mobility); • Some nodes need an IPv4 stack, a position, an energy model. • Some nodes need just two out of three. • Others need other unknown features. • The obvious solution: add everything to the Node base class: • The class will grow uncontrollably over time • Everyone will need to patch the class • Slowly, every piece of code will depend on every other piece of code (cannot reuse anything without dragging in everything) • A maintenance nightmare... • A better solution: • Separate functionality belongs to separate classes • Objects can be aggregated at runtime to obtain extra functionality Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 67 / 95
  • 75. Object aggregation Node MobilityModel • A circular singly linked-list • AggregateObject is a constant-time operation • GetObject is a O(n) operation • Aggregate contains only one object Node MobilityModel of each type Ipv4 Ipv4 Node MobilityModel Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 68 / 95
  • 76. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 69 / 95
  • 77. The traditional approach In C++, if you want to call methods on an object, you need a pointer to this object. To get a pointer, you need to: • keep local copies of pointers to every object you create • walk pointer chains to get access to objects created within other objects For example, in ns-3, you could do this: Ptr<NetDevice> dev = NodeList::Get (5)->GetDevice (0); Ptr<WifiNetDevice> wifi = dev->GetObject<WifiNetDevice> (); Ptr<WifiPhy> phy = dev->GetPhy (); phy->SetAttribute ("TxGain", ...); phy->ConnectTraceSource (...); It’s not fun to do... Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 70 / 95
  • 78. Use a namespace string ! Set an attribute: Config::SetAttribute ("/NodeList/5/DeviceList/0/Phy/TxGain", StringValue ("10")); Connect a trace sink to a trace source: Config::Connect ("/NodeList/5/DeviceList/0/Phy/TxGain", MakeCallback (&LocalSink)); Just get a pointer: Config::MatchContainer match; match = Config::LookupMatches ("/NodeList/5/DeviceList/0/Phy/"); Ptr<WifiPhy> phy = match.Get (0)->GetObject<WifiPhy> (); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 71 / 95
  • 79. The object namespace I Object namespace strings represent a path through a set of object pointers: NodeListPriv Node /NodeList/[0-n] /DeviceList/[0-n] PointToPointNetDevice CsmaNetDevice /DataRate /InterframeGap /SendEnable /FrameSize For example, /NodeList/x/DeviceList/y/InterframeGap represents the InterframeGap attribute of the device number y in node number x. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 72 / 95
  • 80. The object namespace II Navigating the attributes using paths: • /NodeList/[3-5]|8|[0-1]: matches nodes index 0, 1, 3, 4, 5, 8 • /NodeList/*: matches all nodes • /NodeList/3/$ns3::Ipv4: matches object of type ns3::Ipv4 aggregated to node number 3 • /NodeList/3/DeviceList/*/$ns3::CsmaNetDevice: matches all devices of type ns3::CsmaNetDevice within node number 3 • /NodeList/3/DeviceList/0/RemoteStationManager: matches the object pointed to by attribute RemoteStationManager in device 0 in node 3. Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 73 / 95
  • 81. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 74 / 95
  • 82. Traditionally, in C++ • Export attributes as part of a class’s public API • Use static variables for defaults For example: class MyModel { public: MyModel () : m_foo (m_defaultFoo) {} void SetFoo (int foo) {m_foo = foo;} int GetFoo (void) {return m_foo} static void SetDefaultFoo (int foo) {m_defaultFoo = foo;} static int GetDefaultFoo (void) {return m_defaultFoo;} private: int m_foo; static int m_defaultFoo = 10; }; Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 75 / 95
  • 83. In ns-3, done automatically I • Set a default value: Config::SetDefaultValue ("ns3::WifiPhy::TxGain", StringValue ("10")); • Set a value on a specific object: phy->SetAttribute ("TxGain", StringValue ("10")); • Set a value from the command-line –ns3::WifiPhy::TxGain=10: CommandLine cmd; cmd.Parse (argc, argv); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 76 / 95
  • 84. In ns-3, done automatically II • Load, Change, and Save all values from and to a raw text or xml file with or without a GUI: GtkConfigStore config; config.ConfigureDefaults (); ... config.ConfigureAttributes (); • Set a value with an environment variable NS_ATTRIBUTE_DEFAULT=ns3::WifiPhy::TxGain=10 Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 77 / 95
  • 85. Graphical navigation Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 78 / 95
  • 86. Doxygen documentation Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 79 / 95
  • 87. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 80 / 95
  • 88. Tracing requirements • Tracing is a structured form of simulation output • Example (from ns-2): + 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610 - 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610 r 1.84471 2 1 cbr 210 ------- 1 3.0 1.0 195 600 r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602 + 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611 • Problem: tracing needs vary widely • Would like to change tracing output format without editing the core • Would like to support multiple output formats Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 81 / 95
  • 89. Tracing overview • Simulator provides a set of pre-configured trace sources • Users may edit the core to add their own • Users provide trace sinks and attach to the trace source • Simulator core provides a few examples for common cases • Multiple trace sources can connect to a trace sink Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 82 / 95
  • 90. The ns-3 tracing model Decouple trace sources from trace sinks: Source Source Source Sink Sink Source Source Source Unchanging Configurable by user Unchanging Benefit: Customizable trace sinks Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 83 / 95
  • 91. Ns-3 trace sources • Various trace sources (e.g., packet receptions, state machine transitions) are plumbed through the system • Organized with the rest of the attribute system Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 84 / 95
  • 92. Multiple levels of tracing • High-level: use a helper to hook a predefined trace sink to a trace source and generate simple tracing output (ascii, pcap) • Mid-level: hook a special trace sink to an existing trace source to generate adhoc tracing • Low-level: add a new trace source and connect it to a special trace sink Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 85 / 95
  • 93. High-level tracing • Use predefined trace sinks in helpers • All helpers provide ascii and pcap trace sinks CsmaHelper::EnablePcap ("filename", nodeid, deviceid); std::ofstream os; os.open ("filename.tr"); CsmaHelper::EnableAscii (os, nodeid, deviceid); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 86 / 95
  • 94. Mid-level tracing • Provide a new trace sink • Use attribute/trace namespace to connect trace sink and source void DevTxTrace (std::string context, Ptr<const Packet> p, Mac48Address address) { std::cout << " TX to=" << address << " p: " << *p << std::endl; } Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx", MakeCallback (&DevTxTrace)); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 87 / 95
  • 95. Pcap output The trace sink: static void PcapSnifferEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet) { writer->WritePacket (packet); } Prepare the pcap output: oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; Ptr<PcapWriter> pcap = ::ns3::Create<PcapWriter> (); pcap->Open (oss.str ()); pcap->WriteWifiHeader (); Finally, connect the trace sink to the trace source: oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid; oss << "/$ns3::WifiNetDevice/Phy/PromiscSniffer"; Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapSnifferEvent, pcap)); Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 88 / 95
  • 96. Outline A coherent memory management scheme Maximizing model reuse Getting the right object A uniform configuration system Controlling trace output format The underlying type metadata database Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 89 / 95
  • 97. The ns-3 type system • The aggregation mechanism needs information about the type of objects at runtime • The attribute mechanism needs information about the attributes supported by a specific object • The tracing mechanism needs information about the trace sources supported by a specific object All this information is stored in ns3::TypeId: • The parent type • The name of the type • The list of attributes (their name, their type, etc.) • The list of trace sources (their name, their type, etc.) Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 90 / 95
  • 98. The ns-3 type system It is not very complicated to use: • Derive from the ns3::Object base class • Define a GetTypeId static method: class Foo : public Object { public: static TypeId GetTypeId (void); }; • Define the features of your object: static TypeId tid = TypeId ("ns3::Foo") .SetParent<Object> () .AddAttribute ("Name", "Help", ...) .AddTraceSource ("Name", "Help", ...); return tid; • call NS_OBJECT_ENSURE_REGISTERED Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 91 / 95
  • 99. Summary • Memory management is uniform and simple Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 100. Summary • Memory management is uniform and simple • Dynamic aggregation makes models easier to reuse Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 101. Summary • Memory management is uniform and simple • Dynamic aggregation makes models easier to reuse • Path strings allow access to every object in a simulation Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 102. Summary • Memory management is uniform and simple • Dynamic aggregation makes models easier to reuse • Path strings allow access to every object in a simulation • Attributes allow powerful and uniform configuration Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 103. Summary • Memory management is uniform and simple • Dynamic aggregation makes models easier to reuse • Path strings allow access to every object in a simulation • Attributes allow powerful and uniform configuration • Trace sources allow arbitrary output file formats Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 104. Summary • Memory management is uniform and simple • Dynamic aggregation makes models easier to reuse • Path strings allow access to every object in a simulation • Attributes allow powerful and uniform configuration • Trace sources allow arbitrary output file formats Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 92 / 95
  • 105. Summary • Simulation is a key component of network research • Debuggability • Reproducibility • Parameter exploration • No dependency on existing hardware/software • ns-3 has a strong focus on realism: • Makes models closer to the real world: easier to validate • Allows direct code execution: no model validation • Allows robust emulation for large-scale and mixed experiments • ns-3 also cares about good software engineering: • Single-language architecture is more robust in the long term • Open source community ensures long lifetime to the project Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 93 / 95
  • 106. Resources • Web site: http://www.nsnam.org • Developer mailing list: http://mailman.isi.edu/mailman/listinfo/ns-developers • User mailing list: http://groups.google.com/group/ns-3-users • IRC: #ns-3 at irc.freenode.net • Tutorial: http://www.nsnam.org/docs/tutorial/tutorial.html • Code server: http://code.nsnam.org • Wiki: http://www.nsnam.org/wiki/index.php/Main_Page Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 94 / 95
  • 107. Acknowledgments • Many slides stolen from other’s presentations and tutorials • Many contributors to the ns-3 codebase (developers, testers) • Google summer of code students (2008,2009) Mathieu Lacage (INRIA) Experimentation with ns-3 Trilogy’2009 95 / 95