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