28#include "ns3/net-device.h"
29#include "ns3/node-container.h"
30#include "ns3/packet.h"
31#include "ns3/pointer.h"
47 .AddConstructor<NetworkStatus>()
48 .SetGroupName(
"lorawan");
94 NS_LOG_DEBUG(
"Added to the list a gateway with address " << address);
108 myPacket->RemoveHeader(macHdr);
111 myPacket->RemoveHeader(frameHdr);
131 double replyFrequency;
134 replyFrequency = edStatus->GetFirstReceiveWindowFrequency();
136 else if (window == 2)
138 replyFrequency = edStatus->GetSecondReceiveWindowFrequency();
149 std::map<double, Address> gwAddresses = edStatus->GetPowerGatewayMap();
155 for (
auto it = gwAddresses.rbegin(); it != gwAddresses.rend(); it++)
158 m_gatewayStatuses.find(it->second)->second->IsAvailableForTransmission(replyFrequency);
161 bestGwAddress = it->second;
166 return bestGwAddress;
174 m_gatewayStatuses.find(gwAddress)->second->GetNetDevice()->Send(packet, gwAddress, 0x0800);
182 Ptr<Packet> packet = edStatus->GetCompleteReplyPacket();
186 switch (windowNumber)
189 tag.
SetDataRate(edStatus->GetMac()->GetFirstReceiveWindowDataRate());
190 tag.
SetFrequency(edStatus->GetFirstReceiveWindowFrequency());
193 tag.
SetDataRate(edStatus->GetMac()->GetSecondReceiveWindowDataRate());
194 tag.
SetFrequency(edStatus->GetSecondReceiveWindowFrequency());
198 packet->AddPacketTag(tag);
211 myPacket->RemoveHeader(mHdr);
212 myPacket->RemoveHeader(fHdr);
a polymophic address class
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Class representing the MAC layer of a Class A LoRaWAN device.
This class represents the device address of a LoraWAN end device.
std::string Print() const
Print the address bit-by-bit to a human-readable string.
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
void SetDataRate(uint8_t dataRate)
Set the data rate for this packet.
void SetFrequency(double frequency)
Set the frequency of the packet.
~NetworkStatus() override
Destructor.
Ptr< EndDeviceStatus > GetEndDeviceStatus(Ptr< const Packet > packet)
Get the EndDeviceStatus of the device that sent a packet.
void OnReceivedPacket(Ptr< const Packet > packet, const Address &gwaddress)
Update network status on a received packet.
NetworkStatus()
Default constructor.
bool NeedsReply(LoraDeviceAddress deviceAddress)
Return whether the specified device needs a reply.
void AddNode(Ptr< ClassAEndDeviceLorawanMac > edMac)
Add a device to the ones that are tracked by this NetworkStatus object.
int CountEndDevices()
Return the number of end devices currently managed by the server.
std::map< LoraDeviceAddress, Ptr< EndDeviceStatus > > m_endDeviceStatuses
Map tracking the state of devices connected to this network server.
void SendThroughGateway(Ptr< Packet > packet, Address gwAddress)
Send a packet through a gateway.
std::map< Address, Ptr< GatewayStatus > > m_gatewayStatuses
Map tracking the state of gateways connected to this network server.
void AddGateway(Address &address, Ptr< GatewayStatus > gwStatus)
Add a new gateway to the list of gateways connected to the network.
static TypeId GetTypeId()
Register this type.
Ptr< Packet > GetReplyForDevice(LoraDeviceAddress edAddress, int windowNumber)
Get the reply packet prepared for a reception window of a device.
Address GetBestGatewayForDevice(LoraDeviceAddress deviceAddress, int window)
Return whether we have a gateway that is available to send a reply to the specified device.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.