25 NS_LOG_COMPONENT_DEFINE(
"LoraNetworkScheduler");
30 NS_OBJECT_ENSURE_REGISTERED(LoraNetworkScheduler);
36 TypeId(
"ns3::LoraNetworkScheduler")
38 .AddAttribute(
"FirstWindowAnswerDelay",
39 "Delay to wait between end of reception of paquet and sending of anwser, "
40 "to be in first window opportunity",
41 TimeValue(Seconds(1)),
44 .AddAttribute(
"SecondWindowAnswerDelay",
45 "Delay to wait between end of reception of paquet and sending of anwser, "
46 "to be in second window opportunity",
47 TimeValue(Seconds(2)),
50 .AddTraceSource(
"ReceiveWindowOpened",
51 "Trace source that is fired when a receive window opportunity happens.",
53 "ns3::Packet::TracedCallback")
54 .AddConstructor<LoraNetworkScheduler>();
69 Ptr<LoraNetworkController> controller)
71 m_controller(controller),
72 m_firstWindowAnswerDelay(Seconds(1)),
73 m_secondWindowAnswerDelay(Seconds(2))
75 ObjectBase::ConstructSelf(AttributeConstructionList());
85 NS_LOG_FUNCTION(packet);
88 Ptr<Packet> packetCopy = packet->Copy();
90 packetCopy->RemoveHeader(receivedMacHdr);
93 packetCopy->RemoveHeader(receivedFrameHdr);
96 if (!
m_status->GetEndDeviceStatus(packet)->HasReceiveWindowOpportunityScheduled())
102 m_status->GetEndDeviceStatus(packet)->SetReceiveWindowOpportunity(
114 NS_LOG_FUNCTION(deviceAddress);
116 NS_LOG_DEBUG(
"Opening receive window number " << window <<
" for device " << deviceAddress);
120 Address gwAddress =
m_status->GetBestGatewayForDevice(deviceAddress, window);
122 if (gwAddress == Address() && window == 1)
124 NS_LOG_DEBUG(
"No suitable gateway found for first window.");
129 m_status->GetEndDeviceStatus(deviceAddress)
130 ->SetReceiveWindowOpportunity(
137 else if (gwAddress == Address() && window == 2)
141 NS_LOG_DEBUG(
"Giving up on reply: no suitable gateway was found "
142 <<
"on the second receive window");
146 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
147 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
153 NS_LOG_DEBUG(
"Found available gateway with address: " << gwAddress);
158 bool needsReply =
m_status->NeedsReply(deviceAddress);
162 NS_LOG_INFO(
"A reply is needed");
165 m_status->SendThroughGateway(
m_status->GetReplyForDevice(deviceAddress, window),
169 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
170 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
This class represents the device address of a LoraWAN End Device.
Time m_secondWindowAnswerDelay
Delay to wait between end of reception of paquet and sending of anwser, to be in second window opport...
Ptr< LoraNetworkStatus > m_status
void OnReceivedPacket(Ptr< const Packet > packet)
Method called by NetworkServer to inform the Scheduler of a newly arrived uplink packet.
virtual ~LoraNetworkScheduler()
Time m_firstWindowAnswerDelay
Delay to wait between end of reception of paquet and sending of anwser, to be in first window opportu...
static TypeId GetTypeId(void)
TypeId GetInstanceTypeId(void) const
void OnReceiveWindowOpportunity(LoraDeviceAddress deviceAddress, int window)
Method that is scheduled after packet arrivals in order to act on receive windows 1 and 2 seconds lat...
Ptr< LoraNetworkController > m_controller
TracedCallback< Ptr< const Packet > > m_receiveWindowOpened
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.