Loading...
Searching...
No Matches
lora-gateway-status.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2017 University of Padova
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Davide Magrin <magrinda@dei.unipd.it>
19 *
20 * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21 */
22
23#include "lora-gateway-status.h"
24
25#include "ns3/log.h"
26
27#include <stdint.h>
28
29NS_LOG_COMPONENT_DEFINE("LoraGatewayStatus");
30
31namespace ns3
32{
33
34NS_OBJECT_ENSURE_REGISTERED(LoraGatewayStatus);
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::LoraGatewayStatus").SetParent<Object>().AddConstructor<LoraGatewayStatus>();
41 return tid;
42}
43
45{
46 NS_LOG_FUNCTION(this);
47}
48
50{
51 NS_LOG_FUNCTION(this);
52}
53
55 Ptr<NetDevice> netDevice,
56 Ptr<LorawanMacGateway> gwMac)
57 : m_address(address),
58 m_netDevice(netDevice),
59 m_gatewayMac(gwMac),
60 m_nextTransmissionTime(Seconds(0))
61{
62 NS_LOG_FUNCTION(this);
63}
64
65Address
67{
68 NS_LOG_FUNCTION(this);
69
70 return m_address;
71}
72
73void
75{
76 NS_LOG_FUNCTION(this);
77
78 m_address = address;
79}
80
81Ptr<NetDevice>
86
87void
88LoraGatewayStatus::SetNetDevice(Ptr<NetDevice> netDevice)
89{
90 m_netDevice = netDevice;
91}
92
93Ptr<LorawanMacGateway>
98
99bool
101{
102 NS_LOG_FUNCTION(this << frequency);
103
104 // We can't send multiple packets at once, see SX1301 V2.01 page 29
105
106 // Check that the gateway was not already "booked"
107 if (m_nextTransmissionTime > Simulator::Now() - MilliSeconds(1))
108 {
109 NS_LOG_INFO("This gateway is already booked for a transmission");
110 return false;
111 }
112
113 // Check that the gateway is not already in TX mode
114 if (m_gatewayMac->IsTransmitting())
115 {
116 NS_LOG_INFO("This gateway is currently transmitting");
117 return false;
118 }
119
120 // Check that the gateway is not constrained by the duty cycle
121 Time waitingTime = m_gatewayMac->GetWaitingTime(frequency);
122 if (waitingTime > Seconds(0))
123 {
124 NS_LOG_INFO("Gateway cannot be used because of duty cycle");
125 NS_LOG_INFO("Waiting time at current GW: " << waitingTime.GetSeconds() << " seconds");
126
127 return false;
128 }
129
130 return true;
131}
132
133void
135{
136 NS_LOG_FUNCTION(this << nextTransmissionTime);
137
138 m_nextTransmissionTime = nextTransmissionTime;
139}
140} // namespace ns3
void SetNetDevice(Ptr< NetDevice > netDevice)
Set the NetDevice through which it's possible to contact this gateway from the server.
static TypeId GetTypeId(void)
Time m_nextTransmissionTime
This gateway's next transmission time.
Address GetAddress()
Get this gateway's P2P link address.
Ptr< NetDevice > GetNetDevice()
Get the NetDevice through which it's possible to contact this gateway from the server.
Ptr< LorawanMacGateway > GetGatewayMac(void)
Get a pointer to this gateway's MAC instance.
void SetNextTransmissionTime(Time nextTransmissionTime)
void SetAddress(Address address)
Set this gateway's P2P link address.
Ptr< NetDevice > m_netDevice
The NetDevice through which to reach this gateway from the server.
Ptr< LorawanMacGateway > m_gatewayMac
The Mac layer of the gateway.
bool IsAvailableForTransmission(double frequency)
Set a pointer to this gateway's MAC instance.
Address m_address
The Address of the P2PNetDevice of this gateway // TODO useless ?
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.