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
mu-snr-tag.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021 Universita' degli Studi di Napoli Federico II
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Stefano Avallone <stavallo@unina.it>
7
*/
8
9
#include "
mu-snr-tag.h
"
10
11
namespace
ns3
12
{
13
14
NS_OBJECT_ENSURE_REGISTERED
(MuSnrTag);
15
16
TypeId
17
MuSnrTag::GetTypeId
()
18
{
19
static
TypeId
tid =
20
TypeId
(
"ns3::MuSnrTag"
).
SetParent
<
Tag
>().SetGroupName(
"Wifi"
).AddConstructor<
MuSnrTag
>();
21
return
tid;
22
}
23
24
TypeId
25
MuSnrTag::GetInstanceTypeId
()
const
26
{
27
return
GetTypeId
();
28
}
29
30
MuSnrTag::MuSnrTag
()
31
{
32
}
33
34
void
35
MuSnrTag::Reset
()
36
{
37
m_snrMap
.clear();
38
}
39
40
void
41
MuSnrTag::Set
(uint16_t staId,
double
snr)
42
{
43
m_snrMap
[staId] = snr;
44
}
45
46
bool
47
MuSnrTag::IsPresent
(uint16_t staId)
const
48
{
49
return
m_snrMap
.contains(staId);
50
}
51
52
double
53
MuSnrTag::Get
(uint16_t staId)
const
54
{
55
NS_ASSERT
(
IsPresent
(staId));
56
return
m_snrMap
.at(staId);
57
}
58
59
uint32_t
60
MuSnrTag::GetSerializedSize
()
const
61
{
62
return
(
sizeof
(uint16_t) +
sizeof
(
double
)) *
m_snrMap
.size() + 1;
63
}
64
65
void
66
MuSnrTag::Serialize
(
TagBuffer
i
)
const
67
{
68
i
.WriteU8(
m_snrMap
.size());
69
70
for
(
const
auto
&
staIdSnrPair
:
m_snrMap
)
71
{
72
i
.WriteU16(
staIdSnrPair
.first);
73
i
.WriteDouble(
staIdSnrPair
.second);
74
}
75
}
76
77
void
78
MuSnrTag::Deserialize
(
TagBuffer
i
)
79
{
80
uint8_t n =
i
.ReadU8();
81
for
(uint8_t
j
= 0;
j
< n;
j
++)
82
{
83
uint16_t staId =
i
.ReadU16();
84
double
snr =
i
.ReadDouble();
85
m_snrMap
.insert({staId, snr});
86
}
87
}
88
89
void
90
MuSnrTag::Print
(std::ostream& os)
const
91
{
92
for
(
const
auto
&
staIdSnrPair
:
m_snrMap
)
93
{
94
os <<
"{STA-ID="
<<
staIdSnrPair
.first <<
" Snr="
<<
staIdSnrPair
.second <<
"} "
;
95
}
96
os << std::endl;
97
}
98
99
}
// namespace ns3
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:26
ns3::MuSnrTag::m_snrMap
std::map< uint16_t, double > m_snrMap
Map containing (STA-ID, SNR) pairs.
Definition
mu-snr-tag.h:72
ns3::MuSnrTag::Print
void Print(std::ostream &os) const override
Definition
mu-snr-tag.cc:90
ns3::MuSnrTag::Reset
void Reset()
Reset the content of the tag.
Definition
mu-snr-tag.cc:35
ns3::MuSnrTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
mu-snr-tag.cc:17
ns3::MuSnrTag::Get
double Get(uint16_t staId) const
Return the SNR value for the given sender.
Definition
mu-snr-tag.cc:53
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:47
ns3::MuSnrTag::Serialize
void Serialize(TagBuffer i) const override
Definition
mu-snr-tag.cc:66
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:41
ns3::MuSnrTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
mu-snr-tag.cc:60
ns3::MuSnrTag::Deserialize
void Deserialize(TagBuffer i) override
Definition
mu-snr-tag.cc:78
ns3::MuSnrTag::MuSnrTag
MuSnrTag()
Create an empty MuSnrTag.
Definition
mu-snr-tag.cc:30
ns3::MuSnrTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
mu-snr-tag.cc:25
ns3::TagBuffer
read and write tag data
Definition
tag-buffer.h:41
ns3::Tag
tag a set of bytes in a packet
Definition
tag.h:28
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
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:55
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
mu-snr-tag.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
wifi
model
he
mu-snr-tag.cc
Generated on Mon Dec 15 2025 15:22:07 for ns-3 by
1.9.8