15#include "ns3/buildings-module.h"
16#include "ns3/core-module.h"
17#include "ns3/lorawan-module.h"
18#include "ns3/mobility-helper.h"
19#include "ns3/point-to-point-helper.h"
42main(
int argc,
char* argv[])
45 cmd.AddValue(
"nDevices",
"Number of end devices to include in the simulation",
nDevices);
46 cmd.AddValue(
"radius",
"The radius (m) of the area to simulate",
radiusMeters);
47 cmd.AddValue(
"realisticChannel",
48 "Whether to use a more realistic channel model",
51 cmd.AddValue(
"appPeriod",
52 "The period in seconds to be used by periodically transmitting applications",
54 cmd.AddValue(
"print",
"Whether or not to print building information",
printBuildingInfo);
55 cmd.Parse(argc, argv);
91 mobility.SetPositionAllocator(
"ns3::UniformDiscPositionAllocator",
98 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
106 loss->SetPathLossExponent(3.76);
107 loss->SetReference(1, 7.7);
116 loss->SetNext(shadowing);
121 shadowing->SetNext(buildingLoss);
159 mobility.Install(endDevices);
162 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
165 Vector position = mobility->GetPosition();
167 mobility->SetPosition(position);
180 helper.
Install(phyHelper, macHelper, endDevices);
185 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
202 allocator->Add(Vector(0.0, 0.0, 15.0));
203 mobility.SetPositionAllocator(allocator);
204 mobility.Install(gateways);
209 helper.
Install(phyHelper, macHelper, gateways);
215 double xLength = 130;
228 gridBuildingAllocator->SetAttribute(
"GridWidth",
UintegerValue(gridWidth));
229 gridBuildingAllocator->SetAttribute(
"LengthX",
DoubleValue(xLength));
230 gridBuildingAllocator->SetAttribute(
"LengthY",
DoubleValue(yLength));
231 gridBuildingAllocator->SetAttribute(
"DeltaX",
DoubleValue(deltaX));
232 gridBuildingAllocator->SetAttribute(
"DeltaY",
DoubleValue(deltaY));
233 gridBuildingAllocator->SetAttribute(
"Height",
DoubleValue(6));
234 gridBuildingAllocator->SetBuildingAttribute(
"NRoomsX",
UintegerValue(2));
235 gridBuildingAllocator->SetBuildingAttribute(
"NRoomsY",
UintegerValue(4));
236 gridBuildingAllocator->SetBuildingAttribute(
"NFloors",
UintegerValue(2));
237 gridBuildingAllocator->SetAttribute(
239 DoubleValue(-gridWidth * (xLength + deltaX) / 2 + deltaX / 2));
240 gridBuildingAllocator->SetAttribute(
242 DoubleValue(-gridHeight * (yLength + deltaY) / 2 + deltaY / 2));
243 BuildingContainer bContainer = gridBuildingAllocator->Create(gridWidth * gridHeight);
251 std::ofstream myfile;
252 myfile.open(
"buildings.txt");
253 std::vector<Ptr<Building>>::const_iterator it;
255 for (it = bContainer.
Begin(); it != bContainer.
End(); ++it, ++j)
257 Box boundaries = (*it)->GetBoundaries();
258 myfile <<
"set object " << j <<
" rect from " << boundaries.
xMin <<
","
259 << boundaries.
yMin <<
" to " << boundaries.
xMax <<
"," << boundaries.
yMax
289 appContainer.
Stop(appStopTime);
300 p2p.SetDeviceAttribute(
"DataRate",
StringValue(
"5Mbps"));
301 p2p.SetChannelAttribute(
"Delay",
StringValue(
"2ms"));
304 for (
auto gw = gateways.
Begin(); gw != gateways.
End(); ++gw)
306 auto container = p2p.Install(networkServer, *gw);
308 gwRegistration.emplace_back(serverP2PNetDev, *gw);
314 nsHelper.
Install(networkServer);
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.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
keep track of a set of building pointers.
Iterator End() const
Get an iterator which indicates past-the-last Building in the container.
Iterator Begin() const
Get an iterator which refers to the first Building in the container.
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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.
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.
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.
static std::vector< int > SetSpreadingFactorsUp(NodeContainer endDevices, NodeContainer gateways, Ptr< LoraChannel > channel)
Initialize the end devices' data rate parameter.
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 PeriodicSender applications on a wide range of nodes.
void SetPeriod(Time period)
Set the period to be used by the applications created by this helper.
void SetPacketSize(uint8_t size)
Set the base value for applications packet size in bytes.
ApplicationContainer Install(NodeContainer c) const
Install a PeriodicSender application on each node of the input container configured with all the attr...
double simulationTimeSeconds
Scenario duration (s) in simulated time.
int nDevices
Number of end device nodes to create.
bool realisticChannelModel
Whether to use a more realistic channel model with buildings and correlated shadowing.
int nGateways
Number of gateway nodes to create.
double radiusMeters
Radius (m) of the deployment.
bool printBuildingInfo
Whether to print building information.
int appPeriodSeconds
Duration (s) of the inter-transmission time of end devices.
#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.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
@ LOG_LEVEL_ALL
Print everything.