|
|
| 71 |
|
71 |
|
| 72 |
TIMER_TYPE t0, t1, t2; |
72 |
TIMER_TYPE t0, t1, t2; |
| 73 |
TIMER_NOW (t0); |
73 |
TIMER_NOW (t0); |
| 74 |
cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << endl; |
74 |
std::cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl; |
| 75 |
|
75 |
|
| 76 |
GlobalValue::Bind ("SimulatorImplementationType", |
76 |
GlobalValue::Bind ("SimulatorImplementationType", |
| 77 |
StringValue ("ns3::DistributedSimulatorImpl")); |
77 |
StringValue ("ns3::DistributedSimulatorImpl")); |
|
|
| 94 |
|
94 |
|
| 95 |
if (nCN < 2) |
95 |
if (nCN < 2) |
| 96 |
{ |
96 |
{ |
| 97 |
cout << "Number of total CNs (" << nCN << ") lower than minimum of 2" |
97 |
std::cout << "Number of total CNs (" << nCN << ") lower than minimum of 2" |
| 98 |
<< endl; |
98 |
<< std::endl; |
| 99 |
return 1; |
99 |
return 1; |
| 100 |
} |
100 |
} |
| 101 |
if (systemCount > nCN) |
101 |
if (systemCount > nCN) |
| 102 |
{ |
102 |
{ |
| 103 |
cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" |
103 |
std::cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" |
| 104 |
<< systemCount << ")." << endl; |
104 |
<< systemCount << ")." << std::endl; |
| 105 |
return 1; |
105 |
return 1; |
| 106 |
} |
106 |
} |
| 107 |
|
107 |
|
| 108 |
cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl; |
108 |
std::cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << std::endl; |
| 109 |
|
109 |
|
| 110 |
NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], |
110 |
NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], |
| 111 |
nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], |
111 |
nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], |
|
|
| 139 |
// Create Campus Networks |
139 |
// Create Campus Networks |
| 140 |
for (uint32_t z = 0; z < nCN; ++z) |
140 |
for (uint32_t z = 0; z < nCN; ++z) |
| 141 |
{ |
141 |
{ |
| 142 |
cout << "Creating Campus Network " << z << ":" << endl; |
142 |
std::cout << "Creating Campus Network " << z << ":" << std::endl; |
| 143 |
// Create Net0 |
143 |
// Create Net0 |
| 144 |
cout << " SubNet [ 0"; |
144 |
std::cout << " SubNet [ 0"; |
| 145 |
for (int i = 0; i < 3; ++i) |
145 |
for (int i = 0; i < 3; ++i) |
| 146 |
{ |
146 |
{ |
| 147 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
147 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
|
|
| 157 |
ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]); |
157 |
ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]); |
| 158 |
} |
158 |
} |
| 159 |
// Create Net1 |
159 |
// Create Net1 |
| 160 |
cout << " 1"; |
160 |
std::cout << " 1"; |
| 161 |
for (int i = 0; i < 6; ++i) |
161 |
for (int i = 0; i < 6; ++i) |
| 162 |
{ |
162 |
{ |
| 163 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
163 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
|
|
| 189 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
189 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 190 |
ifs = address.Assign (ndc0_1); |
190 |
ifs = address.Assign (ndc0_1); |
| 191 |
// Create Net2 |
191 |
// Create Net2 |
| 192 |
cout << " 2"; |
192 |
std::cout << " 2"; |
| 193 |
for (int i = 0; i < 14; ++i) |
193 |
for (int i = 0; i < 14; ++i) |
| 194 |
{ |
194 |
{ |
| 195 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
195 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
|
|
| 232 |
} |
232 |
} |
| 233 |
} |
233 |
} |
| 234 |
// Create Net3 |
234 |
// Create Net3 |
| 235 |
cout << " 3 ]" << endl; |
235 |
std::cout << " 3 ]" << std::endl; |
| 236 |
for (int i = 0; i < 9; ++i) |
236 |
for (int i = 0; i < 9; ++i) |
| 237 |
{ |
237 |
{ |
| 238 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
238 |
Ptr<Node> node = CreateObject<Node> (z % systemCount); |
|
|
| 269 |
ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]); |
269 |
ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]); |
| 270 |
} |
270 |
} |
| 271 |
} |
271 |
} |
| 272 |
cout << " Connecting Subnets..." << endl; |
272 |
std::cout << " Connecting Subnets..." << std::endl; |
| 273 |
// Create Lone Routers (Node 4 & 5) |
273 |
// Create Lone Routers (Node 4 & 5) |
| 274 |
Ptr<Node> node1 = CreateObject<Node> (z % systemCount); |
274 |
Ptr<Node> node1 = CreateObject<Node> (z % systemCount); |
| 275 |
Ptr<Node> node2 = CreateObject<Node> (z % systemCount); |
275 |
Ptr<Node> node2 = CreateObject<Node> (z % systemCount); |
|
|
| 324 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
324 |
address.SetBase (oss.str ().c_str (), "255.255.255.0"); |
| 325 |
ifs = address.Assign (ndc3_5b); |
325 |
ifs = address.Assign (ndc3_5b); |
| 326 |
// Assign IP addresses |
326 |
// Assign IP addresses |
| 327 |
cout << " Assigning IP addresses..." << endl; |
327 |
std::cout << " Assigning IP addresses..." << std::endl; |
| 328 |
for (int i = 0; i < 3; ++i) |
328 |
for (int i = 0; i < 3; ++i) |
| 329 |
{ |
329 |
{ |
| 330 |
oss.str (""); |
330 |
oss.str (""); |
|
|
| 365 |
// Create Ring Links |
365 |
// Create Ring Links |
| 366 |
if (nCN > 1) |
366 |
if (nCN > 1) |
| 367 |
{ |
367 |
{ |
| 368 |
cout << "Forming Ring Topology..." << endl; |
368 |
std::cout << "Forming Ring Topology..." << std::endl; |
| 369 |
NodeContainer nodes_ring[nCN]; |
369 |
NodeContainer nodes_ring[nCN]; |
| 370 |
for (uint32_t z = 0; z < nCN - 1; ++z) |
370 |
for (uint32_t z = 0; z < nCN - 1; ++z) |
| 371 |
{ |
371 |
{ |
|
|
| 386 |
} |
386 |
} |
| 387 |
|
387 |
|
| 388 |
// Create Traffic Flows |
388 |
// Create Traffic Flows |
| 389 |
cout << "Creating UDP Traffic Flows:" << endl; |
389 |
std::cout << "Creating UDP Traffic Flows:" << std::endl; |
| 390 |
Config::SetDefault ("ns3::OnOffApplication::MaxBytes", |
390 |
Config::SetDefault ("ns3::OnOffApplication::MaxBytes", |
| 391 |
UintegerValue (nBytes)); |
391 |
UintegerValue (nBytes)); |
| 392 |
Config::SetDefault ("ns3::OnOffApplication::OnTime", |
392 |
Config::SetDefault ("ns3::OnOffApplication::OnTime", |
|
|
| 407 |
|
407 |
|
| 408 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
408 |
OnOffHelper client ("ns3::UdpSocketFactory", Address ()); |
| 409 |
AddressValue remoteAddress (InetSocketAddress (ifs1[0][2].GetAddress (0), 9999)); |
409 |
AddressValue remoteAddress (InetSocketAddress (ifs1[0][2].GetAddress (0), 9999)); |
| 410 |
cout << "Remote Address is " << ifs1[0][2].GetAddress (0) << endl; |
410 |
std::cout << "Remote Address is " << ifs1[0][2].GetAddress (0) << std::endl; |
| 411 |
client.SetAttribute ("Remote", remoteAddress); |
411 |
client.SetAttribute ("Remote", remoteAddress); |
| 412 |
|
412 |
|
| 413 |
ApplicationContainer clientApp; |
413 |
ApplicationContainer clientApp; |
|
|
| 430 |
AddressValue remoteAddress |
430 |
AddressValue remoteAddress |
| 431 |
(InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); |
431 |
(InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); |
| 432 |
|
432 |
|
| 433 |
cout << "Remote Address is " << ifs1[1][0].GetAddress (0) << endl; |
433 |
std::cout << "Remote Address is " << ifs1[1][0].GetAddress (0) << std::endl; |
| 434 |
client.SetAttribute ("Remote", remoteAddress); |
434 |
client.SetAttribute ("Remote", remoteAddress); |
| 435 |
|
435 |
|
| 436 |
ApplicationContainer clientApp; |
436 |
ApplicationContainer clientApp; |
|
|
| 451 |
x = 0; |
451 |
x = 0; |
| 452 |
} |
452 |
} |
| 453 |
// Subnet 2 LANs |
453 |
// Subnet 2 LANs |
| 454 |
cout << " Campus Network " << z << " Flows [ Net2 "; |
454 |
std::cout << " Campus Network " << z << " Flows [ Net2 "; |
| 455 |
for (int i = 0; i < 7; ++i) |
455 |
for (int i = 0; i < 7; ++i) |
| 456 |
{ |
456 |
{ |
| 457 |
for (uint32_t j = 0; j < nLANClients; ++j) |
457 |
for (uint32_t j = 0; j < nLANClients; ++j) |
|
|
| 511 |
} |
511 |
} |
| 512 |
} |
512 |
} |
| 513 |
// Subnet 3 LANs |
513 |
// Subnet 3 LANs |
| 514 |
cout << "Net3 ]" << endl; |
514 |
std::cout << "Net3 ]" << std::endl; |
| 515 |
for (int i = 0; i < 5; ++i) |
515 |
for (int i = 0; i < 5; ++i) |
| 516 |
{ |
516 |
{ |
| 517 |
for (uint32_t j = 0; j < nLANClients; ++j) |
517 |
for (uint32_t j = 0; j < nLANClients; ++j) |
|
|
| 573 |
} |
573 |
} |
| 574 |
} |
574 |
} |
| 575 |
|
575 |
|
| 576 |
cout << "Created " << NodeList::GetNNodes () << " nodes." << endl; |
576 |
std::cout << "Created " << NodeList::GetNNodes () << " nodes." << std::endl; |
| 577 |
TIMER_TYPE routingStart; |
577 |
TIMER_TYPE routingStart; |
| 578 |
TIMER_NOW (routingStart); |
578 |
TIMER_NOW (routingStart); |
| 579 |
|
579 |
|
| 580 |
if (nix) |
580 |
if (nix) |
| 581 |
{ |
581 |
{ |
| 582 |
cout << "Using Nix-vectors..." << endl; |
582 |
std::cout << "Using Nix-vectors..." << std::endl; |
| 583 |
} |
583 |
} |
| 584 |
else |
584 |
else |
| 585 |
{ |
585 |
{ |
| 586 |
// Calculate routing tables |
586 |
// Calculate routing tables |
| 587 |
cout << "Populating Routing tables..." << endl; |
587 |
std::cout << "Populating Routing tables..." << std::endl; |
| 588 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
588 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
| 589 |
} |
589 |
} |
| 590 |
|
590 |
|
| 591 |
TIMER_TYPE routingEnd; |
591 |
TIMER_TYPE routingEnd; |
| 592 |
TIMER_NOW (routingEnd); |
592 |
TIMER_NOW (routingEnd); |
| 593 |
cout << "Routing tables population took " |
593 |
std::cout << "Routing tables population took " |
| 594 |
<< TIMER_DIFF (routingEnd, routingStart) << endl; |
594 |
<< TIMER_DIFF (routingEnd, routingStart) << std::endl; |
| 595 |
|
595 |
|
| 596 |
cout << "Running simulator..." << endl; |
596 |
std::cout << "Running simulator..." << std::endl; |
| 597 |
TIMER_NOW (t1); |
597 |
TIMER_NOW (t1); |
| 598 |
Simulator::Stop (Seconds (100.0)); |
598 |
Simulator::Stop (Seconds (100.0)); |
| 599 |
Simulator::Run (); |
599 |
Simulator::Run (); |
| 600 |
TIMER_NOW (t2); |
600 |
TIMER_NOW (t2); |
| 601 |
cout << "Simulator finished." << endl; |
601 |
std::cout << "Simulator finished." << std::endl; |
| 602 |
Simulator::Destroy (); |
602 |
Simulator::Destroy (); |
| 603 |
// Exit the MPI execution environment |
603 |
// Exit the MPI execution environment |
| 604 |
MpiInterface::Disable (); |
604 |
MpiInterface::Disable (); |
| 605 |
double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1); |
605 |
double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1); |
| 606 |
cout << "-----" << endl << "Runtime Stats:" << endl; |
606 |
std::cout << "-----" << std::endl << "Runtime Stats:" << std::endl; |
| 607 |
cout << "Simulator init time: " << d1 << endl; |
607 |
std::cout << "Simulator init time: " << d1 << std::endl; |
| 608 |
cout << "Simulator run time: " << d2 << endl; |
608 |
std::cout << "Simulator run time: " << d2 << std::endl; |
| 609 |
cout << "Total elapsed time: " << d1 + d2 << endl; |
609 |
std::cout << "Total elapsed time: " << d1 + d2 << std::endl; |
| 610 |
return 0; |
610 |
return 0; |
| 611 |
#else |
611 |
#else |
| 612 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
612 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |