27NS_LOG_COMPONENT_DEFINE(
"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")
65 Ptr<LoraNetworkController> controller)
71 NS_LOG_FUNCTION(
this << status << controller);
77 NS_LOG_FUNCTION(
this);
79 Object::NotifyConstructionCompleted();
82 "First window answer delay must be lower than second window answer delay");
92 NS_LOG_FUNCTION(packet);
95 Ptr<Packet> packetCopy = packet->Copy();
97 packetCopy->RemoveHeader(receivedMacHdr);
100 packetCopy->RemoveHeader(receivedFrameHdr);
103 if (!
m_status->GetEndDeviceStatus(packet)->HasReceiveWindowOpportunityScheduled())
109 m_status->GetEndDeviceStatus(packet)->SetReceiveWindowOpportunity(
121 NS_LOG_FUNCTION(deviceAddress);
123 NS_LOG_DEBUG(
"Opening receive window number " << window <<
" for device " << deviceAddress);
127 Address gwAddress =
m_status->GetBestGatewayForDevice(deviceAddress, window);
129 if (gwAddress == Address() && window == 1)
131 NS_LOG_DEBUG(
"No suitable gateway found for first window.");
136 m_status->GetEndDeviceStatus(deviceAddress)
137 ->SetReceiveWindowOpportunity(
144 else if (gwAddress == Address() && window == 2)
148 NS_LOG_DEBUG(
"Giving up on reply: no suitable gateway was found "
149 <<
"on the second receive window");
153 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
154 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
160 NS_LOG_DEBUG(
"Found available gateway with address: " << gwAddress);
165 bool needsReply =
m_status->NeedsReply(deviceAddress);
169 NS_LOG_INFO(
"A reply is needed");
172 m_status->SendThroughGateway(
m_status->GetReplyForDevice(deviceAddress, window),
176 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
177 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)
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
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.