23 : m_lastPhyPerformanceUpdate(
Seconds(0)),
24 m_lastGlobalPerformanceUpdate(
Seconds(0))
42 for (
auto i = c.
Begin(); i != c.
End(); ++i)
60 phy->TraceConnectWithoutContext(
66 phy->TraceConnectWithoutContext(
69 phy->TraceConnectWithoutContext(
72 phy->TraceConnectWithoutContext(
73 "LostPacketBecauseInterference",
75 phy->TraceConnectWithoutContext(
76 "LostPacketBecauseNoMoreReceivers",
78 phy->TraceConnectWithoutContext(
79 "LostPacketBecauseUnderSensitivity",
81 phy->TraceConnectWithoutContext(
82 "NoReceptionBecauseTransmitting",
98 mac->TraceConnectWithoutContext(
102 mac->TraceConnectWithoutContext(
103 "RequiredTransmissions",
109 mac->TraceConnectWithoutContext(
113 mac->TraceConnectWithoutContext(
119 node->AddDevice(device);
160 std::string filename,
180 std::string filename)
182 const char* c = filename.c_str();
183 std::ofstream outputFile;
187 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
192 outputFile.open(c, std::ofstream::out | std::ofstream::app);
196 for (
auto j = endDevices.
Begin(); j != endDevices.
End(); ++j)
206 int dr = int(mac->GetDataRate());
207 double txPower = mac->GetTransmissionPower();
208 Vector pos = position->GetPosition();
209 outputFile << currentTime.
GetSeconds() <<
" " <<
object->GetId() <<
" " << pos.x <<
" "
210 << pos.y <<
" " << dr <<
" " << unsigned(txPower) << std::endl;
226 std::string filename,
246 const char* c = filename.c_str();
247 std::ofstream outputFile;
251 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
256 outputFile.open(c, std::ofstream::out | std::ofstream::app);
259 for (
auto it = gateways.
Begin(); it != gateways.
End(); ++it)
261 int systemId = (*it)->GetId();
293 const char* c = filename.c_str();
294 std::ofstream outputFile;
298 outputFile.open(c, std::ofstream::out | std::ofstream::trunc);
303 outputFile.open(c, std::ofstream::out | std::ofstream::app);
321 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.
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.
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 ",...
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.
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.