16 TypeId(
"ns3::NetworkScheduler")
18 .AddConstructor<NetworkScheduler>()
19 .AddTraceSource(
"ReceiveWindowOpened",
20 "Trace source that is fired when a receive window opportunity happens.",
22 "ns3::Packet::TracedCallback")
23 .SetGroupName(
"lorawan");
33 m_controller(controller)
49 packetCopy->RemoveHeader(receivedMacHdr);
52 packetCopy->RemoveHeader(receivedFrameHdr);
55 if (!
m_status->GetEndDeviceStatus(packet)->HasReceiveWindowOpportunityScheduled())
61 m_status->GetEndDeviceStatus(packet)->SetReceiveWindowOpportunity(
75 NS_LOG_DEBUG(
"Opening receive window number " << window <<
" for device " << deviceAddress);
79 Address gwAddress =
m_status->GetBestGatewayForDevice(deviceAddress, window);
81 if (gwAddress ==
Address() && window == 1)
83 NS_LOG_DEBUG(
"No suitable gateway found for first window.");
88 m_status->GetEndDeviceStatus(deviceAddress)
89 ->SetReceiveWindowOpportunity(
96 else if (gwAddress ==
Address() && window == 2)
100 NS_LOG_DEBUG(
"Giving up on reply: no suitable gateway was found "
101 <<
"on the second receive window");
105 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
106 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
112 NS_LOG_DEBUG(
"Found available gateway with address: " << gwAddress);
117 bool needsReply =
m_status->NeedsReply(deviceAddress);
124 m_status->SendThroughGateway(
m_status->GetReplyForDevice(deviceAddress, window),
128 m_status->GetEndDeviceStatus(deviceAddress)->RemoveReceiveWindowOpportunity();
129 m_status->GetEndDeviceStatus(deviceAddress)->InitializeReply();
a polymophic address class
A base class which provides memory management and object aggregation.
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.
~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.