This class represents the network server's knowledge about an end device in the LoRaWAN network it is administering. More...
#include "end-device-status.h"
Classes | |
struct | PacketInfoPerGw |
Structure saving information regarding the packet reception in each gateway. More... | |
struct | ReceivedPacketInfo |
Structure saving information regarding all packet receptions. More... | |
struct | Reply |
Structure representing the reply that the network server will send this device at the first opportunity. More... | |
Public Types | |
typedef std::map< Address, PacketInfoPerGw > | GatewayList |
typedef of a list of gateways with relative reception information. | |
typedef std::list< std::pair< Ptr< const Packet >, ReceivedPacketInfo > > | ReceivedPacketList |
typedef of a list of packets paired to their reception info. | |
Public Member Functions | |
EndDeviceStatus () | |
Default constructor. | |
EndDeviceStatus (LoraDeviceAddress endDeviceAddress, Ptr< ClassAEndDeviceLorawanMac > endDeviceMac) | |
Constructor with initialization parameters. | |
~EndDeviceStatus () override | |
Destructor. | |
void | AddMACCommand (Ptr< MacCommand > macCommand) |
Add MAC command to the frame header of next reply. | |
Ptr< Packet > | GetCompleteReplyPacket () |
Get the reply packet. | |
double | GetFirstReceiveWindowFrequency () const |
Get the first window frequency of this device. | |
uint8_t | GetFirstReceiveWindowSpreadingFactor () const |
Get the spreading factor this device is using in the first receive window. | |
Ptr< const Packet > | GetLastPacketReceivedFromDevice () |
Return the last packet that was received from this device. | |
EndDeviceStatus::ReceivedPacketInfo | GetLastReceivedPacketInfo () |
Return the information about the last packet that was received from the device. | |
Ptr< ClassAEndDeviceLorawanMac > | GetMac () |
Get the MAC layer of the end device. | |
std::map< double, Address > | GetPowerGatewayMap () |
Get the gateways which received the last packet from the end device. | |
ReceivedPacketList | GetReceivedPacketList () const |
Get the received packet list. | |
LoraFrameHeader | GetReplyFrameHeader () const |
Get the reply packet frame header. | |
LorawanMacHeader | GetReplyMacHeader () const |
Get the reply packet mac header. | |
Ptr< Packet > | GetReplyPayload () |
Get the data of the reply packet. | |
double | GetSecondReceiveWindowFrequency () const |
Return the second window frequency of this device. | |
uint8_t | GetSecondReceiveWindowSpreadingFactor () const |
Get the spreading factor this device is using in the second receive window. | |
bool | HasReceiveWindowOpportunityScheduled () |
Check if there is already a running reception window event scheduled for this end device. | |
void | InitializeReply () |
Reset the next reply state. | |
void | InsertReceivedPacket (Ptr< const Packet > receivedPacket, const Address &gwAddress) |
Insert a received packet in the packet list. | |
bool | NeedsReply () const |
Whether the end device needs a reply. | |
void | RemoveReceiveWindowOpportunity () |
Cancel next scheduled reception window event. | |
void | SetFirstReceiveWindowFrequency (double frequency) |
Set the first window frequency of this device. | |
void | SetFirstReceiveWindowSpreadingFactor (uint8_t sf) |
Set the spreading factor this device is using in the first receive window. | |
void | SetReceiveWindowOpportunity (EventId event) |
Store next scheduled reception window event. | |
void | SetReplyFrameHeader (LoraFrameHeader frameHeader) |
Set the reply packet frame header. | |
void | SetReplyMacHeader (LorawanMacHeader macHeader) |
Set the reply packet mac header. | |
void | SetReplyPayload (Ptr< Packet > replyPayload) |
Set the packet reply payload. | |
void | SetSecondReceiveWindowFrequency (double frequency) |
Set the second window frequency of this device. | |
void | SetSecondReceiveWindowSpreadingFactor (uint8_t sf) |
Set the spreading factor this device is using in the second receive window. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
void | UnidirectionalAggregateObject (Ptr< Object > other) |
Aggregate an Object to another Object. | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
virtual TypeId | GetInstanceTypeId () const =0 |
Get the most derived TypeId for this Object. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Public Attributes | |
LoraDeviceAddress | m_endDeviceAddress |
The address of this device. | |
struct Reply | m_reply |
Next reply intended for this device. | |
Private Attributes | |
double | m_firstReceiveWindowFrequency = 0 |
Frequency [MHz] for RX1 window. | |
uint8_t | m_firstReceiveWindowSpreadingFactor = 0 |
Spreading Factor (SF) for RX1 window. | |
Ptr< ClassAEndDeviceLorawanMac > | m_mac |
Pointer to the MAC layer of this device. | |
ReceivedPacketList | m_receivedPacketList |
List of received packets. | |
EventId | m_receiveWindowEvent |
Event storing the next scheduled downlink transmission. | |
double | m_secondReceiveWindowFrequency = 869.525 |
Frequency [MHz] for RX2 window. | |
uint8_t | m_secondReceiveWindowSpreadingFactor = 0 |
Spreading Factor (SF) for RX2 window. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const EndDeviceStatus &status) |
Stream insertion operator. | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | DoDispose () |
Destructor implementation. | |
virtual void | DoInitialize () |
Initialize() implementation. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
This class represents the network server's knowledge about an end device in the LoRaWAN network it is administering.
The network server's NetworkStatus component contains a list of instances of this class, one for each device in the network. Each instance contains all the parameters and information of the end device and the packets received from it. Furthermore, this class holds the reply packet that the network server will send to this device at the first available receive window. Upon new packet arrivals at the network server, the OnReceivedPacket method is called to update the information regarding the last received packet and its parameters.
Diagram of the end-device-status data structure. One instance of this class for each end device, that will be identified by its address.
Public Access:
(End device address) — Current device parameters:
Private Access:
(Received packets list) - List of gateways that received the packet (see below)
(Gateway list) - Time at which the packet was received
Definition at line 82 of file end-device-status.h.
typedef std::map<Address, PacketInfoPerGw> ns3::lorawan::EndDeviceStatus::GatewayList |
typedef of a list of gateways with relative reception information.
Definition at line 157 of file end-device-status.h.
typedef std::list<std::pair<Ptr<const Packet>, ReceivedPacketInfo> > ns3::lorawan::EndDeviceStatus::ReceivedPacketList |
typedef of a list of packets paired to their reception info.
Definition at line 174 of file end-device-status.h.
ns3::lorawan::EndDeviceStatus::EndDeviceStatus | ( | ) |
Default constructor.
Definition at line 62 of file end-device-status.cc.
References m_receivedPacketList, m_reply, and NS_LOG_FUNCTION_NOARGS.
|
override |
ns3::lorawan::EndDeviceStatus::EndDeviceStatus | ( | LoraDeviceAddress | endDeviceAddress, |
Ptr< ClassAEndDeviceLorawanMac > | endDeviceMac | ||
) |
Constructor with initialization parameters.
endDeviceAddress | Address of the end device. |
endDeviceMac | Pointer to the MAC layer of the end device. |
Definition at line 52 of file end-device-status.cc.
References NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceStatus::AddMACCommand | ( | Ptr< MacCommand > | macCommand | ) |
Add MAC command to the frame header of next reply.
macCommand | The MAC command. |
Definition at line 364 of file end-device-status.cc.
References ns3::lorawan::LoraFrameHeader::AddCommand(), ns3::lorawan::EndDeviceStatus::Reply::frameHeader, and m_reply.
Get the reply packet.
Definition at line 112 of file end-device-status.cc.
References ns3::Packet::Copy(), ns3::lorawan::EndDeviceStatus::Reply::frameHeader, ns3::lorawan::LoraFrameHeader::GetFCnt(), GetLastPacketReceivedFromDevice(), m_endDeviceAddress, m_reply, ns3::lorawan::EndDeviceStatus::Reply::macHeader, NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, ns3::lorawan::EndDeviceStatus::Reply::payload, ns3::lorawan::LoraFrameHeader::SetAddress(), ns3::lorawan::LoraFrameHeader::SetAsUplink(), ns3::lorawan::LoraFrameHeader::SetFCnt(), ns3::lorawan::LorawanMacHeader::SetMType(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_DOWN.
double ns3::lorawan::EndDeviceStatus::GetFirstReceiveWindowFrequency | ( | ) | const |
Get the first window frequency of this device.
Definition at line 89 of file end-device-status.cc.
References m_firstReceiveWindowFrequency, and NS_LOG_FUNCTION_NOARGS.
uint8_t ns3::lorawan::EndDeviceStatus::GetFirstReceiveWindowSpreadingFactor | ( | ) | const |
Get the spreading factor this device is using in the first receive window.
Definition at line 81 of file end-device-status.cc.
References m_firstReceiveWindowSpreadingFactor, and NS_LOG_FUNCTION_NOARGS.
Return the last packet that was received from this device.
Definition at line 341 of file end-device-status.cc.
References m_receivedPacketList, and NS_LOG_FUNCTION_NOARGS.
Referenced by GetCompleteReplyPacket().
EndDeviceStatus::ReceivedPacketInfo ns3::lorawan::EndDeviceStatus::GetLastReceivedPacketInfo | ( | ) |
Return the information about the last packet that was received from the device.
Definition at line 326 of file end-device-status.cc.
References m_receivedPacketList, and NS_LOG_FUNCTION_NOARGS.
Ptr< ClassAEndDeviceLorawanMac > ns3::lorawan::EndDeviceStatus::GetMac | ( | ) |
Get the MAC layer of the end device.
Definition at line 178 of file end-device-status.cc.
References m_mac.
Get the gateways which received the last packet from the end device.
Gateways are mapped to their measured reception power of the last packet, in ascending order.
Definition at line 388 of file end-device-status.cc.
References ns3::lorawan::EndDeviceStatus::ReceivedPacketInfo::gwList, and m_receivedPacketList.
EndDeviceStatus::ReceivedPacketList ns3::lorawan::EndDeviceStatus::GetReceivedPacketList | ( | ) | const |
Get the received packet list.
Definition at line 184 of file end-device-status.cc.
References m_receivedPacketList, and NS_LOG_FUNCTION_NOARGS.
LoraFrameHeader ns3::lorawan::EndDeviceStatus::GetReplyFrameHeader | ( | ) | const |
Get the reply packet frame header.
Definition at line 164 of file end-device-status.cc.
References ns3::lorawan::EndDeviceStatus::Reply::frameHeader, m_reply, and NS_LOG_FUNCTION_NOARGS.
LorawanMacHeader ns3::lorawan::EndDeviceStatus::GetReplyMacHeader | ( | ) | const |
Get the reply packet mac header.
Definition at line 157 of file end-device-status.cc.
References m_reply, ns3::lorawan::EndDeviceStatus::Reply::macHeader, and NS_LOG_FUNCTION_NOARGS.
Get the data of the reply packet.
Definition at line 171 of file end-device-status.cc.
References ns3::Packet::Copy(), m_reply, NS_LOG_FUNCTION_NOARGS, and ns3::lorawan::EndDeviceStatus::Reply::payload.
double ns3::lorawan::EndDeviceStatus::GetSecondReceiveWindowFrequency | ( | ) | const |
Return the second window frequency of this device.
Definition at line 105 of file end-device-status.cc.
References m_secondReceiveWindowFrequency, and NS_LOG_FUNCTION_NOARGS.
uint8_t ns3::lorawan::EndDeviceStatus::GetSecondReceiveWindowSpreadingFactor | ( | ) | const |
Get the spreading factor this device is using in the second receive window.
Definition at line 97 of file end-device-status.cc.
References m_secondReceiveWindowSpreadingFactor, and NS_LOG_FUNCTION_NOARGS.
|
static |
Register this type.
Definition at line 43 of file end-device-status.cc.
References ns3::TypeId::SetParent().
bool ns3::lorawan::EndDeviceStatus::HasReceiveWindowOpportunityScheduled | ( | ) |
Check if there is already a running reception window event scheduled for this end device.
Definition at line 370 of file end-device-status.cc.
References ns3::EventId::IsPending(), and m_receiveWindowEvent.
void ns3::lorawan::EndDeviceStatus::InitializeReply | ( | ) |
Reset the next reply state.
Definition at line 356 of file end-device-status.cc.
References m_reply, ns3::lorawan::EndDeviceStatus::Reply::needsReply, and NS_LOG_FUNCTION_NOARGS.
void ns3::lorawan::EndDeviceStatus::InsertReceivedPacket | ( | Ptr< const Packet > | receivedPacket, |
const Address & | gwAddress | ||
) |
Insert a received packet in the packet list.
receivedPacket | The packet received. |
gwAddress | The address of the receiver gateway. |
Definition at line 244 of file end-device-status.cc.
References ns3::Copy(), ns3::lorawan::EndDeviceStatus::ReceivedPacketInfo::frequency, ns3::lorawan::LoraFrameHeader::GetFCnt(), ns3::lorawan::LoraTag::GetFrequency(), ns3::lorawan::LoraTag::GetReceivePower(), ns3::lorawan::LoraTag::GetSpreadingFactor(), ns3::lorawan::EndDeviceStatus::PacketInfoPerGw::gwAddress, ns3::lorawan::EndDeviceStatus::ReceivedPacketInfo::gwList, m_receivedPacketList, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, ns3::lorawan::EndDeviceStatus::ReceivedPacketInfo::packet, ns3::lorawan::EndDeviceStatus::PacketInfoPerGw::receivedTime, ns3::lorawan::EndDeviceStatus::PacketInfoPerGw::rxPower, ns3::lorawan::LoraFrameHeader::SetAsUplink(), SetFirstReceiveWindowFrequency(), SetFirstReceiveWindowSpreadingFactor(), and ns3::lorawan::EndDeviceStatus::ReceivedPacketInfo::sf.
bool ns3::lorawan::EndDeviceStatus::NeedsReply | ( | ) | const |
Whether the end device needs a reply.
This is determined by looking at headers and payload of the Reply structure: if they are empty, no reply should be needed.
Definition at line 149 of file end-device-status.cc.
References m_reply, ns3::lorawan::EndDeviceStatus::Reply::needsReply, and NS_LOG_FUNCTION_NOARGS.
void ns3::lorawan::EndDeviceStatus::RemoveReceiveWindowOpportunity | ( | ) |
Cancel next scheduled reception window event.
Definition at line 382 of file end-device-status.cc.
References ns3::Simulator::Cancel(), and m_receiveWindowEvent.
void ns3::lorawan::EndDeviceStatus::SetFirstReceiveWindowFrequency | ( | double | frequency | ) |
Set the first window frequency of this device.
frequency | The frequency [MHz]. |
Definition at line 198 of file end-device-status.cc.
References m_firstReceiveWindowFrequency, and NS_LOG_FUNCTION_NOARGS.
Referenced by InsertReceivedPacket().
void ns3::lorawan::EndDeviceStatus::SetFirstReceiveWindowSpreadingFactor | ( | uint8_t | sf | ) |
Set the spreading factor this device is using in the first receive window.
sf | The spreading factor. |
Definition at line 191 of file end-device-status.cc.
References m_firstReceiveWindowSpreadingFactor, and NS_LOG_FUNCTION_NOARGS.
Referenced by InsertReceivedPacket().
void ns3::lorawan::EndDeviceStatus::SetReceiveWindowOpportunity | ( | EventId | event | ) |
Store next scheduled reception window event.
event | The event. |
Definition at line 376 of file end-device-status.cc.
References m_receiveWindowEvent.
void ns3::lorawan::EndDeviceStatus::SetReplyFrameHeader | ( | LoraFrameHeader | frameHeader | ) |
Set the reply packet frame header.
frameHeader | The frame header (FHDR + FPort). |
Definition at line 226 of file end-device-status.cc.
References ns3::lorawan::EndDeviceStatus::Reply::frameHeader, m_reply, and NS_LOG_FUNCTION_NOARGS.
void ns3::lorawan::EndDeviceStatus::SetReplyMacHeader | ( | LorawanMacHeader | macHeader | ) |
Set the reply packet mac header.
macHeader | The mac header (MHDR). |
Definition at line 219 of file end-device-status.cc.
References m_reply, ns3::lorawan::EndDeviceStatus::Reply::macHeader, and NS_LOG_FUNCTION_NOARGS.
Set the packet reply payload.
replyPayload | Packet containing the FRMPayload. |
Definition at line 233 of file end-device-status.cc.
References m_reply, NS_LOG_FUNCTION_NOARGS, and ns3::lorawan::EndDeviceStatus::Reply::payload.
void ns3::lorawan::EndDeviceStatus::SetSecondReceiveWindowFrequency | ( | double | frequency | ) |
Set the second window frequency of this device.
frequency | The frequency [MHz]. |
Definition at line 212 of file end-device-status.cc.
References m_secondReceiveWindowFrequency, and NS_LOG_FUNCTION_NOARGS.
void ns3::lorawan::EndDeviceStatus::SetSecondReceiveWindowSpreadingFactor | ( | uint8_t | sf | ) |
Set the spreading factor this device is using in the second receive window.
sf | The spreading factor. |
Definition at line 205 of file end-device-status.cc.
References m_firstReceiveWindowSpreadingFactor, and NS_LOG_FUNCTION_NOARGS.
|
friend |
Stream insertion operator.
os | The stream. |
status | The status. |
Definition at line 408 of file end-device-status.cc.
LoraDeviceAddress ns3::lorawan::EndDeviceStatus::m_endDeviceAddress |
The address of this device.
Definition at line 357 of file end-device-status.h.
Referenced by GetCompleteReplyPacket().
|
private |
Frequency [MHz] for RX1 window.
Definition at line 371 of file end-device-status.h.
Referenced by GetFirstReceiveWindowFrequency(), and SetFirstReceiveWindowFrequency().
|
private |
Spreading Factor (SF) for RX1 window.
Definition at line 370 of file end-device-status.h.
Referenced by GetFirstReceiveWindowSpreadingFactor(), SetFirstReceiveWindowSpreadingFactor(), and SetSecondReceiveWindowSpreadingFactor().
|
private |
Pointer to the MAC layer of this device.
Definition at line 380 of file end-device-status.h.
Referenced by GetMac().
|
private |
List of received packets.
Definition at line 376 of file end-device-status.h.
Referenced by EndDeviceStatus(), GetLastPacketReceivedFromDevice(), GetLastReceivedPacketInfo(), GetPowerGatewayMap(), GetReceivedPacketList(), and InsertReceivedPacket().
|
private |
Event storing the next scheduled downlink transmission.
Definition at line 374 of file end-device-status.h.
Referenced by HasReceiveWindowOpportunityScheduled(), RemoveReceiveWindowOpportunity(), and SetReceiveWindowOpportunity().
struct Reply ns3::lorawan::EndDeviceStatus::m_reply |
Next reply intended for this device.
Definition at line 356 of file end-device-status.h.
Referenced by EndDeviceStatus(), AddMACCommand(), GetCompleteReplyPacket(), GetReplyFrameHeader(), GetReplyMacHeader(), GetReplyPayload(), InitializeReply(), NeedsReply(), SetReplyFrameHeader(), SetReplyMacHeader(), and SetReplyPayload().
|
private |
Frequency [MHz] for RX2 window.
Definition at line 373 of file end-device-status.h.
Referenced by GetSecondReceiveWindowFrequency(), and SetSecondReceiveWindowFrequency().
|
private |
Spreading Factor (SF) for RX2 window.
Definition at line 372 of file end-device-status.h.
Referenced by GetSecondReceiveWindowSpreadingFactor().