author | Craig Dowell <craigdo@ee.washington.edu> |
Sun, 12 Aug 2007 22:41:24 -0700 | |
changeset 1430 | 25fa26a6533e |
parent 1429 | 31cb0668defd |
child 1432 | 3aef7d7a71c2 |
permissions | -rw-r--r-- |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
*/ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
// Network topology |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
// |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
// n0 n1 n2 n3 |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
// | | | | |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
// ===================== |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
// |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
// - CBR/UDP flows from n0 to n1, and from n3 to n0 |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
// (i.e., DataRate of 448,000 bps) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// - DropTail queues |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// - Tracing of queues and packet receptions to file "csma-one-subnet.tr" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
#include <iostream> |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
#include <fstream> |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
#include <string> |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
#include <cassert> |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
#include "ns3/command-line.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
#include "ns3/default-value.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
#include "ns3/ptr.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
#include "ns3/random-variable.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
#include "ns3/debug.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
#include "ns3/simulator.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
#include "ns3/nstime.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
#include "ns3/data-rate.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
#include "ns3/ascii-trace.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
#include "ns3/pcap-trace.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
#include "ns3/internet-node.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
#include "ns3/csma-channel.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
#include "ns3/csma-net-device.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
#include "ns3/csma-topology.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
#include "ns3/csma-ipv4-topology.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
#include "ns3/eui48-address.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
#include "ns3/ipv4-address.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
#include "ns3/inet-socket-address.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
#include "ns3/ipv4.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
#include "ns3/socket.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
#include "ns3/ipv4-route.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
#include "ns3/onoff-application.h" |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
using namespace ns3; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
|
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
61 |
NS_DEBUG_COMPONENT_DEFINE ("Me"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
62 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
int |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
main (int argc, char *argv[]) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
// Users may find it convenient to turn on explicit debugging |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
// for selected modules; the below lines suggest how to do this |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
#if 0 |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
69 |
DebugComponentEnable("Me"); |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
70 |
DebugComponentEnable("Object"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
71 |
DebugComponentEnable("Queue"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
72 |
DebugComponentEnable("DropTailQueue"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
73 |
DebugComponentEnable("Channel"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
74 |
DebugComponentEnable("CsmaChannel"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
DebugComponentEnable("CsmaNetDevice"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
DebugComponentEnable("Ipv4L3Protocol"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
DebugComponentEnable("NetDevice"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
DebugComponentEnable("PacketSocket"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
79 |
DebugComponentEnable("OnOffApplication"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
80 |
DebugComponentEnable("UdpSocket"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
81 |
DebugComponentEnable("UdpL4Protocol"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
82 |
DebugComponentEnable("Ipv4L3Protocol"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
83 |
DebugComponentEnable("Ipv4StaticRouting"); |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
84 |
DebugComponentEnable("Ipv4Interface"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
85 |
DebugComponentEnable("ArpIpv4Interface"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
86 |
DebugComponentEnable("Ipv4LoopbackInterface"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
#endif |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
|
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
89 |
DebugComponentEnable("Me"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
90 |
DebugComponentEnable("OnOffApplication"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
91 |
DebugComponentEnable("UdpSocket"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
92 |
DebugComponentEnable("UdpL4Protocol"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
93 |
DebugComponentEnable("Ipv4L3Protocol"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
94 |
DebugComponentEnable("Ipv4StaticRouting"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
95 |
DebugComponentEnable("CsmaNetDevice"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
96 |
DebugComponentEnable("CsmaChannel"); |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
97 |
DebugComponentEnable("Ipv4Interface"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
98 |
DebugComponentEnable("ArpIpv4Interface"); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
99 |
DebugComponentEnable("Ipv4LoopbackInterface"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
100 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
// Set up some default values for the simulation. Use the Bind() |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
// technique to tell the system what subclass of Queue to use, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
// and what the queue limit is |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
// The below Bind command tells the queue factory which class to |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
// instantiate, when the queue factory is invoked in the topology code |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
DefaultValue::Bind ("Queue", "DropTailQueue"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
// Allow the user to override any of the defaults and the above |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
// Bind()s at run-time, via command-line arguments |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
CommandLine::Parse (argc, argv); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
// Here, we will explicitly create four nodes. In more sophisticated |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
// topologies, we could configure a node factory. |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
115 |
NS_DEBUG("Create nodes."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
Ptr<Node> n0 = Create<InternetNode> (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
Ptr<Node> n1 = Create<InternetNode> (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
Ptr<Node> n2 = Create<InternetNode> (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
Ptr<Node> n3 = Create<InternetNode> (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
|
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
121 |
NS_DEBUG("Create channels."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
// We create the channels first without any IP addressing information |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
Ptr<CsmaChannel> channel0 = |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
CsmaTopology::CreateCsmaChannel( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
DataRate(5000000), MilliSeconds(2)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
|
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
127 |
NS_DEBUG("Build Topology."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
uint32_t n0ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n0, channel0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
Eui48Address("10:54:23:54:23:50")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
uint32_t n1ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n1, channel0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
Eui48Address("10:54:23:54:23:51")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
uint32_t n2ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n2, channel0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
Eui48Address("10:54:23:54:23:52")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
uint32_t n3ifIndex = CsmaIpv4Topology::AddIpv4CsmaNode (n3, channel0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
Eui48Address("10:54:23:54:23:53")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
// Later, we add IP addresses. |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
138 |
NS_DEBUG("Assign IP Addresses."); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
139 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
CsmaIpv4Topology::AddIpv4Address ( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
n0, n0ifIndex, Ipv4Address("10.1.1.1"), Ipv4Mask("255.255.255.0")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
CsmaIpv4Topology::AddIpv4Address ( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
n1, n1ifIndex, Ipv4Address("10.1.1.2"), Ipv4Mask("255.255.255.0")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
CsmaIpv4Topology::AddIpv4Address ( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
n2, n2ifIndex, Ipv4Address("10.1.1.3"), Ipv4Mask("255.255.255.0")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
CsmaIpv4Topology::AddIpv4Address ( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
n3, n3ifIndex, Ipv4Address("10.1.1.4"), Ipv4Mask("255.255.255.0")); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
// Configure multicasting |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
153 |
NS_DEBUG("Configure multicasting."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
Ipv4Address multicastSource ("10.1.1.1"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
Ipv4Address multicastGroup ("225.0.0.0"); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
Ptr<Ipv4> ipv4; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
std::vector<uint32_t> outputInterfaces (1); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
outputInterfaces[0] = n0ifIndex; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
ipv4->AddMulticastRoute (multicastSource, multicastGroup, 0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
164 |
outputInterfaces); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
165 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
166 |
ipv4 = n1->QueryInterface<Ipv4> (Ipv4::iid); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
167 |
ipv4->JoinMulticastGroup (multicastSource, multicastGroup); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
ipv4 = n2->QueryInterface<Ipv4> (Ipv4::iid); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
ipv4->JoinMulticastGroup (multicastSource, multicastGroup); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
ipv4->JoinMulticastGroup (multicastSource, multicastGroup); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
// Create the OnOff application to send UDP datagrams of size |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
// 210 bytes at a rate of 448 Kb/s |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
177 |
// from n0 to the multicast group |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
178 |
NS_DEBUG("Create Applications."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
Ptr<OnOffApplication> ooff = Create<OnOffApplication> ( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
n0, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
InetSocketAddress (multicastGroup, 80), |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
"Udp", |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
183 |
ConstantVariable(1), |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
ConstantVariable(0)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
185 |
// Start the application |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
186 |
ooff->Start(Seconds(1.0)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
187 |
ooff->Stop (Seconds(10.0)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
// Configure tracing of all enqueue, dequeue, and NetDevice receive events |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
190 |
// Trace output will be sent to the csma-one-subnet.tr file |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
191 |
NS_DEBUG("Configure Tracing."); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
192 |
AsciiTrace asciitrace ("csma-multicast.tr"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
asciitrace.TraceAllNetDeviceRx (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
asciitrace.TraceAllQueues (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
196 |
// Also configure some tcpdump traces; each interface will be traced |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
197 |
// The output files will be named |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
// simple-point-to-point.pcap-<nodeId>-<interfaceId> |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
199 |
// and can be read by the "tcpdump -r" command (use "-tt" option to |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
200 |
// display timestamps correctly) |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
201 |
PcapTrace pcaptrace ("csma-multicast.pcap"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
pcaptrace.TraceAllIp (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
203 |
|
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
204 |
NS_DEBUG("Run Simulation."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
205 |
Simulator::Run (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
206 |
Simulator::Destroy (); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
207 |
NS_DEBUG("Done."); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
} |