Loading...
Searching...
No Matches
lora-tag.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2017 University of Padova
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Davide Magrin <magrinda@dei.unipd.it>
19 *
20 * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21 */
22
23#include "lora-tag.h"
24
25#include "ns3/tag.h"
26#include "ns3/uinteger.h"
27
28#include <ostream>
29
30namespace ns3
31{
32
33NS_OBJECT_ENSURE_REGISTERED(LoraTag);
34
35TypeId
37{
38 static TypeId tid = TypeId("ns3::LoraTag").SetParent<Tag>().AddConstructor<LoraTag>();
39 return tid;
40}
41
42TypeId
44{
45 return GetTypeId();
46}
47
48LoraTag::LoraTag(uint8_t sf, uint8_t destroyedBy)
49 : m_sf(sf),
50 m_modcod(0),
51 m_destroyedBy(destroyedBy),
53 m_dataRate(0),
55{
56}
57
61
62uint32_t
64{
65 // Each datum about a SF is 1 byte + receivePower (the size of a double) +
66 // frequency (the size of a double)
67 return 4 + 2 * sizeof(double);
68}
69
70void
71LoraTag::Serialize(TagBuffer i) const
72{
73 i.WriteU8(m_sf);
74 i.WriteU8(m_modcod);
75 i.WriteU8(m_destroyedBy);
76 i.WriteDouble(m_receivePower);
77 i.WriteU8(m_dataRate);
78 i.WriteDouble(m_frequency);
79}
80
81void
83{
84 m_sf = i.ReadU8();
85 m_modcod = i.ReadU8();
86 m_destroyedBy = i.ReadU8();
87 m_receivePower = i.ReadDouble();
88 m_dataRate = i.ReadU8();
89 m_frequency = i.ReadDouble();
90}
91
92void
93LoraTag::Print(std::ostream& os) const
94{
95 os << m_sf << " " << m_modcod << " " << m_destroyedBy << " " << m_receivePower << " "
96 << m_dataRate;
97}
98
99uint8_t
101{
102 return m_sf;
103}
104
105uint8_t
107{
108 return m_destroyedBy;
109}
110
111double
113{
114 return m_receivePower;
115}
116
117void
119{
120 m_destroyedBy = sf;
121}
122
123void
125{
126 m_sf = sf;
127}
128
129void
130LoraTag::SetReceivePower(double receivePower)
131{
132 m_receivePower = receivePower;
133}
134
135void
136LoraTag::SetFrequency(double frequency)
137{
138 m_frequency = frequency;
139}
140
141double
143{
144 return m_frequency;
145}
146
147uint8_t
149{
150 return m_dataRate;
151}
152
153void
154LoraTag::SetDataRate(uint8_t dataRate)
155{
156 m_dataRate = dataRate;
157}
158
159uint8_t
164
165void
166LoraTag::SetModcod(uint8_t modcod)
167{
168 m_modcod = modcod;
169}
170
171} // namespace ns3
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
Definition lora-tag.h:41
uint8_t m_sf
The Spreading Factor used by the packet.
Definition lora-tag.h:148
double GetFrequency(void)
Get the frequency of the packet.
Definition lora-tag.cc:142
uint8_t m_modcod
The Modcod ID used by the packet.
Definition lora-tag.h:149
void SetSpreadingFactor(uint8_t sf)
Set which Spreading Factor this packet was transmitted with.
Definition lora-tag.cc:124
static TypeId GetTypeId(void)
Definition lora-tag.cc:36
virtual ~LoraTag()
Definition lora-tag.cc:58
uint8_t m_dataRate
The Data Rate that needs to be used to send this.
Definition lora-tag.h:152
uint8_t GetSpreadingFactor() const
Read which Spreading Factor this packet was transmitted with.
Definition lora-tag.cc:100
double m_receivePower
The reception power of this packet.
Definition lora-tag.h:151
void SetDestroyedBy(uint8_t sf)
Set which Spreading Factor this packet was destroyed by.
Definition lora-tag.cc:118
uint8_t GetDataRate(void)
Get the data rate for this packet.
Definition lora-tag.cc:148
virtual TypeId GetInstanceTypeId(void) const
Definition lora-tag.cc:43
virtual uint32_t GetSerializedSize() const
Definition lora-tag.cc:63
void SetDataRate(uint8_t dataRate)
Set the data rate for this packet.
Definition lora-tag.cc:154
uint8_t GetModcod(void)
Get the modcod for this packet.
Definition lora-tag.cc:160
virtual void Serialize(TagBuffer i) const
Definition lora-tag.cc:71
void SetFrequency(double frequency)
Set the frequency of the packet.
Definition lora-tag.cc:136
double GetReceivePower() const
Read the power this packet arrived with.
Definition lora-tag.cc:112
virtual void Deserialize(TagBuffer i)
Definition lora-tag.cc:82
void SetReceivePower(double receivePower)
Set the power this packet was received with.
Definition lora-tag.cc:130
virtual void Print(std::ostream &os) const
Definition lora-tag.cc:93
double m_frequency
packet.
Definition lora-tag.h:154
void SetModcod(uint8_t modcod)
Set the modcod for this packet.
Definition lora-tag.cc:166
LoraTag(uint8_t sf=0, uint8_t destroyedBy=0)
Create a LoraTag with a given spreading factor and collision.
Definition lora-tag.cc:48
uint8_t GetDestroyedBy() const
Read which Spreading Factor this packet was destroyed by.
Definition lora-tag.cc:106
uint8_t m_destroyedBy
The Spreading Factor that destroyed the packet.
Definition lora-tag.h:150
SatModcod_t
Modulation scheme and coding rate for DVB-S2.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.