A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
lora-tx-current-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
7
*/
8
9
#include "
lora-tx-current-model.h
"
10
11
#include "
lora-utils.h
"
12
13
#include "ns3/double.h"
14
#include "ns3/log.h"
15
16
namespace
ns3
17
{
18
namespace
lorawan
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"LoraTxCurrentModel"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(
LoraTxCurrentModel
);
24
25
TypeId
26
LoraTxCurrentModel::GetTypeId
()
27
{
28
static
TypeId
tid =
TypeId
(
"ns3::LoraTxCurrentModel"
).
SetParent
<
Object
>().SetGroupName(
"Lora"
);
29
return
tid;
30
}
31
32
LoraTxCurrentModel::LoraTxCurrentModel
()
33
{
34
}
35
36
LoraTxCurrentModel::~LoraTxCurrentModel
()
37
{
38
}
39
40
// Similarly to the wifi case
41
NS_OBJECT_ENSURE_REGISTERED
(
LinearLoraTxCurrentModel
);
42
43
TypeId
44
LinearLoraTxCurrentModel::GetTypeId
()
45
{
46
static
TypeId
tid =
47
TypeId
(
"ns3::LinearLoraTxCurrentModel"
)
48
.
SetParent
<
LoraTxCurrentModel
>()
49
.SetGroupName(
"Lora"
)
50
.AddConstructor<
LinearLoraTxCurrentModel
>()
51
.AddAttribute(
"Eta"
,
52
"The efficiency of the power amplifier."
,
53
DoubleValue
(0.10),
54
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetEta
,
55
&
LinearLoraTxCurrentModel::GetEta
),
56
MakeDoubleChecker<double>
())
57
.AddAttribute(
"Voltage"
,
58
"The supply voltage (in Volts)."
,
59
DoubleValue
(3.3),
60
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetVoltage
,
61
&
LinearLoraTxCurrentModel::GetVoltage
),
62
MakeDoubleChecker<double>
())
63
.AddAttribute(
"StandbyCurrent"
,
64
"The current in the STANDBY state (in Watts)."
,
65
DoubleValue
(0.0014),
// idle mode = 1.4mA
66
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetStandbyCurrent
,
67
&
LinearLoraTxCurrentModel::GetStandbyCurrent
),
68
MakeDoubleChecker<double>
());
69
return
tid;
70
}
71
72
LinearLoraTxCurrentModel::LinearLoraTxCurrentModel
()
73
{
74
NS_LOG_FUNCTION
(
this
);
75
}
76
77
LinearLoraTxCurrentModel::~LinearLoraTxCurrentModel
()
78
{
79
NS_LOG_FUNCTION
(
this
);
80
}
81
82
void
83
LinearLoraTxCurrentModel::SetEta
(
double
eta)
84
{
85
NS_LOG_FUNCTION
(
this
<< eta);
86
m_eta
= eta;
87
}
88
89
void
90
LinearLoraTxCurrentModel::SetVoltage
(
double
voltage)
91
{
92
NS_LOG_FUNCTION
(
this
<< voltage);
93
m_voltage
= voltage;
94
}
95
96
void
97
LinearLoraTxCurrentModel::SetStandbyCurrent
(
double
idleCurrent)
98
{
99
NS_LOG_FUNCTION
(
this
<< idleCurrent);
100
m_idleCurrent
= idleCurrent;
101
}
102
103
double
104
LinearLoraTxCurrentModel::GetEta
()
const
105
{
106
return
m_eta
;
107
}
108
109
double
110
LinearLoraTxCurrentModel::GetVoltage
()
const
111
{
112
return
m_voltage
;
113
}
114
115
double
116
LinearLoraTxCurrentModel::GetStandbyCurrent
()
const
117
{
118
return
m_idleCurrent
;
119
}
120
121
double
122
LinearLoraTxCurrentModel::CalcTxCurrent
(
double
txPowerDbm)
const
123
{
124
NS_LOG_FUNCTION
(
this
<< txPowerDbm);
125
return
DbmToW
(txPowerDbm) / (
m_voltage
*
m_eta
) +
m_idleCurrent
;
126
}
127
128
NS_OBJECT_ENSURE_REGISTERED
(
ConstantLoraTxCurrentModel
);
129
130
TypeId
131
ConstantLoraTxCurrentModel::GetTypeId
()
132
{
133
static
TypeId
tid =
134
TypeId
(
"ns3::ConstantLoraTxCurrentModel"
)
135
.
SetParent
<
LoraTxCurrentModel
>()
136
.SetGroupName(
"Lora"
)
137
.AddConstructor<
ConstantLoraTxCurrentModel
>()
138
.AddAttribute(
"TxCurrent"
,
139
"The radio Tx current in Ampere."
,
140
DoubleValue
(0.028),
// transmit at 0dBm = 28mA
141
MakeDoubleAccessor
(&
ConstantLoraTxCurrentModel::SetTxCurrent
,
142
&
ConstantLoraTxCurrentModel::GetTxCurrent
),
143
MakeDoubleChecker<double>
());
144
return
tid;
145
}
146
147
ConstantLoraTxCurrentModel::ConstantLoraTxCurrentModel
()
148
{
149
NS_LOG_FUNCTION
(
this
);
150
}
151
152
ConstantLoraTxCurrentModel::~ConstantLoraTxCurrentModel
()
153
{
154
NS_LOG_FUNCTION
(
this
);
155
}
156
157
void
158
ConstantLoraTxCurrentModel::SetTxCurrent
(
double
txCurrent)
159
{
160
NS_LOG_FUNCTION
(
this
<< txCurrent);
161
m_txCurrent
= txCurrent;
162
}
163
164
double
165
ConstantLoraTxCurrentModel::GetTxCurrent
()
const
166
{
167
return
m_txCurrent
;
168
}
169
170
double
171
ConstantLoraTxCurrentModel::CalcTxCurrent
(
double
txPowerDbm)
const
172
{
173
NS_LOG_FUNCTION
(
this
<< txPowerDbm);
174
return
m_txCurrent
;
175
}
176
177
}
// namespace lorawan
178
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::Object::Object
Object()
Constructor.
Definition
object.cc:96
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::lorawan::ConstantLoraTxCurrentModel
A constant model of the transmission current for a LoRa device, always yielding the same current inde...
Definition
lora-tx-current-model.h:122
ns3::lorawan::ConstantLoraTxCurrentModel::m_txCurrent
double m_txCurrent
The transmission current [Ampere].
Definition
lora-tx-current-model.h:150
ns3::lorawan::ConstantLoraTxCurrentModel::CalcTxCurrent
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
Definition
lora-tx-current-model.cc:171
ns3::lorawan::ConstantLoraTxCurrentModel::SetTxCurrent
void SetTxCurrent(double txCurrent)
Set the current in the TX state.
Definition
lora-tx-current-model.cc:158
ns3::lorawan::ConstantLoraTxCurrentModel::~ConstantLoraTxCurrentModel
~ConstantLoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:152
ns3::lorawan::ConstantLoraTxCurrentModel::ConstantLoraTxCurrentModel
ConstantLoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:147
ns3::lorawan::ConstantLoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:131
ns3::lorawan::ConstantLoraTxCurrentModel::GetTxCurrent
double GetTxCurrent() const
Get the current of the TX state.
Definition
lora-tx-current-model.cc:165
ns3::lorawan::LinearLoraTxCurrentModel
A linear model of the transmission current for a LoRa device, based on the WiFi model.
Definition
lora-tx-current-model.h:54
ns3::lorawan::LinearLoraTxCurrentModel::GetStandbyCurrent
double GetStandbyCurrent() const
Get the current in the STANDBY state.
Definition
lora-tx-current-model.cc:116
ns3::lorawan::LinearLoraTxCurrentModel::m_idleCurrent
double m_idleCurrent
Standby current.
Definition
lora-tx-current-model.h:112
ns3::lorawan::LinearLoraTxCurrentModel::SetStandbyCurrent
void SetStandbyCurrent(double idleCurrent)
Set the current in the STANDBY state.
Definition
lora-tx-current-model.cc:97
ns3::lorawan::LinearLoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:44
ns3::lorawan::LinearLoraTxCurrentModel::m_voltage
double m_voltage
Voltage.
Definition
lora-tx-current-model.h:111
ns3::lorawan::LinearLoraTxCurrentModel::LinearLoraTxCurrentModel
LinearLoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:72
ns3::lorawan::LinearLoraTxCurrentModel::GetEta
double GetEta() const
Get the power amplifier efficiency.
Definition
lora-tx-current-model.cc:104
ns3::lorawan::LinearLoraTxCurrentModel::SetVoltage
void SetVoltage(double voltage)
Set the supply voltage.
Definition
lora-tx-current-model.cc:90
ns3::lorawan::LinearLoraTxCurrentModel::m_eta
double m_eta
ETA.
Definition
lora-tx-current-model.h:110
ns3::lorawan::LinearLoraTxCurrentModel::~LinearLoraTxCurrentModel
~LinearLoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:77
ns3::lorawan::LinearLoraTxCurrentModel::GetVoltage
double GetVoltage() const
Get the supply voltage.
Definition
lora-tx-current-model.cc:110
ns3::lorawan::LinearLoraTxCurrentModel::CalcTxCurrent
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
Definition
lora-tx-current-model.cc:122
ns3::lorawan::LinearLoraTxCurrentModel::SetEta
void SetEta(double eta)
Set the power amplifier efficiency.
Definition
lora-tx-current-model.cc:83
ns3::lorawan::LoraTxCurrentModel
Model the transmit current as a function of the transmit power and mode.
Definition
lora-tx-current-model.h:27
ns3::lorawan::LoraTxCurrentModel::LoraTxCurrentModel
LoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:32
ns3::lorawan::LoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:26
ns3::lorawan::LoraTxCurrentModel::~LoraTxCurrentModel
~LoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:36
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
lora-tx-current-model.h
lora-utils.h
ns3::lorawan
Definition
forwarder-helper.cc:25
ns3::lorawan::DbmToW
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition
lora-utils.cc:26
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
src
lorawan
model
lora-tx-current-model.cc
Generated on Wed Jun 11 2025 13:15:32 for ns-3 by
1.13.2