|
|
| 248 |
Now we have a topology built, but we need applications. This section is |
248 |
Now we have a topology built, but we need applications. This section is |
| 249 |
going to be fundamentally similar to the applications section of |
249 |
going to be fundamentally similar to the applications section of |
| 250 |
@code{first.cc} but we are going to instantiate the server on one of the |
250 |
@code{first.cc} but we are going to instantiate the server on one of the |
| 251 |
nodes that has a CSMA node and the client on the node having only a |
251 |
nodes that has a CSMA device and the client on the node having only a |
| 252 |
point-to-point device. |
252 |
point-to-point device. |
| 253 |
|
253 |
|
| 254 |
First, we set up the echo server. We create a @code{UdpEchoServerHelper} and |
254 |
First, we set up the echo server. We create a @code{UdpEchoServerHelper} and |
|
|
| 296 |
Since we have actually built an internetwork here, we need some form of |
296 |
Since we have actually built an internetwork here, we need some form of |
| 297 |
internetwork routing. @command{ns-3} provides what we call a global route |
297 |
internetwork routing. @command{ns-3} provides what we call a global route |
| 298 |
manager to set up the routing tables on nodes. This route manager has a |
298 |
manager to set up the routing tables on nodes. This route manager has a |
| 299 |
global function that runs though the nodes created for the simulation and does |
299 |
global function that runs through the nodes created for the simulation and does |
| 300 |
the hard work of setting up routing for you. |
300 |
the hard work of setting up routing for you. |
| 301 |
|
301 |
|
| 302 |
Basically, what happens is that each node behaves as if it were an OSPF router |
302 |
Basically, what happens is that each node behaves as if it were an OSPF router |
|
|
| 317 |
|
317 |
|
| 318 |
@verbatim |
318 |
@verbatim |
| 319 |
PointToPointHelper::EnablePcapAll ("second"); |
319 |
PointToPointHelper::EnablePcapAll ("second"); |
| 320 |
CsmaHelper::EnablePcap ("second", csmaDevices.Get (0), true); |
320 |
CsmaHelper::EnablePcap ("second", csmaDevices.Get (1), true); |
| 321 |
@end verbatim |
321 |
@end verbatim |
| 322 |
|
322 |
|
| 323 |
The CSMA network is a multi-point-to-point network. This means that there |
323 |
The CSMA network is a multi-point-to-point network. This means that there |
|
|
| 336 |
network and ask it to perform a promiscuous sniff of the network, thereby |
336 |
network and ask it to perform a promiscuous sniff of the network, thereby |
| 337 |
emulating what @code{tcpdump} would do. If you were on a Linux machine |
337 |
emulating what @code{tcpdump} would do. If you were on a Linux machine |
| 338 |
you might do something like @code{tcpdump -i eth0} to get the trace. |
338 |
you might do something like @code{tcpdump -i eth0} to get the trace. |
| 339 |
In this case, we specify the device using @code{csmaDevices.Get(0)}, |
339 |
In this case, we specify the device using @code{csmaDevices.Get(1)}, |
| 340 |
which selects the zeroth device in the container. Setting the final |
340 |
which selects the first device in the container. Setting the final |
| 341 |
parameter to true enables promiscuous captures. |
341 |
parameter to true enables promiscuous captures. |
| 342 |
|
342 |
|
| 343 |
The last section of code just runs and cleans up the simulation just like |
343 |
The last section of code just runs and cleans up the simulation just like |
|
|
| 374 |
@verbatim |
374 |
@verbatim |
| 375 |
export NS_LOG= |
375 |
export NS_LOG= |
| 376 |
./waf --run scratch/mysecond |
376 |
./waf --run scratch/mysecond |
| 377 |
#end verbatim |
377 |
@end verbatim |
| 378 |
|
378 |
|
| 379 |
Since we have set up the UDP echo applications to log just as we did in |
379 |
Since we have set up the UDP echo applications to log just as we did in |
| 380 |
@code{first.cc}, you will see similar output when you run the script. |
380 |
@code{first.cc}, you will see similar output when you run the script. |
|
|
| 395 |
is from the echo client, indicating that it has received its echo back from |
395 |
is from the echo client, indicating that it has received its echo back from |
| 396 |
the server. |
396 |
the server. |
| 397 |
|
397 |
|
| 398 |
If you now go and look in the top level directory, you will find two trace |
398 |
If you now go and look in the top level directory, you will find three trace |
| 399 |
files: |
399 |
files: |
| 400 |
|
400 |
|
| 401 |
@verbatim |
401 |
@verbatim |
|
|
| 648 |
|
648 |
|
| 649 |
To illustrate the difference between promiscuous and non-promiscuous traces, we |
649 |
To illustrate the difference between promiscuous and non-promiscuous traces, we |
| 650 |
also requested a non-promiscuous trace for the next-to-last node. Go ahead and |
650 |
also requested a non-promiscuous trace for the next-to-last node. Go ahead and |
| 651 |
take a look at the @code{tcpdump} for @code{second-10-0.pcap}. |
651 |
take a look at the @code{tcpdump} for @code{second-100-0.pcap}. |
| 652 |
|
652 |
|
| 653 |
@verbatim |
653 |
@verbatim |
| 654 |
tcpdump -nn -tt -r second-100-0.pcap |
654 |
tcpdump -nn -tt -r second-100-0.pcap |
|
|
| 845 |
|
845 |
|
| 846 |
For simplicity, this code uses the default PHY layer configuration and |
846 |
For simplicity, this code uses the default PHY layer configuration and |
| 847 |
channel models which are documented in the API doxygen documentation for |
847 |
channel models which are documented in the API doxygen documentation for |
| 848 |
the @code{YansWifiChannelHelper::Default} and @code{YAnsWifiPhyHelper::Default} |
848 |
the @code{YansWifiChannelHelper::Default} and @code{YansWifiPhyHelper::Default} |
| 849 |
methods. Once these objects are created, we create a channel object |
849 |
methods. Once these objects are created, we create a channel object |
| 850 |
and associate it to our PHY layer object manager to make sure |
850 |
and associate it to our PHY layer object manager to make sure |
| 851 |
that all the PHY objects created layer by the @code{YansWifiPhyHelper} |
851 |
that all the PHY layer objects created by the @code{YansWifiPhyHelper} |
| 852 |
all share the same underlying channel, that is, they share the same |
852 |
share the same underlying channel, that is, they share the same |
| 853 |
wireless medium and can communication and interfere: |
853 |
wireless medium and can communication and interfere: |
| 854 |
|
854 |
|
| 855 |
@verbatim |
855 |
@verbatim |
|
|
| 1108 |
@end verbatim |
1108 |
@end verbatim |
| 1109 |
|
1109 |
|
| 1110 |
The file ``third-0-0.pcap'' corresponds to the point-to-point device on node |
1110 |
The file ``third-0-0.pcap'' corresponds to the point-to-point device on node |
| 1111 |
zero -- the left side of the ``backbone.'' The file ``third-1-0.pcap'' |
1111 |
zero -- the left side of the ``backbone''. The file ``third-1-0.pcap'' |
| 1112 |
corresponds to the point-to-point device on node one -- the right side of the |
1112 |
corresponds to the point-to-point device on node one -- the right side of the |
| 1113 |
``backbone.'' The file ``third-0-1.pcap'' will be the promiscuous (monitor |
1113 |
``backbone''. The file ``third-0-1.pcap'' will be the promiscuous (monitor |
| 1114 |
mode) trace from the Wifi network and the file ``third-1-1.pcap'' will be the |
1114 |
mode) trace from the Wifi network and the file ``third-1-1.pcap'' will be the |
| 1115 |
promiscuous trace from the CSMA network. Can you verify this by inspecting |
1115 |
promiscuous trace from the CSMA network. Can you verify this by inspecting |
| 1116 |
the code? |
1116 |
the code? |
|
|
| 1326 |
@uref{http://www.nsnam.org/doxygen-release/index.html,,ns-3 Doxygen} |
1326 |
@uref{http://www.nsnam.org/doxygen-release/index.html,,ns-3 Doxygen} |
| 1327 |
which you can find in the ``Modules'' tab. |
1327 |
which you can find in the ``Modules'' tab. |
| 1328 |
Under the ``core'' section, you will find a link to ``The list of all trace |
1328 |
Under the ``core'' section, you will find a link to ``The list of all trace |
| 1329 |
sources.'' You may find it interesting to try and hook some of these |
1329 |
sources.''. You may find it interesting to try and hook some of these |
| 1330 |
traces yourself. Additionally in the ``Modules'' documentation, there is |
1330 |
traces yourself. Additionally in the ``Modules'' documentation, there is |
| 1331 |
a link to ``The list of all attributes.'' You can set the default value of |
1331 |
a link to ``The list of all attributes.''. You can set the default value of |
| 1332 |
any of these @code{Attributes} via the command line as we have previously |
1332 |
any of these @code{Attributes} via the command line as we have previously |
| 1333 |
discussed. |
1333 |
discussed. |
| 1334 |
|
1334 |
|