14#include "ns3/simulator.h"
29 TypeId(
"ns3::NetworkScheduler")
31 .AddConstructor<NetworkScheduler>()
32 .AddTraceSource(
"ReceiveWindowOpened",
33 "Trace source that is fired when a receive window opportunity happens.",
35 "ns3::Packet::TracedCallback")
36 .SetGroupName(
"lorawan");
62 packetCopy->RemoveHeader(receivedMacHdr);
65 packetCopy->RemoveHeader(receivedFrameHdr);
68 if (!
m_status->GetEndDeviceStatus(packet)->HasReceiveWindowOpportunityScheduled())
74 m_status->GetEndDeviceStatus(packet)->SetReceiveWindowOpportunity(
88 NS_LOG_DEBUG(
"Opening receive window number " << window <<
" for device " << deviceAddress);
92 Address gwAddress =
m_status->GetBestGatewayForDevice(deviceAddress, window);
94 if (gwAddress ==
Address() && window == 1)
96 NS_LOG_DEBUG(
"No suitable gateway found for first window.");
101 m_status->GetEndDeviceStatus(deviceAddress)
102 ->SetReceiveWindowOpportunity(
109 else if (gwAddress ==
Address() && window == 2)
113 NS_LOG_DEBUG(
"Giving up on reply: no suitable gateway was found "
114 <<
"on the second receive window");
118 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
119 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
125 NS_LOG_DEBUG(
"Found available gateway with address: " << gwAddress);
130 bool needsReply =
m_status->NeedsReply(deviceAddress);
137 m_status->SendThroughGateway(
m_status->GetReplyForDevice(deviceAddress, window),
141 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
142 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
a polymophic address class
Object()
Caller graph was not generated because of its size.
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.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class represents the device address of a LoraWAN end device.
Network server component in charge of scheduling downling packets onto devices' reception windows.
~NetworkScheduler() override
Destructor.
void OnReceivedPacket(Ptr< const Packet > packet)
Method called by NetworkServer application to inform the Scheduler of a newly arrived uplink packet.
Ptr< NetworkController > m_controller
A pointer to the NetworkController object.
Ptr< NetworkStatus > m_status
A pointer to the NetworkStatus object.
NetworkScheduler()
Default constructor.
static TypeId GetTypeId()
Register this type.
void OnReceiveWindowOpportunity(LoraDeviceAddress deviceAddress, int window)
Method that is scheduled after packet arrival in order to take action on sender's receive windows ope...
TracedCallback< Ptr< const Packet > > m_receiveWindowOpened
Trace callback source for reception windows openings.
#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(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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.