7#include "ns3/applications-module.h"
8#include "ns3/core-module.h"
9#include "ns3/csma-module.h"
10#include "ns3/internet-module.h"
11#include "ns3/mobility-module.h"
12#include "ns3/mpi-module.h"
13#include "ns3/network-module.h"
14#include "ns3/point-to-point-module.h"
16#include "ns3/yans-wifi-helper.h"
48main(
int argc,
char* argv[])
58 cmd.AddValue(
"nCsma",
"Number of \"extra\" CSMA nodes/devices", nCsma);
59 cmd.AddValue(
"nWifi",
"Number of wifi STA devices", nWifi);
60 cmd.AddValue(
"verbose",
"Tell echo applications to log if true",
verbose);
61 cmd.AddValue(
"tracing",
"Enable pcap tracing",
tracing);
62 cmd.AddValue(
"nullmsg",
"Enable the use of null-message synchronization", nullmsg);
63 cmd.AddValue(
"test",
"Enable regression test output", testing);
65 cmd.Parse(argc, argv);
72 std::cout <<
"nWifi should be 18 or less; otherwise grid layout exceeds the bounding box"
110 if (systemCount != 2)
112 std::cout <<
"This simulation requires 2 and only 2 logical processors." << std::endl;
120 uint32_t systemCsma = systemCount - 1;
172 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
186 mobility.SetMobilityModel(
"ns3::RandomWalk2dMobilityModel",
191 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
195 stack.Install(csmaNodes);
196 stack.Install(wifiApNode);
197 stack.Install(wifiStaNodes);
201 address.SetBase(
"10.1.1.0",
"255.255.255.0");
205 address.SetBase(
"10.1.2.0",
"255.255.255.0");
209 address.SetBase(
"10.1.3.0",
"255.255.255.0");
216 if (systemId == systemCsma)
226 serverApps.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
234 if (systemId == systemWifi)
247 clientApps.Get(0)->TraceConnectWithoutContext(
"RxWithAddresses",
263 if (systemId == systemCsma)
266 phy.EnablePcap(
"third-distributed-csma",
apDevices.Get(0));
272 phy.EnablePcap(
"third-distributed-wifi",
apDevices.Get(0));
holds a vector of ns3::Application pointers.
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'.
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 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.
Helper class used to assign positions and mobility models to nodes.
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
keep track of a set of node pointers.
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.
The IEEE 802.11 SSID Information Element.
Hold variables of type string.
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.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
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.
bool tracing
Flag to enable/disable generation of tracing files.