A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
mu-snr-tag.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2021 Universita' degli Studi di Napoli Federico II
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: Stefano Avallone <stavallo@unina.it>
19
*/
20
21
#include "
mu-snr-tag.h
"
22
23
namespace
ns3
{
24
25
NS_OBJECT_ENSURE_REGISTERED
(MuSnrTag);
26
27
TypeId
28
MuSnrTag::GetTypeId
(
void
)
29
{
30
static
TypeId
tid =
TypeId
(
"ns3::MuSnrTag"
)
31
.
SetParent
<
Tag
> ()
32
.SetGroupName (
"Wifi"
)
33
.AddConstructor<
MuSnrTag
> ()
34
;
35
return
tid;
36
}
37
38
TypeId
39
MuSnrTag::GetInstanceTypeId
(
void
)
const
40
{
41
return
GetTypeId
();
42
}
43
44
MuSnrTag::MuSnrTag
()
45
{
46
}
47
48
void
49
MuSnrTag::Reset
(
void
)
50
{
51
m_snrMap
.clear ();
52
}
53
54
void
55
MuSnrTag::Set
(uint16_t staId,
double
snr)
56
{
57
m_snrMap
[staId] = snr;
58
}
59
60
bool
61
MuSnrTag::IsPresent
(uint16_t staId)
const
62
{
63
return
(
m_snrMap
.find (staId) !=
m_snrMap
.end ());
64
}
65
66
double
67
MuSnrTag::Get
(uint16_t staId)
const
68
{
69
NS_ASSERT
(
IsPresent
(staId));
70
return
m_snrMap
.at (staId);
71
}
72
73
uint32_t
74
MuSnrTag::GetSerializedSize
(
void
)
const
75
{
76
return
(
sizeof
(uint16_t) +
sizeof
(
double
)) *
m_snrMap
.size () + 1;
77
}
78
79
void
80
MuSnrTag::Serialize
(
TagBuffer
i)
const
81
{
82
i.
WriteU8
(
m_snrMap
.size ());
83
84
for
(
const
auto
& staIdSnrPair :
m_snrMap
)
85
{
86
i.
WriteU16
(staIdSnrPair.first);
87
i.
WriteDouble
(staIdSnrPair.second);
88
}
89
}
90
91
void
92
MuSnrTag::Deserialize
(
TagBuffer
i)
93
{
94
uint8_t
n
= i.
ReadU8
();
95
for
(uint8_t j = 0; j <
n
; j++)
96
{
97
uint16_t staId = i.
ReadU16
();
98
double
snr = i.
ReadDouble
();
99
m_snrMap
.insert ({staId, snr});
100
}
101
}
102
103
void
104
MuSnrTag::Print
(std::ostream &os)
const
105
{
106
for
(
const
auto
& staIdSnrPair :
m_snrMap
)
107
{
108
os <<
"{STA-ID="
<< staIdSnrPair.first <<
" Snr="
<< staIdSnrPair.second <<
"} "
;
109
}
110
os << std::endl;
111
}
112
113
}
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::MuSnrTag::Print
void Print(std::ostream &os) const override
Definition:
mu-snr-tag.cc:104
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:67
ns3::TagBuffer::WriteDouble
void WriteDouble(double v)
Definition:
tag-buffer.cc:115
ns3::MuSnrTag::Serialize
void Serialize(TagBuffer i) const override
Definition:
mu-snr-tag.cc:80
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MuSnrTag
A tag to be attached to a response to a multi-user UL frame, that carries the SNR values with which t...
Definition:
mu-snr-tag.h:36
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::MuSnrTag::GetSerializedSize
uint32_t GetSerializedSize(void) const override
Definition:
mu-snr-tag.cc:74
ns3::TagBuffer::ReadU16
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Definition:
tag-buffer.h:205
ns3::MuSnrTag::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
mu-snr-tag.cc:28
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:37
ns3::MuSnrTag::Set
void Set(uint16_t staId, double snr)
Set the SNR for the given sender to the given value.
Definition:
mu-snr-tag.cc:55
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition:
tag-buffer.h:195
ns3::MuSnrTag::Reset
void Reset(void)
Reset the content of the tag.
Definition:
mu-snr-tag.cc:49
ns3::MuSnrTag::IsPresent
bool IsPresent(uint16_t staId) const
Return true if the SNR value for the given STA-ID is present.
Definition:
mu-snr-tag.cc:61
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:172
ns3::MuSnrTag::Get
double Get(uint16_t staId) const
Return the SNR value for the given sender.
Definition:
mu-snr-tag.cc:67
ns3::MuSnrTag::MuSnrTag
MuSnrTag()
Create an empty MuSnrTag.
Definition:
mu-snr-tag.cc:44
mu-snr-tag.h
ns3::MuSnrTag::m_snrMap
std::map< uint16_t, double > m_snrMap
Map containing (STA-ID, SNR) pairs.
Definition:
mu-snr-tag.h:83
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::TagBuffer::WriteU16
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition:
tag-buffer.h:180
ns3::MuSnrTag::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const override
Get the most derived TypeId for this Object.
Definition:
mu-snr-tag.cc:39
ns3::TagBuffer::ReadDouble
double ReadDouble(void)
Definition:
tag-buffer.cc:164
sample-rng-plot.n
n
Definition:
sample-rng-plot.py:37
ns3::MuSnrTag::Deserialize
void Deserialize(TagBuffer i) override
Definition:
mu-snr-tag.cc:92
src
wifi
model
he
mu-snr-tag.cc
Generated on Fri Oct 1 2021 17:03:44 for ns-3 by
1.8.20