15#include "ns3/building-allocator.h"
16#include "ns3/building-penetration-loss.h"
17#include "ns3/buildings-helper.h"
18#include "ns3/callback.h"
19#include "ns3/class-a-end-device-lorawan-mac.h"
20#include "ns3/command-line.h"
21#include "ns3/constant-position-mobility-model.h"
22#include "ns3/correlated-shadowing-propagation-loss-model.h"
23#include "ns3/double.h"
24#include "ns3/end-device-lora-phy.h"
25#include "ns3/forwarder-helper.h"
26#include "ns3/gateway-lora-phy.h"
27#include "ns3/gateway-lorawan-mac.h"
29#include "ns3/lora-helper.h"
30#include "ns3/lorawan-mac-header.h"
31#include "ns3/mobility-helper.h"
32#include "ns3/network-server-helper.h"
33#include "ns3/node-container.h"
34#include "ns3/one-shot-sender-helper.h"
35#include "ns3/periodic-sender-helper.h"
36#include "ns3/pointer.h"
37#include "ns3/position-allocator.h"
38#include "ns3/random-variable-stream.h"
39#include "ns3/simulator.h"
45using namespace lorawan;
65 packetCopy->RemoveHeader(mHdr);
67 packetCopy->RemoveHeader(fHdr);
109 endDevice->GetObject<
MobilityModel>()->SetPosition(Vector(0.0, 0.0, 0.0));
114 endDevice->GetObject<
MobilityModel>()->SetPosition(Vector(10000.0, 0.0, 0.0));
119main(
int argc,
char* argv[])
123 cmd.AddValue(
"MaxTransmissions",
"ns3::EndDeviceLorawanMac::MaxTransmissions");
124 cmd.AddValue(
"MType",
"ns3::EndDeviceLorawanMac::MType");
125 cmd.Parse(argc, argv);
138 allocator->Add(Vector(100000.0, 0.0, 15.0));
139 allocator->Add(Vector(0.0, 0.0, 15.0));
140 mobility.SetPositionAllocator(allocator);
141 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
149 loss->SetPathLossExponent(3.76);
150 loss->SetReference(1, 7.7);
189 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
192 Vector position =
mobility->GetPosition();
208 helper.
Install(phyHelper, macHelper, endDevices);
211 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
226 mobility.SetPositionAllocator(allocator);
232 helper.
Install(phyHelper, macHelper, gateways);
245 appContainer.
Add(appHelper.
Install(endDevices));
247 appContainer.
Add(appHelper.
Install(endDevices));
250 appContainer.
Stop(appStopTime);
269 for (
auto gw = gateways.
Begin(); gw != gateways.
End(); ++gw)
273 gwRegistration.emplace_back(serverP2PNetDev, *gw);
279 nsHelper.
Install(networkServer);
300 NS_LOG_INFO(
"Printing total sent MAC-layer packets and successful MAC-layer packets");
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 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.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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 void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
This class can be used to install Forwarder applications on a set of gateways.
ApplicationContainer Install(NodeContainer c) const
Install a Forwarder application on each node of the input container configured with all the attribute...
Helps to create LoraNetDevice objects.
void EnablePacketTracking()
Enable tracking of packets via trace sources.
LoraPacketTracker & GetPacketTracker()
Get a reference to the Packet Tracker object.
virtual NetDeviceContainer Install(const LoraPhyHelper &phyHelper, const LorawanMacHelper &macHelper, NodeContainer c) const
Install LoraNetDevices on a list of nodes.
Tracks and stores packets sent in the simulation and provides aggregation functionality.
std::string CountMacPacketsGlobally(Time startTime, Time stopTime)
In a time interval, count packets to evaluate the global performance at MAC level of the whole networ...
Helper to install LoraPhy instances on multiple Nodes.
void SetDeviceType(enum DeviceType dt)
Set the kind of PHY this helper will create.
void SetChannel(Ptr< LoraChannel > channel)
Set the LoraChannel to connect the PHYs to.
Helper class for configuring and installing the LorawanMac class on devices and gateways.
void SetDeviceType(enum DeviceType dt)
Set the kind of MAC this helper will create.
void SetAddressGenerator(Ptr< LoraDeviceAddressGenerator > addrGen)
Set the address generator to use for creation of these nodes.
void Set(std::string name, const AttributeValue &v)
Set an attribute of the underlying MAC object.
This class can install a NetworkServer application on a node.
void SetGatewaysP2P(const P2PGwRegistration_t ®istration)
Register gateways connected with point-to-point to this network server.
void SetEndDevices(NodeContainer endDevices)
Set which end devices will be managed by this network server.
ApplicationContainer Install(Ptr< Node > node)
Create one lorawan network server application on the Node.
This class can be used to install OneShotSender applications on multiple nodes at once.
void SetSendTime(Time sendTime)
Set the send time of the applications.
ApplicationContainer Install(NodeContainer c) const
Install a OneShotSender application on each node of the input container configured with all the attri...
void OnPhySentPacket(Ptr< const Packet > packet, uint32_t index)
Record a packet TX start by the PHY layer of an end device.
double simulationTimeSeconds
Scenario duration (s) in simulated time.
void OnMacPacketOutcome(uint8_t transmissions, bool successful, Time firstAttempt, Ptr< Packet > packet)
Record the exit status of a MAC layer packet retransmission process of an end device.
void ChangeEndDevicePosition(Ptr< Node > endDevice, bool inRange)
Set the position of an end device as either in range or out of range.
int nGateways
Number of gateway nodes to create.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Hours(double value)
Construct a Time in the indicated unit.
std::list< std::pair< Ptr< PointToPointNetDevice >, Ptr< Node > > > P2PGwRegistration_t
Store network server app registration details for gateway nodes having a P2P link with the network se...
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
@ LOG_LEVEL_ALL
Print everything.