A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
network-status.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Martina Capuzzo <capuzzom@dei.unipd.it>
7 * Davide Magrin <magrinda@dei.unipd.it>
8 */
9
10#ifndef NETWORK_STATUS_H
11#define NETWORK_STATUS_H
12
14#include "end-device-status.h"
15#include "gateway-status.h"
16#include "lora-device-address.h"
17#include "network-scheduler.h"
18
19#include <iterator>
20
21namespace ns3
22{
23namespace lorawan
24{
25
26/**
27 * \ingroup lorawan
28 *
29 * This class represents the knowledge about the state of the network that is
30 * available at the network server. It is essentially a collection of two maps:
31 * one containing DeviceStatus objects, and the other containing GatewayStatus
32 * objects.
33 *
34 * This class is meant to be queried by NetworkController components, which
35 * can decide to take action based on the current status of the network.
36 */
37class NetworkStatus : public Object
38{
39 public:
40 /**
41 * Register this type.
42 * \return The object TypeId.
43 */
44 static TypeId GetTypeId();
45
46 NetworkStatus(); //!< Default constructor
47 ~NetworkStatus() override; //!< Destructor
48
49 /**
50 * Add a device to the ones that are tracked by this NetworkStatus object.
51 *
52 * \param edMac Pointer to the MAC layer object of the device to be tracked.
53 */
55
56 /**
57 * Add a new gateway to the list of gateways connected to the network.
58 *
59 * Each gateway is identified by its NetDevice Address in the network connecting it to the
60 * network server.
61 *
62 * \param address The gateway's NetDevice Address.
63 * \param gwStatus A pointer to a GatewayStatus object for the gateway.
64 */
65 void AddGateway(Address& address, Ptr<GatewayStatus> gwStatus);
66
67 /**
68 * Update network status on a received packet.
69 *
70 * \param packet The received packet.
71 * \param gwaddress Address of the gateway this packet was received from.
72 */
73 void OnReceivedPacket(Ptr<const Packet> packet, const Address& gwaddress);
74
75 /**
76 * Return whether the specified device needs a reply.
77 *
78 * \param deviceAddress The address of the device we are interested in.
79 * \return True if we need to reply to the last packet from the device, false otherwise.
80 */
81 bool NeedsReply(LoraDeviceAddress deviceAddress);
82
83 /**
84 * Return whether we have a gateway that is available to send a reply to the specified
85 * device.
86 *
87 * \param deviceAddress The address of the device we are interested in.
88 * \param window The device reception window we are currently targeting (1 or 2).
89 * \return The Address of the gateway which measured the best RSSI of the last packet from the
90 * device, selected among the gateways being currently available for downlink transmission.
91 */
92 Address GetBestGatewayForDevice(LoraDeviceAddress deviceAddress, int window);
93
94 /**
95 * Send a packet through a gateway.
96 *
97 * This function assumes that the packet is already tagged with a LoraTag
98 * that will inform the gateway of the parameters to use for the
99 * transmission.
100 *
101 * \param packet The packet.
102 * \param gwAddress The address of the gateway.
103 */
104 void SendThroughGateway(Ptr<Packet> packet, Address gwAddress);
105
106 /**
107 * Get the reply packet prepared for a reception window of a device.
108 *
109 * \param edAddress The address of the device.
110 * \param windowNumber The reception window number (1 or 2).
111 * \return The reply packet.
112 */
113 Ptr<Packet> GetReplyForDevice(LoraDeviceAddress edAddress, int windowNumber);
114
115 /**
116 * Get the EndDeviceStatus of the device that sent a packet.
117 *
118 * \param packet The packet sent by the end device.
119 * \return A pointer to the end device status.
120 */
122
123 /**
124 * Get the EndDeviceStatus corresponding to a LoraDeviceAddress.
125 *
126 * \param address The LoraDeviceAddress of the end device.
127 * \return A pointer to the end device status.
128 */
130
131 /**
132 * Return the number of end devices currently managed by the server.
133 *
134 * \return The number of end devices as an int.
135 */
136 int CountEndDevices();
137
138 public:
139 std::map<LoraDeviceAddress, Ptr<EndDeviceStatus>>
140 m_endDeviceStatuses; //!< Map tracking the state of devices connected to this network server
141 std::map<Address, Ptr<GatewayStatus>>
142 m_gatewayStatuses; //!< Map tracking the state of gateways connected to this network server
143};
144
145} // namespace lorawan
146
147} // namespace ns3
148#endif /* NETWORK_STATUS_H */
a polymophic address class
Definition address.h:90
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
This class represents the device address of a LoraWAN end device.
This class represents the knowledge about the state of the network that is available at the network s...
~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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.