31#include "ns3/core-module.h"
32#include "ns3/internet-module.h"
33#include "ns3/mpi-interface.h"
34#include "ns3/network-module.h"
35#include "ns3/nix-vector-helper.h"
36#include "ns3/on-off-helper.h"
37#include "ns3/packet-sink-helper.h"
38#include "ns3/point-to-point-helper.h"
56 typedef std::vector<vectorOfVectorOfIpv4InterfaceContainer>
78 cmd.AddValue(
"campuses",
"Number of campus networks",
nCN);
79 cmd.AddValue(
"clients",
"Number of client nodes per LAN",
nLANClients);
80 cmd.AddValue(
"packets",
"Number of packets each on/off app should send", nPackets);
81 cmd.AddValue(
"nix",
"Toggle the use of nix-vector or global routing",
nix);
82 cmd.AddValue(
"stop",
"Simulation run time", stop);
83 cmd.AddValue(
"single",
"Use single on/off app per campus network", single);
84 cmd.AddValue(
"verbose",
"Show extra timing information",
verbose);
85 cmd.AddValue(
"test",
"Enable regression test output", testing);
97 RANK0COUT(
" ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl);
103 RANK0COUT(
"Number of total CNs (" <<
nCN <<
") lower than minimum of 2" << std::endl);
109 <<
")." << std::endl);
147 std::ostringstream
oss;
158 stack.SetRoutingHelper(nixRouting);
164 RANK0COUT(
"Creating Campus Network " << z <<
":" << std::endl);
167 for (
int i = 0;
i < 3; ++
i)
177 for (
int i = 0;
i < 3; ++
i)
183 for (
int i = 0;
i < 6; ++
i)
195 for (
int i = 0;
i < 6; ++
i)
210 oss << 10 + z <<
".1.252.0";
211 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
215 for (
int i = 0;
i < 14; ++
i)
236 for (
int i = 0;
i < 14; ++
i)
241 for (
int i = 0;
i < 7; ++
i)
244 oss << 10 + z <<
".4." << 15 +
i <<
".0";
245 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
258 for (
int i = 0;
i < 9; ++
i)
274 for (
int i = 0;
i < 9; ++
i)
279 for (
int i = 0;
i < 5; ++
i)
282 oss << 10 + z <<
".5." << 10 +
i <<
".0";
283 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
294 RANK0COUT(
" Connecting Subnets..." << std::endl);
330 oss << 10 + z <<
".1.253.0";
331 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
335 oss << 10 + z <<
".1.254.0";
336 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
340 oss << 10 + z <<
".4.253.0";
341 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
345 oss << 10 + z <<
".4.254.0";
346 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
350 oss << 10 + z <<
".5.253.0";
351 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
355 oss << 10 + z <<
".5.254.0";
356 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
359 RANK0COUT(
" Assigning IP addresses..." << std::endl);
360 for (
int i = 0;
i < 3; ++
i)
363 oss << 10 + z <<
".1." << 1 +
i <<
".0";
364 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
367 for (
int i = 0;
i < 6; ++
i)
374 oss << 10 + z <<
".2." << 1 +
i <<
".0";
375 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
379 oss << 10 + z <<
".3.1.0";
380 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
382 for (
int i = 0;
i < 14; ++
i)
385 oss << 10 + z <<
".4." << 1 +
i <<
".0";
386 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
389 for (
int i = 0;
i < 9; ++
i)
392 oss << 10 + z <<
".5." << 1 +
i <<
".0";
393 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
400 RANK0COUT(
"Forming Ring Topology..." << std::endl);
414 oss <<
"254.1." << z + 1 <<
".0";
415 address.SetBase(
oss.str().c_str(),
"255.255.255.0");
421 RANK0COUT(
"Creating UDP Traffic Flows:" << std::endl);
424 StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
426 StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
438 sinkApp.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
444 RANK0COUT(
"Remote Address is " <<
ifs1[0][2].GetAddress(0) << std::endl);
445 client.SetAttribute(
"Remote", remoteAddress);
459 sinkApp.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
468 RANK0COUT(
"Remote Address is " <<
ifs1[1][0].GetAddress(0) << std::endl);
469 client.SetAttribute(
"Remote", remoteAddress);
489 RANK0COUT(
" Campus Network " << z <<
" Flows [ Net2 ");
490 for (
int i = 0;
i < 7; ++
i)
506 sinkApp.Get(0)->TraceConnectWithoutContext(
522 sinkApp.Get(0)->TraceConnectWithoutContext(
530 r1 = 2 + (int)(4 *
urng->GetValue());
531 r2 = 10 *
urng->GetValue();
537 client.SetAttribute(
"Remote", remoteAddress);
544 r1 = 2 + (int)(4 *
urng->GetValue());
545 r2 = 10 *
urng->GetValue();
551 client.SetAttribute(
"Remote", remoteAddress);
560 for (
int i = 0;
i < 5; ++
i)
575 sinkApp.Get(0)->TraceConnectWithoutContext(
591 sinkApp.Get(0)->TraceConnectWithoutContext(
599 r1 = 2 + (int)(4 *
urng->GetValue());
600 r2 = 10 *
urng->GetValue();
606 client.SetAttribute(
"Remote", remoteAddress);
613 r1 = 2 + (int)(4 *
urng->GetValue());
614 r2 = 10 *
urng->GetValue();
620 client.SetAttribute(
"Remote", remoteAddress);
637 RANK0COUT(
"Using Nix-vectors..." << std::endl);
642 RANK0COUT(
"Populating Routing tables..." << std::endl);
653 RANK0COUT(
"Running simulator..." << std::endl);
658 RANK0COUT(
"Simulator finished." << std::endl);
678 <<
"Simulator init time: " <<
t1.GetElapsedReal() <<
"ms\n"
679 <<
"Simulator run time: " <<
t2.GetElapsedReal() <<
"ms\n"
680 <<
"Total elapsed time: " <<
t0.GetElapsedReal() <<
"ms" << std::endl);
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.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
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.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
static uint32_t GetSystemId()
Get the id number of this rank.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
static void Disable()
Clean up the ns-3 parallel communications interface.
static void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
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 void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static void SinkTrace(const ns3::Ptr< const ns3::Packet > packet, const ns3::Address &srcAddress, const ns3::Address &destAddress)
PacketSink receive trace callback.
static void Verify(unsigned long expectedCount)
Verify the sink trace count observed matches the expected count.
static void Init()
PacketSink Init.
Hold variables of type string.
Measure elapsed wall clock time in milliseconds.
void Start()
Start a measure.
Simulation virtual time values and global simulation resolution.
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.
#define RANK0COUT(x)
Write to std::cout only from rank 0.
#define RANK0COUTAPPEND(x)
Append to std::cout only from rank 0.
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.
Common methods for MPI examples.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...