author | Mitch Watrous <watrous@u.washington.edu> |
Thu, 14 Apr 2011 14:22:09 -0700 | |
changeset 7025 | 32212c736ab4 |
parent 7024 | 4392d52b3536 |
child 7071 | 24c505cb1c87 |
permissions | -rw-r--r-- |
6754 | 1 |
.. include:: replace.txt |
2 |
||
3 |
||
4 |
Getting Started |
|
5 |
--------------- |
|
6 |
||
7 |
Downloading ns-3 |
|
8 |
**************** |
|
9 |
||
10 |
The |ns3| system as a whole is a fairly complex system and has a |
|
11 |
number of dependencies on other components. Along with the systems you will |
|
12 |
most likely deal with every day (the GNU toolchain, Mercurial, you programmer |
|
13 |
editor) you will need to ensure that a number of additional libraries are |
|
14 |
present on your system before proceeding. |ns3| provides a wiki |
|
15 |
for your reading pleasure that includes pages with many useful hints and tips. |
|
16 |
One such page is the "Installation" page, |
|
17 |
http://www.nsnam.org/wiki/index.php/Installation. |
|
18 |
||
19 |
The "Prerequisites" section of this wiki page explains which packages are |
|
20 |
required to support common |ns3| options, and also provides the |
|
21 |
commands used to install them for common Linux variants. Cygwin users will |
|
22 |
have to use the Cygwin installer (if you are a Cygwin user, you used it to |
|
23 |
install Cygwin). |
|
24 |
||
25 |
You may want to take this opportunity to explore the |ns3| wiki |
|
26 |
a bit since there really is a wealth of information there. |
|
27 |
||
28 |
From this point forward, we are going to assume that the reader is working in |
|
29 |
Linux or a Linux emulation environment (Linux, Cygwin, etc.) and has the GNU |
|
30 |
toolchain installed and verified along with the prerequisites mentioned |
|
31 |
above. We are also going to assume that you have Mercurial and Waf installed |
|
32 |
and running on the target system as described in the "Getting Started" section |
|
33 |
of the |ns3| web site: |
|
34 |
http://www.nsnam.org/getting_started.html. |
|
35 |
||
36 |
The |ns3| code is available in Mercurial repositories on the server |
|
37 |
http://code.nsnam.org. You can also download a tarball release at |
|
38 |
http://www.nsnam.org/releases/, or you can work with repositories |
|
39 |
using Mercurial. We recommend using Mercurial unless there's a good reason |
|
40 |
not to. See the end of this section for instructions on how to get a tarball |
|
41 |
release. |
|
42 |
||
43 |
The simplest way to get started using Mercurial repositories is to use the |
|
44 |
``ns-3-allinone`` environment. This is a set of scripts that manages the |
|
45 |
downloading and building of various subsystems of |ns3| for you. We |
|
46 |
recommend that you begin your |ns3| adventures in this environment |
|
47 |
as it can really simplify your life at this point. |
|
48 |
||
49 |
Downloading ns-3 Using Mercurial |
|
50 |
++++++++++++++++++++++++++++++++ |
|
51 |
One practice is to create a directory called ``repos`` in one's home |
|
52 |
directory under which one can keep local Mercurial repositories. |
|
53 |
*Hint: we will assume you do this later in the tutorial.* If you adopt |
|
54 |
that approach, you can get a copy of ``ns-3-allinone`` by typing the |
|
55 |
following into your Linux shell (assuming you have installed Mercurial): |
|
56 |
||
57 |
:: |
|
58 |
||
59 |
cd |
|
60 |
mkdir repos |
|
61 |
cd repos |
|
62 |
hg clone http://code.nsnam.org/ns-3-allinone |
|
63 |
||
64 |
As the hg (Mercurial) command executes, you should see something like the |
|
65 |
following displayed, |
|
66 |
||
67 |
:: |
|
68 |
||
69 |
destination directory: ns-3-allinone |
|
70 |
requesting all changes |
|
71 |
adding changesets |
|
72 |
adding manifests |
|
73 |
adding file changes |
|
74 |
added 31 changesets with 45 changes to 7 files |
|
75 |
7 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
76 |
||
77 |
After the clone command completes, you should have a directory called |
|
78 |
``ns-3-allinone`` under your ``~/repos`` directory, the contents of which should |
|
79 |
look something like the following: |
|
80 |
||
81 |
:: |
|
82 |
||
83 |
build.py* constants.py dist.py* download.py* README util.py |
|
84 |
||
85 |
Notice that you really just downloaded some Python scripts. The next step |
|
86 |
will be to use those scripts to download and build the |ns3| |
|
87 |
distribution of your choice. |
|
88 |
||
89 |
If you go to the following link: http://code.nsnam.org/, |
|
90 |
you will see a number of repositories. Many are the private repositories of |
|
91 |
the |ns3| development team. The repositories of interest to you will |
|
92 |
be prefixed with "ns-3". Official releases of |ns3| will be |
|
93 |
numbered as ``ns-3.<release>.<hotfix>``. For example, a second hotfix to a |
|
94 |
still hypothetical release nine of |ns3| would be numbered as |
|
95 |
``ns-3.9.2``. |
|
96 |
||
97 |
The current development snapshot (unreleased) of |ns3| may be found |
|
98 |
at http://code.nsnam.org/ns-3-dev/. The |
|
99 |
developers attempt to keep these repository in consistent, working states but |
|
100 |
they are in a development area with unreleased code present, so you may want |
|
101 |
to consider staying with an official release if you do not need newly- |
|
102 |
introduced features. |
|
103 |
||
104 |
Since the release numbers are going to be changing, I will stick with |
|
105 |
the more constant ns-3-dev here in the tutorial, but you can replace the |
|
106 |
string "ns-3-dev" with your choice of release (e.g., ns-3.10) in the |
|
107 |
text below. You can find the latest version of the |
|
108 |
code either by inspection of the repository list or by going to the |
|
109 |
`"Getting Started" |
|
110 |
<http://www.nsnam.org/getting_started.html>`_ |
|
111 |
web page and looking for the latest release identifier. |
|
112 |
||
113 |
Go ahead and change into the ``ns-3-allinone`` directory you created when |
|
114 |
you cloned that repository. We are now going to use the ``download.py`` |
|
115 |
script to pull down the various pieces of |ns3| you will be using. |
|
116 |
||
117 |
Go ahead and type the following into your shell (remember you can substitute |
|
118 |
the name of your chosen release number instead of ``ns-3-dev`` -- like |
|
119 |
``"ns-3.10"`` if you want to work with a |
|
120 |
stable release). |
|
121 |
||
122 |
:: |
|
123 |
||
124 |
./download.py -n ns-3-dev |
|
125 |
||
126 |
Note that the default for the ``-n`` option is ``ns-3-dev`` and so the |
|
127 |
above is actually redundant. We provide this example to illustrate how to |
|
128 |
specify alternate repositories. In order to download ``ns-3-dev`` you |
|
129 |
can actually use the defaults and simply type, |
|
130 |
||
131 |
:: |
|
132 |
||
133 |
./download.py |
|
134 |
||
135 |
As the hg (Mercurial) command executes, you should see something like the |
|
136 |
following, |
|
137 |
||
138 |
:: |
|
139 |
||
140 |
# |
|
141 |
# Get NS-3 |
|
142 |
# |
|
143 |
||
144 |
Cloning ns-3 branch |
|
145 |
=> hg clone http://code.nsnam.org/ns-3-dev ns-3-dev |
|
146 |
requesting all changes |
|
147 |
adding changesets |
|
148 |
adding manifests |
|
149 |
adding file changes |
|
150 |
added 4634 changesets with 16500 changes to 1762 files |
|
151 |
870 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
152 |
||
153 |
This is output by the download script as it fetches the actual ``ns-3`` |
|
154 |
code from the repository. |
|
155 |
||
156 |
The download script is smart enough to know that on some platforms various |
|
157 |
pieces of ns-3 are not supported. On your platform you may not see some |
|
158 |
of these pieces come down. However, on most platforms, the process should |
|
159 |
continue with something like, |
|
160 |
||
161 |
:: |
|
162 |
||
163 |
# |
|
164 |
# Get PyBindGen |
|
165 |
# |
|
166 |
||
167 |
Required pybindgen version: 0.10.0.640 |
|
168 |
Trying to fetch pybindgen; this will fail if no network connection is available. Hit Ctrl-C to skip. |
|
169 |
=> bzr checkout -rrevno:640 https://launchpad.net/pybindgen pybindgen |
|
170 |
Fetch was successful. |
|
171 |
||
172 |
This was the download script getting the Python bindings generator for you. |
|
173 |
Note that you will need bazaar (bzr), a version control system, to download |
|
174 |
PyBindGen. Next you should see (modulo platform variations) something along |
|
175 |
the lines of, |
|
176 |
||
177 |
:: |
|
178 |
||
179 |
# |
|
180 |
# Get NSC |
|
181 |
# |
|
182 |
||
183 |
Required NSC version: nsc-0.5.0 |
|
184 |
Retrieving nsc from https://secure.wand.net.nz/mercurial/nsc |
|
185 |
=> hg clone https://secure.wand.net.nz/mercurial/nsc nsc |
|
186 |
requesting all changes |
|
187 |
adding changesets |
|
188 |
adding manifests |
|
189 |
adding file changes |
|
190 |
added 273 changesets with 17565 changes to 15175 files |
|
191 |
10622 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
192 |
||
193 |
This part of the process is the script downloading the Network Simulation |
|
194 |
Cradle for you. Note that NSC is not supported on OSX or Cygwin and works |
|
195 |
best with gcc-3.4 or gcc-4.2 or greater series. |
|
196 |
||
197 |
After the download.py script completes, you should have several new directories |
|
198 |
under ``~/repos/ns-3-allinone``: |
|
199 |
||
200 |
:: |
|
201 |
||
202 |
build.py* constants.pyc download.py* nsc/ README util.pyc |
|
203 |
constants.py dist.py* ns-3-dev/ pybindgen/ util.py |
|
204 |
||
205 |
Go ahead and change into ``ns-3-dev`` under your ``~/repos/ns-3-allinone`` |
|
206 |
directory. You should see something like the following there: |
|
207 |
||
208 |
:: |
|
209 |
||
7025
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
210 |
AUTHORS examples/ RELEASE_NOTES VERSION wutils.py |
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
211 |
bindings/ LICENSE scratch/ waf* |
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
212 |
CHANGES.html ns3/ src/ waf.bat* |
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
213 |
doc/ README utils/ wscript |
6754 | 214 |
|
215 |
You are now ready to build the |ns3| distribution. |
|
216 |
||
217 |
Downloading ns-3 Using a Tarball |
|
218 |
++++++++++++++++++++++++++++++++ |
|
219 |
The process for downloading |ns3| via tarball is simpler than the |
|
220 |
Mercurial process since all of the pieces are pre-packaged for you. You just |
|
221 |
have to pick a release, download it and decompress it. |
|
222 |
||
223 |
As mentioned above, one practice is to create a directory called ``repos`` |
|
224 |
in one's home directory under which one can keep local Mercurial repositories. |
|
225 |
One could also keep a ``tarballs`` directory. *Hint: the tutorial |
|
226 |
will assume you downloaded into a ``repos`` directory, so remember the |
|
227 |
placekeeper.``* If you adopt the ``tarballs`` directory approach, you can |
|
228 |
get a copy of a release by typing the following into your Linux shell |
|
229 |
(substitute the appropriate version numbers, of course): |
|
230 |
||
231 |
:: |
|
232 |
||
233 |
cd |
|
234 |
mkdir tarballs |
|
235 |
cd tarballs |
|
236 |
wget http://www.nsnam.org/releases/ns-allinone-3.10.tar.bz2 |
|
237 |
tar xjf ns-allinone-3.10.tar.bz2 |
|
238 |
||
239 |
If you change into the directory ``ns-allinone-3.10`` you should see a |
|
240 |
number of files: |
|
241 |
||
242 |
:: |
|
243 |
||
244 |
build.py ns-3.10/ pybindgen-0.15.0/ util.py |
|
245 |
constants.py nsc-0.5.2/ README |
|
246 |
||
247 |
You are now ready to build the |ns3| distribution. |
|
248 |
||
249 |
Building ns-3 |
|
250 |
************* |
|
251 |
||
252 |
Building with build.py |
|
253 |
++++++++++++++++++++++ |
|
254 |
The first time you build the |ns3| project you should build using the |
|
255 |
``allinone`` environment. This will get the project configured for you |
|
256 |
in the most commonly useful way. |
|
257 |
||
258 |
Change into the directory you created in the download section above. If you |
|
259 |
downloaded using Mercurial you should have a directory called |
|
260 |
``ns-3-allinone`` under your ``~/repos`` directory. If you downloaded |
|
261 |
using a tarball you should have a directory called something like |
|
262 |
``ns-allinone-3.10`` under your ``~/tarballs`` directory. Take a deep |
|
263 |
breath and type the following: |
|
264 |
||
265 |
:: |
|
266 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
267 |
./build.py --enable-examples --enable-tests |
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
268 |
|
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
269 |
Because we are working with examples and tests in this tutorial, and |
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
270 |
because they are not built by default in |ns3|, the arguments for |
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
271 |
build.py tells it to build them for us. In the future you can build |
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
272 |
|ns3| without examples and tests if you wish. |
6754 | 273 |
|
274 |
You will see lots of typical compiler output messages displayed as the build |
|
275 |
script builds the various pieces you downloaded. Eventually you should see the |
|
276 |
following magic words: |
|
277 |
||
278 |
:: |
|
279 |
||
280 |
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build' |
|
281 |
'build' finished successfully (2m30.586s) |
|
282 |
||
283 |
Once the project has built you can say goodbye to your old friends, the |
|
284 |
``ns-3-allinone`` scripts. You got what you needed from them and will now |
|
285 |
interact directly with Waf and we do it in the ``ns-3-dev`` directory, |
|
286 |
not in the ``ns-3-allinone`` directory. Go ahead and change into the |
|
287 |
``ns-3-dev`` directory (or the directory for the appropriate release you |
|
288 |
downloaded. |
|
289 |
||
290 |
:: |
|
291 |
||
292 |
cd ns-3-dev |
|
293 |
||
294 |
Building with Waf |
|
295 |
+++++++++++++++++ |
|
296 |
We use Waf to configure and build the |ns3| project. It's not |
|
297 |
strictly required at this point, but it will be valuable to take a slight |
|
298 |
detour and look at how to make changes to the configuration of the project. |
|
299 |
Probably the most useful configuration change you can make will be to |
|
300 |
build the optimized version of the code. By default you have configured |
|
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
301 |
your project to build the debug version. Let's tell the project to |
6754 | 302 |
make an optimized build. To explain to Waf that it should do optimized |
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
303 |
builds that include the examples and tests, you will need to execute the |
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
304 |
following command, |
6754 | 305 |
|
306 |
:: |
|
307 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
308 |
./waf -d optimized --enable-examples --enable-tests configure |
6754 | 309 |
|
310 |
This runs Waf out of the local directory (which is provided as a convenience |
|
311 |
for you). As the build system checks for various dependencies you should see |
|
312 |
output that looks similar to the following, |
|
313 |
||
314 |
:: |
|
315 |
||
316 |
Checking for program g++ : ok /usr/bin/g++ |
|
317 |
Checking for program cpp : ok /usr/bin/cpp |
|
318 |
Checking for program ar : ok /usr/bin/ar |
|
319 |
Checking for program ranlib : ok /usr/bin/ranlib |
|
320 |
Checking for g++ : ok |
|
321 |
Checking for program pkg-config : ok /usr/bin/pkg-config |
|
322 |
Checking for -Wno-error=deprecated-declarations support : yes |
|
323 |
Checking for -Wl,--soname=foo support : yes |
|
324 |
Checking for header stdlib.h : ok |
|
325 |
Checking for header signal.h : ok |
|
326 |
Checking for header pthread.h : ok |
|
327 |
Checking for high precision time implementation : 128-bit integer |
|
328 |
Checking for header stdint.h : ok |
|
329 |
Checking for header inttypes.h : ok |
|
330 |
Checking for header sys/inttypes.h : not found |
|
331 |
Checking for library rt : ok |
|
332 |
Checking for header netpacket/packet.h : ok |
|
333 |
Checking for pkg-config flags for GSL : ok |
|
334 |
Checking for header linux/if_tun.h : ok |
|
335 |
Checking for pkg-config flags for GTK_CONFIG_STORE : ok |
|
336 |
Checking for pkg-config flags for LIBXML2 : ok |
|
337 |
Checking for library sqlite3 : ok |
|
338 |
Checking for NSC location : ok ../nsc (guessed) |
|
339 |
Checking for library dl : ok |
|
340 |
Checking for NSC supported architecture x86_64 : ok |
|
341 |
Checking for program python : ok /usr/bin/python |
|
342 |
Checking for Python version >= 2.3 : ok 2.5.2 |
|
343 |
Checking for library python2.5 : ok |
|
344 |
Checking for program python2.5-config : ok /usr/bin/python2.5-config |
|
345 |
Checking for header Python.h : ok |
|
346 |
Checking for -fvisibility=hidden support : yes |
|
347 |
Checking for pybindgen location : ok ../pybindgen (guessed) |
|
348 |
Checking for Python module pybindgen : ok |
|
349 |
Checking for pybindgen version : ok 0.10.0.640 |
|
350 |
Checking for Python module pygccxml : ok |
|
351 |
Checking for pygccxml version : ok 0.9.5 |
|
352 |
Checking for program gccxml : ok /usr/local/bin/gccxml |
|
353 |
Checking for gccxml version : ok 0.9.0 |
|
354 |
Checking for program sudo : ok /usr/bin/sudo |
|
355 |
Checking for program hg : ok /usr/bin/hg |
|
356 |
Checking for program valgrind : ok /usr/bin/valgrind |
|
357 |
---- Summary of optional NS-3 features: |
|
358 |
Threading Primitives : enabled |
|
359 |
Real Time Simulator : enabled |
|
360 |
Emulated Net Device : enabled |
|
361 |
GNU Scientific Library (GSL) : enabled |
|
362 |
Tap Bridge : enabled |
|
363 |
GtkConfigStore : enabled |
|
364 |
XmlIo : enabled |
|
365 |
SQlite stats data output : enabled |
|
366 |
Network Simulation Cradle : enabled |
|
367 |
Python Bindings : enabled |
|
368 |
Python API Scanning Support : enabled |
|
369 |
Use sudo to set suid bit : not enabled (option --enable-sudo not selected) |
|
7025
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
370 |
Build examples : enabled |
6754 | 371 |
Static build : not enabled (option --enable-static not selected) |
372 |
'configure' finished successfully (2.870s) |
|
373 |
||
374 |
Note the last part of the above output. Some ns-3 options are not enabled by |
|
375 |
default or require support from the underlying system to work properly. |
|
376 |
For instance, to enable XmlTo, the library libxml-2.0 must be found on the |
|
377 |
system. If this library were not found, the corresponding |ns3| feature |
|
378 |
would not be enabled and a message would be displayed. Note further that there is |
|
379 |
a feature to use the program ``sudo`` to set the suid bit of certain programs. |
|
380 |
This is not enabled by default and so this feature is reported as "not enabled." |
|
381 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
382 |
Now go ahead and switch back to the debug build that includes the examples and tests. |
6754 | 383 |
|
384 |
:: |
|
385 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
386 |
./waf -d debug --enable-examples --enable-tests configure |
6754 | 387 |
|
388 |
The build system is now configured and you can build the debug versions of |
|
389 |
the |ns3| programs by simply typing, |
|
390 |
||
391 |
:: |
|
392 |
||
393 |
./waf |
|
394 |
||
395 |
Some waf commands are meaningful during the build phase and some commands are valid |
|
396 |
in the configuration phase. For example, if you wanted to use the emulation |
|
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
397 |
features of |ns3|, you might want to enable setting the suid bit using |
6754 | 398 |
sudo as described above. This turns out to be a configuration-time command, and so |
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
399 |
you could reconfigure using the following command that also includes the examples and tests |
6754 | 400 |
|
401 |
:: |
|
402 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
403 |
./waf -d debug --enable-sudo --enable-examples --enable-tests configure |
6754 | 404 |
|
405 |
If you do this, waf will have run sudo to change the socket creator programs of the |
|
406 |
emulation code to run as root. There are many other configure- and build-time options |
|
407 |
available in waf. To explore these options, type: |
|
408 |
||
409 |
:: |
|
410 |
||
411 |
./waf --help |
|
412 |
||
413 |
We'll use some of the testing-related commands in the next section. |
|
414 |
||
415 |
Okay, sorry, I made you build the |ns3| part of the system twice, |
|
416 |
but now you know how to change the configuration and build optimized code. |
|
417 |
||
418 |
Testing ns-3 |
|
419 |
************ |
|
420 |
||
421 |
You can run the unit tests of the |ns3| distribution by running the |
|
422 |
"./test.py -c core" script, |
|
423 |
||
424 |
:: |
|
425 |
||
426 |
./test.py -c core |
|
427 |
||
428 |
These tests are run in parallel by waf. You should eventually |
|
429 |
see a report saying that, |
|
430 |
||
431 |
:: |
|
432 |
||
433 |
47 of 47 tests passed (47 passed, 0 failed, 0 crashed, 0 valgrind errors) |
|
434 |
||
435 |
This is the important message. |
|
436 |
||
437 |
You will also see output from the test runner and the output will actually look something like, |
|
438 |
||
439 |
:: |
|
440 |
||
441 |
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build' |
|
442 |
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build' |
|
443 |
'build' finished successfully (1.799s) |
|
444 |
PASS: TestSuite ns3-wifi-interference |
|
445 |
PASS: TestSuite histogram |
|
446 |
PASS: TestSuite sample |
|
447 |
PASS: TestSuite ipv4-address-helper |
|
448 |
PASS: TestSuite devices-wifi |
|
449 |
PASS: TestSuite propagation-loss-model |
|
450 |
||
451 |
... |
|
452 |
||
453 |
PASS: TestSuite attributes |
|
454 |
PASS: TestSuite config |
|
455 |
PASS: TestSuite global-value |
|
456 |
PASS: TestSuite command-line |
|
457 |
PASS: TestSuite basic-random-number |
|
458 |
PASS: TestSuite object |
|
459 |
PASS: TestSuite random-number-generators |
|
460 |
47 of 47 tests passed (47 passed, 0 failed, 0 crashed, 0 valgrind errors) |
|
461 |
||
462 |
This command is typically run by ``users`` to quickly verify that an |
|
463 |
|ns3| distribution has built correctly. |
|
464 |
||
465 |
Running a Script |
|
466 |
**************** |
|
467 |
We typically run scripts under the control of Waf. This allows the build |
|
468 |
system to ensure that the shared library paths are set correctly and that |
|
469 |
the libraries are available at run time. To run a program, simply use the |
|
470 |
``--run`` option in Waf. Let's run the |ns3| equivalent of the |
|
471 |
ubiquitous hello world program by typing the following: |
|
472 |
||
473 |
:: |
|
474 |
||
475 |
./waf --run hello-simulator |
|
476 |
||
477 |
Waf first checks to make sure that the program is built correctly and |
|
478 |
executes a build if required. Waf then executes the program, which |
|
479 |
produces the following output. |
|
480 |
||
481 |
:: |
|
482 |
||
483 |
Hello Simulator |
|
484 |
||
485 |
*Congratulations. You are now an ns-3 user.* |
|
486 |
||
487 |
*What do I do if I don't see the output?* |
|
488 |
||
489 |
If you don't see ``waf`` messages indicating that the build was |
|
490 |
completed successfully, but do not see the "Hello Simulator" output, |
|
491 |
chances are that you have switched your build mode to "optimized" in |
|
492 |
the "Building with Waf" section, but have missed the change back to |
|
493 |
"debug" mode. All of the console output used in this tutorial uses a |
|
494 |
special |ns3| logging component that is useful for printing |
|
495 |
user messages to the console. Output from this component is |
|
496 |
automatically disabled when you compile optimized code -- it is |
|
497 |
"optimized out." If you don't see the "Hello Simulator" output, |
|
498 |
type the following, |
|
499 |
||
500 |
:: |
|
501 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
502 |
./waf -d debug --enable-examples --enable-tests configure |
6754 | 503 |
|
504 |
to tell ``waf`` to build the debug versions of the |ns3| |
|
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
505 |
programs that includes the examples and tests. You must still build |
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
506 |
the actual debug version of the code by typing, |
6754 | 507 |
|
508 |
:: |
|
509 |
||
510 |
./waf |
|
511 |
||
512 |
Now, if you run the ``hello-simulator`` program, you should see the |
|
513 |
expected output. |
|
514 |
||
515 |
If you want to run programs under another tool such as gdb or valgrind, |
|
516 |
see this `wiki entry |
|
517 |
<http://www.nsnam.org/wiki/index.php/User_FAQ#How_to_run_NS-3_programs_under_another_tool>`_. |
|
518 |