A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lora-tag.h
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#ifndef LORA_TAG_H
21#define LORA_TAG_H
22
23#include "ns3/tag.h"
24
25namespace ns3
26{
27namespace lorawan
28{
29
30/**
31 * \ingroup lorawan
32 *
33 * Tag used to save various data about a packet, like its Spreading Factor and data about
34 * interference.
35 */
36class LoraTag : public Tag
37{
38 public:
39 /**
40 * Register this type.
41 * \return The object TypeId.
42 */
43 static TypeId GetTypeId();
44 TypeId GetInstanceTypeId() const override;
45
46 /**
47 * Create a LoraTag with a given spreading factor and collision.
48 *
49 * \param sf The Spreading Factor.
50 * \param destroyedBy The spreading factor this tag's packet was destroyed by.
51 */
52 LoraTag(uint8_t sf = 0, uint8_t destroyedBy = 0);
53
54 ~LoraTag() override; //!< Destructor
55
56 void Serialize(TagBuffer i) const override;
57 void Deserialize(TagBuffer i) override;
58 uint32_t GetSerializedSize() const override;
59 void Print(std::ostream& os) const override;
60
61 /**
62 * Read which Spreading Factor this packet was transmitted with.
63 *
64 * \return This tag's packet's spreading factor.
65 */
66 uint8_t GetSpreadingFactor() const;
67
68 /**
69 * Read which Spreading Factor this packet was destroyed by.
70 *
71 * \return The spreading factor this packet was destroyed by.
72 */
73 uint8_t GetDestroyedBy() const;
74
75 /**
76 * Read the power this packet arrived with.
77 *
78 * \return This tag's packet received power.
79 */
80 double GetReceivePower() const;
81
82 /**
83 * Set which Spreading Factor this packet was transmitted with.
84 *
85 * \param sf The Spreading Factor.
86 */
87 void SetSpreadingFactor(uint8_t sf);
88
89 /**
90 * Set which Spreading Factor this packet was destroyed by.
91 *
92 * \param sf The Spreading Factor.
93 */
94 void SetDestroyedBy(uint8_t sf);
95
96 /**
97 * Set the power this packet was received with.
98 *
99 * \param receivePower The power, in dBm.
100 */
101 void SetReceivePower(double receivePower);
102
103 /**
104 * Set the frequency of the packet.
105 *
106 * This value works in two ways:
107 * - It is used by the gateway to signal to the network server the frequency of the uplink
108 * packet
109 * - It is used by the network server to signal to the gateway the frequency of a downlink
110 * packet.
111 *
112 * \param frequency The frequency value [MHz].
113 */
114 void SetFrequency(double frequency);
115
116 /**
117 * Get the frequency of the packet.
118 *
119 * This value works in two ways:
120 * - It is used by the gateway to signal to the network server the frequency of the uplink
121 * packet
122 * - It is used by the network server to signal to the gateway the frequency of a downlink
123 * packet.
124 *
125 * \return The frequency value [MHz].
126 */
127 double GetFrequency() const;
128
129 /**
130 * Get the data rate for this packet.
131 *
132 * \return The data rate that needs to be employed for this packet.
133 */
134 uint8_t GetDataRate() const;
135
136 /**
137 * Set the data rate for this packet.
138 *
139 * \param dataRate The data rate.
140 */
141 void SetDataRate(uint8_t dataRate);
142
143 private:
144 uint8_t m_sf; //!< The Spreading Factor used by the packet.
145 uint8_t m_destroyedBy; //!< The Spreading Factor that destroyed the packet.
146 double m_receivePower; //!< The reception power of this packet.
147 uint8_t m_dataRate; //!< The data rate that needs to be used to send this packet.
148 double m_frequency; //!< The frequency of this packet
149};
150} // namespace lorawan
151} // namespace ns3
152#endif
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
Definition: lora-tag.h:37
static TypeId GetTypeId()
Register this type.
Definition: lora-tag.cc:33
double m_frequency
The frequency of this packet.
Definition: lora-tag.h:148
uint8_t GetDestroyedBy() const
Read which Spreading Factor this packet was destroyed by.
Definition: lora-tag.cc:100
uint8_t m_dataRate
The data rate that needs to be used to send this packet.
Definition: lora-tag.h:147
void SetDataRate(uint8_t dataRate)
Set the data rate for this packet.
Definition: lora-tag.cc:148
void Deserialize(TagBuffer i) override
Definition: lora-tag.cc:78
~LoraTag() override
Destructor.
Definition: lora-tag.cc:55
void SetSpreadingFactor(uint8_t sf)
Set which Spreading Factor this packet was transmitted with.
Definition: lora-tag.cc:118
uint8_t GetDataRate() const
Get the data rate for this packet.
Definition: lora-tag.cc:142
void Serialize(TagBuffer i) const override
Definition: lora-tag.cc:68
double GetReceivePower() const
Read the power this packet arrived with.
Definition: lora-tag.cc:106
uint32_t GetSerializedSize() const override
Definition: lora-tag.cc:60
void SetFrequency(double frequency)
Set the frequency of the packet.
Definition: lora-tag.cc:130
uint8_t m_destroyedBy
The Spreading Factor that destroyed the packet.
Definition: lora-tag.h:145
uint8_t m_sf
The Spreading Factor used by the packet.
Definition: lora-tag.h:144
uint8_t GetSpreadingFactor() const
Read which Spreading Factor this packet was transmitted with.
Definition: lora-tag.cc:94
void Print(std::ostream &os) const override
Definition: lora-tag.cc:88
void SetReceivePower(double receivePower)
Set the power this packet was received with.
Definition: lora-tag.cc:124
double GetFrequency() const
Get the frequency of the packet.
Definition: lora-tag.cc:136
void SetDestroyedBy(uint8_t sf)
Set which Spreading Factor this packet was destroyed by.
Definition: lora-tag.cc:112
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: lora-tag.cc:41
double m_receivePower
The reception power of this packet.
Definition: lora-tag.h:146
Every class exported by the ns3 library is enclosed in the ns3 namespace.