doc/tutorial/source/conceptual-overview.rst
author Peter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 14 Aug 2013 16:52:06 -0700
changeset 10171 0b3ce943b7c8
parent 9957 1a4d84a85bad
child 10950 9a28fac0260b
permissions -rw-r--r--
bug 954: Changing the simulation time resolution does not work well with attributes v.3 Responding to code review comments https://codereview.appspot.com/6821106/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
.. include:: replace.txt
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
     2
.. highlight:: cpp
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
Conceptual Overview
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
-------------------
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
The first thing we need to do before actually starting to look at or write
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
|ns3| code is to explain a few core concepts and abstractions in the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
system.  Much of this may appear transparently obvious to some, but we
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
recommend taking the time to read through this section just to ensure you
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
are starting on a firm foundation.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
Key Abstractions
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
****************
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
In this section, we'll review some terms that are commonly used in
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
networking, but have a specific meaning in |ns3|.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
Node
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
In Internet jargon, a computing device that connects to a network is called
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
a *host* or sometimes an *end system*.  Because |ns3| is a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
*network* simulator, not specifically an *Internet* simulator, we 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
intentionally do not use the term host since it is closely associated with
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
the Internet and its protocols.  Instead, we use a more generic term also
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
used by other simulators that originates in Graph Theory --- the *node*.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
In |ns3| the basic computing device abstraction is called the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
node.  This abstraction is represented in C++ by the class ``Node``.  The 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
``Node`` class provides methods for managing the representations of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
computing devices in simulations.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
You should think of a ``Node`` as a computer to which you will add 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
functionality.  One adds things like applications, protocol stacks and
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
peripheral cards with their associated drivers to enable the computer to do
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
useful work.  We use the same basic model in |ns3|.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
Application
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
+++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
Typically, computer software is divided into two broad classes.  *System
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
Software* organizes various computer resources such as memory, processor
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
cycles, disk, network, etc., according to some computing model.  System
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
software usually does not use those resources to complete tasks that directly
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
benefit a user.  A user would typically run an *application* that acquires
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
and uses the resources controlled by the system software to accomplish some
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
goal.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
Often, the line of separation between system and application software is made
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
at the privilege level change that happens in operating system traps.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
In |ns3| there is no real concept of operating system and especially
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
no concept of privilege levels or system calls.  We do, however, have the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
idea of an application.  Just as software applications run on computers to
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
perform tasks in the "real world," |ns3| applications run on
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
|ns3| ``Nodes`` to drive simulations in the simulated world.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
In |ns3| the basic abstraction for a user program that generates some
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
activity to be simulated is the application.  This abstraction is represented 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
in C++ by the class ``Application``.  The ``Application`` class provides 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
methods for managing the representations of our version of user-level 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
applications in simulations.  Developers are expected to specialize the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
``Application`` class in the object-oriented programming sense to create new
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
applications.  In this tutorial, we will use specializations of class 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
``Application`` called ``UdpEchoClientApplication`` and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
``UdpEchoServerApplication``.  As you might expect, these applications 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
compose a client/server application set used to generate and echo simulated 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
network packets 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
Channel
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
+++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
In the real world, one can connect a computer to a network.  Often the media
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
over which data flows in these networks are called *channels*.  When
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
you connect your Ethernet cable to the plug in the wall, you are connecting 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
your computer to an Ethernet communication channel.  In the simulated world
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
of |ns3|, one connects a ``Node`` to an object representing a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
communication channel.  Here the basic communication subnetwork abstraction 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
is called the channel and is represented in C++ by the class ``Channel``.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
The ``Channel`` class provides methods for managing communication 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
subnetwork objects and connecting nodes to them.  ``Channels`` may also be
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
specialized by developers in the object oriented programming sense.  A 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
``Channel`` specialization may model something as simple as a wire.  The 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
specialized  ``Channel`` can also model things as complicated as a large 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
Ethernet switch, or three-dimensional space full of obstructions in the case 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
of wireless networks.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
We will use specialized versions of the ``Channel`` called
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
``CsmaChannel``, ``PointToPointChannel`` and ``WifiChannel`` in this
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
tutorial.  The ``CsmaChannel``, for example, models a version of a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    90
communication subnetwork that implements a *carrier sense multiple 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    91
access* communication medium.  This gives us Ethernet-like functionality.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
Net Device
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
It used to be the case that if you wanted to connect a computers to a network,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
you had to buy a specific kind of network cable and a hardware device called
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
(in PC terminology) a *peripheral card* that needed to be installed in
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
your computer.  If the peripheral card implemented some networking function,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
they were called Network Interface Cards, or *NICs*.  Today most 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
computers come with the network interface hardware built in and users don't 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
see these building blocks.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
A NIC will not work without a software driver to control the hardware.  In 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
Unix (or Linux), a piece of peripheral hardware is classified as a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
*device*.  Devices are controlled using *device drivers*, and network
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
devices (NICs) are controlled using *network device drivers*
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
collectively known as *net devices*.  In Unix and Linux you refer
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
to these net devices by names such as *eth0*.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
In |ns3| the *net device* abstraction covers both the software 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
driver and the simulated hardware.  A net device is "installed" in a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
``Node`` in order to enable the ``Node`` to communicate with other 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
``Nodes`` in the simulation via ``Channels``.  Just as in a real
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
computer, a ``Node`` may be connected to more than one ``Channel`` via
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
multiple ``NetDevices``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
The net device abstraction is represented in C++ by the class ``NetDevice``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
The ``NetDevice`` class provides methods for managing connections to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
``Node`` and ``Channel`` objects; and may be specialized by developers
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
in the object-oriented programming sense.  We will use the several specialized
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
versions of the ``NetDevice`` called ``CsmaNetDevice``,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
``PointToPointNetDevice``, and ``WifiNetDevice`` in this tutorial.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
Just as an Ethernet NIC is designed to work with an Ethernet network, the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
``CsmaNetDevice`` is designed to work with a ``CsmaChannel``; the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
``PointToPointNetDevice`` is designed to work with a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
``PointToPointChannel`` and a ``WifiNetNevice`` is designed to work with
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
a ``WifiChannel``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
Topology Helpers
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
++++++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
In a real network, you will find host computers with added (or built-in)
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
NICs.  In |ns3| we would say that you will find ``Nodes`` with 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
attached ``NetDevices``.  In a large simulated network you will need to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
arrange many connections between ``Nodes``, ``NetDevices`` and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
``Channels``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   137
Since connecting ``NetDevices`` to ``Nodes``, ``NetDevices``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
to ``Channels``, assigning IP addresses,  etc., are such common tasks
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
in |ns3|, we provide what we call *topology helpers* to make 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
this as easy as possible.  For example, it may take many distinct 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
|ns3| core operations to create a NetDevice, add a MAC address, 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
install that net device on a ``Node``, configure the node's protocol stack,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
and then connect the ``NetDevice`` to a ``Channel``.  Even more
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
operations would be required to connect multiple devices onto multipoint 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
channels and then to connect individual networks together into internetworks.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
We provide topology helper objects that combine those many distinct operations
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
into an easy to use model for your convenience.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
A First ns-3 Script
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
*******************
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
If you downloaded the system as was suggested above, you will have a release
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
of |ns3| in a directory called ``repos`` under your home 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
directory.  Change into that release directory, and you should find a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
directory structure something like the following:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   156
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
7275
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   158
  AUTHORS       examples       scratch        utils      waf.bat*
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   159
  bindings      LICENSE        src            utils.py   waf-tools
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   160
  build         ns3            test.py*       utils.pyc  wscript
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   161
  CHANGES.html  README         testpy-output  VERSION    wutils.py
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   162
  doc           RELEASE_NOTES  testpy.supp    waf*       wutils.pyc
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   163
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
Change into the ``examples/tutorial`` directory.  You should see a file named 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
``first.cc`` located there.  This is a script that will create a simple
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
point-to-point link between two nodes and echo a single packet between the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
nodes.  Let's take a look at that script line by line, so go ahead and open
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
``first.cc`` in your favorite editor.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
Boilerplate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
+++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
The first line in the file is an emacs mode line.  This tells emacs about the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
formatting conventions (coding style) we use in our source code.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   175
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   178
  /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
This is always a somewhat controversial subject, so we might as well get it
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   181
out of the way immediately.  The |ns3| project, like most large 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   182
projects, has adopted a coding style to which all contributed code must 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
adhere.  If you want to contribute your code to the project, you will 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
eventually have to conform to the |ns3| coding standard as described 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
in the file ``doc/codingstd.txt`` or shown on the project web page
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
`here
7867
87c579ca5690 fix broken tutorial link
Bruno Haick <bghaick@hotmail.com>
parents: 7479
diff changeset
   187
<http://www.nsnam.org/developers/contributing-code/coding-style/>`_.
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   188
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
We recommend that you, well, just get used to the look and feel of |ns3|
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
code and adopt this standard whenever you are working with our code.  All of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   191
the development team and contributors have done so with various amounts of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   192
grumbling.  The emacs mode line above makes it easier to get the formatting 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
correct if you use the emacs editor.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   194
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
The |ns3| simulator is licensed using the GNU General Public 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
License.  You will see the appropriate GNU legalese at the head of every file 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   197
in the |ns3| distribution.  Often you will see a copyright notice for
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
one of the institutions involved in the |ns3| project above the GPL
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
text and an author listed below.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   200
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   202
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   203
  /*
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   204
   * This program is free software; you can redistribute it and/or modify
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   205
   * it under the terms of the GNU General Public License version 2 as
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   206
   * published by the Free Software Foundation;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
   *
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   208
   * This program is distributed in the hope that it will be useful,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   209
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
   * GNU General Public License for more details.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
   *
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
   * You should have received a copy of the GNU General Public License
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
   * along with this program; if not, write to the Free Software
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
   */
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
Module Includes
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
+++++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   220
The code proper starts with a number of include statements.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   221
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   222
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   224
  #include "ns3/core-module.h"
7137
dbefbad7bee3 Fix module names in documentation
Mitch Watrous <watrous@u.washington.edu>
parents: 7025
diff changeset
   225
  #include "ns3/network-module.h"
dbefbad7bee3 Fix module names in documentation
Mitch Watrous <watrous@u.washington.edu>
parents: 7025
diff changeset
   226
  #include "ns3/internet-module.h"
dbefbad7bee3 Fix module names in documentation
Mitch Watrous <watrous@u.washington.edu>
parents: 7025
diff changeset
   227
  #include "ns3/point-to-point-module.h"
dbefbad7bee3 Fix module names in documentation
Mitch Watrous <watrous@u.washington.edu>
parents: 7025
diff changeset
   228
  #include "ns3/applications-module.h"
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
To help our high-level script users deal with the large number of include 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
files present in the system, we group includes according to relatively large 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
modules.  We provide a single include file that will recursively load all of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
the include files used in each module.  Rather than having to look up exactly
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
what header you need, and possibly have to get a number of dependencies right,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   235
we give you the ability to load a group of files at a large granularity.  This
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   236
is not the most efficient approach but it certainly makes writing scripts much
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
easier.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   238
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   239
Each of the |ns3| include files is placed in a directory called 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   240
``ns3`` (under the build directory) during the build process to help avoid
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   241
include file name collisions.  The ``ns3/core-module.h`` file corresponds 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
to the ns-3 module you will find in the directory ``src/core`` in your 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   243
downloaded release distribution.  If you list this directory you will find a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   244
large number of header files.  When you do a build, Waf will place public 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   245
header files in an ``ns3`` directory under the appropriate 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   246
``build/debug`` or ``build/optimized`` directory depending on your 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   247
configuration.  Waf will also automatically generate a module include file to
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   248
load all of the public header files.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   249
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   250
Since you are, of course, following this tutorial religiously, you will 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   251
already have done a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   252
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   253
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   254
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   255
  $ ./waf -d debug --enable-examples --enable-tests configure
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   256
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6754
diff changeset
   257
in order to configure the project to perform debug builds that include 
7024
4392d52b3536 Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6998
diff changeset
   258
examples and tests.  You will also have done a
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   259
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   260
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   261
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   262
  $ ./waf
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   263
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   264
to build the project.  So now if you look in the directory 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   265
``../../build/debug/ns3`` you will find the four module include files shown 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   266
above.  You can take a look at the contents of these files and find that they
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   267
do include all of the public include files in their respective modules.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   268
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   269
Ns3 Namespace
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   270
+++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   271
The next line in the ``first.cc`` script is a namespace declaration.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   272
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   273
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   274
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   275
  using namespace ns3;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   276
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   277
The |ns3| project is implemented in a C++ namespace called 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   278
``ns3``.  This groups all |ns3|-related declarations in a scope
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   279
outside the global namespace, which we hope will help with integration with 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   280
other code.  The C++ ``using`` statement introduces the |ns3|
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   281
namespace into the current (global) declarative region.  This is a fancy way
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   282
of saying that after this declaration, you will not have to type ``ns3::``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   283
scope resolution operator before all of the |ns3| code in order to use
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   284
it.  If you are unfamiliar with namespaces, please consult almost any C++ 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   285
tutorial and compare the ``ns3`` namespace and usage here with instances of
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   286
the ``std`` namespace and the ``using namespace std;`` statements you 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   287
will often find in discussions of ``cout`` and streams.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   288
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   289
Logging
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   290
+++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   291
The next line of the script is the following,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   292
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   293
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   294
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   295
  NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   296
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   297
We will use this statement as a convenient place to talk about our Doxygen
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   298
documentation system.  If you look at the project web site, 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   299
`ns-3 project
7479
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   300
<http://www.nsnam.org>`_, you will find a link to "Documentation" in the navigation bar.  If you select this link, you will be
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   301
taken to our documentation page. There 
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   302
is a link to "Latest Release" that will take you to the documentation
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   303
for the latest stable release of |ns3|.
7479
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   304
If you select the "API Documentation" link, you will be
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   305
taken to the |ns3| API documentation page.
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   306
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   307
Along the left side, you will find a graphical representation of the structure
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   308
of the documentation.  A good place to start is the ``NS-3 Modules``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   309
"book" in the |ns3| navigation tree.  If you expand ``Modules`` 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   310
you will see a list of |ns3| module documentation.  The concept of 
7479
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   311
module here ties directly into the module include files discussed above.  The |ns3| logging subsystem is discussed in the ``C++ Constructs Used by All Modules`` 
0ff4a85b9e04 Fix references to old website in Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents: 7275
diff changeset
   312
section, so go ahead and expand that documentation node.  Now, expand the 
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   313
``Debugging`` book and then select the ``Logging`` page.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   314
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   315
You should now be looking at the Doxygen documentation for the Logging module.
9183
1a2abe07b53d bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9163
diff changeset
   316
In the list of ``#define``'s at the top of the page you will see the entry
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   317
for ``NS_LOG_COMPONENT_DEFINE``.  Before jumping in, it would probably be 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   318
good to look for the "Detailed Description" of the logging module to get a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   319
feel for the overall operation.  You can either scroll down or select the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   320
"More..." link under the collaboration diagram to do this.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   321
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   322
Once you have a general idea of what is going on, go ahead and take a look at
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   323
the specific ``NS_LOG_COMPONENT_DEFINE`` documentation.  I won't duplicate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   324
the documentation here, but to summarize, this line declares a logging 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   325
component called ``FirstScriptExample`` that allows you to enable and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   326
disable console message logging by reference to the name.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   327
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   328
Main Function
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   329
+++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   330
The next lines of the script you will find are,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   331
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   332
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   333
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   334
  int
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   335
  main (int argc, char *argv[])
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   336
  {
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   337
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   338
This is just the declaration of the main function of your program (script).
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   339
Just as in any C++ program, you need to define a main function that will be 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   340
the first function run.  There is nothing at all special here.  Your 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   341
|ns3| script is just a C++ program.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   342
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   343
The next line sets the time resolution to one nanosecond, which happens
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   344
to be the default value:
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   345
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   346
::
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   347
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   348
    Time::SetResolution (Time::NS);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   349
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   350
The resolution is the smallest time value that can be represented (as well as
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   351
the smallest representable difference between two time values).
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   352
You can change the resolution exactly once.  The mechanism enabling this
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   353
flexibility is somewhat memory hungry, so once the resolution has been
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   354
set explicitly we release the memory, preventing further updates.   (If
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   355
you don't set the resolution explicitly, it will default to one nanosecond,
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   356
and the memory will be released when the simulation starts.)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9957
diff changeset
   357
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   358
The next two lines of the script are used to enable two logging components that
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   359
are built into the Echo Client and Echo Server applications:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   360
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   361
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   362
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   363
    LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   364
    LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   365
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   366
If you have read over the Logging component documentation you will have seen
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   367
that there are a number of levels of logging verbosity/detail that you can 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   368
enable on each component.  These two lines of code enable debug logging at the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   369
INFO level for echo clients and servers.  This will result in the application
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   370
printing out messages as packets are sent and received during the simulation.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   371
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   372
Now we will get directly to the business of creating a topology and running 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   373
a simulation.  We use the topology helper objects to make this job as
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   374
easy as possible.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   375
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   376
Topology Helpers
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   377
++++++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   378
NodeContainer
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   379
~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   380
The next two lines of code in our script will actually create the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   381
|ns3| ``Node`` objects that will represent the computers in the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   382
simulation.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   383
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   384
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   385
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   386
    NodeContainer nodes;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   387
    nodes.Create (2);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   388
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   389
Let's find the documentation for the ``NodeContainer`` class before we
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   390
continue.  Another way to get into the documentation for a given class is via 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   391
the ``Classes`` tab in the Doxygen pages.  If you still have the Doxygen 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   392
handy, just scroll up to the top of the page and select the ``Classes`` 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   393
tab.  You should see a new set of tabs appear, one of which is 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   394
``Class List``.  Under that tab you will see a list of all of the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   395
|ns3| classes.  Scroll down, looking for ``ns3::NodeContainer``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   396
When you find the class, go ahead and select it to go to the documentation for
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   397
the class.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   398
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   399
You may recall that one of our key abstractions is the ``Node``.  This
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   400
represents a computer to which we are going to add things like protocol stacks,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   401
applications and peripheral cards.  The ``NodeContainer`` topology helper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   402
provides a convenient way to create, manage and access any ``Node`` objects
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   403
that we create in order to run a simulation.  The first line above just 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   404
declares a NodeContainer which we call ``nodes``.  The second line calls the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   405
``Create`` method on the ``nodes`` object and asks the container to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   406
create two nodes.  As described in the Doxygen, the container calls down into
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   407
the |ns3| system proper to create two ``Node`` objects and stores
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   408
pointers to those objects internally.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   409
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   410
The nodes as they stand in the script do nothing.  The next step in 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   411
constructing a topology is to connect our nodes together into a network.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   412
The simplest form of network we support is a single point-to-point link 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   413
between two nodes.  We'll construct one of those links here.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   414
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   415
PointToPointHelper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   416
~~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   417
We are constructing a point to point link, and, in a pattern which will become
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   418
quite familiar to you, we use a topology helper object to do the low-level
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   419
work required to put the link together.  Recall that two of our key 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   420
abstractions are the ``NetDevice`` and the ``Channel``.  In the real
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   421
world, these terms correspond roughly to peripheral cards and network cables.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   422
Typically these two things are intimately tied together and one cannot expect
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   423
to interchange, for example, Ethernet devices and wireless channels.  Our 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   424
Topology Helpers follow this intimate coupling and therefore you will use a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   425
single ``PointToPointHelper`` to configure and connect |ns3|
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   426
``PointToPointNetDevice`` and ``PointToPointChannel`` objects in this 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   427
script.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   428
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   429
The next three lines in the script are,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   430
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   431
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   432
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   433
    PointToPointHelper pointToPoint;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   434
    pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   435
    pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   436
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   437
The first line,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   438
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   439
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   440
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   441
    PointToPointHelper pointToPoint;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   442
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   443
instantiates a ``PointToPointHelper`` object on the stack.  From a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   444
high-level perspective the next line,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   445
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   446
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   447
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   448
    pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   449
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   450
tells the ``PointToPointHelper`` object to use the value "5Mbps"
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   451
(five megabits per second) as the "DataRate" when it creates a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   452
``PointToPointNetDevice`` object.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   453
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   454
From a more detailed perspective, the string "DataRate" corresponds
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   455
to what we call an ``Attribute`` of the ``PointToPointNetDevice``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   456
If you look at the Doxygen for class ``ns3::PointToPointNetDevice`` and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   457
find the documentation for the ``GetTypeId`` method, you will find a list
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   458
of  ``Attributes`` defined for the device.  Among these is the "DataRate"
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   459
``Attribute``.  Most user-visible |ns3| objects have similar lists of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   460
``Attributes``.  We use this mechanism to easily configure simulations without
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   461
recompiling as you will see in a following section.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   462
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   463
Similar to the "DataRate" on the ``PointToPointNetDevice`` you will find a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   464
"Delay" ``Attribute`` associated with the ``PointToPointChannel``.  The 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   465
final line,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   466
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   467
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   468
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   469
    pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   470
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   471
tells the ``PointToPointHelper`` to use the value "2ms" (two milliseconds)
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   472
as the value of the transmission delay of every point to point channel it 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   473
subsequently creates.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   474
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   475
NetDeviceContainer
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   476
~~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   477
At this point in the script, we have a ``NodeContainer`` that contains
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   478
two nodes.  We have a ``PointToPointHelper`` that is primed and ready to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   479
make ``PointToPointNetDevices`` and wire ``PointToPointChannel`` objects
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   480
between them.  Just as we used the ``NodeContainer`` topology helper object
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   481
to create the ``Nodes`` for our simulation, we will ask the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   482
``PointToPointHelper`` to do the work involved in creating, configuring and
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   483
installing our devices for us.  We will need to have a list of all of the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   484
NetDevice objects that are created, so we use a NetDeviceContainer to hold 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   485
them just as we used a NodeContainer to hold the nodes we created.  The 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   486
following two lines of code,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   487
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   488
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   489
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   490
    NetDeviceContainer devices;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   491
    devices = pointToPoint.Install (nodes);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   492
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   493
will finish configuring the devices and channel.  The first line declares the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   494
device container mentioned above and the second does the heavy lifting.  The 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   495
``Install`` method of the ``PointToPointHelper`` takes a 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   496
``NodeContainer`` as a parameter.  Internally, a ``NetDeviceContainer`` 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   497
is created.  For each node in the ``NodeContainer`` (there must be exactly 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   498
two for a point-to-point link) a ``PointToPointNetDevice`` is created and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   499
saved in the device container.  A ``PointToPointChannel`` is created and 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   500
the two ``PointToPointNetDevices`` are attached.  When objects are created
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   501
by the ``PointToPointHelper``, the ``Attributes`` previously set in the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   502
helper are used to initialize the corresponding ``Attributes`` in the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   503
created objects.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   504
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   505
After executing the ``pointToPoint.Install (nodes)`` call we will have
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   506
two nodes, each with an installed point-to-point net device and a single
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   507
point-to-point channel between them.  Both devices will be configured to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   508
transmit data at five megabits per second over the channel which has a two 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   509
millisecond transmission delay.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   510
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   511
InternetStackHelper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   512
~~~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   513
We now have nodes and devices configured, but we don't have any protocol stacks
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   514
installed on our nodes.  The next two lines of code will take care of that.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   515
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   516
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   517
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   518
    InternetStackHelper stack;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   519
    stack.Install (nodes);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   520
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   521
The ``InternetStackHelper`` is a topology helper that is to internet stacks
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   522
what the ``PointToPointHelper`` is to point-to-point net devices.  The
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   523
``Install`` method takes a ``NodeContainer`` as a parameter.  When it is
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   524
executed, it will install an Internet Stack (TCP, UDP, IP, etc.) on each of
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   525
the nodes in the node container.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   526
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   527
Ipv4AddressHelper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   528
~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   529
Next we need to associate the devices on our nodes with IP addresses.  We 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   530
provide a topology helper to manage the allocation of IP addresses.  The only
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   531
user-visible API is to set the base IP address and network mask to use when
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   532
performing the actual address allocation (which is done at a lower level 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   533
inside the helper).
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   534
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   535
The next two lines of code in our example script, ``first.cc``,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   536
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   537
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   538
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   539
    Ipv4AddressHelper address;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   540
    address.SetBase ("10.1.1.0", "255.255.255.0");
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   541
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   542
declare an address helper object and tell it that it should begin allocating IP
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   543
addresses from the network 10.1.1.0 using the mask 255.255.255.0 to define 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   544
the allocatable bits.  By default the addresses allocated will start at one
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   545
and increase monotonically, so the first address allocated from this base will
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   546
be 10.1.1.1, followed by 10.1.1.2, etc.  The low level |ns3| system
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   547
actually remembers all of the IP addresses allocated and will generate a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   548
fatal error if you accidentally cause the same address to be generated twice 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   549
(which is a very hard to debug error, by the way).
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   550
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   551
The next line of code,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   552
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   553
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   554
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   555
    Ipv4InterfaceContainer interfaces = address.Assign (devices);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   556
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   557
performs the actual address assignment.  In |ns3| we make the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   558
association between an IP address and a device using an ``Ipv4Interface``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   559
object.  Just as we sometimes need a list of net devices created by a helper 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   560
for future reference we sometimes need a list of ``Ipv4Interface`` objects.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   561
The ``Ipv4InterfaceContainer`` provides this functionality.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   562
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   563
Now we have a point-to-point network built, with stacks installed and IP 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   564
addresses assigned.  What we need at this point are applications to generate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   565
traffic.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   566
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   567
Applications
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   568
++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   569
Another one of the core abstractions of the ns-3 system is the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   570
``Application``.  In this script we use two specializations of the core
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   571
|ns3| class ``Application`` called ``UdpEchoServerApplication``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   572
and ``UdpEchoClientApplication``.  Just as we have in our previous 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   573
explanations,  we use helper objects to help configure and manage the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   574
underlying objects.  Here, we use ``UdpEchoServerHelper`` and
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   575
``UdpEchoClientHelper`` objects to make our lives easier.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   576
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   577
UdpEchoServerHelper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   578
~~~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   579
The following lines of code in our example script, ``first.cc``, are used
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   580
to set up a UDP echo server application on one of the nodes we have previously
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   581
created.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   582
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   583
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   584
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   585
    UdpEchoServerHelper echoServer (9);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   586
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   587
    ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   588
    serverApps.Start (Seconds (1.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   589
    serverApps.Stop (Seconds (10.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   590
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   591
The first line of code in the above snippet declares the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   592
``UdpEchoServerHelper``.  As usual, this isn't the application itself, it
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   593
is an object used to help us create the actual applications.  One of our 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   594
conventions is to place *required* ``Attributes`` in the helper constructor.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   595
In this case, the helper can't do anything useful unless it is provided with
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   596
a port number that the client also knows about.  Rather than just picking one 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   597
and hoping it all works out, we require the port number as a parameter to the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   598
constructor.  The constructor, in turn, simply does a ``SetAttribute``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   599
with the passed value.  If you want, you can set the "Port" ``Attribute``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   600
to another value later using ``SetAttribute``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   601
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   602
Similar to many other helper objects, the ``UdpEchoServerHelper`` object 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   603
has an ``Install`` method.  It is the execution of this method that actually
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   604
causes the underlying echo server application to be instantiated and attached
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   605
to a node.  Interestingly, the ``Install`` method takes a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   606
``NodeContainter`` as a parameter just as the other ``Install`` methods
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   607
we have seen.  This is actually what is passed to the method even though it 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   608
doesn't look so in this case.  There is a C++ *implicit conversion* at
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   609
work here that takes the result of ``nodes.Get (1)`` (which returns a smart
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   610
pointer to a node object --- ``Ptr<Node>``) and uses that in a constructor
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   611
for an unnamed ``NodeContainer`` that is then passed to ``Install``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   612
If you are ever at a loss to find a particular method signature in C++ code
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   613
that compiles and runs just fine, look for these kinds of implicit conversions.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   614
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   615
We now see that ``echoServer.Install`` is going to install a
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   616
``UdpEchoServerApplication`` on the node found at index number one of the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   617
``NodeContainer`` we used to manage our nodes.  ``Install`` will return
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   618
a container that holds pointers to all of the applications (one in this case 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   619
since we passed a ``NodeContainer`` containing one node) created by the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   620
helper.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   621
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   622
Applications require a time to "start" generating traffic and may take an
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   623
optional time to "stop".  We provide both.  These times are set using  the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   624
``ApplicationContainer`` methods ``Start`` and ``Stop``.  These 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   625
methods take ``Time`` parameters.  In this case, we use an *explicit*
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   626
C++ conversion sequence to take the C++ double 1.0 and convert it to an 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   627
|ns3| ``Time`` object using a ``Seconds`` cast.  Be aware that
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   628
the conversion rules may be controlled by the model author, and C++ has its
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   629
own rules, so you can't always just assume that parameters will be happily 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   630
converted for you.  The two lines,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   631
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   632
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   633
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   634
    serverApps.Start (Seconds (1.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   635
    serverApps.Stop (Seconds (10.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   636
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   637
will cause the echo server application to ``Start`` (enable itself) at one
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   638
second into the simulation and to ``Stop`` (disable itself) at ten seconds
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   639
into the simulation.  By virtue of the fact that we have declared a simulation
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   640
event (the application stop event) to be executed at ten seconds, the simulation
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   641
will last *at least* ten seconds.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   642
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   643
UdpEchoClientHelper
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   644
~~~~~~~~~~~~~~~~~~~
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   645
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   646
The echo client application is set up in a method substantially similar to
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   647
that for the server.  There is an underlying ``UdpEchoClientApplication``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   648
that is managed by an ``UdpEchoClientHelper``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   649
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   650
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   651
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   652
    UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   653
    echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
9112
ede7a74e7411 bug 1514: make TimeValue usage consistent in the tutorial
Tom Henderson <tomh@tomh.org>
parents: 7867
diff changeset
   654
    echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   655
    echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   656
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   657
    ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   658
    clientApps.Start (Seconds (2.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   659
    clientApps.Stop (Seconds (10.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   660
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   661
For the echo client, however, we need to set five different ``Attributes``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   662
The first two ``Attributes`` are set during construction of the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   663
``UdpEchoClientHelper``.  We pass parameters that are used (internally to
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   664
the helper) to set the "RemoteAddress" and "RemotePort" ``Attributes``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   665
in accordance with our convention to make required ``Attributes`` parameters
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   666
in the helper constructors.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   667
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   668
Recall that we used an ``Ipv4InterfaceContainer`` to keep track of the IP 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   669
addresses we assigned to our devices.  The zeroth interface in the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   670
``interfaces`` container is going to correspond to the IP address of the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   671
zeroth node in the ``nodes`` container.  The first interface in the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   672
``interfaces`` container corresponds to the IP address of the first node 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   673
in the ``nodes`` container.  So, in the first line of code (from above), we
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   674
are creating the helper and telling it so set the remote address of the client
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   675
to be  the IP address assigned to the node on which the server resides.  We 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   676
also tell it to arrange to send packets to port nine.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   677
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   678
The "MaxPackets" ``Attribute`` tells the client the maximum number of 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   679
packets we allow it to send during the simulation.  The "Interval" 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   680
``Attribute`` tells the client how long to wait between packets, and the
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   681
"PacketSize" ``Attribute`` tells the client how large its packet payloads
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   682
should be.  With this particular combination of ``Attributes``, we are 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   683
telling the client to send one 1024-byte packet.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   684
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   685
Just as in the case of the echo server, we tell the echo client to ``Start``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   686
and ``Stop``, but here we start the client one second after the server is
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   687
enabled (at two seconds into the simulation).
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   688
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   689
Simulator
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   690
+++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   691
What we need to do at this point is to actually run the simulation.  This is 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   692
done using the global function ``Simulator::Run``.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   693
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   694
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   695
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   696
    Simulator::Run ();
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   697
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   698
When we previously called the methods,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   699
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   700
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   701
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   702
    serverApps.Start (Seconds (1.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   703
    serverApps.Stop (Seconds (10.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   704
    ...
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   705
    clientApps.Start (Seconds (2.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   706
    clientApps.Stop (Seconds (10.0));
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   707
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   708
we actually scheduled events in the simulator at 1.0 seconds, 2.0 seconds and
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   709
two events at 10.0 seconds.  When ``Simulator::Run`` is called, the system 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   710
will begin looking through the list of scheduled events and executing them.  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   711
First it will run the event at 1.0 seconds, which will enable the echo server 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   712
application (this event may, in turn, schedule many other events).  Then it 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   713
will run the event scheduled for t=2.0 seconds which will start the echo client
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   714
application.  Again, this event may schedule many more events.  The start event
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   715
implementation in the echo client application will begin the data transfer phase
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   716
of the simulation by sending a packet to the server.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   717
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   718
The act of sending the packet to the server will trigger a chain of events
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   719
that will be automatically scheduled behind the scenes and which will perform 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   720
the mechanics of the packet echo according to the various timing parameters 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   721
that we have set in the script.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   722
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   723
Eventually, since we only send one packet (recall the ``MaxPackets`` 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   724
``Attribute`` was set to one), the chain of events triggered by 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   725
that single client echo request will taper off and the simulation will go 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   726
idle.  Once this happens, the remaining events will be the ``Stop`` events
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   727
for the server and the client.  When these events are executed, there are
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   728
no further events to process and ``Simulator::Run`` returns.  The simulation
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   729
is then complete.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   730
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   731
All that remains is to clean up.  This is done by calling the global function 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   732
``Simulator::Destroy``.  As the helper functions (or low level 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   733
|ns3| code) executed, they arranged it so that hooks were inserted in
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   734
the simulator to destroy all of the objects that were created.  You did not 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   735
have to keep track of any of these objects yourself --- all you had to do 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   736
was to call ``Simulator::Destroy`` and exit.  The |ns3| system
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   737
took care of the hard part for you.  The remaining lines of our first 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   738
|ns3| script, ``first.cc``, do just that:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   739
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   740
::
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   741
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   742
    Simulator::Destroy ();
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   743
    return 0;
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   744
  }
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   745
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   746
Building Your Script
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   747
++++++++++++++++++++
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   748
We have made it trivial to build your simple scripts.  All you have to do is 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   749
to drop your script into the scratch directory and it will automatically be 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   750
built if you run Waf.  Let's try it.  Copy ``examples/tutorial/first.cc`` into 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   751
the ``scratch`` directory after changing back into the top level directory.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   752
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   753
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   754
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   755
  $ cd ../..
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   756
  $ cp examples/tutorial/first.cc scratch/myfirst.cc
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   757
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   758
Now build your first example script using waf:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   759
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   760
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   761
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   762
  $ ./waf
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   763
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   764
You should see messages reporting that your ``myfirst`` example was built
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   765
successfully.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   766
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   767
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   768
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   769
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   770
  [614/708] cxx: scratch/myfirst.cc -> build/debug/scratch/myfirst_3.o
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   771
  [706/708] cxx_link: build/debug/scratch/myfirst_3.o -> build/debug/scratch/myfirst
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   772
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   773
  'build' finished successfully (2.357s)
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   774
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   775
You can now run the example (note that if you build your program in the scratch
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   776
directory you must run it out of the scratch directory):
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   777
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   778
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   779
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   780
  $ ./waf --run scratch/myfirst
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   781
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   782
You should see some output:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   783
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   784
.. sourcecode:: bash
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   785
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   786
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   787
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   788
  'build' finished successfully (0.418s)
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   789
  Sent 1024 bytes to 10.1.1.2
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   790
  Received 1024 bytes from 10.1.1.1
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   791
  Received 1024 bytes from 10.1.1.2
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   792
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   793
Here you see that the build system checks to make sure that the file has been
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   794
build and then runs it.  You see the logging component on the echo client 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   795
indicate that it has sent one 1024 byte packet to the Echo Server on 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   796
10.1.1.2.  You also see the logging component on the echo server say that
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   797
it has received the 1024 bytes from 10.1.1.1.  The echo server silently 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   798
echoes the packet and you see the echo client log that it has received its 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   799
packet back from the server.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   800
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   801
Ns-3 Source Code
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   802
****************
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   803
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   804
Now that you have used some of the |ns3| helpers you may want to 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   805
have a look at some of the source code that implements that functionality.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   806
The most recent code can be browsed on our web server at the following link:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   807
http://code.nsnam.org/ns-3-dev.  There, you will see the Mercurial
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   808
summary page for our |ns3| development tree.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   809
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   810
At the top of the page, you will see a number of links,
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   811
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   812
.. sourcecode:: text
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   813
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   814
  summary | shortlog | changelog | graph | tags | files 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   815
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   816
Go ahead and select the ``files`` link.  This is what the top-level of
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   817
most of our *repositories* will look:
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   818
9957
1a4d84a85bad Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
   819
.. sourcecode:: text
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   820
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   821
  drwxr-xr-x                               [up]     
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   822
  drwxr-xr-x                               bindings python  files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   823
  drwxr-xr-x                               doc              files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   824
  drwxr-xr-x                               examples         files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   825
  drwxr-xr-x                               ns3              files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   826
  drwxr-xr-x                               scratch          files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   827
  drwxr-xr-x                               src              files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   828
  drwxr-xr-x                               utils            files
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   829
  -rw-r--r-- 2009-07-01 12:47 +0200 560    .hgignore        file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   830
  -rw-r--r-- 2009-07-01 12:47 +0200 1886   .hgtags          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   831
  -rw-r--r-- 2009-07-01 12:47 +0200 1276   AUTHORS          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   832
  -rw-r--r-- 2009-07-01 12:47 +0200 30961  CHANGES.html     file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   833
  -rw-r--r-- 2009-07-01 12:47 +0200 17987  LICENSE          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   834
  -rw-r--r-- 2009-07-01 12:47 +0200 3742   README           file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   835
  -rw-r--r-- 2009-07-01 12:47 +0200 16171  RELEASE_NOTES    file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   836
  -rw-r--r-- 2009-07-01 12:47 +0200 6      VERSION          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   837
  -rwxr-xr-x 2009-07-01 12:47 +0200 88110  waf              file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   838
  -rwxr-xr-x 2009-07-01 12:47 +0200 28     waf.bat          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   839
  -rw-r--r-- 2009-07-01 12:47 +0200 35395  wscript          file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   840
  -rw-r--r-- 2009-07-01 12:47 +0200 7673   wutils.py        file | revisions | annotate
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   841
  
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   842
Our example scripts are in the ``examples`` directory.  If you click on ``examples``
7275
83f76a2f8449 documentation fixes
Andrey Mazo <mazo@iitp.ru>
parents: 7147
diff changeset
   843
you will see a list of subdirectories.  One of the files in ``tutorial`` subdirectory is ``first.cc``.  If
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   844
you click on ``first.cc`` you will find the code you just walked through.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   845
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   846
The source code is mainly in the ``src`` directory.  You can view source
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   847
code either by clicking on the directory name or by clicking on the ``files``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   848
link to the right of the directory name.  If you click on the ``src``
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   849
directory, you will be taken to the listing of the ``src`` subdirectories.  If you 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   850
then click on ``core`` subdirectory, you will find a list of files.  The first file
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   851
you will find (as of this writing) is ``abort.h``.  If you click on the 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   852
``abort.h`` link, you will be sent to the source file for ``abort.h`` which 
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   853
contains useful macros for exiting scripts if abnormal conditions are detected.
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   854
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   855
The source code for the helpers we have used in this chapter can be found in the 
7147
71adbc0422a5 Fix more paths in the documentation
Mitch Watrous <watrous@u.washington.edu>
parents: 7137
diff changeset
   856
``src/applications/helper`` directory.  Feel free to poke around in the directory tree to
6754
7ff69b244b5b Move tutorial to Sphinx
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   857
get a feel for what is there and the style of |ns3| programs.