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