68#include "ns3/core-module.h"
69#include "ns3/internet-stack-helper.h"
70#include "ns3/ipv4-address-helper.h"
71#include "ns3/ipv4-global-routing-helper.h"
72#include "ns3/mpi-interface.h"
73#include "ns3/network-module.h"
74#include "ns3/nix-vector-helper.h"
75#include "ns3/on-off-helper.h"
76#include "ns3/packet-sink-helper.h"
77#include "ns3/point-to-point-helper.h"
86main(
int argc,
char* argv[])
96 cmd.AddValue(
"nix",
"Enable the use of nix-vector or global routing", nix);
97 cmd.AddValue(
"nullmsg",
"Enable the use of null-message synchronization", nullmsg);
98 cmd.AddValue(
"tracing",
"Enable pcap tracing",
tracing);
99 cmd.AddValue(
"verbose",
"verbose output",
verbose);
100 cmd.AddValue(
"test",
"Enable regression test output", testing);
101 cmd.Parse(argc, argv);
106 GlobalValue::Bind(
"SimulatorImplementationType",
111 GlobalValue::Bind(
"SimulatorImplementationType",
115 MpiInterface::Enable(&argc, &argv);
125 uint32_t systemId = MpiInterface::GetSystemId();
132 if (systemCount == 2)
134 rightHalfSystemId = 0;
136 else if (systemCount == 3)
138 rightHalfSystemId = 1;
142 std::cout <<
"This simulation requires 2 or 3 logical processors." << std::endl;
153 leftLeafNodes.
Create(4, 0);
159 Ptr<Node> routerNode1 = CreateObject<Node>(0);
160 Ptr<Node> routerNode2 = CreateObject<Node>(rightHalfSystemId);
161 routerNodes.
Add(routerNode1);
162 routerNodes.
Add(routerNode2);
166 rightLeafNodes.
Create(4, rightHalfSystemId);
178 routerDevices = routerLink.
Install(routerNodes);
186 leftLeafDevices.
Add(temp.
Get(0));
187 leftRouterDevices.
Add(temp.
Get(1));
196 rightLeafDevices.
Add(temp.
Get(0));
197 rightRouterDevices.
Add(temp.
Get(1));
204 stack.SetRoutingHelper(nixRouting);
216 leftAddress.
SetBase(
"10.1.1.0",
"255.255.255.0");
219 routerAddress.
SetBase(
"10.2.1.0",
"255.255.255.0");
222 rightAddress.
SetBase(
"10.3.1.0",
"255.255.255.0");
225 routerInterfaces = routerAddress.
Assign(routerDevices);
231 ndc.
Add(leftLeafDevices.
Get(i));
232 ndc.
Add(leftRouterDevices.
Get(i));
234 leftLeafInterfaces.
Add(ifc.
Get(0));
235 leftRouterInterfaces.
Add(ifc.
Get(1));
243 ndc.
Add(rightLeafDevices.
Get(i));
244 ndc.
Add(rightRouterDevices.
Get(i));
246 rightLeafInterfaces.
Add(ifc.
Get(0));
247 rightRouterInterfaces.
Add(ifc.
Get(1));
253 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
260 routerLink.
EnablePcap(
"router-left", routerDevices,
true);
261 leafLink.
EnablePcap(
"leaf-left", leftLeafDevices,
true);
264 if (systemId == rightHalfSystemId)
266 routerLink.
EnablePcap(
"router-right", routerDevices,
true);
267 leafLink.
EnablePcap(
"leaf-right", rightLeafDevices,
true);
272 uint16_t
port = 50000;
273 if (systemId == rightHalfSystemId)
280 sinkApp.
Add(sinkHelper.Install(rightLeafNodes.
Get(i)));
295 clientHelper.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
296 clientHelper.SetAttribute(
"OffTime",
297 StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
303 clientHelper.SetAttribute(
"Remote", remoteAddress);
312 Simulator::Destroy();
316 SinkTracer::Verify(4);
320 MpiInterface::Disable();
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.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the 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.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address NewNetwork()
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Helper class that adds Nix-vector routing to nodes.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
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.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
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.
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.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
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...
LogLevel
Logging severity classes and levels.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
@ LOG_LEVEL_INFO
LOG_INFO and above.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
bool tracing
Flag to enable/disable generation of tracing files.