27 NS_LOG_COMPONENT_DEFINE(
"LoraNetworkScheduler");
32 NS_OBJECT_ENSURE_REGISTERED(LoraNetworkScheduler);
38 TypeId(
"ns3::LoraNetworkScheduler")
40 .AddAttribute(
"FirstWindowAnswerDelay",
41 "Delay to wait between end of reception of paquet and sending of anwser, "
42 "to be in first window opportunity",
43 TimeValue(Seconds(1)),
46 .AddAttribute(
"SecondWindowAnswerDelay",
47 "Delay to wait between end of reception of paquet and sending of anwser, "
48 "to be in second window opportunity",
49 TimeValue(Seconds(2)),
52 .AddTraceSource(
"ReceiveWindowOpened",
53 "Trace source that is fired when a receive window opportunity happens.",
55 "ns3::Packet::TracedCallback")
56 .AddConstructor<LoraNetworkScheduler>();
71 Ptr<LoraNetworkController> controller)
73 m_controller(controller),
74 m_firstWindowAnswerDelay(Seconds(1)),
75 m_secondWindowAnswerDelay(Seconds(2))
77 ObjectBase::ConstructSelf(AttributeConstructionList());
80 "First window answer delay must be lower than second window answer delay");
90 NS_LOG_FUNCTION(packet);
93 Ptr<Packet> packetCopy = packet->Copy();
95 packetCopy->RemoveHeader(receivedMacHdr);
98 packetCopy->RemoveHeader(receivedFrameHdr);
101 if (!
m_status->GetEndDeviceStatus(packet)->HasReceiveWindowOpportunityScheduled())
107 m_status->GetEndDeviceStatus(packet)->SetReceiveWindowOpportunity(
119 NS_LOG_FUNCTION(deviceAddress);
121 NS_LOG_DEBUG(
"Opening receive window number " << window <<
" for device " << deviceAddress);
125 Address gwAddress =
m_status->GetBestGatewayForDevice(deviceAddress, window);
127 if (gwAddress == Address() && window == 1)
129 NS_LOG_DEBUG(
"No suitable gateway found for first window.");
134 m_status->GetEndDeviceStatus(deviceAddress)
135 ->SetReceiveWindowOpportunity(
142 else if (gwAddress == Address() && window == 2)
146 NS_LOG_DEBUG(
"Giving up on reply: no suitable gateway was found "
147 <<
"on the second receive window");
151 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
152 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
158 NS_LOG_DEBUG(
"Found available gateway with address: " << gwAddress);
163 bool needsReply =
m_status->NeedsReply(deviceAddress);
167 NS_LOG_INFO(
"A reply is needed");
170 m_status->SendThroughGateway(
m_status->GetReplyForDevice(deviceAddress, window),
174 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
175 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.