11#include "ns3/class-a-end-device-lorawan-mac.h"
12#include "ns3/lora-net-device.h"
13#include "ns3/lora-phy.h"
14#include "ns3/simulator.h"
45 for (
auto i = c.
Begin(); i != c.
End(); ++i)
63 phy->TraceConnectWithoutContext(
69 phy->TraceConnectWithoutContext(
72 phy->TraceConnectWithoutContext(
75 phy->TraceConnectWithoutContext(
76 "LostPacketBecauseInterference",
78 phy->TraceConnectWithoutContext(
79 "LostPacketBecauseNoMoreReceivers",
81 phy->TraceConnectWithoutContext(
82 "LostPacketBecauseUnderSensitivity",
84 phy->TraceConnectWithoutContext(
85 "NoReceptionBecauseTransmitting",
101 mac->TraceConnectWithoutContext(
105 mac->TraceConnectWithoutContext(
106 "RequiredTransmissions",
112 mac->TraceConnectWithoutContext(
116 mac->TraceConnectWithoutContext(
122 node->AddDevice(device);
163 std::string filename,
183 std::string filename)
185 const char* c = filename.c_str();
186 std::ofstream outputFile;
190 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
195 outputFile.open(c, std::ofstream::out | std::ofstream::app);
199 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
209 int dr = int(mac->GetDataRate());
210 double txPower = mac->GetTransmissionPowerDbm();
211 Vector pos = position->GetPosition();
212 outputFile << currentTime.
As(
Time::S) <<
" " <<
object->GetId() <<
" " << pos.x <<
" "
213 << pos.y <<
" " << dr <<
" " << unsigned(txPower) << std::endl;
229 std::string filename,
249 const char* c = filename.c_str();
250 std::ofstream outputFile;
254 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
259 outputFile.open(c, std::ofstream::out | std::ofstream::app);
262 for (
auto it = gateways.
Begin(); it != gateways.
End(); ++it)
264 int systemId = (*it)->GetId();
265 outputFile <<
Now().
As(
Time::S) <<
" " << std::to_string(systemId) <<
" "
296 const char* c = filename.c_str();
297 std::ofstream outputFile;
301 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
306 outputFile.open(c, std::ofstream::out | std::ofstream::app);
322 std::cout <<
"Simulated time: " <<
Now().
As(
Time::H) << std::endl;
323 std::cout <<
"Real time from last call: " << std::time(
nullptr) -
m_oldtime <<
" seconds"
Keep track of the current position and velocity of an object.
Vector GetPosition() const
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
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.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
void EnablePeriodicDeviceStatusPrinting(NodeContainer endDevices, NodeContainer gateways, std::string filename, Time interval)
Periodically prints the status of devices in the network to a file.
LoraHelper()
Default constructor.
void DoPrintSimulationTime(Time interval)
Actually print the simulation time and re-schedule execution of this function.
void DoPrintDeviceStatus(NodeContainer endDevices, NodeContainer gateways, std::string filename)
Print a summary of the current status of input devices.
time_t m_oldtime
Real time (i.e., physical) of the last simulation time print.
virtual ~LoraHelper()
Destructor.
Time m_lastGlobalPerformanceUpdate
Timestamp of the last global performance update.
void EnablePeriodicPhyPerformancePrinting(NodeContainer gateways, std::string filename, Time interval)
Periodically prints PHY-level performance at every gateway in the container.
void DoPrintPhyPerformance(NodeContainer gateways, std::string filename)
Print the PHY-level performance of every gateway in the container since the last performance update.
void DoPrintGlobalPerformance(std::string filename)
Print global performance as the total number of send and received packets since last performance upda...
LoraPacketTracker * m_packetTracker
Pointer to the Packet Tracker object.
void EnablePacketTracking()
Enable tracking of packets via trace sources.
void EnableSimulationTimePrinting(Time interval)
Periodically prints the simulation time to the standard output.
LoraPacketTracker & GetPacketTracker()
Get a reference to the Packet Tracker object.
Time m_lastPhyPerformanceUpdate
Timestamp of the last PHY performance update.
virtual NetDeviceContainer Install(const LoraPhyHelper &phyHelper, const LorawanMacHelper &macHelper, NodeContainer c) const
Install LoraNetDevices on a list of nodes.
void EnablePeriodicGlobalPerformancePrinting(std::string filename, Time interval)
Periodically print global performance as the total number of send and received packets.
Tracks and stores packets sent in the simulation and provides aggregation functionality.
void NoMoreReceiversCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a gateway packet loss caused by lack of free reception paths.
void MacTransmissionCallback(Ptr< const Packet > packet)
Trace a packet leaving a node's MAC layer to go down the stack and be sent by the PHY layer.
void RequiredTransmissionsCallback(uint8_t reqTx, bool success, Time firstAttempt, Ptr< Packet > packet)
Trace the exit status of a MAC layer packet retransmission process of an end device.
void UnderSensitivityCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a gateway packet loss caused by signal strength under sensitivity.
void LostBecauseTxCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a gateway packet loss caused by concurrent downlink transmission.
void MacGwReceptionCallback(Ptr< const Packet > packet)
Trace a packet leaving a gateway's MAC layer to go up the stack and be delivered to the node's applic...
void PacketReceptionCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a correct packet RX by the PHY layer of a gateway.
void InterferenceCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a gateway packet loss caused by interference.
void TransmissionCallback(Ptr< const Packet > packet, uint32_t systemId)
Trace a packet TX start by the PHY layer of an end device.
Helper to install LoraPhy instances on multiple Nodes.
TypeId GetDeviceType() const
Get the TypeId of the object to be created with LoraPhyHelper.
Ptr< LoraPhy > Install(Ptr< Node > node, Ptr< NetDevice > device) const
Create a LoraPhy and connect it to a device on a node.
Helper class for configuring and installing the LorawanMac class on devices and gateways.
Ptr< LorawanMac > Install(Ptr< Node > node, Ptr< NetDevice > device) const
Create the LorawanMac instance and connect it to a device.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
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...
#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_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.