|
|
| 40 |
Simulator::Schedule (Seconds (0.1), Progress); |
40 |
Simulator::Schedule (Seconds (0.1), Progress); |
| 41 |
} |
41 |
} |
| 42 |
|
42 |
|
|
|
43 |
template <typename T> |
| 44 |
class Array2D |
| 45 |
{ |
| 46 |
public: |
| 47 |
Array2D (const size_t x, const size_t y) : p (new T*[x]), m_xMax (x) |
| 48 |
{ |
| 49 |
for (size_t i = 0; i < m_xMax; i++) |
| 50 |
p[i] = new T[y]; |
| 51 |
} |
| 52 |
|
| 53 |
~Array2D (void) |
| 54 |
{ |
| 55 |
for (size_t i = 0; i < m_xMax; i++) |
| 56 |
delete[] p[i]; |
| 57 |
delete p; |
| 58 |
p = 0; |
| 59 |
} |
| 60 |
|
| 61 |
T* operator[] (const size_t i) |
| 62 |
{ |
| 63 |
return p[i]; |
| 64 |
} |
| 65 |
private: |
| 66 |
T** p; |
| 67 |
const size_t m_xMax; |
| 68 |
}; |
| 69 |
|
| 70 |
template <typename T> |
| 71 |
class Array3D |
| 72 |
{ |
| 73 |
public: |
| 74 |
Array3D (const size_t x, const size_t y, const size_t z) |
| 75 |
: p (new Array2D<T>*[x]), m_xMax (x) |
| 76 |
{ |
| 77 |
for (size_t i = 0; i < m_xMax; i++) |
| 78 |
p[i] = new Array2D<T> (y, z); |
| 79 |
} |
| 80 |
|
| 81 |
~Array3D (void) |
| 82 |
{ |
| 83 |
for (size_t i = 0; i < m_xMax; i++) |
| 84 |
{ |
| 85 |
delete p[i]; |
| 86 |
p[i] = 0; |
| 87 |
} |
| 88 |
delete[] p; |
| 89 |
p = 0; |
| 90 |
} |
| 91 |
|
| 92 |
Array2D<T>& operator[] (const size_t i) |
| 93 |
{ |
| 94 |
return *(p[i]); |
| 95 |
} |
| 96 |
private: |
| 97 |
Array2D<T>** p; |
| 98 |
const size_t m_xMax; |
| 99 |
}; |
| 100 |
|
| 43 |
int |
101 |
int |
| 44 |
main (int argc, char *argv[]) |
102 |
main (int argc, char *argv[]) |
| 45 |
{ |
103 |
{ |
|
|
| 69 |
|
127 |
|
| 70 |
cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl; |
128 |
cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl; |
| 71 |
|
129 |
|
| 72 |
NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], |
130 |
/// NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], |
| 73 |
nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], |
131 |
/// nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], |
| 74 |
nodes_net3[nCN][9], nodes_net3LAN[nCN][5][nLANClients]; |
132 |
/// nodes_net3[nCN][9], nodes_net3LAN[nCN][5][nLANClients]; |
|
|
133 |
Array2D<NodeContainer> nodes_net0(nCN, 3); |
| 134 |
Array2D<NodeContainer> nodes_net1(nCN, 6); |
| 135 |
NodeContainer* nodes_netLR = new NodeContainer[nCN]; |
| 136 |
Array2D<NodeContainer> nodes_net2(nCN, 14); |
| 137 |
Array3D<NodeContainer> nodes_net2LAN(nCN, 7, nLANClients); |
| 138 |
Array2D<NodeContainer> nodes_net3(nCN, 9); |
| 139 |
Array3D<NodeContainer> nodes_net3LAN(nCN, 5, nLANClients); |
| 140 |
|
| 75 |
PointToPointHelper p2p_2gb200ms, p2p_1gb5ms, p2p_100mb1ms; |
141 |
PointToPointHelper p2p_2gb200ms, p2p_1gb5ms, p2p_100mb1ms; |
| 76 |
InternetStackHelper stack; |
142 |
InternetStackHelper stack; |
| 77 |
Ipv4InterfaceContainer ifs, ifs0[nCN][3], ifs1[nCN][6], ifs2[nCN][14], |
143 |
/// Ipv4InterfaceContainer ifs, ifs0[nCN][3], ifs1[nCN][6], ifs2[nCN][14], |
| 78 |
ifs3[nCN][9], ifs2LAN[nCN][7][nLANClients], |
144 |
/// ifs3[nCN][9], ifs2LAN[nCN][7][nLANClients], |
| 79 |
ifs3LAN[nCN][5][nLANClients]; |
145 |
/// ifs3LAN[nCN][5][nLANClients]; |
|
|
146 |
Ipv4InterfaceContainer ifs; |
| 147 |
Array2D<Ipv4InterfaceContainer> ifs0(nCN, 3); |
| 148 |
Array2D<Ipv4InterfaceContainer> ifs1(nCN, 6); |
| 149 |
Array2D<Ipv4InterfaceContainer> ifs2(nCN, 14); |
| 150 |
Array2D<Ipv4InterfaceContainer> ifs3(nCN, 9); |
| 151 |
Array3D<Ipv4InterfaceContainer> ifs2LAN(nCN, 7, nLANClients); |
| 152 |
Array3D<Ipv4InterfaceContainer> ifs3LAN(nCN, 5, nLANClients); |
| 153 |
|
| 80 |
Ipv4AddressHelper address; |
154 |
Ipv4AddressHelper address; |
| 81 |
std::ostringstream oss; |
155 |
std::ostringstream oss; |
| 82 |
p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); |
156 |
p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); |
|
|
| 175 |
{ |
249 |
{ |
| 176 |
ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]); |
250 |
ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]); |
| 177 |
} |
251 |
} |
| 178 |
NetDeviceContainer ndc2LAN[7][nLANClients]; |
252 |
/// NetDeviceContainer ndc2LAN[7][nLANClients]; |
|
|
253 |
Array2D<NetDeviceContainer> ndc2LAN(7, nLANClients); |
| 179 |
for (int i = 0; i < 7; ++i) |
254 |
for (int i = 0; i < 7; ++i) |
| 180 |
{ |
255 |
{ |
| 181 |
oss.str (""); |
256 |
oss.str (""); |
|
|
| 211 |
{ |
286 |
{ |
| 212 |
ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]); |
287 |
ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]); |
| 213 |
} |
288 |
} |
| 214 |
NetDeviceContainer ndc3LAN[5][nLANClients]; |
289 |
/// NetDeviceContainer ndc3LAN[5][nLANClients]; |
|
|
290 |
Array2D<NetDeviceContainer> ndc3LAN(5, nLANClients); |
| 215 |
for (int i = 0; i < 5; ++i) |
291 |
for (int i = 0; i < 5; ++i) |
| 216 |
{ |
292 |
{ |
| 217 |
oss.str (""); |
293 |
oss.str (""); |
|
|
| 320 |
if (nCN > 1) |
396 |
if (nCN > 1) |
| 321 |
{ |
397 |
{ |
| 322 |
cout << "Forming Ring Topology..." << endl; |
398 |
cout << "Forming Ring Topology..." << endl; |
| 323 |
NodeContainer nodes_ring[nCN]; |
399 |
NodeContainer* nodes_ring = new NodeContainer[nCN]; |
| 324 |
for (int z = 0; z < nCN-1; ++z) |
400 |
for (int z = 0; z < nCN-1; ++z) |
| 325 |
{ |
401 |
{ |
| 326 |
nodes_ring[z].Add (nodes_net0[z][0].Get (0)); |
402 |
nodes_ring[z].Add (nodes_net0[z][0].Get (0)); |
|
|
| 328 |
} |
404 |
} |
| 329 |
nodes_ring[nCN-1].Add (nodes_net0[nCN-1][0].Get (0)); |
405 |
nodes_ring[nCN-1].Add (nodes_net0[nCN-1][0].Get (0)); |
| 330 |
nodes_ring[nCN-1].Add (nodes_net0[0][0].Get (0)); |
406 |
nodes_ring[nCN-1].Add (nodes_net0[0][0].Get (0)); |
| 331 |
NetDeviceContainer ndc_ring[nCN]; |
407 |
NetDeviceContainer* ndc_ring = new NetDeviceContainer[nCN]; |
| 332 |
for (int z = 0; z < nCN; ++z) |
408 |
for (int z = 0; z < nCN; ++z) |
| 333 |
{ |
409 |
{ |
| 334 |
ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]); |
410 |
ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]); |
|
|
| 337 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
413 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 338 |
ifs = address.Assign (ndc_ring[z]); |
414 |
ifs = address.Assign (ndc_ring[z]); |
| 339 |
} |
415 |
} |
|
|
416 |
delete[] ndc_ring; |
| 417 |
delete[] nodes_ring; |
| 340 |
} |
418 |
} |
| 341 |
|
419 |
|
| 342 |
// Create Traffic Flows |
420 |
// Create Traffic Flows |
|
|
| 443 |
cout << "Simulator init time: " << d1 << endl; |
521 |
cout << "Simulator init time: " << d1 << endl; |
| 444 |
cout << "Simulator run time: " << d2 << endl; |
522 |
cout << "Simulator run time: " << d2 << endl; |
| 445 |
cout << "Total elapsed time: " << d1+d2 << endl; |
523 |
cout << "Total elapsed time: " << d1+d2 << endl; |
|
|
524 |
|
| 525 |
delete[] nodes_netLR; |
| 446 |
return 0; |
526 |
return 0; |
| 447 |
} |
527 |
} |