author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Fri, 11 Jul 2008 18:39:19 +0100 | |
changeset 3416 | 926ccb845111 |
parent 3383 | f21d3d5926b9 |
child 3700 | fa1c7b813873 |
permissions | -rw-r--r-- |
3332 | 1 |
|
2 |
@c ======================================================================== |
|
3 |
@c Begin document body here |
|
4 |
@c ======================================================================== |
|
5 |
||
6 |
@c ======================================================================== |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
7 |
@c Conceptual Overview |
3332 | 8 |
@c ======================================================================== |
3340 | 9 |
@node Conceptual Overview |
3332 | 10 |
@chapter Conceptual Overview |
11 |
||
12 |
@menu |
|
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 | 15 |
@end menu |
16 |
||
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 | 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 | 21 |
are starting on a firm foundation. |
22 |
||
23 |
@node Key Abstractions |
|
24 |
@section Key Abstractions |
|
25 |
||
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 | 28 |
|
29 |
@subsection Node |
|
30 |
@cindex Node |
|
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 | 33 |
@emph{network} simulator, not specifically an @emph{Internet} simulator, we |
34 |
intentionally do not use the term host since it is closely associated with |
|
35 |
the Internet and its protocols. Instead, we use a more generic term also |
|
36 |
used by other simulators that originates in Graph Theory --- the @emph{node}. |
|
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 | 40 |
node. This abstraction is represented in C++ by the class @code{Node}. The |
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 | 43 |
|
44 |
You should think of a @code{Node} as a computer to which you will add |
|
45 |
functionality. One adds things like applications, protocol stacks and |
|
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 | 48 |
|
49 |
@subsection Application |
|
50 |
@cindex Application |
|
51 |
Typically, computer software is divided into two broad classes. @emph{System |
|
52 |
Software} organizes various computer resources such as memory, processor |
|
53 |
cycles, disk, network, etc., according to some computing model. System |
|
54 |
software usually does not use those resources to complete tasks that directly |
|
55 |
benefit a user. A user would typically run an @emph{application} that acquires |
|
56 |
and uses the resources controlled by the system software to accomplish some |
|
57 |
goal. |
|
58 |
||
59 |
@cindex system call |
|
60 |
Often, the line of separation between system and application software is made |
|
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 | 63 |
no concept of privilege levels or system calls. We do, however, have the |
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 | 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 | 70 |
activity to be simulated is the application. This abstraction is represented |
71 |
in C++ by the class @code{Application}. The @code{Application} class provides |
|
72 |
methods for managing the representations of our version of user-level |
|
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 | 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 | 80 |
|
81 |
@subsection Channel |
|
82 |
@cindex Channel |
|
83 |
||
84 |
In the real world, one can connect a computer to a network. Often the media |
|
85 |
over which data flows in these netowrks are called @emph{channels}. When |
|
86 |
you connect your Ethernet cable to the plug in the wall, you are connecting |
|
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 | 89 |
communication channel. Here the basic communication subnetwork abstraction |
90 |
is called the channel and is represented in C++ by the class @code{Channel}. |
|
91 |
||
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 | 99 |
|
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 | 105 |
|
106 |
@subsection Net Device |
|
107 |
@cindex NetDevice |
|
108 |
@cindex Ethernet |
|
109 |
It used to be the case that if you wanted to connect a computers to a network, |
|
110 |
you had to buy a specific kind of network cable and a hardware device called |
|
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 | 116 |
|
117 |
A NIC will not work without a software driver to control the hardware. In |
|
118 |
Unix (or Linux), a piece of peripheral hardware is classified as a |
|
119 |
@emph{device}. Devices are controlled using @emph{device drivers}, and network |
|
120 |
devices (NICs) are controlled using @emph{network device drivers} |
|
121 |
collectively known as @emph{net devices}. In Unix and Linux you refer |
|
122 |
to these net devices by names such as @emph{eth0}. |
|
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 | 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 | 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 | 130 |
|
131 |
The net device abstraction is represented in C++ by the class @code{NetDevice}. |
|
132 |
The @code{NetDevice} class provides methods for managing connections to |
|
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 | 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 | 142 |
|
143 |
@subsection Topology Helpers |
|
144 |
@cindex helper |
|
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 | 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 | 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 | 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 | 164 |
|
165 |
@c ======================================================================== |
|
166 |
@c A First ns-3 script |
|
167 |
@c ======================================================================== |
|
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 | 170 |
@cindex first script |
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 | 175 |
|
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 | 180 |
@end verbatim |
181 |
||
182 |
@cindex first.cc |
|
183 |
Change into the examples directory. You should see a file named |
|
184 |
@code{first.cc} located there. This is a script that will create a simple |
|
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 | 188 |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
189 |
@subsection Boilerplate |
3332 | 190 |
The first line in the file is an emacs mode line. This tells emacs about the |
191 |
formatting conventions (coding style) we use in our source code. |
|
192 |
||
193 |
@verbatim |
|
194 |
/* -*- Mode:C++; c-file-style:''gnu''; indent-tabs-mode:nil; -*- */ |
|
195 |
@end verbatim |
|
196 |
||
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 | 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 | 216 |
|
217 |
@verbatim |
|
218 |
/* |
|
219 |
* This program is free software; you can redistribute it and/or modify |
|
220 |
* it under the terms of the GNU General Public License version 2 as |
|
221 |
* published by the Free Software Foundation; |
|
222 |
* |
|
223 |
* This program is distributed in the hope that it will be useful, |
|
224 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
225 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
226 |
* GNU General Public License for more details. |
|
227 |
* |
|
228 |
* You should have received a copy of the GNU General Public License |
|
229 |
* along with this program; if not, write to the Free Software |
|
230 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
231 |
*/ |
|
232 |
@end verbatim |
|
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 | 236 |
|
237 |
@verbatim |
|
238 |
#include "ns3/core-module.h" |
|
239 |
#include "ns3/simulator-module.h" |
|
240 |
#include "ns3/node-module.h" |
|
241 |
#include "ns3/helper-module.h" |
|
242 |
@end verbatim |
|
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 | 266 |
|
267 |
@verbatim |
|
268 |
./waf -d debug configure |
|
269 |
@end verbatim |
|
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 | 273 |
|
274 |
@verbatim |
|
275 |
./waf |
|
276 |
@end verbatim |
|
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 | 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 | 285 |
|
286 |
@verbatim |
|
287 |
using namespace ns3; |
|
288 |
@end verbatim |
|
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 | 301 |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
302 |
@subsection Logging |
3332 | 303 |
The next line of the script is the following, |
304 |
||
305 |
@verbatim |
|
306 |
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); |
|
307 |
@end verbatim |
|
308 |
||
309 |
We will use this statement as a convenient place to talk about our Doxygen |
|
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 | 314 |
|
315 |
Along the left side, you will find a graphical representation of the structure |
|
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 | 323 |
|
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 | 332 |
the specific @code{NS_LOG_COMPONENT_DEFINE} documentation. I won't duplicate |
333 |
the documentation here, but to summarize, this line declares a logging |
|
334 |
component called @code{FirstScriptExample} that allows you to enable and |
|
335 |
disable console message logging by reference to the name. |
|
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 | 339 |
|
340 |
@verbatim |
|
341 |
int |
|
342 |
main (int argc, char *argv[]) |
|
343 |
{ |
|
344 |
@end verbatim |
|
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 | 350 |
|
351 |
The next two lines of the script are used to enable two logging components that |
|
352 |
are built into the Echo Client and Echo Server applications: |
|
353 |
||
354 |
@verbatim |
|
355 |
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); |
|
356 |
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); |
|
357 |
@end verbatim |
|
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 | 364 |
|
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 | 367 |
easy as possible. |
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 | 374 |
|
375 |
@verbatim |
|
376 |
NodeContainer nodes; |
|
377 |
nodes.Create (2); |
|
378 |
@end verbatim |
|
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 | 389 |
|
390 |
You may recall that one of our key abstractions is the @code{Node}. This |
|
391 |
represents a computer to which we are going to add things like protocol stacks, |
|
392 |
applications and peripheral cards. The @code{NodeContainer} topology helper |
|
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 | 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 | 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 | 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 | 408 |
quite familiar to you, we use a topology helper object to do the low-level |
409 |
work required to put the link together. Recall that two of our key |
|
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 | 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 | 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 | 416 |
@code{PointToPointNetDevice} and @code{PointToPointChannel} objects in this |
417 |
script. |
|
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 | 420 |
|
421 |
@verbatim |
|
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 | 425 |
@end verbatim |
426 |
||
427 |
The first line |
|
428 |
||
429 |
@verbatim |
|
430 |
PointToPointHelper pointToPoint; |
|
431 |
@end verbatim |
|
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 | 435 |
|
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 | 438 |
@end verbatim |
439 |
||
440 |
tells the @code{PointToPointHelper} object to use the value ``5mbps'' |
|
441 |
(five megabits per second) as the ``DataRate'' when it creates a |
|
442 |
@code{PointToPointNetDevice} object. |
|
443 |
||
444 |
From a more detailed perspective, the string ``DataRate'' corresponds |
|
445 |
to what we call an @code{Attribute} of the @code{PointToPointNetDevice}. |
|
446 |
If you look at the Doxygen for class @code{ns3::PointToPointNetDevice} and |
|
447 |
find the documentation for the @code{GetTypeId} method, you will find a list |
|
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 | 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 | 455 |
final line, |
456 |
||
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 | 459 |
@end verbatim |
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 | 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 | 464 |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
465 |
@subsubsection NetDeviceContainer |
3332 | 466 |
At this point in the script, we have a @code{NodeContainer} that contains |
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 | 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 | 471 |
@code{PointToPointHelper} to do the work involved in creating, configuring and |
472 |
installing our devices for us. We will need to have a list of all of the |
|
473 |
NetDevice objects that are created, so we use a NetDeviceContainer to hold |
|
474 |
them just as we used a NodeContainer to hold the nodes we created. The |
|
475 |
following two lines of code, |
|
476 |
||
477 |
@verbatim |
|
478 |
NetDeviceContainer devices; |
|
479 |
devices = pointToPoint.Install (nodes); |
|
480 |
@end verbatim |
|
481 |
||
482 |
will finish configuring the devices and channel. The first line declares the |
|
483 |
device container mentioned above and the second does the heavy lifting. The |
|
484 |
@code{Install} method of the @code{PointToPointHelper} takes a |
|
485 |
@code{NodeContainer} as a parameter. Internally, a @code{NetDeviceContainer} |
|
486 |
is created. For each node in the @code{NodeContainer} (there must be exactly |
|
487 |
two for a point-to-point link) a @code{PointToPointNetDevice} is created and |
|
488 |
saved in the device container. A @code{PointToPointChannel} is created and |
|
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 | 491 |
are used to initialize the corresponding attributes in the created objects. |
492 |
||
493 |
After executing the the @code{pointToPoint.Install (nodes)} call we will have |
|
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 | 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 | 502 |
|
503 |
@verbatim |
|
504 |
InternetStackHelper stack; |
|
505 |
stack.Install (nodes); |
|
506 |
@end verbatim |
|
507 |
||
508 |
The @code{InternetStackHelper} is a topology helper that is to internet stacks |
|
509 |
what the @code{PointToPointHelper} is to point-to-point net devices. The |
|
510 |
@code{Install} method takes a @code{NodeContainer} as a parameter. When it is |
|
511 |
executed, it will install an Internet Stack (TCP, UDP, IP, etc.) on each of |
|
512 |
the nodes in the node container. |
|
513 |
||
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
514 |
@subsubsection Ipv4AddressHelper |
3332 | 515 |
Next we need to associate the devices on our nodes with IP addresses. We |
516 |
provide a topology helper to manage the allocation of IP addresses. The only |
|
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 | 520 |
|
521 |
The next two lines of code in our example script, @code{first.cc}, |
|
522 |
||
523 |
@verbatim |
|
524 |
Ipv4AddressHelper address; |
|
525 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
|
526 |
@end verbatim |
|
527 |
||
528 |
declare an address helper object and tell it that it should begin allocating IP |
|
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 | 536 |
|
537 |
The next line of code, |
|
538 |
||
539 |
@verbatim |
|
540 |
Ipv4InterfaceContainer interfaces = address.Assign (devices); |
|
541 |
@end verbatim |
|
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 | 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 | 552 |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
553 |
@subsection Applications |
3332 | 554 |
Another one of the core abstractions of the ns-3 system is the |
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 | 560 |
@code{UdpEchoClientHelper} objects to make our lives easier. |
561 |
||
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
562 |
@subsubsection UdpEchoServerHelper |
3332 | 563 |
The following lines of code in our example script, @code{first.cc}, are used |
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 | 566 |
|
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 | 569 |
|
570 |
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); |
|
571 |
serverApps.Start (Seconds (1.0)); |
|
572 |
serverApps.Stop (Seconds (10.0)); |
|
573 |
@end verbatim |
|
574 |
||
575 |
The first line of code in the above snippet declares the |
|
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 | 585 |
|
586 |
Similar to many other helper objects, the @code{UdpEchoServerHelper} object |
|
587 |
has an @code{Install} method. It is the execution of this method that actually |
|
588 |
causes the underlying echo server application to be instantiated and attached |
|
589 |
to a node. Interestingly, the @code{Install} method takes a |
|
590 |
@code{NodeContainter} as a parameter just as the other @code{Install} methods |
|
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 | 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 | 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 | 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 | 608 |
|
609 |
@verbatim |
|
610 |
serverApps.Start (Seconds (1.0)); |
|
611 |
serverApps.Stop (Seconds (10.0)); |
|
612 |
@end verbatim |
|
613 |
||
614 |
will cause the echo server application to @code{Start} (enable itself) at one |
|
615 |
second into the simulation and to @code{Stop} (disable itself) at ten seconds |
|
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 | 619 |
|
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
620 |
@subsubsection UdpEchoClientHelper |
3332 | 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 | 625 |
|
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 | 631 |
|
632 |
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); |
|
633 |
clientApps.Start (Seconds (2.0)); |
|
634 |
clientApps.Stop (Seconds (10.0)); |
|
635 |
@end verbatim |
|
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 | 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 | 653 |
|
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 | 660 |
|
661 |
Just as in the case of the echo server, we tell the echo client to @code{Start} |
|
662 |
and @code{Stop}, but here we start the client one second after the server is |
|
663 |
enabled (at two seconds into the simulation). |
|
664 |
||
665 |
@subsection Simulator |
|
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 | 668 |
|
669 |
@verbatim |
|
670 |
Simulator::Run (); |
|
671 |
@end verbatim |
|
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 | 674 |
|
675 |
@verbatim |
|
676 |
serverApps.Start (Seconds (1.0)); |
|
677 |
serverApps.Stop (Seconds (10.0)); |
|
678 |
... |
|
679 |
clientApps.Start (Seconds (2.0)); |
|
680 |
clientApps.Stop (Seconds (10.0)); |
|
681 |
@end verbatim |
|
682 |
||
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 | 691 |
|
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 | 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 | 700 |
for the server and the client. When these events are executed, there are |
701 |
no further events to process and @code{Simulator::Run} returns. The simulation |
|
702 |
is complete. |
|
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 | 712 |
|
713 |
@verbatim |
|
714 |
Simulator::Destroy (); |
|
715 |
return 0; |
|
716 |
} |
|
717 |
@end verbatim |
|
718 |
||
3345
b0af63b9f9a6
editing pass through the tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
719 |
@subsection Building Your Script |
3332 | 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 | 724 |
|
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 | 727 |
@end verbatim |
728 |
||
729 |
and then build it using waf, |
|
730 |
||
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 | 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 | 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 | 738 |
@end verbatim |
739 |
||
740 |
You can now run the example (note that if you build your program in the scratch |
|
741 |
directory you must run it out of the scratch direcory): |
|
742 |
||
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 | 746 |
Compilation finished successfully |
747 |
Sent 1024 bytes to 10.1.1.2 |
|
748 |
Received 1024 bytes from 10.1.1.1 |
|
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 | 751 |
@end verbatim |
752 |
||
753 |
Here you see that the build system checks to make sure that the file has been |
|
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. |