18#include "ns3/applications-module.h"
19#include "ns3/core-module.h"
20#include "ns3/csma-module.h"
21#include "ns3/internet-module.h"
22#include "ns3/mobility-module.h"
23#include "ns3/mpi-module.h"
24#include "ns3/network-module.h"
25#include "ns3/point-to-point-module.h"
27#include "ns3/yans-wifi-helper.h"
59main(
int argc,
char* argv[])
69 cmd.AddValue(
"nCsma",
"Number of \"extra\" CSMA nodes/devices",
nCsma);
70 cmd.AddValue(
"nWifi",
"Number of wifi STA devices",
nWifi);
71 cmd.AddValue(
"verbose",
"Tell echo applications to log if true",
verbose);
72 cmd.AddValue(
"tracing",
"Enable pcap tracing",
tracing);
73 cmd.AddValue(
"nullmsg",
"Enable the use of null-message synchronization", nullmsg);
74 cmd.AddValue(
"test",
"Enable regression test output", testing);
76 cmd.Parse(argc, argv);
83 std::cout <<
"nWifi should be 18 or less; otherwise grid layout exceeds the bounding box"
103 GlobalValue::Bind(
"SimulatorImplementationType",
108 GlobalValue::Bind(
"SimulatorImplementationType",
112 MpiInterface::Enable(&argc, &argv);
116 systemId = MpiInterface::GetSystemId();
121 if (systemCount != 2)
123 std::cout <<
"This simulation requires 2 and only 2 logical processors." << std::endl;
131 uint32_t systemCsma = systemCount - 1;
135 Ptr<Node> p2pNode1 = CreateObject<Node>(systemWifi);
136 Ptr<Node> p2pNode2 = CreateObject<Node>(systemCsma);
183 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
197 mobility.SetMobilityModel(
"ns3::RandomWalk2dMobilityModel",
202 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
212 address.SetBase(
"10.1.1.0",
"255.255.255.0");
216 address.SetBase(
"10.1.2.0",
"255.255.255.0");
220 address.SetBase(
"10.1.3.0",
"255.255.255.0");
227 if (systemId == systemCsma)
237 serverApps.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
245 if (systemId == systemWifi)
258 clientApps.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
263 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
265 Simulator::Stop(
Seconds(10.0));
274 if (systemId == systemCsma)
277 phy.EnablePcap(
"third-distributed-csma",
apDevices.Get(0));
283 phy.EnablePcap(
"third-distributed-wifi",
apDevices.Get(0));
289 Simulator::Destroy();
293 SinkTracer::Verify(2);
297 MpiInterface::Disable();
holds a vector of ns3::Application pointers.
AttributeValue implementation for Boolean.
Parse command-line arguments.
build a set of CsmaNetDevice objects
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Build a set of PointToPointNetDevice objects.
AttributeValue implementation for Rectangle.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
AttributeValue implementation for Time.
Create an application which sends a UDP packet and waits for an echo of this packet.
Create a server application which waits for input UDP packets and sends them back to the original sen...
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...
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.
void LogComponentEnable(const char *name, enum LogLevel level)
Enable the logging output associated with that log component.
bool tracing
Flag to enable/disable generation of tracing files.