A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
snr-tag.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005,2006 INRIA
3
* Copyright (c) 2009 MIRKO BANCHI
4
* Copyright (c) 2013 University of Surrey
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Mirko Banchi <mk.banchi@gmail.com>
21
* Konstantinos Katsaros <dinos.katsaros@gmail.com>
22
*/
23
24
#include "
snr-tag.h
"
25
26
#include "ns3/double.h"
27
28
namespace
ns3
29
{
30
31
NS_OBJECT_ENSURE_REGISTERED
(SnrTag);
32
33
TypeId
34
SnrTag::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::SnrTag"
)
37
.
SetParent
<
Tag
>()
38
.SetGroupName(
"Wifi"
)
39
.AddConstructor<
SnrTag
>()
40
.AddAttribute(
"Snr"
,
41
"The SNR of the last packet received"
,
42
DoubleValue
(0.0),
43
MakeDoubleAccessor
(&
SnrTag::Get
),
44
MakeDoubleChecker<double>());
45
return
tid;
46
}
47
48
TypeId
49
SnrTag::GetInstanceTypeId
()
const
50
{
51
return
GetTypeId
();
52
}
53
54
SnrTag::SnrTag
()
55
: m_snr(0)
56
{
57
}
58
59
uint32_t
60
SnrTag::GetSerializedSize
()
const
61
{
62
return
sizeof
(double);
63
}
64
65
void
66
SnrTag::Serialize
(
TagBuffer
i)
const
67
{
68
i.
WriteDouble
(
m_snr
);
69
}
70
71
void
72
SnrTag::Deserialize
(
TagBuffer
i)
73
{
74
m_snr
= i.
ReadDouble
();
75
}
76
77
void
78
SnrTag::Print
(std::ostream& os)
const
79
{
80
os <<
"Snr="
<<
m_snr
;
81
}
82
83
void
84
SnrTag::Set
(
double
snr)
85
{
86
m_snr
= snr;
87
}
88
89
double
90
SnrTag::Get
()
const
91
{
92
return
m_snr
;
93
}
94
95
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::SnrTag
Definition:
snr-tag.h:35
ns3::SnrTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
snr-tag.cc:34
ns3::SnrTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
snr-tag.cc:49
ns3::SnrTag::Set
void Set(double snr)
Set the SNR to the given value.
Definition:
snr-tag.cc:84
ns3::SnrTag::Serialize
void Serialize(TagBuffer i) const override
Definition:
snr-tag.cc:66
ns3::SnrTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
snr-tag.cc:60
ns3::SnrTag::Print
void Print(std::ostream &os) const override
Definition:
snr-tag.cc:78
ns3::SnrTag::m_snr
double m_snr
SNR value in linear scale.
Definition:
snr-tag.h:68
ns3::SnrTag::SnrTag
SnrTag()
Create a SnrTag with the default SNR 0.
Definition:
snr-tag.cc:54
ns3::SnrTag::Deserialize
void Deserialize(TagBuffer i) override
Definition:
snr-tag.cc:72
ns3::SnrTag::Get
double Get() const
Return the SNR value.
Definition:
snr-tag.cc:90
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::TagBuffer::WriteDouble
void WriteDouble(double v)
Definition:
tag-buffer.cc:118
ns3::TagBuffer::ReadDouble
double ReadDouble()
Definition:
tag-buffer.cc:170
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:39
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition:
double.h:43
snr-tag.h
src
wifi
model
snr-tag.cc
Generated on Sun Mar 3 2024 17:11:11 for ns-3 by
1.9.1