29#include "ns3/applications-module.h"
30#include "ns3/core-module.h"
31#include "ns3/internet-module.h"
32#include "ns3/network-module.h"
33#include "ns3/nix-vector-helper.h"
34#include "ns3/onoff-application.h"
35#include "ns3/packet-sink.h"
36#include "ns3/point-to-point-module.h"
37#include "ns3/simulator.h"
114 Array3D(
const size_t x,
const size_t y,
const size_t z)
153 auto t0 = std::chrono::steady_clock::now();
155 std::cout <<
" ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl;
164 cmd.AddValue(
"useIPv6",
"Use IPv6 instead of IPv4",
useIpv6);
165 cmd.AddValue(
"CN",
"Number of total CNs [2]",
nCN);
166 cmd.AddValue(
"LAN",
"Number of nodes per LAN [42]",
nLANClients);
167 cmd.AddValue(
"NIX",
"Toggle nix-vector routing",
nix);
172 std::cout <<
"This script can work in IPv6 only by using NIX" << std::endl;
177 std::cout <<
"Number of total CNs (" <<
nCN <<
") lower than minimum of 2" << std::endl;
181 std::cout <<
"Number of CNs: " <<
nCN <<
", LAN nodes: " <<
nLANClients << std::endl;
200 std::ostringstream
oss;
214 stack.SetRoutingHelper(nixRouting);
219 stack.SetRoutingHelper(nixRouting);
224 for (
int z = 0; z <
nCN; ++z)
226 std::cout <<
"Creating Campus Network " << z <<
":" << std::endl;
228 std::cout <<
" SubNet [ 0";
229 for (
int i = 0;
i < 3; ++
i)
238 for (
int i = 0;
i < 3; ++
i)
244 for (
int i = 0;
i < 6; ++
i)
255 for (
int i = 0;
i < 6; ++
i)
272 oss << 10 + z <<
".1.252.0";
278 oss << 2001 + z <<
":1:252::";
284 for (
int i = 0;
i < 14; ++
i)
304 for (
int i = 0;
i < 14; ++
i)
309 for (
int i = 0;
i < 7; ++
i)
314 oss << 10 + z <<
".4." << 15 +
i <<
".0";
319 oss << 2001 + z <<
":4:" << 15 +
i <<
"::";
343 std::cout <<
" 3 ]" << std::endl;
344 for (
int i = 0;
i < 9; ++
i)
359 for (
int i = 0;
i < 9; ++
i)
364 for (
int i = 0;
i < 5; ++
i)
369 oss << 10 + z <<
".5." << 10 +
i <<
".0";
374 oss << 2001 + z <<
":5:" << 10 +
i <<
"::";
397 std::cout <<
" Connecting Subnets..." << std::endl;
441 oss << 10 + z <<
".1.253.0";
446 oss << 10 + z <<
".1.254.0";
451 oss << 10 + z <<
".4.253.0";
456 oss << 10 + z <<
".4.254.0";
461 oss << 10 + z <<
".5.253.0";
466 oss << 10 + z <<
".5.254.0";
474 oss << 2001 + z <<
":1:253::";
479 oss << 2001 + z <<
":1:254::";
484 oss << 2001 + z <<
":4:253::";
489 oss << 2001 + z <<
":4:254::";
494 oss << 2001 + z <<
":5:253::";
499 oss << 2001 + z <<
":5:254::";
504 std::cout <<
" Assigning IP addresses..." << std::endl;
505 for (
int i = 0;
i < 3; ++
i)
510 oss << 10 + z <<
".1." << 1 +
i <<
".0";
516 oss << 2001 + z <<
":1:" << 1 +
i <<
"::";
521 for (
int i = 0;
i < 6; ++
i)
530 oss << 10 + z <<
".2." << 1 +
i <<
".0";
536 oss << 2001 + z <<
":2:" << 1 +
i <<
"::";
544 oss << 10 + z <<
".3.1.0";
550 oss << 2001 + z <<
":3:1::";
554 for (
int i = 0;
i < 14; ++
i)
559 oss << 10 + z <<
".4." << 1 +
i <<
".0";
565 oss << 2001 + z <<
":4:" << 1 +
i <<
"::";
570 for (
int i = 0;
i < 9; ++
i)
575 oss << 10 + z <<
".5." << 1 +
i <<
".0";
581 oss << 2001 + z <<
":5:" << 1 +
i <<
"::";
590 std::cout <<
"Forming Ring Topology..." << std::endl;
592 for (
int z = 0; z <
nCN - 1; ++z)
600 for (
int z = 0; z <
nCN; ++z)
606 oss <<
"254.1." << z + 1 <<
".0";
612 oss <<
"254:1:" << z + 1 <<
"::";
622 std::cout <<
"Creating TCP Traffic Flows:" << std::endl;
625 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
627 StringValue(
"ns3::ConstantRandomVariable[Constant=0.0]"));
644 for (
int z = 0; z <
nCN; ++z)
652 std::cout <<
" Campus Network " << z <<
" Flows [ Net2 ";
653 for (
int i = 0;
i < 7; ++
i)
662 r1 = 2 + (int)(4 *
urng->GetValue());
663 r2 = 10 *
urng->GetValue();
666 client.SetAttribute(
"Remote", remoteAddress);
673 std::cout <<
"Net3 ]" << std::endl;
674 for (
int i = 0;
i < 5; ++
i)
683 r1 = 2 + (int)(4 *
urng->GetValue());
684 r2 = 10 *
urng->GetValue();
687 client.SetAttribute(
"Remote", remoteAddress);
701 std::cout <<
"Using Nix-vectors..." << std::endl;
706 std::cout <<
"Populating Global Static Routing Tables..." << std::endl;
710 auto routingEnd = std::chrono::steady_clock::now();
712 <<
"Routing tables population took "
714 <<
"ms" << std::endl;
717 std::cout <<
"Running simulator..." << std::endl;
718 auto t1 = std::chrono::steady_clock::now();
721 auto t2 = std::chrono::steady_clock::now();
722 std::cout <<
"Simulator finished." << std::endl;
725 auto d1 = std::chrono::duration_cast<std::chrono::seconds>(
t1 -
t0);
726 auto d2 = std::chrono::duration_cast<std::chrono::seconds>(
t2 -
t1);
728 std::cout <<
"-----" << std::endl <<
"Runtime Stats:" << std::endl;
729 std::cout <<
"Simulator init time: " <<
d1.count() <<
"s" << std::endl;
730 std::cout <<
"Simulator run time: " <<
d2.count() <<
"s" << std::endl;
731 std::cout <<
"Total elapsed time: " << (
d1 +
d2).count() <<
"s" << std::endl;
2D array used in nix-vector-routing example "nms-p2p-nix.cc"
Array2D(const size_t x, const size_t y)
Constructor.
T * operator[](const size_t i)
Accessor operator.
const size_t m_xMax
maximum number of rows
3D array used in nix-vector-routing example "nms-p2p-nix.cc"
Array3D(const size_t x, const size_t y, const size_t z)
Constructor.
const size_t m_xMax
maximum number of rows
Array2D< T > ** p
Stored elements.
Array2D< T > & operator[](const size_t i)
Accessor operator.
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Parse command-line arguments.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Helper class to auto-assign global IPv6 unicast addresses.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Describes an IPv6 prefix.
holds a vector of ns3::NetDevice pointers
Helper class that adds Nix-vector routing to nodes.
keep track of a set of node pointers.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
static uint32_t GetNNodes()
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.