A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
9 * Mirko Banchi <mk.banchi@gmail.com>
10 * Konstantinos Katsaros <dinos.katsaros@gmail.com>
11 */
12
13#include "snr-tag.h"
14
15#include "ns3/double.h"
16
17namespace ns3
18{
19
21
22TypeId
24{
25 static TypeId tid = TypeId("ns3::SnrTag")
26 .SetParent<Tag>()
27 .SetGroupName("Wifi")
28 .AddConstructor<SnrTag>()
29 .AddAttribute("Snr",
30 "The SNR of the last packet received",
31 DoubleValue(0.0),
34 return tid;
35}
36
39{
40 return GetTypeId();
41}
42
44 : m_snr(0)
45{
46}
47
50{
51 return sizeof(double);
52}
53
54void
59
60void
65
66void
67SnrTag::Print(std::ostream& os) const
68{
69 os << "Snr=" << m_snr;
70}
71
72void
73SnrTag::Set(double snr)
74{
75 m_snr = snr;
76}
77
78double
80{
81 return m_snr;
82}
83
84} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
static TypeId GetTypeId()
Get the type ID.
Definition snr-tag.cc:23
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition snr-tag.cc:38
void Set(double snr)
Set the SNR to the given value.
Definition snr-tag.cc:73
void Serialize(TagBuffer i) const override
Definition snr-tag.cc:55
uint32_t GetSerializedSize() const override
Definition snr-tag.cc:49
void Print(std::ostream &os) const override
Definition snr-tag.cc:67
double m_snr
SNR value in linear scale.
Definition snr-tag.h:57
SnrTag()
Create a SnrTag with the default SNR 0.
Definition snr-tag.cc:43
void Deserialize(TagBuffer i) override
Definition snr-tag.cc:61
double Get() const
Return the SNR value.
Definition snr-tag.cc:79
read and write tag data
Definition tag-buffer.h:41
void WriteDouble(double v)
double ReadDouble()
tag a set of bytes in a packet
Definition tag.h:28
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32