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/log.h"
12
#include "ns3/simple-gateway-lora-phy.h"
13
14
namespace
ns3
15
{
16
namespace
lorawan
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"LoraPhyHelper"
);
20
21
LoraPhyHelper::LoraPhyHelper
()
22
:
m_maxReceptionPaths
(8),
23
m_txPriority
(true)
24
{
25
NS_LOG_FUNCTION
(
this
);
26
}
27
28
void
29
LoraPhyHelper::SetChannel
(
Ptr<LoraChannel>
channel)
30
{
31
m_channel
= channel;
32
}
33
34
void
35
LoraPhyHelper::SetDeviceType
(
enum
DeviceType
dt)
36
{
37
NS_LOG_FUNCTION
(
this
<< dt);
38
switch
(dt)
39
{
40
case
GW
:
41
m_phy
.SetTypeId(
"ns3::SimpleGatewayLoraPhy"
);
42
break
;
43
case
ED
:
44
m_phy
.SetTypeId(
"ns3::SimpleEndDeviceLoraPhy"
);
45
break
;
46
}
47
}
48
49
TypeId
50
LoraPhyHelper::GetDeviceType
()
const
51
{
52
NS_LOG_FUNCTION
(
this
);
53
return
m_phy
.GetTypeId();
54
}
55
56
void
57
LoraPhyHelper::Set
(std::string name,
const
AttributeValue
&
v
)
58
{
59
m_phy
.Set(name,
v
);
60
}
61
62
Ptr<LoraPhy>
63
LoraPhyHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
device)
const
64
{
65
NS_LOG_FUNCTION
(
this
<< node->GetId() << device);
66
67
// Create the PHY and set its channel
68
Ptr<LoraPhy>
phy =
m_phy
.Create<
LoraPhy
>();
69
phy->SetChannel(
m_channel
);
70
71
// Configuration is different based on the kind of device we have to create
72
std::string typeId =
m_phy
.GetTypeId().GetName();
73
if
(typeId ==
"ns3::SimpleGatewayLoraPhy"
)
74
{
75
// Inform the channel of the presence of this PHY
76
m_channel
->Add(phy);
77
78
// For now, assume that the PHY will listen to the default EU channels
79
// We expect that MacHelper instances will overwrite this setting if the
80
// device will operate in a different region
81
std::vector<uint32_t> frequenciesHz;
82
frequenciesHz.push_back(868100000);
83
frequenciesHz.push_back(868300000);
84
frequenciesHz.push_back(868500000);
85
86
for
(
auto
& f : frequenciesHz)
87
{
88
DynamicCast<SimpleGatewayLoraPhy>
(phy)->AddFrequency(f);
89
}
90
91
int
receptionPaths = 0;
92
// Set maxReceptionPaths as a parameter
93
// int maxReceptionPaths = 8;
94
while
(receptionPaths <
m_maxReceptionPaths
)
95
{
96
DynamicCast<SimpleGatewayLoraPhy>
(phy)->AddReceptionPath();
97
receptionPaths++;
98
}
99
}
100
else
if
(typeId ==
"ns3::SimpleEndDeviceLoraPhy"
)
101
{
102
// The line below can be commented to speed up uplink-only simulations.
103
// This implies that the LoraChannel instance will only know about
104
// Gateways, and it will not lose time delivering packets and interference
105
// information to devices which will never listen.
106
107
m_channel
->Add(phy);
108
}
109
110
// Link the PHY to its net device
111
phy->SetDevice(device);
112
113
return
phy;
114
}
115
116
void
117
LoraPhyHelper::SetMaxReceptionPaths
(
int
maxReceptionPaths)
118
{
119
NS_LOG_FUNCTION
(
this
<< maxReceptionPaths);
120
m_maxReceptionPaths
= maxReceptionPaths;
121
}
122
123
void
124
LoraPhyHelper::SetGatewayTransmissionPriority
(
bool
txPriority)
125
{
126
m_txPriority
= txPriority;
127
}
128
129
}
// namespace lorawan
130
}
// 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:35
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:50
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:63
ns3::lorawan::LoraPhyHelper::SetMaxReceptionPaths
void SetMaxReceptionPaths(int maxReceptionPaths)
Set the maximum number of gateway receive paths.
Definition
lora-phy-helper.cc:117
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:57
ns3::lorawan::LoraPhyHelper::LoraPhyHelper
LoraPhyHelper()
Default constructor.
Definition
lora-phy-helper.cc:21
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:124
ns3::lorawan::LoraPhyHelper::SetChannel
void SetChannel(Ptr< LoraChannel > channel)
Set the LoraChannel to connect the PHYs to.
Definition
lora-phy-helper.cc:29
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:102
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:201
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:214
lora-phy-helper.h
ns3::lorawan
Definition
forwarder-helper.cc:20
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:643
src
lorawan
helper
lora-phy-helper.cc
Generated on
for ns-3 by
1.16.1