34 : m_lastPhyPerformanceUpdate(
Seconds(0)),
35 m_lastGlobalPerformanceUpdate(
Seconds(0))
53 for (
auto i = c.
Begin(); i != c.
End(); ++i)
71 phy->TraceConnectWithoutContext(
77 phy->TraceConnectWithoutContext(
80 phy->TraceConnectWithoutContext(
83 phy->TraceConnectWithoutContext(
84 "LostPacketBecauseInterference",
86 phy->TraceConnectWithoutContext(
87 "LostPacketBecauseNoMoreReceivers",
89 phy->TraceConnectWithoutContext(
90 "LostPacketBecauseUnderSensitivity",
92 phy->TraceConnectWithoutContext(
93 "NoReceptionBecauseTransmitting",
109 mac->TraceConnectWithoutContext(
113 mac->TraceConnectWithoutContext(
114 "RequiredTransmissions",
120 mac->TraceConnectWithoutContext(
124 mac->TraceConnectWithoutContext(
130 node->AddDevice(device);
171 std::string filename,
191 std::string filename)
193 const char* c = filename.c_str();
194 std::ofstream outputFile;
198 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
203 outputFile.open(c, std::ofstream::out | std::ofstream::app);
207 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
217 int dr = int(mac->GetDataRate());
218 double txPower = mac->GetTransmissionPower();
219 Vector pos = position->GetPosition();
220 outputFile << currentTime.
GetSeconds() <<
" " <<
object->GetId() <<
" " << pos.x <<
" "
221 << pos.y <<
" " << dr <<
" " << unsigned(txPower) << std::endl;
237 std::string filename,
257 const char* c = filename.c_str();
258 std::ofstream outputFile;
262 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
267 outputFile.open(c, std::ofstream::out | std::ofstream::app);
270 for (
auto it = gateways.
Begin(); it != gateways.
End(); ++it)
272 int systemId = (*it)->GetId();
304 const char* c = filename.c_str();
305 std::ofstream outputFile;
309 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
314 outputFile.open(c, std::ofstream::out | std::ofstream::app);
332 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.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetHours() const
Get an approximation of the time stored in this instance in the indicated unit.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Class representing the MAC layer of a Class A LoRaWAN device.
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.
Hold together all LoRa related objects.
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.
std::string PrintPhyPacketsPerGw(Time startTime, Time stopTime, int systemId)
Count packets in a time interval to evaluate the performance at PHY level of a specific gateway.
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.
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...
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 > Create(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 > Create(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,...
#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 ",...
Time Seconds(double value)
Construct a Time in the indicated unit.
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...