|
|
| 133 |
p2pNodes.Create (2); |
133 |
p2pNodes.Create (2); |
| 134 |
@end verbatim |
134 |
@end verbatim |
| 135 |
|
135 |
|
| 136 |
Next, we delare another @code{NodeContainer} to hold the nodes that will be |
136 |
Next, we declare another @code{NodeContainer} to hold the nodes that will be |
| 137 |
part of the bus (CSMA) network. First, we just instantiate the container |
137 |
part of the bus (CSMA) network. First, we just instantiate the container |
| 138 |
object itself. |
138 |
object itself. |
| 139 |
|
139 |
|
|
|
| 171 |
channels, and the next lines introduce them. The @code{CsmaHelper} works just |
171 |
channels, and the next lines introduce them. The @code{CsmaHelper} works just |
| 172 |
like a @code{PointToPointHelper}, but it creates and connects CSMA devices and |
172 |
like a @code{PointToPointHelper}, but it creates and connects CSMA devices and |
| 173 |
channels. In the case of a CSMA device and channel pair, notice that the data |
173 |
channels. In the case of a CSMA device and channel pair, notice that the data |
| 174 |
rate is specified by a @em{channel} attribute instead of a device attribute. |
174 |
rate is specified by a @emph{channel} attribute instead of a device attribute. |
| 175 |
This is because a real CSMA network does not allow one to mix, for example, |
175 |
This is because a real CSMA network does not allow one to mix, for example, |
| 176 |
10Base-T and 100Base-T devices on a given channel. We first set the data rate |
176 |
10Base-T and 100Base-T devices on a given channel. We first set the data rate |
| 177 |
to 100 megabits per second, and then set the speed-of-light delay of the channel |
177 |
to 100 megabits per second, and then set the speed-of-light delay of the channel |
|
|
| 260 |
Recall that the @code{csmaNodes NodeContainer} contains one of the |
260 |
Recall that the @code{csmaNodes NodeContainer} contains one of the |
| 261 |
nodes created for the point-to-point network and @code{nCsma} ``extra'' nodes. |
261 |
nodes created for the point-to-point network and @code{nCsma} ``extra'' nodes. |
| 262 |
What we want to get at is the last of the ``extra'' nodes. The zeroth entry of |
262 |
What we want to get at is the last of the ``extra'' nodes. The zeroth entry of |
| 263 |
the @code{csmaNodes} container will the the point-to-point node. The easy |
263 |
the @code{csmaNodes} container will be the point-to-point node. The easy |
| 264 |
way to think of this, then, is if we create one ``extra'' CSMA node, then it |
264 |
way to think of this, then, is if we create one ``extra'' CSMA node, then it |
| 265 |
will be be at index one of the @code{csmaNodes} container. By induction, |
265 |
will be at index one of the @code{csmaNodes} container. By induction, |
| 266 |
if we create @code{nCsma} ``extra'' nodes the last one will be at index |
266 |
if we create @code{nCsma} ``extra'' nodes the last one will be at index |
| 267 |
@code{nCsma}. You see this exhibited in the @code{Get} of the first line of |
267 |
@code{nCsma}. You see this exhibited in the @code{Get} of the first line of |
| 268 |
code. |
268 |
code. |
|
|
| 367 |
|
367 |
|
| 368 |
Now look at @code{second-1-0.pcap} and @code{second-1-1.pcap}. The former is |
368 |
Now look at @code{second-1-0.pcap} and @code{second-1-1.pcap}. The former is |
| 369 |
the pcap trace for device zero on node one and the latter is the trace file |
369 |
the pcap trace for device zero on node one and the latter is the trace file |
| 370 |
for device one on node one. If you refer back to the topology illustrration at |
370 |
for device one on node one. If you refer back to the topology illustration at |
| 371 |
the start of the section, you will see that node one is the node that has |
371 |
the start of the section, you will see that node one is the node that has |
| 372 |
both a point-to-point device and a CSMA device, so we should expect two pcap |
372 |
both a point-to-point device and a CSMA device, so we should expect two pcap |
| 373 |
traces for that node. |
373 |
traces for that node. |
|
|
| 416 |
~/repos/ns-3-dev > |
416 |
~/repos/ns-3-dev > |
| 417 |
@end verbatim |
417 |
@end verbatim |
| 418 |
|
418 |
|
| 419 |
As you can see, the link type is now ``Ethernet.'' Something new has appeared, |
419 |
As you can see, the link type is now ``Ethernet''. Something new has appeared, |
| 420 |
though. The bus network needs @code{ARP}, the Address Resolution Protocol. |
420 |
though. The bus network needs @code{ARP}, the Address Resolution Protocol. |
| 421 |
The node knows it needs to send the packet to IP address 10.1.2.4, but it |
421 |
The node knows it needs to send the packet to IP address 10.1.2.4, but it |
| 422 |
doesn't know the MAC address of the corresponding node. It broadcasts on the |
422 |
doesn't know the MAC address of the corresponding node. It broadcasts on the |
|
|
| 445 |
~/repos/ns-3-dev > |
445 |
~/repos/ns-3-dev > |
| 446 |
@end verbatim |
446 |
@end verbatim |
| 447 |
|
447 |
|
| 448 |
Again, you see that the link type is ``Ethernet.'' The first two entries are |
448 |
Again, you see that the link type is ``Ethernet''. The first two entries are |
| 449 |
the ARP exchange we just explained. The third packet is the echo packet |
449 |
the ARP exchange we just explained. The third packet is the echo packet |
| 450 |
being delivered to its final destination. |
450 |
being delivered to its final destination. |
| 451 |
|
451 |
|
|
|
| 706 |
p2pDevices = pointToPoint.Install (p2pNodes); |
706 |
p2pDevices = pointToPoint.Install (p2pNodes); |
| 707 |
@end verbatim |
707 |
@end verbatim |
| 708 |
|
708 |
|
| 709 |
Next, we delare another @code{NodeContainer} to hold the nodes that will be |
709 |
Next, we declare another @code{NodeContainer} to hold the nodes that will be |
| 710 |
part of the bus (CSMA) network. |
710 |
part of the bus (CSMA) network. |
| 711 |
|
711 |
|
| 712 |
@verbatim |
712 |
@verbatim |
|
|
| 835 |
Now, we are going to add mobility models. We want the STA nodes to be mobile, |
835 |
Now, we are going to add mobility models. We want the STA nodes to be mobile, |
| 836 |
wandering around inside a bounding box, and we want to make the AP node |
836 |
wandering around inside a bounding box, and we want to make the AP node |
| 837 |
stationary. We use the @code{MobilityHelper} to make this easy for us. |
837 |
stationary. We use the @code{MobilityHelper} to make this easy for us. |
| 838 |
First, we instantiate a @code{MobilityHelper} obejct and set some attributes |
838 |
First, we instantiate a @code{MobilityHelper} object and set some attributes |
| 839 |
controlling the ``position allocator'' functionality. |
839 |
controlling the ``position allocator'' functionality. |
| 840 |
|
840 |
|
| 841 |
@verbatim |
841 |
@verbatim |
|
|
| 854 |
place the STA nodes. Feel free to explore the Doxygen for class |
854 |
place the STA nodes. Feel free to explore the Doxygen for class |
| 855 |
@code{ns3::GridPositionAllocator} to see exactly what is being done. |
855 |
@code{ns3::GridPositionAllocator} to see exactly what is being done. |
| 856 |
|
856 |
|
| 857 |
We have aranged our nodes on an initial grid, but now we need to tell them |
857 |
We have arranged our nodes on an initial grid, but now we need to tell them |
| 858 |
how to move. We choose the @code{RandomWalk2dMobilityModel} which has the |
858 |
how to move. We choose the @code{RandomWalk2dMobilityModel} which has the |
| 859 |
nodes move in a random direction at a random speed around inside a bounding |
859 |
nodes move in a random direction at a random speed around inside a bounding |
| 860 |
box. |
860 |
box. |
|
|
| 896 |
@code{Ipv4AddressHelper} to assign IP addresses to our device interfaces. |
896 |
@code{Ipv4AddressHelper} to assign IP addresses to our device interfaces. |
| 897 |
First we use the network 10.1.1.0 to create the two addresses needed for our |
897 |
First we use the network 10.1.1.0 to create the two addresses needed for our |
| 898 |
two point-to-point devices. Then we use network 10.1.2.0 to assign addresses |
898 |
two point-to-point devices. Then we use network 10.1.2.0 to assign addresses |
| 899 |
the the CSMA network and then we assign addresses from network 10.1.3.0 to |
899 |
to the CSMA network and then we assign addresses from network 10.1.3.0 to |
| 900 |
both the STA devices and the AP on the wireless network. |
900 |
both the STA devices and the AP on the wireless network. |
| 901 |
|
901 |
|
| 902 |
@verbatim |
902 |
@verbatim |
|
|
| 941 |
clientApps.Stop (Seconds (10.0)); |
941 |
clientApps.Stop (Seconds (10.0)); |
| 942 |
@end verbatim |
942 |
@end verbatim |
| 943 |
|
943 |
|
| 944 |
Since we have built an internetwork here, we need enable internetwork routing |
944 |
Since we have built an internetwork here, we need to enable internetwork routing |
| 945 |
just as we did in the @code{second.cc} example script. |
945 |
just as we did in the @code{second.cc} example script. |
| 946 |
|
946 |
|
| 947 |
@verbatim |
947 |
@verbatim |