author | Mitch Watrous <watrous@u.washington.edu> |
Thu, 12 May 2011 14:13:48 -0700 | |
changeset 7155 | e3e4192e2f67 |
child 7163 | a8d7b6569add |
permissions | -rw-r--r-- |
7155
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1 |
.. include:: replace.txt |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
2 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
3 |
Adding a New Module to |ns3| |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
4 |
---------------------------- |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
5 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
6 |
When you have created a group of related classes, examples, and tests, |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
7 |
they can be combined together into an |ns3| module so that they can be |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
8 |
used with existing |ns3| modules and by other researchers. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
9 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
10 |
This chapter walks you through the steps necessary to add a new module |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
11 |
to |ns3|. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
12 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
13 |
Step 1 - Familiarize yourself with the module layout |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
14 |
**************************************************** |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
15 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
16 |
All modules can be found in the ``src`` directory. Each module can be |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
17 |
found in a directory that has the same name as the module. For |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
18 |
example, the spectrum module can be found here: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
19 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
20 |
src/spectrum |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
21 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
22 |
A prototypical module has the following directory structure and |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
23 |
required files: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
24 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
25 |
src/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
26 |
module-name/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
27 |
bindings/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
28 |
doc/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
29 |
examples/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
30 |
wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
31 |
helper/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
32 |
model/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
33 |
test/ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
34 |
examples-to-run.py |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
35 |
wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
36 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
37 |
Not all directories will be present in each module. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
38 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
39 |
Step 2 - Copy the template module |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
40 |
********************************* |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
41 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
42 |
The template module :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
43 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
44 |
src/template |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
45 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
46 |
is a skeleton module that shows how modules should be created. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
47 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
48 |
For the purposes of this discussion we will assume that your new module is called "new-module". From the top level |ns3| directory, do the following to copy the template module to a new directory with the same name as your new module: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
49 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
50 |
cp -r src/template src/new-module |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
51 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
52 |
Now you will need to open the following file in your favorite text editor: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
53 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
54 |
src/new-module/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
55 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
56 |
and replace all of the occurrences of "template" in this wscript file with the name of your new module, i.e. "new-module" for our assumed module name. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
57 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
58 |
If your module will have model source files, then create the following directory where they will go: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
59 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
60 |
mkdir src/new-module/model |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
61 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
62 |
Copy all of your module's model source files to the above directory. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
63 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
64 |
If your module will have helper source files, then create the following directory where they will go: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
65 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
66 |
mkdir src/new-module/helper |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
67 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
68 |
Copy all of your module's helper source files to the above directory. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
69 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
70 |
Step 3 - Specify your module's source files |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
71 |
******************************************* |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
72 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
73 |
If your new module has model and/or helper source files, then they |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
74 |
must be specified in your :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
75 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
76 |
src/new-module/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
77 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
78 |
file by modifying it with your text editor. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
79 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
80 |
As an example, the source files for the spectrum module are specified |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
81 |
in :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
82 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
83 |
src/spectrum/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
84 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
85 |
with the following function call and list |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
86 |
of source files. Note that the second argument for the function |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
87 |
create_ns3_module() is the list of modules that the module being created |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
88 |
depends on: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
89 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
90 |
module = bld.create_ns3_module('spectrum', ['internet', 'propagation', 'applications']) |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
91 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
92 |
module.source = [ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
93 |
'model/spectrum-model.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
94 |
'model/spectrum-value.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
95 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
96 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
97 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
98 |
'model/microwave-oven-spectrum-value-helper.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
99 |
'helper/spectrum-helper.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
100 |
'helper/adhoc-aloha-noack-ideal-phy-helper.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
101 |
'helper/waveform-generator-helper.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
102 |
'helper/spectrum-analyzer-helper.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
103 |
] |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
104 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
105 |
Step 4 - Specify your module's header files |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
106 |
******************************************* |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
107 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
108 |
If your new module has model and/or helper header files, then they |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
109 |
must be specified in your :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
110 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
111 |
src/new-module/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
112 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
113 |
file by modifying it with your text editor. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
114 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
115 |
As an example, the header files for the spectrum module are specified |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
116 |
in :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
117 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
118 |
src/spectrum/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
119 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
120 |
with the following function call, module name, and list of header |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
121 |
files: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
122 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
123 |
headers = bld.new_task_gen('ns3header') |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
124 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
125 |
headers.module = 'spectrum' |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
126 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
127 |
headers.source = [ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
128 |
'model/spectrum-model.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
129 |
'model/spectrum-value.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
130 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
131 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
132 |
. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
133 |
'model/microwave-oven-spectrum-value-helper.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
134 |
'helper/spectrum-helper.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
135 |
'helper/adhoc-aloha-noack-ideal-phy-helper.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
136 |
'helper/waveform-generator-helper.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
137 |
'helper/spectrum-analyzer-helper.h', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
138 |
] |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
139 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
140 |
Step 5 - Specify your module's tests |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
141 |
************************************ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
142 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
143 |
If your new module has tests, then they must be specified in your :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
144 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
145 |
src/new-module/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
146 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
147 |
file by modifying it with your text editor. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
148 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
149 |
As an example, the tests for the spectrum module are specified in :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
150 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
151 |
src/spectrum/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
152 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
153 |
with the following function call and list of test suites: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
154 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
155 |
module_test = bld.create_ns3_module_test_library('spectrum') |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
156 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
157 |
module_test.source = [ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
158 |
'test/spectrum-interference-test.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
159 |
'test/spectrum-value-test.cc', |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
160 |
] |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
161 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
162 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
163 |
Step 6 - Specify your module's examples |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
164 |
*************************************** |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
165 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
166 |
If your new module has examples, then they must be specified in your :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
167 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
168 |
src/new-module/examples/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
169 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
170 |
file by modifying it with your text editor. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
171 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
172 |
As an example, the examples for the core module are specified in :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
173 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
174 |
src/core/examples/wscript |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
175 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
176 |
The core module's C++ examples are specified using the following |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
177 |
function call and source file name. Note that the second argument for |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
178 |
the function create_ns3_program() is the list of modules that the |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
179 |
program being created depends on: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
180 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
181 |
obj = bld.create_ns3_program('sample-simulator', ['core']) |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
182 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
183 |
obj.source = 'sample-simulator.cc' |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
184 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
185 |
The core module's Python examples are specified using the following |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
186 |
function call. Note that the second argument for the function |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
187 |
register_ns3_script() is the list of modules that the Python example |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
188 |
depends on: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
189 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
190 |
bld.register_ns3_script('sample-simulator.py', ['core']) |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
191 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
192 |
Step 7 - Specify which of your module's examples should be run |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
193 |
************************************************************** |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
194 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
195 |
If your new module has examples, then you must specify which of them |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
196 |
should be run in your :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
197 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
198 |
src/new-module/tests/examples-to-run.py |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
199 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
200 |
file by modifying it with your text editor. These examples are run by |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
201 |
test.py. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
202 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
203 |
As an example, the examples that are run by test.py for the core module are specified in :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
204 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
205 |
src/core/tests/examples-to-run |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
206 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
207 |
using the following two lists of C++ and Python examples: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
208 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
209 |
# A list of C++ examples to run in order to ensure that they remain |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
210 |
# buildable and runnable over time. Each tuple in the list contains |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
211 |
# |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
212 |
# (example_name, do_run, do_valgrind_run). |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
213 |
# |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
214 |
# See test.py for more information. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
215 |
cpp_examples = [ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
216 |
("main-attribute-value", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
217 |
("main-callback", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
218 |
("sample-simulator", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
219 |
("main-ptr", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
220 |
("main-random-variable", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
221 |
("sample-random-variable", "True", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
222 |
] |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
223 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
224 |
# A list of Python examples to run in order to ensure that they remain |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
225 |
# runnable over time. Each tuple in the list contains |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
226 |
# |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
227 |
# (example_name, do_run). |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
228 |
# |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
229 |
# See test.py for more information. |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
230 |
python_examples = [ |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
231 |
("sample-simulator.py", "True"), |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
232 |
] |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
233 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
234 |
Step 8 - Build and test your new module |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
235 |
*************************************** |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
236 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
237 |
You can now build and test your module as normal: :: |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
238 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
239 |
./waf configure --enable-examples --enable-tests |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
240 |
./waf build |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
241 |
./test.py |
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
242 |
|
e3e4192e2f67
Add manual chapter for adding new modules
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
243 |