42 static TypeId tid =
TypeId(
"ns3::ConfirmedMessagesComponent")
44 .AddConstructor<ConfirmedMessagesComponent>()
45 .SetGroupName(
"lorawan");
69 myPacket->RemoveHeader(mHdr);
70 myPacket->RemoveHeader(fHdr);
72 NS_LOG_INFO(
"Received packet Mac Header: " << mHdr);
73 NS_LOG_INFO(
"Received packet Frame Header: " << fHdr);
80 status->m_reply.frameHeader.SetAsDownlink();
81 status->m_reply.frameHeader.SetAck(
true);
82 status->m_reply.frameHeader.SetAddress(fHdr.
GetAddress());
84 status->m_reply.needsReply =
true;
111 status->m_reply.frameHeader.SetAck(
false);
122 .AddConstructor<LinkCheckComponent>()
123 .SetGroupName(
"lorawan");
152 Ptr<Packet> myPacket = status->GetLastPacketReceivedFromDevice()->Copy();
156 myPacket->RemoveHeader(mHdr);
157 myPacket->RemoveHeader(fHdr);
164 status->m_reply.needsReply =
true;
166 auto info = status->GetLastReceivedPacketInfo();
171 double maxRssi = -1e3;
172 for (
const auto& [_, gwRxData] : info.gwList)
174 if (gwRxData.rxPower > maxRssi)
176 maxRssi = gwRxData.rxPower;
180 double maxSnr = maxRssi + 174 - 10 * log10(125000) - 6;
182 double requiredSnr[] = {-20.0, -17.5, -15.0, -12.5, -10.0, -7.5, -5};
183 double diff = maxSnr - requiredSnr[12 - info.sf];
184 uint8_t margin = (diff < 0) ? 0 : (diff > 254) ? 254 : diff;
187 uint8_t gwCount = info.gwList.size();
190 status->m_reply.frameHeader.SetAsDownlink();
191 status->m_reply.frameHeader.AddCommand(replyCommand);
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void BeforeSendingReply(Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
Function called as a downlink reply is about to leave the NetworkServer application.
void OnFailedReply(Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
Method that is called when a packet cannot be sent in the downlink.
~ConfirmedMessagesComponent() override
Destructor.
static TypeId GetTypeId()
Register this type.
ConfirmedMessagesComponent()
Default constructor.
void OnReceivedPacket(Ptr< const Packet > packet, Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
This method checks whether the received packet requires an acknowledgment and sets up the appropriate...
~LinkCheckComponent() override
Destructor.
void OnReceivedPacket(Ptr< const Packet > packet, Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
This method checks whether the received packet requires an acknowledgment and sets up the appropriate...
void OnFailedReply(Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
Method that is called when a packet cannot be sent in the downlink.
static TypeId GetTypeId()
Register this type.
LinkCheckComponent()
Default constructor.
void BeforeSendingReply(Ptr< EndDeviceStatus > status, Ptr< NetworkStatus > networkStatus) override
Function called as a downlink reply is about to leave the NetworkServer application.
Implementation of the LinkCheckReq LoRaWAN MAC command.
Generic class describing a component of the NetworkController.
static TypeId GetTypeId()
Register this type.
NetworkControllerComponent()
Default constructor.
~NetworkControllerComponent() override
Destructor.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.