A Discrete-Event Network Simulator
API
lte-radio-bearer-tag.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Marco Miozzo <marco.miozzo@cttc.es>
18  */
19 
20 #include "lte-radio-bearer-tag.h"
21 
22 #include "ns3/tag.h"
23 #include "ns3/uinteger.h"
24 
25 namespace ns3
26 {
27 
28 NS_OBJECT_ENSURE_REGISTERED(LteRadioBearerTag);
29 
30 TypeId
32 {
33  static TypeId tid =
34  TypeId("ns3::LteRadioBearerTag")
35  .SetParent<Tag>()
36  .SetGroupName("Lte")
37  .AddConstructor<LteRadioBearerTag>()
38  .AddAttribute("rnti",
39  "The rnti that indicates the UE to which packet belongs",
40  UintegerValue(0),
42  MakeUintegerChecker<uint16_t>())
43  .AddAttribute(
44  "lcid",
45  "The id within the UE identifying the logical channel to which the packet belongs",
46  UintegerValue(0),
48  MakeUintegerChecker<uint8_t>());
49  return tid;
50 }
51 
52 TypeId
54 {
55  return GetTypeId();
56 }
57 
59  : m_rnti(0),
60  m_lcid(0),
61  m_layer(0)
62 {
63 }
64 
65 LteRadioBearerTag::LteRadioBearerTag(uint16_t rnti, uint8_t lcid)
66  : m_rnti(rnti),
67  m_lcid(lcid)
68 {
69 }
70 
71 LteRadioBearerTag::LteRadioBearerTag(uint16_t rnti, uint8_t lcid, uint8_t layer)
72  : m_rnti(rnti),
73  m_lcid(lcid),
74  m_layer(layer)
75 {
76 }
77 
78 void
80 {
81  m_rnti = rnti;
82 }
83 
84 void
86 {
87  m_lcid = lcid;
88 }
89 
90 void
92 {
93  m_layer = layer;
94 }
95 
96 uint32_t
98 {
99  return 4;
100 }
101 
102 void
104 {
105  i.WriteU16(m_rnti);
106  i.WriteU8(m_lcid);
107  i.WriteU8(m_layer);
108 }
109 
110 void
112 {
113  m_rnti = (uint16_t)i.ReadU16();
114  m_lcid = (uint8_t)i.ReadU8();
115  m_layer = (uint8_t)i.ReadU8();
116 }
117 
118 uint16_t
120 {
121  return m_rnti;
122 }
123 
124 uint8_t
126 {
127  return m_lcid;
128 }
129 
130 uint8_t
132 {
133  return m_layer;
134 }
135 
136 void
137 LteRadioBearerTag::Print(std::ostream& os) const
138 {
139  os << "rnti=" << m_rnti << ", lcid=" << (uint16_t)m_lcid << ", layer=" << (uint16_t)m_layer;
140 }
141 
142 } // namespace ns3
Tag used to define the RNTI and LC id for each MAC packet transmitted.
uint32_t GetSerializedSize() const override
void Serialize(TagBuffer i) const override
void SetLayer(uint8_t layer)
Set the layer id to the given value.
uint16_t GetRnti() const
Get RNTI function.
void Print(std::ostream &os) const override
uint8_t GetLcid() const
Get LCID function.
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
LteRadioBearerTag()
Create an empty LteRadioBearerTag.
void SetRnti(uint16_t rnti)
Set the RNTI to the given value.
void SetLcid(uint8_t lcid)
Set the LC id to the given value.
uint8_t GetLayer() const
Get layer function.
void Deserialize(TagBuffer i) override
read and write tag data
Definition: tag-buffer.h:52
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition: tag-buffer.h:196
TAG_BUFFER_INLINE uint16_t ReadU16()
Definition: tag-buffer.h:206
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition: tag-buffer.h:180
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46