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-phy-helper.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: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#include "
lora-phy-helper.h
"
10
11
#include "ns3/simple-gateway-lora-phy.h"
12
13
namespace
ns3
14
{
15
namespace
lorawan
16
{
17
18
NS_LOG_COMPONENT_DEFINE
(
"LoraPhyHelper"
);
19
20
LoraPhyHelper::LoraPhyHelper
()
21
:
m_maxReceptionPaths
(8),
22
m_txPriority
(true)
23
{
24
NS_LOG_FUNCTION
(
this
);
25
}
26
27
void
28
LoraPhyHelper::SetChannel
(
Ptr<LoraChannel>
channel)
29
{
30
m_channel
= channel;
31
}
32
33
void
34
LoraPhyHelper::SetDeviceType
(
enum
DeviceType
dt)
35
{
36
NS_LOG_FUNCTION
(
this
<< dt);
37
switch
(dt)
38
{
39
case
GW
:
40
m_phy
.SetTypeId(
"ns3::SimpleGatewayLoraPhy"
);
41
break
;
42
case
ED
:
43
m_phy
.SetTypeId(
"ns3::SimpleEndDeviceLoraPhy"
);
44
break
;
45
}
46
}
47
48
TypeId
49
LoraPhyHelper::GetDeviceType
()
const
50
{
51
NS_LOG_FUNCTION
(
this
);
52
return
m_phy
.GetTypeId();
53
}
54
55
void
56
LoraPhyHelper::Set
(std::string name,
const
AttributeValue
&
v
)
57
{
58
m_phy
.Set(name,
v
);
59
}
60
61
Ptr<LoraPhy>
62
LoraPhyHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
device)
const
63
{
64
NS_LOG_FUNCTION
(
this
<< node->GetId() << device);
65
66
// Create the PHY and set its channel
67
Ptr<LoraPhy>
phy =
m_phy
.Create<
LoraPhy
>();
68
phy->SetChannel(
m_channel
);
69
70
// Configuration is different based on the kind of device we have to create
71
std::string typeId =
m_phy
.GetTypeId().GetName();
72
if
(typeId ==
"ns3::SimpleGatewayLoraPhy"
)
73
{
74
// Inform the channel of the presence of this PHY
75
m_channel
->Add(phy);
76
77
// For now, assume that the PHY will listen to the default EU channels
78
// with this ReceivePath configuration:
79
// 3 ReceivePaths on 868.1 MHz
80
// 3 ReceivePaths on 868.3 MHz
81
// 2 ReceivePaths on 868.5 MHz
82
83
// We expect that MacHelper instances will overwrite this setting if the
84
// device will operate in a different region
85
std::vector<uint32_t> frequenciesHz;
86
frequenciesHz.push_back(868100000);
87
frequenciesHz.push_back(868300000);
88
frequenciesHz.push_back(868500000);
89
90
for
(
auto
& f : frequenciesHz)
91
{
92
DynamicCast<SimpleGatewayLoraPhy>
(phy)->AddFrequency(f);
93
}
94
95
int
receptionPaths = 0;
96
// Set maxReceptionPaths as a parameter
97
// int maxReceptionPaths = 8;
98
while
(receptionPaths <
m_maxReceptionPaths
)
99
{
100
DynamicCast<SimpleGatewayLoraPhy>
(phy)->AddReceptionPath();
101
receptionPaths++;
102
}
103
}
104
else
if
(typeId ==
"ns3::SimpleEndDeviceLoraPhy"
)
105
{
106
// The line below can be commented to speed up uplink-only simulations.
107
// This implies that the LoraChannel instance will only know about
108
// Gateways, and it will not lose time delivering packets and interference
109
// information to devices which will never listen.
110
111
m_channel
->Add(phy);
112
}
113
114
// Link the PHY to its net device
115
phy->SetDevice(device);
116
117
return
phy;
118
}
119
120
void
121
LoraPhyHelper::SetMaxReceptionPaths
(
int
maxReceptionPaths)
122
{
123
NS_LOG_FUNCTION
(
this
<< maxReceptionPaths);
124
m_maxReceptionPaths
= maxReceptionPaths;
125
}
126
127
void
128
LoraPhyHelper::SetGatewayTransmissionPriority
(
bool
txPriority)
129
{
130
m_txPriority
= txPriority;
131
}
132
133
}
// namespace lorawan
134
}
// namespace ns3
v
uint32_t v
Definition
cairo-wideint.c:749
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::lorawan::LoraPhyHelper::SetDeviceType
void SetDeviceType(enum DeviceType dt)
Set the kind of PHY this helper will create.
Definition
lora-phy-helper.cc:34
ns3::lorawan::LoraPhyHelper::DeviceType
DeviceType
Enum for the type of device: End Device (ED) or Gateway (GW).
Definition
lora-phy-helper.h:34
ns3::lorawan::LoraPhyHelper::GW
@ GW
Definition
lora-phy-helper.h:35
ns3::lorawan::LoraPhyHelper::ED
@ ED
Definition
lora-phy-helper.h:36
ns3::lorawan::LoraPhyHelper::m_channel
Ptr< LoraChannel > m_channel
The channel instance the PHYs will be connected to.
Definition
lora-phy-helper.h:99
ns3::lorawan::LoraPhyHelper::GetDeviceType
TypeId GetDeviceType() const
Get the TypeId of the object to be created with LoraPhyHelper.
Definition
lora-phy-helper.cc:49
ns3::lorawan::LoraPhyHelper::Install
Ptr< LoraPhy > Install(Ptr< Node > node, Ptr< NetDevice > device) const
Create a LoraPhy and connect it to a device on a node.
Definition
lora-phy-helper.cc:62
ns3::lorawan::LoraPhyHelper::SetMaxReceptionPaths
void SetMaxReceptionPaths(int maxReceptionPaths)
Set the maximum number of gateway receive paths.
Definition
lora-phy-helper.cc:121
ns3::lorawan::LoraPhyHelper::Set
void Set(std::string name, const AttributeValue &v)
Set an attribute of the underlying PHY object.
Definition
lora-phy-helper.cc:56
ns3::lorawan::LoraPhyHelper::LoraPhyHelper
LoraPhyHelper()
Default constructor.
Definition
lora-phy-helper.cc:20
ns3::lorawan::LoraPhyHelper::m_txPriority
bool m_txPriority
Whether to give priority to downlink transmission over reception at the gateways.
Definition
lora-phy-helper.h:101
ns3::lorawan::LoraPhyHelper::SetGatewayTransmissionPriority
void SetGatewayTransmissionPriority(bool txPriority)
Set if giving priority to downlink transmission over reception at the gateways.
Definition
lora-phy-helper.cc:128
ns3::lorawan::LoraPhyHelper::SetChannel
void SetChannel(Ptr< LoraChannel > channel)
Set the LoraChannel to connect the PHYs to.
Definition
lora-phy-helper.cc:28
ns3::lorawan::LoraPhyHelper::m_maxReceptionPaths
int m_maxReceptionPaths
The maximum number of receive paths at the gateway.
Definition
lora-phy-helper.h:100
ns3::lorawan::LoraPhyHelper::m_phy
ObjectFactory m_phy
The PHY layer factory object.
Definition
lora-phy-helper.h:98
ns3::lorawan::LoraPhy
Base class for PHY layers implementing the LoRa modulation scheme.
Definition
lora-phy.h:81
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
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:231
lora-phy-helper.h
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DynamicCast
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition
ptr.h:605
src
lorawan
helper
lora-phy-helper.cc
Generated on
for ns-3 by
1.15.0