A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sub-band.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#include "sub-band.h"
21
22#include "ns3/log.h"
23
24namespace ns3
25{
26namespace lorawan
27{
28
30
32
33TypeId
35{
36 static TypeId tid = TypeId("ns3::SubBand").SetParent<Object>().SetGroupName("lorawan");
37 return tid;
38}
39
41{
42 NS_LOG_FUNCTION(this);
43}
44
45SubBand::SubBand(double firstFrequency,
46 double lastFrequency,
47 double dutyCycle,
48 double maxTxPowerDbm)
49 : m_firstFrequency(firstFrequency),
50 m_lastFrequency(lastFrequency),
51 m_dutyCycle(dutyCycle),
52 m_nextTransmissionTime(Seconds(0)),
53 m_maxTxPowerDbm(maxTxPowerDbm)
54{
55 NS_LOG_FUNCTION(this << firstFrequency << lastFrequency << dutyCycle << maxTxPowerDbm);
56}
57
59{
60 NS_LOG_FUNCTION(this);
61}
62
63double
65{
66 return m_firstFrequency;
67}
68
69double
71{
72 return m_dutyCycle;
73}
74
75bool
76SubBand::BelongsToSubBand(double frequency) const
77{
78 return (frequency > m_firstFrequency) && (frequency < m_lastFrequency);
79}
80
81bool
83{
84 double frequency = logicalChannel->GetFrequency();
85 return BelongsToSubBand(frequency);
86}
87
88void
90{
91 m_nextTransmissionTime = nextTime;
92}
93
94Time
96{
98}
99
100void
101SubBand::SetMaxTxPowerDbm(double maxTxPowerDbm)
102{
103 m_maxTxPowerDbm = maxTxPowerDbm;
104}
105
106double
108{
109 return m_maxTxPowerDbm;
110}
111} // namespace lorawan
112} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
double GetDutyCycle() const
‍**
Definition: sub-band.cc:70
Time GetNextTransmissionTime()
Returns the next time from which transmission on this subband will be possible.
Definition: sub-band.cc:95
Time m_nextTransmissionTime
The next time a transmission will be allowed in this subband.
Definition: sub-band.h:141
double m_dutyCycle
The duty cycle that needs to be enforced on this subband.
Definition: sub-band.h:140
double m_firstFrequency
Starting frequency of the subband, in MHz.
Definition: sub-band.h:138
bool BelongsToSubBand(double frequency) const
Return whether or not a frequency belongs to this SubBand.
Definition: sub-band.cc:76
static TypeId GetTypeId()
Register this type.
Definition: sub-band.cc:34
void SetNextTransmissionTime(Time nextTime)
Update the next transmission time.
Definition: sub-band.cc:89
double GetFirstFrequency() const
Get the lowest frequency of the SubBand.
Definition: sub-band.cc:64
~SubBand() override
Destructor.
Definition: sub-band.cc:58
double GetMaxTxPowerDbm() const
Return the maximum transmission power that is allowed on this SubBand.
Definition: sub-band.cc:107
double m_lastFrequency
Ending frequency of the subband, in MHz.
Definition: sub-band.h:139
SubBand()
Default constructor.
Definition: sub-band.cc:40
void SetMaxTxPowerDbm(double maxTxPowerDbm)
Set the maximum transmission power that is allowed on this SubBand.
Definition: sub-band.cc:101
double m_maxTxPowerDbm
The maximum transmission power that is admitted on this subband.
Definition: sub-band.h:142
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.