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