|
|
| 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 |
/* |
2 |
/* |
| 3 |
* This program is free software; you can redistribute it and/or modify |
3 |
* This program is free software; you can redistribute it and/or modify |
| 4 |
* it under the terms of the GNU General Public License version 2 as |
4 |
* it under the terms of the GNU General Public License version 2 as |
| 5 |
* published by the Free Software Foundation; |
5 |
* published by the Free Software Foundation; |
| 6 |
* |
6 |
* |
| 7 |
* This program is distributed in the hope that it will be useful, |
7 |
* This program is distributed in the hope that it will be useful, |
| 8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 |
* GNU General Public License for more details. |
10 |
* GNU General Public License for more details. |
| 11 |
* |
11 |
* |
| 12 |
* You should have received a copy of the GNU General Public License |
12 |
* You should have received a copy of the GNU General Public License |
| 13 |
* along with this program; if not, write to the Free Software |
13 |
* along with this program; if not, write to the Free Software |
| 14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 15 |
* |
15 |
* |
| 16 |
* (c) 2009, GTech Systems, Inc. - Alfred Park <park@gtech-systems.com> |
16 |
* (c) 2009, GTech Systems, Inc. - Alfred Park <park@gtech-systems.com> |
| 17 |
* |
17 |
* |
| 18 |
* DARPA NMS Campus Network Model |
18 |
* DARPA NMS Campus Network Model |
| 19 |
* |
19 |
* |
| 20 |
* This topology replicates the original NMS Campus Network model |
20 |
* This topology replicates the original NMS Campus Network model |
| 21 |
* with the exception of chord links (which were never utilized in the |
21 |
* with the exception of chord links (which were never utilized in the |
| 22 |
* original model) |
22 |
* original model) |
| 23 |
* Link Bandwidths and Delays may not be the same as the original |
23 |
* Link Bandwidths and Delays may not be the same as the original |
| 24 |
* specifications |
24 |
* specifications |
| 25 |
* |
25 |
* |
| 26 |
* Modified for distributed simulation by Josh Pelkey <jpelkey@gatech.edu> |
26 |
* Modified for distributed simulation by Josh Pelkey <jpelkey@gatech.edu> |
| 27 |
* |
27 |
* |
| 28 |
* The fundamental unit of the NMS model consists of a campus network. The |
28 |
* The fundamental unit of the NMS model consists of a campus network. The |
| 29 |
* campus network topology can been seen here: |
29 |
* campus network topology can been seen here: |
| 30 |
* http://www.nsnam.org/~jpelkey3/nms.png |
30 |
* http://www.nsnam.org/~jpelkey3/nms.png |
| 31 |
* The number of hosts (default 42) is variable. Finally, an arbitrary |
31 |
* The number of hosts (default 42) is variable. Finally, an arbitrary |
| 32 |
* number of these campus networks can be connected together (default 2) |
32 |
* number of these campus networks can be connected together (default 2) |
| 33 |
* to make very large simulations. |
33 |
* to make very large simulations. |
| 34 |
*/ |
34 |
*/ |
| 35 |
|
35 |
|
| 36 |
// for timing functions |
36 |
// for timing functions |
| 37 |
#include <cstdlib> |
37 |
#include <cstdlib> |
| 38 |
#include <sys/time.h> |
38 |
#include <sys/time.h> |
| 39 |
#include <fstream> |
39 |
#include <fstream> |
| 40 |
|
40 |
#include <vector> |
| 41 |
#include "ns3/core-module.h" |
41 |
#include "ns3/core-module.h" |
| 42 |
#include "ns3/internet-module.h" |
42 |
#include "ns3/internet-module.h" |
| 43 |
#include "ns3/network-module.h" |
43 |
#include "ns3/network-module.h" |
| 44 |
#include "ns3/on-off-helper.h" |
44 |
#include "ns3/on-off-helper.h" |
| 45 |
#include "ns3/packet-sink-helper.h" |
45 |
#include "ns3/packet-sink-helper.h" |
| 46 |
#include "ns3/point-to-point-helper.h" |
46 |
#include "ns3/point-to-point-helper.h" |
| 47 |
#include "ns3/mpi-interface.h" |
47 |
#include "ns3/mpi-interface.h" |
| 48 |
#include "ns3/ipv4-static-routing-helper.h" |
48 |
#include "ns3/ipv4-static-routing-helper.h" |
| 49 |
#include "ns3/ipv4-list-routing-helper.h" |
49 |
#include "ns3/ipv4-list-routing-helper.h" |
| 50 |
#include "ns3/ipv4-nix-vector-helper.h" |
50 |
#include "ns3/ipv4-nix-vector-helper.h" |
| 51 |
|
51 |
|
| 52 |
#ifdef NS3_MPI |
52 |
#ifdef NS3_MPI |
| 53 |
#include <mpi.h> |
53 |
#include <mpi.h> |
| 54 |
#endif |
54 |
#endif |
| 55 |
|
55 |
|
| 56 |
using namespace ns3; |
56 |
using namespace ns3; |
| 57 |
|
57 |
using namespace std; |
| 58 |
typedef struct timeval TIMER_TYPE; |
58 |
|
| 59 |
#define TIMER_NOW(_t) gettimeofday (&_t,NULL); |
59 |
typedef struct timeval TIMER_TYPE; |
| 60 |
#define TIMER_SECONDS(_t) ((double)(_t).tv_sec + (_t).tv_usec * 1e-6) |
60 |
#define TIMER_NOW(_t) gettimeofday (&_t,NULL); |
| 61 |
#define TIMER_DIFF(_t1, _t2) (TIMER_SECONDS (_t1) - TIMER_SECONDS (_t2)) |
61 |
#define TIMER_SECONDS(_t) ((double)(_t).tv_sec + (_t).tv_usec * 1e-6) |
| 62 |
|
62 |
#define TIMER_DIFF(_t1, _t2) (TIMER_SECONDS (_t1) - TIMER_SECONDS (_t2)) |
| 63 |
NS_LOG_COMPONENT_DEFINE ("CampusNetworkModelDistributed"); |
63 |
|
| 64 |
|
64 |
NS_LOG_COMPONENT_DEFINE ("CampusNetworkModelDistributed"); |
| 65 |
int |
65 |
|
| 66 |
main (int argc, char *argv[]) |
66 |
int |
| 67 |
{ |
67 |
main (int argc, char *argv[]) |
| 68 |
#ifdef NS3_MPI |
68 |
{ |
| 69 |
// Enable MPI with the command line arguments |
69 |
#ifdef NS3_MPI |
| 70 |
MpiInterface::Enable (&argc, &argv); |
70 |
// Enable MPI with the command line arguments |
| 71 |
|
71 |
MpiInterface::Enable (&argc, &argv); |
| 72 |
TIMER_TYPE t0, t1, t2; |
72 |
|
| 73 |
TIMER_NOW (t0); |
73 |
TIMER_TYPE t0, t1, t2; |
| 74 |
std::cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl; |
74 |
TIMER_NOW (t0); |
| 75 |
|
75 |
std::cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl; |
| 76 |
GlobalValue::Bind ("SimulatorImplementationType", |
76 |
|
| 77 |
StringValue ("ns3::DistributedSimulatorImpl")); |
77 |
GlobalValue::Bind ("SimulatorImplementationType", |
| 78 |
|
78 |
StringValue ("ns3::DistributedSimulatorImpl")); |
| 79 |
uint32_t systemId = MpiInterface::GetSystemId (); |
79 |
|
| 80 |
uint32_t systemCount = MpiInterface::GetSize (); |
80 |
int systemId = MpiInterface::GetSystemId (); |
| 81 |
|
81 |
int systemCount = MpiInterface::GetSize (); |
| 82 |
//temporary fix see bug 1560 |
82 |
|
| 83 |
#define nCN (2) |
83 |
//temporary fix see bug 1560 |
| 84 |
#define nLANClients (42) |
84 |
//#define nCN (2) |
| 85 |
//uint32_t nCN = 2, nLANClients = 42; |
85 |
//#define nLANClients (42) |
| 86 |
int32_t single = 0; |
86 |
//int nCN = 2, nLANClients = 42; |
| 87 |
int nBytes = 500000; // Bytes for each on/off app |
87 |
int nCN=2; |
| 88 |
bool nix = true; |
88 |
int nLANClients=42; |
| 89 |
|
89 |
int single = 0; |
| 90 |
CommandLine cmd; |
90 |
int nBytes = 500000; // Bytes for each on/off app |
| 91 |
//cmd.AddValue ("CN", "Number of total CNs [2]", nCN); |
91 |
bool nix = true; |
| 92 |
//cmd.AddValue ("LAN", "Number of nodes per LAN [42]", nLANClients); |
92 |
|
| 93 |
cmd.AddValue ("single", "1 if use single flow", single); |
93 |
CommandLine cmd; |
| 94 |
cmd.AddValue ("nBytes", "Number of bytes for each on/off app", nBytes); |
94 |
cmd.AddValue ("CN", "Number of total CNs [2]", nCN); |
| 95 |
cmd.AddValue ("nix", "Toggle the use of nix-vector or global routing", nix); |
95 |
cmd.AddValue ("LAN", "Number of nodes per LAN [42]", nLANClients); |
| 96 |
cmd.Parse (argc,argv); |
96 |
cmd.AddValue ("single", "1 if use single flow", single); |
| 97 |
|
97 |
cmd.AddValue ("nBytes", "Number of bytes for each on/off app", nBytes); |
| 98 |
if (nCN < 2) |
98 |
cmd.AddValue ("nix", "Toggle the use of nix-vector or global routing", nix); |
| 99 |
{ |
99 |
cmd.Parse (argc,argv); |
| 100 |
std::cout << "Number of total CNs (" << nCN << ") lower than minimum of 2" |
100 |
|
| 101 |
<< std::endl; |
101 |
if (nCN < 2) |
| 102 |
return 1; |
102 |
{ |
| 103 |
} |
103 |
std::cout << "Number of total CNs (" << nCN << ") lower than minimum of 2" |
| 104 |
if (systemCount > nCN) |
104 |
<< std::endl; |
| 105 |
{ |
105 |
return 1; |
| 106 |
std::cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" |
106 |
} |
| 107 |
<< systemCount << ")." << std::endl; |
107 |
if (systemCount > nCN) |
| 108 |
return 1; |
108 |
{ |
| 109 |
} |
109 |
std::cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" |
| 110 |
|
110 |
<< systemCount << ")." << std::endl; |
| 111 |
std::cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << std::endl; |
111 |
return 1; |
| 112 |
|
112 |
} |
| 113 |
NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], |
113 |
|
| 114 |
nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], |
114 |
std::cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << std::endl; |
| 115 |
nodes_net3[nCN][9], nodes_net3LAN[nCN][5][nLANClients]; |
115 |
/*added by Zeheng Chen |
| 116 |
PointToPointHelper p2p_2gb200ms, p2p_1gb5ms, p2p_100mb1ms; |
116 |
Original: |
| 117 |
InternetStackHelper stack; |
117 |
NodeContainer nodes_net0[nCN][3]; |
| 118 |
Ipv4InterfaceContainer ifs, ifs0[nCN][3], ifs1[nCN][6], ifs2[nCN][14], |
118 |
NodeContainer nodes_net1[nCN][6]; |
| 119 |
ifs3[nCN][9], ifs2LAN[nCN][7][nLANClients], |
119 |
NodeContainer nodes_netLR[nCN]; |
| 120 |
ifs3LAN[nCN][5][nLANClients]; |
120 |
NodeContainer nodes_net2[nCN][14]; |
| 121 |
Ipv4AddressHelper address; |
121 |
NodeContainer nodes_net2LAN[nCN][7][nLANClients]; |
| 122 |
std::ostringstream oss; |
122 |
NodeContainer nodes_net3[nCN][9]; |
| 123 |
p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); |
123 |
NodeContainer nodes_net3LAN[nCN][5][nLANClients]; |
| 124 |
p2p_1gb5ms.SetChannelAttribute ("Delay", StringValue ("5ms")); |
124 |
|
| 125 |
p2p_2gb200ms.SetDeviceAttribute ("DataRate", StringValue ("2Gbps")); |
125 |
*/ |
| 126 |
p2p_2gb200ms.SetChannelAttribute ("Delay", StringValue ("200ms")); |
126 |
typedef vector<NodeContainer> vectorOfNodeContainer; |
| 127 |
p2p_100mb1ms.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
127 |
typedef vector<vectorOfNodeContainer> vectorOfVectorOfNodeContainer; |
| 128 |
p2p_100mb1ms.SetChannelAttribute ("Delay", StringValue ("1ms")); |
128 |
typedef vector<vectorOfVectorOfNodeContainer> vectorOfVectorOfVectorOfNodeContainer; |
| 129 |
|
129 |
|
| 130 |
Ipv4NixVectorHelper nixRouting; |
130 |
vectorOfNodeContainer nodes_netLR(nCN); |
| 131 |
Ipv4StaticRoutingHelper staticRouting; |
131 |
vectorOfVectorOfNodeContainer nodes_net0(nCN,vectorOfNodeContainer(3)); |
| 132 |
|
132 |
vectorOfVectorOfNodeContainer nodes_net1(nCN,vectorOfNodeContainer(6)); |
| 133 |
Ipv4ListRoutingHelper list; |
133 |
vectorOfVectorOfNodeContainer nodes_net2(nCN,vectorOfNodeContainer(14)); |
| 134 |
list.Add (staticRouting, 0); |
134 |
vectorOfVectorOfNodeContainer nodes_net3(nCN,vectorOfNodeContainer(9)); |
| 135 |
list.Add (nixRouting, 10); |
135 |
|
| 136 |
|
136 |
vectorOfVectorOfVectorOfNodeContainer nodes_net2LAN(nCN,vectorOfVectorOfNodeContainer(7,vectorOfNodeContainer(nLANClients))); |
| 137 |
if (nix) |
137 |
vectorOfVectorOfVectorOfNodeContainer nodes_net3LAN(nCN,vectorOfVectorOfNodeContainer(5,vectorOfNodeContainer(nLANClients))); |
| 138 |
{ |
138 |
|
| 139 |
stack.SetRoutingHelper (list); // has effect on the next Install () |
139 |
|
| 140 |
} |
140 |
|
| 141 |
|
141 |
PointToPointHelper p2p_2gb200ms, p2p_1gb5ms, p2p_100mb1ms; |
| 142 |
// Create Campus Networks |
142 |
InternetStackHelper stack; |
| 143 |
for (uint32_t z = 0; z < nCN; ++z) |
143 |
/*added by Zeheng Chen |
| 144 |
{ |
144 |
Original: |
| 145 |
std::cout << "Creating Campus Network " << z << ":" << std::endl; |
145 |
Ipv4InterfaceContainer ifs0[nCN][3]; |
| 146 |
// Create Net0 |
146 |
Ipv4InterfaceContainer ifs1[nCN][6]; |
| 147 |
std::cout << " SubNet [ 0"; |
147 |
Ipv4InterfaceContainer ifs2[nCN][14]; |
| 148 |
for (int i = 0; i < 3; ++i) |
148 |
Ipv4InterfaceContainer ifs3[nCN][9]; |
| 149 |
{ |
149 |
Ipv4InterfaceContainer ifs2LAN[nCN][7][nLANClients]; |
| 150 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
150 |
Ipv4InterfaceContainer ifs3LAN[nCN][5][nLANClients]; |
| 151 |
nodes_net0[z][i].Add (node); |
151 |
|
| 152 |
stack.Install (nodes_net0[z][i]); |
152 |
*/ |
| 153 |
} |
153 |
typedef vector<Ipv4InterfaceContainer> vectorOfIpv4InterfaceContainer; |
| 154 |
nodes_net0[z][0].Add (nodes_net0[z][1].Get (0)); |
154 |
typedef vector<vectorOfIpv4InterfaceContainer> vectorOfVectorOfIpv4InterfaceContainer; |
| 155 |
nodes_net0[z][1].Add (nodes_net0[z][2].Get (0)); |
155 |
typedef vector<vectorOfVectorOfIpv4InterfaceContainer> vectorOfVectorOfVectorOfIpv4InterfaceContainer; |
| 156 |
nodes_net0[z][2].Add (nodes_net0[z][0].Get (0)); |
156 |
|
| 157 |
NetDeviceContainer ndc0[3]; |
157 |
Ipv4InterfaceContainer ifs; |
| 158 |
for (int i = 0; i < 3; ++i) |
158 |
|
| 159 |
{ |
159 |
vectorOfVectorOfIpv4InterfaceContainer ifs0(nCN,vectorOfIpv4InterfaceContainer(3)); |
| 160 |
ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]); |
160 |
vectorOfVectorOfIpv4InterfaceContainer ifs1(nCN,vectorOfIpv4InterfaceContainer(6)); |
| 161 |
} |
161 |
vectorOfVectorOfIpv4InterfaceContainer ifs2(nCN,vectorOfIpv4InterfaceContainer(14)); |
| 162 |
// Create Net1 |
162 |
vectorOfVectorOfIpv4InterfaceContainer ifs3(nCN,vectorOfIpv4InterfaceContainer(9)); |
| 163 |
std::cout << " 1"; |
163 |
vectorOfVectorOfVectorOfIpv4InterfaceContainer ifs2LAN(nCN,vectorOfVectorOfIpv4InterfaceContainer(7,vectorOfIpv4InterfaceContainer(nLANClients))); |
| 164 |
for (int i = 0; i < 6; ++i) |
164 |
vectorOfVectorOfVectorOfIpv4InterfaceContainer ifs3LAN(nCN,vectorOfVectorOfIpv4InterfaceContainer(5,vectorOfIpv4InterfaceContainer(nLANClients))); |
| 165 |
{ |
165 |
|
| 166 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
166 |
Ipv4AddressHelper address; |
| 167 |
nodes_net1[z][i].Add (node); |
167 |
std::ostringstream oss; |
| 168 |
stack.Install (nodes_net1[z][i]); |
168 |
p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); |
| 169 |
} |
169 |
p2p_1gb5ms.SetChannelAttribute ("Delay", StringValue ("5ms")); |
| 170 |
nodes_net1[z][0].Add (nodes_net1[z][1].Get (0)); |
170 |
p2p_2gb200ms.SetDeviceAttribute ("DataRate", StringValue ("2Gbps")); |
| 171 |
nodes_net1[z][2].Add (nodes_net1[z][0].Get (0)); |
171 |
p2p_2gb200ms.SetChannelAttribute ("Delay", StringValue ("200ms")); |
| 172 |
nodes_net1[z][3].Add (nodes_net1[z][0].Get (0)); |
172 |
p2p_100mb1ms.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
| 173 |
nodes_net1[z][4].Add (nodes_net1[z][1].Get (0)); |
173 |
p2p_100mb1ms.SetChannelAttribute ("Delay", StringValue ("1ms")); |
| 174 |
nodes_net1[z][5].Add (nodes_net1[z][1].Get (0)); |
174 |
|
| 175 |
NetDeviceContainer ndc1[6]; |
175 |
Ipv4NixVectorHelper nixRouting; |
| 176 |
for (int i = 0; i < 6; ++i) |
176 |
Ipv4StaticRoutingHelper staticRouting; |
| 177 |
{ |
177 |
|
| 178 |
if (i == 1) |
178 |
Ipv4ListRoutingHelper list; |
| 179 |
{ |
179 |
list.Add (staticRouting, 0); |
| 180 |
continue; |
180 |
list.Add (nixRouting, 10); |
| 181 |
} |
181 |
|
| 182 |
ndc1[i] = p2p_1gb5ms.Install (nodes_net1[z][i]); |
182 |
if (nix) |
| 183 |
} |
183 |
{ |
| 184 |
// Connect Net0 <-> Net1 |
184 |
stack.SetRoutingHelper (list); // has effect on the next Install () |
| 185 |
NodeContainer net0_1; |
185 |
} |
| 186 |
net0_1.Add (nodes_net0[z][2].Get (0)); |
186 |
|
| 187 |
net0_1.Add (nodes_net1[z][0].Get (0)); |
187 |
// Create Campus Networks |
| 188 |
NetDeviceContainer ndc0_1; |
188 |
for (int z = 0; z < nCN; ++z) |
| 189 |
ndc0_1 = p2p_1gb5ms.Install (net0_1); |
189 |
{ |
| 190 |
oss.str (""); |
190 |
std::cout << "Creating Campus Network " << z << ":" << std::endl; |
| 191 |
oss << 10 + z << ".1.252.0"; |
191 |
// Create Net0 |
| 192 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
192 |
std::cout << " SubNet [ 0"; |
| 193 |
ifs = address.Assign (ndc0_1); |
193 |
for (int i = 0; i < 3; ++i) |
| 194 |
// Create Net2 |
194 |
{ |
| 195 |
std::cout << " 2"; |
195 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 196 |
for (int i = 0; i < 14; ++i) |
196 |
nodes_net0[z][i].Add (node); |
| 197 |
{ |
197 |
stack.Install (nodes_net0[z][i]); |
| 198 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
198 |
} |
| 199 |
nodes_net2[z][i].Add (node); |
199 |
nodes_net0[z][0].Add (nodes_net0[z][1].Get (0)); |
| 200 |
stack.Install (nodes_net2[z][i]); |
200 |
nodes_net0[z][1].Add (nodes_net0[z][2].Get (0)); |
| 201 |
} |
201 |
nodes_net0[z][2].Add (nodes_net0[z][0].Get (0)); |
| 202 |
nodes_net2[z][0].Add (nodes_net2[z][1].Get (0)); |
202 |
NetDeviceContainer ndc0[3]; |
| 203 |
nodes_net2[z][2].Add (nodes_net2[z][0].Get (0)); |
203 |
for (int i = 0; i < 3; ++i) |
| 204 |
nodes_net2[z][1].Add (nodes_net2[z][3].Get (0)); |
204 |
{ |
| 205 |
nodes_net2[z][3].Add (nodes_net2[z][2].Get (0)); |
205 |
ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]); |
| 206 |
nodes_net2[z][4].Add (nodes_net2[z][2].Get (0)); |
206 |
} |
| 207 |
nodes_net2[z][5].Add (nodes_net2[z][3].Get (0)); |
207 |
// Create Net1 |
| 208 |
nodes_net2[z][6].Add (nodes_net2[z][5].Get (0)); |
208 |
std::cout << " 1"; |
| 209 |
nodes_net2[z][7].Add (nodes_net2[z][2].Get (0)); |
209 |
for (int i = 0; i < 6; ++i) |
| 210 |
nodes_net2[z][8].Add (nodes_net2[z][3].Get (0)); |
210 |
{ |
| 211 |
nodes_net2[z][9].Add (nodes_net2[z][4].Get (0)); |
211 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 212 |
nodes_net2[z][10].Add (nodes_net2[z][5].Get (0)); |
212 |
nodes_net1[z][i].Add (node); |
| 213 |
nodes_net2[z][11].Add (nodes_net2[z][6].Get (0)); |
213 |
stack.Install (nodes_net1[z][i]); |
| 214 |
nodes_net2[z][12].Add (nodes_net2[z][6].Get (0)); |
214 |
} |
| 215 |
nodes_net2[z][13].Add (nodes_net2[z][6].Get (0)); |
215 |
nodes_net1[z][0].Add (nodes_net1[z][1].Get (0)); |
| 216 |
NetDeviceContainer ndc2[14]; |
216 |
nodes_net1[z][2].Add (nodes_net1[z][0].Get (0)); |
| 217 |
for (int i = 0; i < 14; ++i) |
217 |
nodes_net1[z][3].Add (nodes_net1[z][0].Get (0)); |
| 218 |
{ |
218 |
nodes_net1[z][4].Add (nodes_net1[z][1].Get (0)); |
| 219 |
ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]); |
219 |
nodes_net1[z][5].Add (nodes_net1[z][1].Get (0)); |
| 220 |
} |
220 |
NetDeviceContainer ndc1[6]; |
| 221 |
NetDeviceContainer ndc2LAN[7][nLANClients]; |
221 |
for (int i = 0; i < 6; ++i) |
| 222 |
for (int i = 0; i < 7; ++i) |
222 |
{ |
| 223 |
{ |
223 |
if (i == 1) |
| 224 |
oss.str (""); |
224 |
{ |
| 225 |
oss << 10 + z << ".4." << 15 + i << ".0"; |
225 |
continue; |
| 226 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
226 |
} |
| 227 |
for (uint32_t j = 0; j < nLANClients; ++j) |
227 |
ndc1[i] = p2p_1gb5ms.Install (nodes_net1[z][i]); |
| 228 |
{ |
228 |
} |
| 229 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
229 |
// Connect Net0 <-> Net1 |
| 230 |
nodes_net2LAN[z][i][j].Add (node); |
230 |
NodeContainer net0_1; |
| 231 |
stack.Install (nodes_net2LAN[z][i][j]); |
231 |
net0_1.Add (nodes_net0[z][2].Get (0)); |
| 232 |
nodes_net2LAN[z][i][j].Add (nodes_net2[z][i + 7].Get (0)); |
232 |
net0_1.Add (nodes_net1[z][0].Get (0)); |
| 233 |
ndc2LAN[i][j] = p2p_100mb1ms.Install (nodes_net2LAN[z][i][j]); |
233 |
NetDeviceContainer ndc0_1; |
| 234 |
ifs2LAN[z][i][j] = address.Assign (ndc2LAN[i][j]); |
234 |
ndc0_1 = p2p_1gb5ms.Install (net0_1); |
| 235 |
} |
235 |
oss.str (""); |
| 236 |
} |
236 |
oss << 10 + z << ".1.252.0"; |
| 237 |
// Create Net3 |
237 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 238 |
std::cout << " 3 ]" << std::endl; |
238 |
ifs = address.Assign (ndc0_1); |
| 239 |
for (int i = 0; i < 9; ++i) |
239 |
// Create Net2 |
| 240 |
{ |
240 |
std::cout << " 2"; |
| 241 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
241 |
for (int i = 0; i < 14; ++i) |
| 242 |
nodes_net3[z][i].Add (node); |
242 |
{ |
| 243 |
stack.Install (nodes_net3[z][i]); |
243 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 244 |
} |
244 |
nodes_net2[z][i].Add (node); |
| 245 |
nodes_net3[z][0].Add (nodes_net3[z][1].Get (0)); |
245 |
stack.Install (nodes_net2[z][i]); |
| 246 |
nodes_net3[z][1].Add (nodes_net3[z][2].Get (0)); |
246 |
} |
| 247 |
nodes_net3[z][2].Add (nodes_net3[z][3].Get (0)); |
247 |
nodes_net2[z][0].Add (nodes_net2[z][1].Get (0)); |
| 248 |
nodes_net3[z][3].Add (nodes_net3[z][1].Get (0)); |
248 |
nodes_net2[z][2].Add (nodes_net2[z][0].Get (0)); |
| 249 |
nodes_net3[z][4].Add (nodes_net3[z][0].Get (0)); |
249 |
nodes_net2[z][1].Add (nodes_net2[z][3].Get (0)); |
| 250 |
nodes_net3[z][5].Add (nodes_net3[z][0].Get (0)); |
250 |
nodes_net2[z][3].Add (nodes_net2[z][2].Get (0)); |
| 251 |
nodes_net3[z][6].Add (nodes_net3[z][2].Get (0)); |
251 |
nodes_net2[z][4].Add (nodes_net2[z][2].Get (0)); |
| 252 |
nodes_net3[z][7].Add (nodes_net3[z][3].Get (0)); |
252 |
nodes_net2[z][5].Add (nodes_net2[z][3].Get (0)); |
| 253 |
nodes_net3[z][8].Add (nodes_net3[z][3].Get (0)); |
253 |
nodes_net2[z][6].Add (nodes_net2[z][5].Get (0)); |
| 254 |
NetDeviceContainer ndc3[9]; |
254 |
nodes_net2[z][7].Add (nodes_net2[z][2].Get (0)); |
| 255 |
for (int i = 0; i < 9; ++i) |
255 |
nodes_net2[z][8].Add (nodes_net2[z][3].Get (0)); |
| 256 |
{ |
256 |
nodes_net2[z][9].Add (nodes_net2[z][4].Get (0)); |
| 257 |
ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]); |
257 |
nodes_net2[z][10].Add (nodes_net2[z][5].Get (0)); |
| 258 |
} |
258 |
nodes_net2[z][11].Add (nodes_net2[z][6].Get (0)); |
| 259 |
NetDeviceContainer ndc3LAN[5][nLANClients]; |
259 |
nodes_net2[z][12].Add (nodes_net2[z][6].Get (0)); |
| 260 |
for (int i = 0; i < 5; ++i) |
260 |
nodes_net2[z][13].Add (nodes_net2[z][6].Get (0)); |
| 261 |
{ |
261 |
NetDeviceContainer ndc2[14]; |
| 262 |
oss.str (""); |
262 |
for (int i = 0; i < 14; ++i) |
| 263 |
oss << 10 + z << ".5." << 10 + i << ".0"; |
263 |
{ |
| 264 |
address.SetBase (oss.str ().c_str (), "255.255.255.255"); |
264 |
ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]); |
| 265 |
for (uint32_t j = 0; j < nLANClients; ++j) |
265 |
} |
| 266 |
{ |
266 |
NetDeviceContainer ndc2LAN[7][nLANClients]; |
| 267 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
267 |
for (int i = 0; i < 7; ++i) |
| 268 |
nodes_net3LAN[z][i][j].Add (node); |
268 |
{ |
| 269 |
stack.Install (nodes_net3LAN[z][i][j]); |
269 |
oss.str (""); |
| 270 |
nodes_net3LAN[z][i][j].Add (nodes_net3[z][i + 4].Get (0)); |
270 |
oss << 10 + z << ".4." << 15 + i << ".0"; |
| 271 |
ndc3LAN[i][j] = p2p_100mb1ms.Install (nodes_net3LAN[z][i][j]); |
271 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 272 |
ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]); |
272 |
for (int j = 0; j < nLANClients; ++j) |
| 273 |
} |
273 |
{ |
| 274 |
} |
274 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 275 |
std::cout << " Connecting Subnets..." << std::endl; |
275 |
nodes_net2LAN[z][i][j].Add (node); |
| 276 |
// Create Lone Routers (Node 4 & 5) |
276 |
stack.Install (nodes_net2LAN[z][i][j]); |
| 277 |
Ptr<Node> node1 = CreateObject<Node> (z % systemCount); |
277 |
nodes_net2LAN[z][i][j].Add (nodes_net2[z][i + 7].Get (0)); |
| 278 |
Ptr<Node> node2 = CreateObject<Node> (z % systemCount); |
278 |
ndc2LAN[i][j] = p2p_100mb1ms.Install (nodes_net2LAN[z][i][j]); |
| 279 |
nodes_netLR[z].Add (node1); |
279 |
ifs2LAN[z][i][j] = address.Assign (ndc2LAN[i][j]); |
| 280 |
nodes_netLR[z].Add (node2); |
280 |
} |
| 281 |
stack.Install (nodes_netLR[z]); |
281 |
} |
| 282 |
NetDeviceContainer ndcLR; |
282 |
// Create Net3 |
| 283 |
ndcLR = p2p_1gb5ms.Install (nodes_netLR[z]); |
283 |
std::cout << " 3 ]" << std::endl; |
| 284 |
// Connect Net2/Net3 through Lone Routers to Net0 |
284 |
for (int i = 0; i < 9; ++i) |
| 285 |
NodeContainer net0_4, net0_5, net2_4a, net2_4b, net3_5a, net3_5b; |
285 |
{ |
| 286 |
net0_4.Add (nodes_netLR[z].Get (0)); |
286 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 287 |
net0_4.Add (nodes_net0[z][0].Get (0)); |
287 |
nodes_net3[z][i].Add (node); |
| 288 |
net0_5.Add (nodes_netLR[z].Get (1)); |
288 |
stack.Install (nodes_net3[z][i]); |
| 289 |
net0_5.Add (nodes_net0[z][1].Get (0)); |
289 |
} |
| 290 |
net2_4a.Add (nodes_netLR[z].Get (0)); |
290 |
nodes_net3[z][0].Add (nodes_net3[z][1].Get (0)); |
| 291 |
net2_4a.Add (nodes_net2[z][0].Get (0)); |
291 |
nodes_net3[z][1].Add (nodes_net3[z][2].Get (0)); |
| 292 |
net2_4b.Add (nodes_netLR[z].Get (1)); |
292 |
nodes_net3[z][2].Add (nodes_net3[z][3].Get (0)); |
| 293 |
net2_4b.Add (nodes_net2[z][1].Get (0)); |
293 |
nodes_net3[z][3].Add (nodes_net3[z][1].Get (0)); |
| 294 |
net3_5a.Add (nodes_netLR[z].Get (1)); |
294 |
nodes_net3[z][4].Add (nodes_net3[z][0].Get (0)); |
| 295 |
net3_5a.Add (nodes_net3[z][0].Get (0)); |
295 |
nodes_net3[z][5].Add (nodes_net3[z][0].Get (0)); |
| 296 |
net3_5b.Add (nodes_netLR[z].Get (1)); |
296 |
nodes_net3[z][6].Add (nodes_net3[z][2].Get (0)); |
| 297 |
net3_5b.Add (nodes_net3[z][1].Get (0)); |
297 |
nodes_net3[z][7].Add (nodes_net3[z][3].Get (0)); |
| 298 |
NetDeviceContainer ndc0_4, ndc0_5, ndc2_4a, ndc2_4b, ndc3_5a, ndc3_5b; |
298 |
nodes_net3[z][8].Add (nodes_net3[z][3].Get (0)); |
| 299 |
ndc0_4 = p2p_1gb5ms.Install (net0_4); |
299 |
NetDeviceContainer ndc3[9]; |
| 300 |
oss.str (""); |
300 |
for (int i = 0; i < 9; ++i) |
| 301 |
oss << 10 + z << ".1.253.0"; |
301 |
{ |
| 302 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
302 |
ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]); |
| 303 |
ifs = address.Assign (ndc0_4); |
303 |
} |
| 304 |
ndc0_5 = p2p_1gb5ms.Install (net0_5); |
304 |
NetDeviceContainer ndc3LAN[5][nLANClients]; |
| 305 |
oss.str (""); |
305 |
for (int i = 0; i < 5; ++i) |
| 306 |
oss << 10 + z << ".1.254.0"; |
306 |
{ |
| 307 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
307 |
oss.str (""); |
| 308 |
ifs = address.Assign (ndc0_5); |
308 |
oss << 10 + z << ".5." << 10 + i << ".0"; |
| 309 |
ndc2_4a = p2p_1gb5ms.Install (net2_4a); |
309 |
address.SetBase (oss.str ().c_str (), "255.255.255.255"); |
| 310 |
oss.str (""); |
310 |
for (int j = 0; j < nLANClients; ++j) |
| 311 |
oss << 10 + z << ".4.253.0"; |
311 |
{ |
| 312 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
312 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
| 313 |
ifs = address.Assign (ndc2_4a); |
313 |
nodes_net3LAN[z][i][j].Add (node); |
| 314 |
ndc2_4b = p2p_1gb5ms.Install (net2_4b); |
314 |
stack.Install (nodes_net3LAN[z][i][j]); |
| 315 |
oss.str (""); |
315 |
nodes_net3LAN[z][i][j].Add (nodes_net3[z][i + 4].Get (0)); |
| 316 |
oss << 10 + z << ".4.254.0"; |
316 |
ndc3LAN[i][j] = p2p_100mb1ms.Install (nodes_net3LAN[z][i][j]); |
| 317 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
317 |
ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]); |
| 318 |
ifs = address.Assign (ndc2_4b); |
318 |
} |
| 319 |
ndc3_5a = p2p_1gb5ms.Install (net3_5a); |
319 |
} |
| 320 |
oss.str (""); |
320 |
std::cout << " Connecting Subnets..." << std::endl; |
| 321 |
oss << 10 + z << ".5.253.0"; |
321 |
// Create Lone Routers (Node 4 & 5) |
| 322 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
322 |
Ptr<Node> node1 = CreateObject<Node> (z % systemCount); |
| 323 |
ifs = address.Assign (ndc3_5a); |
323 |
Ptr<Node> node2 = CreateObject<Node> (z % systemCount); |
| 324 |
ndc3_5b = p2p_1gb5ms.Install (net3_5b); |
324 |
nodes_netLR[z].Add (node1); |
| 325 |
oss.str (""); |
325 |
nodes_netLR[z].Add (node2); |
| 326 |
oss << 10 + z << ".5.254.0"; |
326 |
stack.Install (nodes_netLR[z]); |
| 327 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
327 |
NetDeviceContainer ndcLR; |
| 328 |
ifs = address.Assign (ndc3_5b); |
328 |
ndcLR = p2p_1gb5ms.Install (nodes_netLR[z]); |
| 329 |
// Assign IP addresses |
329 |
// Connect Net2/Net3 through Lone Routers to Net0 |
| 330 |
std::cout << " Assigning IP addresses..." << std::endl; |
330 |
NodeContainer net0_4, net0_5, net2_4a, net2_4b, net3_5a, net3_5b; |
| 331 |
for (int i = 0; i < 3; ++i) |
331 |
net0_4.Add (nodes_netLR[z].Get (0)); |
| 332 |
{ |
332 |
net0_4.Add (nodes_net0[z][0].Get (0)); |
| 333 |
oss.str (""); |
333 |
net0_5.Add (nodes_netLR[z].Get (1)); |
| 334 |
oss << 10 + z << ".1." << 1 + i << ".0"; |
334 |
net0_5.Add (nodes_net0[z][1].Get (0)); |
| 335 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
335 |
net2_4a.Add (nodes_netLR[z].Get (0)); |
| 336 |
ifs0[z][i] = address.Assign (ndc0[i]); |
336 |
net2_4a.Add (nodes_net2[z][0].Get (0)); |
| 337 |
} |
337 |
net2_4b.Add (nodes_netLR[z].Get (1)); |
| 338 |
for (int i = 0; i < 6; ++i) |
338 |
net2_4b.Add (nodes_net2[z][1].Get (0)); |
| 339 |
{ |
339 |
net3_5a.Add (nodes_netLR[z].Get (1)); |
| 340 |
if (i == 1) |
340 |
net3_5a.Add (nodes_net3[z][0].Get (0)); |
| 341 |
{ |
341 |
net3_5b.Add (nodes_netLR[z].Get (1)); |
| 342 |
continue; |
342 |
net3_5b.Add (nodes_net3[z][1].Get (0)); |
| 343 |
} |
343 |
NetDeviceContainer ndc0_4, ndc0_5, ndc2_4a, ndc2_4b, ndc3_5a, ndc3_5b; |
| 344 |
oss.str (""); |
344 |
ndc0_4 = p2p_1gb5ms.Install (net0_4); |
| 345 |
oss << 10 + z << ".2." << 1 + i << ".0"; |
345 |
oss.str (""); |
| 346 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
346 |
oss << 10 + z << ".1.253.0"; |
| 347 |
ifs1[z][i] = address.Assign (ndc1[i]); |
347 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 348 |
} |
348 |
ifs = address.Assign (ndc0_4); |
| 349 |
oss.str (""); |
349 |
ndc0_5 = p2p_1gb5ms.Install (net0_5); |
| 350 |
oss << 10 + z << ".3.1.0"; |
350 |
oss.str (""); |
| 351 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
351 |
oss << 10 + z << ".1.254.0"; |
| 352 |
ifs = address.Assign (ndcLR); |
352 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 353 |
for (int i = 0; i < 14; ++i) |
353 |
ifs = address.Assign (ndc0_5); |
| 354 |
{ |
354 |
ndc2_4a = p2p_1gb5ms.Install (net2_4a); |
| 355 |
oss.str (""); |
355 |
oss.str (""); |
| 356 |
oss << 10 + z << ".4." << 1 + i << ".0"; |
356 |
oss << 10 + z << ".4.253.0"; |
| 357 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
357 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 358 |
ifs2[z][i] = address.Assign (ndc2[i]); |
358 |
ifs = address.Assign (ndc2_4a); |
| 359 |
} |
359 |
ndc2_4b = p2p_1gb5ms.Install (net2_4b); |
| 360 |
for (int i = 0; i < 9; ++i) |
360 |
oss.str (""); |
| 361 |
{ |
361 |
oss << 10 + z << ".4.254.0"; |
| 362 |
oss.str (""); |
362 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 363 |
oss << 10 + z << ".5." << 1 + i << ".0"; |
363 |
ifs = address.Assign (ndc2_4b); |
| 364 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
364 |
ndc3_5a = p2p_1gb5ms.Install (net3_5a); |
| 365 |
ifs3[z][i] = address.Assign (ndc3[i]); |
365 |
oss.str (""); |
| 366 |
} |
366 |
oss << 10 + z << ".5.253.0"; |
| 367 |
} |
367 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 368 |
// Create Ring Links |
368 |
ifs = address.Assign (ndc3_5a); |
| 369 |
if (nCN > 1) |
369 |
ndc3_5b = p2p_1gb5ms.Install (net3_5b); |
| 370 |
{ |
370 |
oss.str (""); |
| 371 |
std::cout << "Forming Ring Topology..." << std::endl; |
371 |
oss << 10 + z << ".5.254.0"; |
| 372 |
NodeContainer nodes_ring[nCN]; |
372 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 373 |
for (uint32_t z = 0; z < nCN - 1; ++z) |
373 |
ifs = address.Assign (ndc3_5b); |
| 374 |
{ |
374 |
// Assign IP addresses |
| 375 |
nodes_ring[z].Add (nodes_net0[z][0].Get (0)); |
375 |
std::cout << " Assigning IP addresses..." << std::endl; |
| 376 |
nodes_ring[z].Add (nodes_net0[z + 1][0].Get (0)); |
376 |
for (int i = 0; i < 3; ++i) |
| 377 |
} |
377 |
{ |
| 378 |
nodes_ring[nCN - 1].Add (nodes_net0[nCN - 1][0].Get (0)); |
378 |
oss.str (""); |
| 379 |
nodes_ring[nCN - 1].Add (nodes_net0[0][0].Get (0)); |
379 |
oss << 10 + z << ".1." << 1 + i << ".0"; |
| 380 |
NetDeviceContainer ndc_ring[nCN]; |
380 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 381 |
for (uint32_t z = 0; z < nCN; ++z) |
381 |
ifs0[z][i] = address.Assign (ndc0[i]); |
| 382 |
{ |
382 |
} |
| 383 |
ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]); |
383 |
for (int i = 0; i < 6; ++i) |
| 384 |
oss.str (""); |
384 |
{ |
| 385 |
oss << "254.1." << z + 1 << ".0"; |
385 |
if (i == 1) |
| 386 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
386 |
{ |
| 387 |
ifs = address.Assign (ndc_ring[z]); |
387 |
continue; |
| 388 |
} |
388 |
} |
| 389 |
} |
389 |
oss.str (""); |
| 390 |
|
390 |
oss << 10 + z << ".2." << 1 + i << ".0"; |
| 391 |
// Create Traffic Flows |
391 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 392 |
std::cout << "Creating UDP Traffic Flows:" << std::endl; |
392 |
ifs1[z][i] = address.Assign (ndc1[i]); |
| 393 |
Config::SetDefault ("ns3::OnOffApplication::MaxBytes", |
393 |
} |
| 394 |
UintegerValue (nBytes)); |
394 |
oss.str (""); |
| 395 |
Config::SetDefault ("ns3::OnOffApplication::OnTime", |
395 |
oss << 10 + z << ".3.1.0"; |
| 396 |
StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
396 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 397 |
Config::SetDefault ("ns3::OnOffApplication::OffTime", |
397 |
ifs = address.Assign (ndcLR); |
| 398 |
StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
398 |
for (int i = 0; i < 14; ++i) |
| 399 |
|
399 |
{ |
| 400 |
|
400 |
oss.str (""); |
| 401 |
if (single) |
401 |
oss << 10 + z << ".4." << 1 + i << ".0"; |
| 402 |
{ |
402 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 403 |
if (systemCount == 1) |
403 |
ifs2[z][i] = address.Assign (ndc2[i]); |
| 404 |
{ |
404 |
} |
| 405 |
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", |
405 |
for (int i = 0; i < 9; ++i) |
| 406 |
InetSocketAddress (Ipv4Address::GetAny (), |
406 |
{ |
| 407 |
9999)); |
407 |
oss.str (""); |
| 408 |
ApplicationContainer sinkApp = sinkHelper.Install (nodes_net1[0][2].Get (0)); |
408 |
oss << 10 + z << ".5." << 1 + i << ".0"; |
| 409 |
sinkApp.Start (Seconds (0.0)); |
409 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 410 |
|
410 |
ifs3[z][i] = address.Assign (ndc3[i]); |
| 411 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
411 |
} |
| 412 |
AddressValue remoteAddress (InetSocketAddress (ifs1[0][2].GetAddress (0), 9999)); |
412 |
} |
| 413 |
std::cout << "Remote Address is " << ifs1[0][2].GetAddress (0) << std::endl; |
413 |
// Create Ring Links |
| 414 |
client.SetAttribute ("Remote", remoteAddress); |
414 |
if (nCN > 1) |
| 415 |
|
415 |
{ |
| 416 |
ApplicationContainer clientApp; |
416 |
std::cout << "Forming Ring Topology..." << std::endl; |
| 417 |
clientApp.Add (client.Install (nodes_net2LAN[0][0][0].Get (0))); |
417 |
NodeContainer nodes_ring[nCN]; |
| 418 |
clientApp.Start (Seconds (0)); |
418 |
for (int z = 0; z < nCN - 1; ++z) |
| 419 |
} |
419 |
{ |
| 420 |
else if (systemId == 1) |
420 |
nodes_ring[z].Add (nodes_net0[z][0].Get (0)); |
| 421 |
{ |
421 |
nodes_ring[z].Add (nodes_net0[z + 1][0].Get (0)); |
| 422 |
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", |
422 |
} |
| 423 |
InetSocketAddress (Ipv4Address::GetAny (), |
423 |
nodes_ring[nCN - 1].Add (nodes_net0[nCN - 1][0].Get (0)); |
| 424 |
9999)); |
424 |
nodes_ring[nCN - 1].Add (nodes_net0[0][0].Get (0)); |
| 425 |
ApplicationContainer sinkApp = |
425 |
NetDeviceContainer ndc_ring[nCN]; |
| 426 |
sinkHelper.Install (nodes_net1[1][0].Get (0)); |
426 |
for (int z = 0; z < nCN; ++z) |
| 427 |
|
427 |
{ |
| 428 |
sinkApp.Start (Seconds (0.0)); |
428 |
ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]); |
| 429 |
} |
429 |
oss.str (""); |
| 430 |
else if (systemId == 0) |
430 |
oss << "254.1." << z + 1 << ".0"; |
| 431 |
{ |
431 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 432 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
432 |
ifs = address.Assign (ndc_ring[z]); |
| 433 |
AddressValue remoteAddress |
433 |
} |
| 434 |
(InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); |
434 |
} |
| 435 |
|
435 |
|
| 436 |
std::cout << "Remote Address is " << ifs1[1][0].GetAddress (0) << std::endl; |
436 |
// Create Traffic Flows |
| 437 |
client.SetAttribute ("Remote", remoteAddress); |
437 |
std::cout << "Creating UDP Traffic Flows:" << std::endl; |
| 438 |
|
438 |
Config::SetDefault ("ns3::OnOffApplication::MaxBytes", |
| 439 |
ApplicationContainer clientApp; |
439 |
UintegerValue (nBytes)); |
| 440 |
clientApp.Add (client.Install (nodes_net2LAN[0][0][0].Get (0))); |
440 |
Config::SetDefault ("ns3::OnOffApplication::OnTime", |
| 441 |
clientApp.Start (Seconds (0)); |
441 |
StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
| 442 |
} |
442 |
Config::SetDefault ("ns3::OnOffApplication::OffTime", |
| 443 |
} |
443 |
StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
| 444 |
else |
444 |
|
| 445 |
{ |
445 |
|
| 446 |
Ptr<UniformRandomVariable> urng = CreateObject<UniformRandomVariable> (); |
446 |
if (single) |
| 447 |
int r1; |
447 |
{ |
| 448 |
double r2; |
448 |
if (systemCount == 1) |
| 449 |
for (uint32_t z = 0; z < nCN; ++z) |
449 |
{ |
| 450 |
{ |
450 |
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", |
| 451 |
uint32_t x = z + 1; |
451 |
InetSocketAddress (Ipv4Address::GetAny (), |
| 452 |
if (z == nCN - 1) |
452 |
9999)); |
| 453 |
{ |
453 |
ApplicationContainer sinkApp = sinkHelper.Install (nodes_net1[0][2].Get (0)); |
| 454 |
x = 0; |
454 |
sinkApp.Start (Seconds (0.0)); |
| 455 |
} |
455 |
|
| 456 |
// Subnet 2 LANs |
456 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 457 |
std::cout << " Campus Network " << z << " Flows [ Net2 "; |
457 |
AddressValue remoteAddress (InetSocketAddress (ifs1[0][2].GetAddress (0), 9999)); |
| 458 |
for (int i = 0; i < 7; ++i) |
458 |
std::cout << "Remote Address is " << ifs1[0][2].GetAddress (0) << std::endl; |
| 459 |
{ |
459 |
client.SetAttribute ("Remote", remoteAddress); |
| 460 |
for (uint32_t j = 0; j < nLANClients; ++j) |
460 |
|
| 461 |
{ |
461 |
ApplicationContainer clientApp; |
| 462 |
// Sinks |
462 |
clientApp.Add (client.Install (nodes_net2LAN[0][0][0].Get (0))); |
| 463 |
if (systemCount == 1) |
463 |
clientApp.Start (Seconds (0)); |
| 464 |
{ |
464 |
} |
| 465 |
PacketSinkHelper sinkHelper |
465 |
else if (systemId == 1) |
| 466 |
("ns3::UdpSocketFactory", |
466 |
{ |
| 467 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
467 |
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", |
| 468 |
|
468 |
InetSocketAddress (Ipv4Address::GetAny (), |
| 469 |
ApplicationContainer sinkApp = |
469 |
9999)); |
| 470 |
sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); |
470 |
ApplicationContainer sinkApp = |
| 471 |
|
471 |
sinkHelper.Install (nodes_net1[1][0].Get (0)); |
| 472 |
sinkApp.Start (Seconds (0.0)); |
472 |
|
| 473 |
} |
473 |
sinkApp.Start (Seconds (0.0)); |
| 474 |
else if (systemId == z % systemCount) |
474 |
} |
| 475 |
{ |
475 |
else if (systemId == 0) |
| 476 |
PacketSinkHelper sinkHelper |
476 |
{ |
| 477 |
("ns3::UdpSocketFactory", |
477 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 478 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
478 |
AddressValue remoteAddress |
| 479 |
|
479 |
(InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); |
| 480 |
ApplicationContainer sinkApp = |
480 |
|
| 481 |
sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); |
481 |
std::cout << "Remote Address is " << ifs1[1][0].GetAddress (0) << std::endl; |
| 482 |
|
482 |
client.SetAttribute ("Remote", remoteAddress); |
| 483 |
sinkApp.Start (Seconds (0.0)); |
483 |
|
| 484 |
} |
484 |
ApplicationContainer clientApp; |
| 485 |
// Sources |
485 |
clientApp.Add (client.Install (nodes_net2LAN[0][0][0].Get (0))); |
| 486 |
if (systemCount == 1) |
486 |
clientApp.Start (Seconds (0)); |
| 487 |
{ |
487 |
} |
| 488 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
488 |
} |
| 489 |
r2 = 10 * urng->GetValue (); |
489 |
else |
| 490 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
490 |
{ |
| 491 |
|
491 |
Ptr<UniformRandomVariable> urng = CreateObject<UniformRandomVariable> (); |
| 492 |
AddressValue remoteAddress |
492 |
int r1; |
| 493 |
(InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); |
493 |
double r2; |
| 494 |
|
494 |
for (int z = 0; z < nCN; ++z) |
| 495 |
client.SetAttribute ("Remote", remoteAddress); |
495 |
{ |
| 496 |
ApplicationContainer clientApp; |
496 |
int x = z + 1; |
| 497 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
497 |
if (z == nCN - 1) |
| 498 |
clientApp.Start (Seconds (r2)); |
498 |
{ |
| 499 |
} |
499 |
x = 0; |
| 500 |
else if (systemId == x % systemCount) |
500 |
} |
| 501 |
{ |
501 |
// Subnet 2 LANs |
| 502 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
502 |
std::cout << " Campus Network " << z << " Flows [ Net2 "; |
| 503 |
r2 = 10 * urng->GetValue (); |
503 |
for (int i = 0; i < 7; ++i) |
| 504 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
504 |
{ |
| 505 |
|
505 |
for (int j = 0; j < nLANClients; ++j) |
| 506 |
AddressValue remoteAddress |
506 |
{ |
| 507 |
(InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); |
507 |
// Sinks |
| 508 |
|
508 |
if (systemCount == 1) |
| 509 |
client.SetAttribute ("Remote", remoteAddress); |
509 |
{ |
| 510 |
ApplicationContainer clientApp; |
510 |
PacketSinkHelper sinkHelper |
| 511 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
511 |
("ns3::UdpSocketFactory", |
| 512 |
clientApp.Start (Seconds (r2)); |
512 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
| 513 |
} |
513 |
|
| 514 |
} |
514 |
ApplicationContainer sinkApp = |
| 515 |
} |
515 |
sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); |
| 516 |
// Subnet 3 LANs |
516 |
|
| 517 |
std::cout << "Net3 ]" << std::endl; |
517 |
sinkApp.Start (Seconds (0.0)); |
| 518 |
for (int i = 0; i < 5; ++i) |
518 |
} |
| 519 |
{ |
519 |
else if (systemId == z % systemCount) |
| 520 |
for (uint32_t j = 0; j < nLANClients; ++j) |
520 |
{ |
| 521 |
{ |
521 |
PacketSinkHelper sinkHelper |
| 522 |
// Sinks |
522 |
("ns3::UdpSocketFactory", |
| 523 |
if (systemCount == 1) |
523 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
| 524 |
{ |
524 |
|
| 525 |
PacketSinkHelper sinkHelper |
525 |
ApplicationContainer sinkApp = |
| 526 |
("ns3::UdpSocketFactory", |
526 |
sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); |
| 527 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
527 |
|
| 528 |
|
528 |
sinkApp.Start (Seconds (0.0)); |
| 529 |
ApplicationContainer sinkApp = |
529 |
} |
| 530 |
sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); |
530 |
// Sources |
| 531 |
|
531 |
if (systemCount == 1) |
| 532 |
sinkApp.Start (Seconds (0.0)); |
532 |
{ |
| 533 |
} |
533 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
| 534 |
else if (systemId == z % systemCount) |
534 |
r2 = 10 * urng->GetValue (); |
| 535 |
{ |
535 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 536 |
PacketSinkHelper sinkHelper |
536 |
|
| 537 |
("ns3::UdpSocketFactory", |
537 |
AddressValue remoteAddress |
| 538 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
538 |
(InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); |
| 539 |
|
539 |
|
| 540 |
ApplicationContainer sinkApp = |
540 |
client.SetAttribute ("Remote", remoteAddress); |
| 541 |
sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); |
541 |
ApplicationContainer clientApp; |
| 542 |
|
542 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
| 543 |
sinkApp.Start (Seconds (0.0)); |
543 |
clientApp.Start (Seconds (r2)); |
| 544 |
} |
544 |
} |
| 545 |
// Sources |
545 |
else if (systemId == x % systemCount) |
| 546 |
if (systemCount == 1) |
546 |
{ |
| 547 |
{ |
547 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
| 548 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
548 |
r2 = 10 * urng->GetValue (); |
| 549 |
r2 = 10 * urng->GetValue (); |
549 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 550 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
550 |
|
| 551 |
|
551 |
AddressValue remoteAddress |
| 552 |
AddressValue remoteAddress |
552 |
(InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); |
| 553 |
(InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); |
553 |
|
| 554 |
|
554 |
client.SetAttribute ("Remote", remoteAddress); |
| 555 |
client.SetAttribute ("Remote", remoteAddress); |
555 |
ApplicationContainer clientApp; |
| 556 |
ApplicationContainer clientApp; |
556 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
| 557 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
557 |
clientApp.Start (Seconds (r2)); |
| 558 |
clientApp.Start (Seconds (r2)); |
558 |
} |
| 559 |
} |
559 |
} |
| 560 |
else if (systemId == x % systemCount) |
560 |
} |
| 561 |
{ |
561 |
// Subnet 3 LANs |
| 562 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
562 |
std::cout << "Net3 ]" << std::endl; |
| 563 |
r2 = 10 * urng->GetValue (); |
563 |
for (int i = 0; i < 5; ++i) |
| 564 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
564 |
{ |
| 565 |
|
565 |
for (int j = 0; j < nLANClients; ++j) |
| 566 |
AddressValue remoteAddress |
566 |
{ |
| 567 |
(InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); |
567 |
// Sinks |
| 568 |
|
568 |
if (systemCount == 1) |
| 569 |
client.SetAttribute ("Remote", remoteAddress); |
569 |
{ |
| 570 |
ApplicationContainer clientApp; |
570 |
PacketSinkHelper sinkHelper |
| 571 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
571 |
("ns3::UdpSocketFactory", |
| 572 |
clientApp.Start (Seconds (r2)); |
572 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
| 573 |
} |
573 |
|
| 574 |
} |
574 |
ApplicationContainer sinkApp = |
| 575 |
} |
575 |
sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); |
| 576 |
} |
576 |
|
| 577 |
} |
577 |
sinkApp.Start (Seconds (0.0)); |
| 578 |
|
578 |
} |
| 579 |
std::cout << "Created " << NodeList::GetNNodes () << " nodes." << std::endl; |
579 |
else if (systemId == z % systemCount) |
| 580 |
TIMER_TYPE routingStart; |
580 |
{ |
| 581 |
TIMER_NOW (routingStart); |
581 |
PacketSinkHelper sinkHelper |
| 582 |
|
582 |
("ns3::UdpSocketFactory", |
| 583 |
if (nix) |
583 |
InetSocketAddress (Ipv4Address::GetAny (), 9999)); |
| 584 |
{ |
584 |
|
| 585 |
std::cout << "Using Nix-vectors..." << std::endl; |
585 |
ApplicationContainer sinkApp = |
| 586 |
} |
586 |
sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); |
| 587 |
else |
587 |
|
| 588 |
{ |
588 |
sinkApp.Start (Seconds (0.0)); |
| 589 |
// Calculate routing tables |
589 |
} |
| 590 |
std::cout << "Populating Routing tables..." << std::endl; |
590 |
// Sources |
| 591 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
591 |
if (systemCount == 1) |
| 592 |
} |
592 |
{ |
| 593 |
|
593 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
| 594 |
TIMER_TYPE routingEnd; |
594 |
r2 = 10 * urng->GetValue (); |
| 595 |
TIMER_NOW (routingEnd); |
595 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 596 |
std::cout << "Routing tables population took " |
596 |
|
| 597 |
<< TIMER_DIFF (routingEnd, routingStart) << std::endl; |
597 |
AddressValue remoteAddress |
| 598 |
|
598 |
(InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); |
| 599 |
std::cout << "Running simulator..." << std::endl; |
599 |
|
| 600 |
TIMER_NOW (t1); |
600 |
client.SetAttribute ("Remote", remoteAddress); |
| 601 |
Simulator::Stop (Seconds (100.0)); |
601 |
ApplicationContainer clientApp; |
| 602 |
Simulator::Run (); |
602 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
| 603 |
TIMER_NOW (t2); |
603 |
clientApp.Start (Seconds (r2)); |
| 604 |
std::cout << "Simulator finished." << std::endl; |
604 |
} |
| 605 |
Simulator::Destroy (); |
605 |
else if (systemId == x % systemCount) |
| 606 |
// Exit the MPI execution environment |
606 |
{ |
| 607 |
MpiInterface::Disable (); |
607 |
r1 = 2 + (int)(4 * urng->GetValue ()); |
| 608 |
double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1); |
608 |
r2 = 10 * urng->GetValue (); |
| 609 |
std::cout << "-----" << std::endl << "Runtime Stats:" << std::endl; |
609 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 610 |
std::cout << "Simulator init time: " << d1 << std::endl; |
610 |
|
| 611 |
std::cout << "Simulator run time: " << d2 << std::endl; |
611 |
AddressValue remoteAddress |
| 612 |
std::cout << "Total elapsed time: " << d1 + d2 << std::endl; |
612 |
(InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); |
| 613 |
return 0; |
613 |
|
| 614 |
#else |
614 |
client.SetAttribute ("Remote", remoteAddress); |
| 615 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
615 |
ApplicationContainer clientApp; |
| 616 |
#endif |
616 |
clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); |
| 617 |
} |
617 |
clientApp.Start (Seconds (r2)); |
| 618 |
|
618 |
} |
| 619 |
-- |
619 |
} |
|
|
620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
|
| 624 |
std::cout << "Created " << NodeList::GetNNodes () << " nodes." << std::endl; |
| 625 |
TIMER_TYPE routingStart; |
| 626 |
TIMER_NOW (routingStart); |
| 627 |
|
| 628 |
if (nix) |
| 629 |
{ |
| 630 |
std::cout << "Using Nix-vectors..." << std::endl; |
| 631 |
} |
| 632 |
else |
| 633 |
{ |
| 634 |
// Calculate routing tables |
| 635 |
std::cout << "Populating Routing tables..." << std::endl; |
| 636 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
| 637 |
} |
| 638 |
|
| 639 |
TIMER_TYPE routingEnd; |
| 640 |
TIMER_NOW (routingEnd); |
| 641 |
std::cout << "Routing tables population took " |
| 642 |
<< TIMER_DIFF (routingEnd, routingStart) << std::endl; |
| 643 |
|
| 644 |
std::cout << "Running simulator..." << std::endl; |
| 645 |
TIMER_NOW (t1); |
| 646 |
Simulator::Stop (Seconds (100.0)); |
| 647 |
Simulator::Run (); |
| 648 |
TIMER_NOW (t2); |
| 649 |
std::cout << "Simulator finished." << std::endl; |
| 650 |
Simulator::Destroy (); |
| 651 |
// Exit the MPI execution environment |
| 652 |
MpiInterface::Disable (); |
| 653 |
double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1); |
| 654 |
std::cout << "-----" << std::endl << "Runtime Stats:" << std::endl; |
| 655 |
std::cout << "Simulator init time: " << d1 << std::endl; |
| 656 |
std::cout << "Simulator run time: " << d2 << std::endl; |
| 657 |
std::cout << "Total elapsed time: " << d1 + d2 << std::endl; |
| 658 |
return 0; |
| 659 |
#else |
| 660 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
| 661 |
#endif |
| 662 |
} |
| 663 |
|