A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
lte-rlc-header.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Manuel Requena <manuel.requena@cttc.es>
19
*/
20
21
#include "ns3/log.h"
22
23
#include "ns3/lte-rlc-header.h"
24
25
namespace
ns3
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"LteRlcHeader"
);
28
29
NS_OBJECT_ENSURE_REGISTERED
(LteRlcHeader);
30
31
LteRlcHeader::LteRlcHeader
()
32
: m_headerLength (0),
33
m_framingInfo (0xff),
34
m_sequenceNumber (0xfffa)
35
{
36
}
37
38
LteRlcHeader::~LteRlcHeader
()
39
{
40
m_headerLength
= 0;
41
m_framingInfo
= 0xff;
42
m_sequenceNumber
= 0xfffb;
43
}
44
45
void
46
LteRlcHeader::SetFramingInfo
(uint8_t framingInfo)
47
{
48
m_framingInfo
= framingInfo & 0x03;
49
}
50
51
void
52
LteRlcHeader::SetSequenceNumber
(
SequenceNumber10
sequenceNumber)
53
{
54
m_sequenceNumber
= sequenceNumber;
55
}
56
57
uint8_t
58
LteRlcHeader::GetFramingInfo
()
const
59
{
60
return
m_framingInfo
;
61
}
62
63
SequenceNumber10
64
LteRlcHeader::GetSequenceNumber
()
const
65
{
66
return
m_sequenceNumber
;
67
}
68
69
70
void
71
LteRlcHeader::PushExtensionBit
(uint8_t extensionBit)
72
{
73
m_extensionBits
.push_back (extensionBit);
74
if
(
m_extensionBits
.size() == 1)
75
{
76
m_headerLength
= 2;
// Only fixed part
77
}
78
else
if
(
m_extensionBits
.size() % 2)
79
{
80
m_headerLength
+= 1;
81
}
82
else
83
{
84
m_headerLength
+= 2;
85
}
86
}
87
88
void
89
LteRlcHeader::PushLengthIndicator
(uint16_t lengthIndicator)
90
{
91
m_lengthIndicators
.push_back (lengthIndicator);
92
}
93
94
95
uint8_t
96
LteRlcHeader::PopExtensionBit
(
void
)
97
{
98
uint8_t extensionBit =
m_extensionBits
.front ();
99
m_extensionBits
.pop_front ();
100
101
return
extensionBit;
102
}
103
104
uint16_t
105
LteRlcHeader::PopLengthIndicator
(
void
)
106
{
107
uint16_t lengthIndicator =
m_lengthIndicators
.front ();
108
m_lengthIndicators
.pop_front ();
109
110
return
lengthIndicator;
111
}
112
113
114
TypeId
115
LteRlcHeader::GetTypeId
(
void
)
116
{
117
static
TypeId
tid =
TypeId
(
"ns3::LteRlcHeader"
)
118
.
SetParent
<
Header
> ()
119
.SetGroupName(
"Lte"
)
120
.AddConstructor<
LteRlcHeader
> ()
121
;
122
return
tid;
123
}
124
125
TypeId
126
LteRlcHeader::GetInstanceTypeId
(
void
)
const
127
{
128
return
GetTypeId
();
129
}
130
131
void
LteRlcHeader::Print
(std::ostream &os)
const
132
{
133
std::list <uint8_t>::const_iterator it1 =
m_extensionBits
.begin ();
134
std::list <uint16_t>::const_iterator it2 =
m_lengthIndicators
.begin ();
135
136
os <<
"Len="
<<
m_headerLength
;
137
os <<
" FI="
<< (uint16_t)
m_framingInfo
;
138
os <<
" E="
<< (uint16_t)(*it1);
139
os <<
" SN="
<<
m_sequenceNumber
;
140
141
it1++;
142
if
(it1 !=
m_extensionBits
.end ())
143
{
144
os <<
" E="
;
145
}
146
while
( it1 !=
m_extensionBits
.end () )
147
{
148
os << (uint16_t)(*it1);
149
it1++;
150
}
151
152
if
(it2 !=
m_lengthIndicators
.end ())
153
{
154
os <<
" LI="
;
155
}
156
while
( it2 !=
m_lengthIndicators
.end () )
157
{
158
os << (uint16_t)(*it2) <<
" "
;
159
it2++;
160
}
161
}
162
163
uint32_t
LteRlcHeader::GetSerializedSize
(
void
)
const
164
{
165
return
m_headerLength
;
166
}
167
168
void
LteRlcHeader::Serialize
(
Buffer::Iterator
start
)
const
169
{
170
Buffer::Iterator
i =
start
;
171
172
std::list <uint8_t>::const_iterator it1 =
m_extensionBits
.begin ();
173
std::list <uint16_t>::const_iterator it2 =
m_lengthIndicators
.begin ();
174
175
i.
WriteU8
( ((
m_framingInfo
<< 3) & 0x18) |
176
(((*it1) << 2) & 0x04) |
177
((
m_sequenceNumber
.
GetValue
() >> 8) & 0x0003) );
178
i.
WriteU8
(
m_sequenceNumber
.
GetValue
() & 0x00FF );
179
it1++;
180
181
while
( it1 !=
m_extensionBits
.end () &&
182
it2 !=
m_lengthIndicators
.end () )
183
{
184
uint16_t oddLi, evenLi;
185
uint8_t oddE, evenE;
186
187
oddE = *it1;
188
oddLi = *it2;
189
190
it1++;
191
it2++;
192
193
if
( it1 !=
m_extensionBits
.end () &&
194
it2 !=
m_lengthIndicators
.end () )
195
{
196
evenE = *it1;
197
evenLi = *it2;
198
199
i.
WriteU8
( ((oddE << 7) & 0x80) | ((oddLi >> 4) & 0x007F) );
200
i.
WriteU8
( ((oddLi << 4) & 0x00F0) | ((evenE << 3) & 0x08) | ((evenLi >> 8) & 0x0007) );
201
i.
WriteU8
( evenLi & 0x00FF );
202
203
it1++;
204
it2++;
205
}
206
else
207
{
208
i.
WriteU8
( ((oddE << 7) & 0x80) | ((oddLi >> 4) & 0x007F) );
209
i.
WriteU8
( ((oddLi << 4) & 0x00F0) );
// Padding is implicit
210
}
211
}
212
}
213
214
uint32_t
LteRlcHeader::Deserialize
(
Buffer::Iterator
start
)
215
{
216
Buffer::Iterator
i =
start
;
217
uint8_t byte_1;
218
uint8_t byte_2;
219
uint8_t byte_3;
220
uint8_t extensionBit;
221
222
byte_1 = i.
ReadU8
();
223
byte_2 = i.
ReadU8
();
224
m_headerLength
= 2;
225
m_framingInfo
= (byte_1 & 0x18) >> 3;
226
m_sequenceNumber
= ((byte_1 & 0x03) << 8) | byte_2;
227
228
extensionBit = (byte_1 & 0x04) >> 2;
229
m_extensionBits
.push_back (extensionBit);
230
231
if
(extensionBit ==
DATA_FIELD_FOLLOWS
)
232
{
233
return
GetSerializedSize
();
234
}
235
236
uint16_t oddLi, evenLi;
237
uint8_t oddE, evenE;
238
bool
moreLiFields = (extensionBit ==
E_LI_FIELDS_FOLLOWS
);
239
240
while
(moreLiFields)
241
{
242
byte_1 = i.
ReadU8
();
243
byte_2 = i.
ReadU8
();
244
245
oddE = (byte_1 & 0x80) >> 7;
246
oddLi = ((byte_1 & 0x7F) << 4) | ((byte_2 & 0xF0) >> 4);
247
moreLiFields = (oddE ==
E_LI_FIELDS_FOLLOWS
);
248
249
m_extensionBits
.push_back (oddE);
250
m_lengthIndicators
.push_back (oddLi);
251
m_headerLength
+= 2;
252
253
if
(moreLiFields)
254
{
255
byte_3 = i.
ReadU8
();
256
257
evenE = (byte_2 & 0x08) >> 3;
258
evenLi = ((byte_2 & 0x07) << 8) | (byte_3 & 0xFF);
259
moreLiFields = (evenE ==
E_LI_FIELDS_FOLLOWS
);
260
261
m_extensionBits
.push_back (evenE);
262
m_lengthIndicators
.push_back (evenLi);
263
264
m_headerLength
+= 1;
265
}
266
}
267
268
return
GetSerializedSize
();
269
}
270
271
};
// namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::LteRlcHeader::PopExtensionBit
uint8_t PopExtensionBit(void)
Pop extension bit.
Definition:
lte-rlc-header.cc:96
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LteRlcHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
lte-rlc-header.cc:126
ns3::LteRlcHeader::PopLengthIndicator
uint16_t PopLengthIndicator(void)
Pop length indicator.
Definition:
lte-rlc-header.cc:105
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1021
ns3::LteRlcHeader::Print
virtual void Print(std::ostream &os) const
Definition:
lte-rlc-header.cc:131
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:869
ns3::LteRlcHeader::DATA_FIELD_FOLLOWS
@ DATA_FIELD_FOLLOWS
Definition:
lte-rlc-header.h:105
ns3::LteRlcHeader::GetSequenceNumber
SequenceNumber10 GetSequenceNumber() const
Get sequence number.
Definition:
lte-rlc-header.cc:64
ns3::LteRlcHeader
The packet header for the Radio Link Control (RLC) protocol packets.
Definition:
lte-rlc-header.h:40
ns3::LteRlcHeader::m_framingInfo
uint8_t m_framingInfo
2 bits
Definition:
lte-rlc-header.h:135
ns3::LteRlcHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
lte-rlc-header.cc:163
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::LteRlcHeader::m_headerLength
uint16_t m_headerLength
header length
Definition:
lte-rlc-header.h:134
visualizer.core.start
def start()
Definition:
core.py:1855
ns3::LteRlcHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
lte-rlc-header.cc:115
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:43
ns3::LteRlcHeader::E_LI_FIELDS_FOLLOWS
@ E_LI_FIELDS_FOLLOWS
Definition:
lte-rlc-header.h:106
ns3::LteRlcHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
lte-rlc-header.cc:168
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::LteRlcHeader::SetSequenceNumber
void SetSequenceNumber(SequenceNumber10 sequenceNumber)
Set sequence number.
Definition:
lte-rlc-header.cc:52
ns3::LteRlcHeader::~LteRlcHeader
~LteRlcHeader()
Definition:
lte-rlc-header.cc:38
ns3::LteRlcHeader::SetFramingInfo
void SetFramingInfo(uint8_t framingInfo)
Set framing info.
Definition:
lte-rlc-header.cc:46
ns3::LteRlcHeader::PushExtensionBit
void PushExtensionBit(uint8_t extensionBit)
Push extension bit.
Definition:
lte-rlc-header.cc:71
ns3::LteRlcHeader::PushLengthIndicator
void PushLengthIndicator(uint16_t lengthIndicator)
Push length indicator.
Definition:
lte-rlc-header.cc:89
ns3::LteRlcHeader::m_lengthIndicators
std::list< uint16_t > m_lengthIndicators
length indicators
Definition:
lte-rlc-header.h:139
ns3::LteRlcHeader::m_sequenceNumber
SequenceNumber10 m_sequenceNumber
sequence number
Definition:
lte-rlc-header.h:136
ns3::SequenceNumber10
SequenceNumber10 class.
Definition:
lte-rlc-sequence-number.h:37
ns3::LteRlcHeader::GetFramingInfo
uint8_t GetFramingInfo() const
Get framing info.
Definition:
lte-rlc-header.cc:58
ns3::LteRlcHeader::m_extensionBits
std::list< uint8_t > m_extensionBits
Includes extensionBit of the fixed part.
Definition:
lte-rlc-header.h:138
ns3::SequenceNumber10::GetValue
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
Definition:
lte-rlc-sequence-number.h:81
ns3::LteRlcHeader::LteRlcHeader
LteRlcHeader()
Constructor.
Definition:
lte-rlc-header.cc:31
src
lte
model
lte-rlc-header.cc
Generated on Fri Oct 1 2021 17:03:20 for ns-3 by
1.8.20