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
lte-pdcp-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Manuel Requena <manuel.requena@cttc.es>
7
*/
8
9
#include "
lte-pdcp-header.h
"
10
11
#include "ns3/log.h"
12
13
namespace
ns3
14
{
15
16
NS_LOG_COMPONENT_DEFINE
(
"LtePdcpHeader"
);
17
18
NS_OBJECT_ENSURE_REGISTERED
(LtePdcpHeader);
19
20
LtePdcpHeader::LtePdcpHeader
()
21
: m_dcBit(0xff),
22
m_sequenceNumber(0xfffa)
23
{
24
}
25
26
LtePdcpHeader::~LtePdcpHeader
()
27
{
28
m_dcBit
= 0xff;
29
m_sequenceNumber
= 0xfffb;
30
}
31
32
void
33
LtePdcpHeader::SetDcBit
(uint8_t dcBit)
34
{
35
m_dcBit
= dcBit & 0x01;
36
}
37
38
void
39
LtePdcpHeader::SetSequenceNumber
(uint16_t sequenceNumber)
40
{
41
m_sequenceNumber
= sequenceNumber & 0x0FFF;
42
}
43
44
uint8_t
45
LtePdcpHeader::GetDcBit
()
const
46
{
47
return
m_dcBit
;
48
}
49
50
uint16_t
51
LtePdcpHeader::GetSequenceNumber
()
const
52
{
53
return
m_sequenceNumber
;
54
}
55
56
TypeId
57
LtePdcpHeader::GetTypeId
()
58
{
59
static
TypeId
tid =
TypeId
(
"ns3::LtePdcpHeader"
)
60
.
SetParent
<
Header
>()
61
.SetGroupName(
"Lte"
)
62
.AddConstructor<
LtePdcpHeader
>();
63
return
tid;
64
}
65
66
TypeId
67
LtePdcpHeader::GetInstanceTypeId
()
const
68
{
69
return
GetTypeId
();
70
}
71
72
void
73
LtePdcpHeader::Print
(std::ostream& os)
const
74
{
75
os <<
"D/C="
<< (uint16_t)
m_dcBit
;
76
os <<
" SN="
<<
m_sequenceNumber
;
77
}
78
79
uint32_t
80
LtePdcpHeader::GetSerializedSize
()
const
81
{
82
return
2;
83
}
84
85
void
86
LtePdcpHeader::Serialize
(
Buffer::Iterator
start)
const
87
{
88
Buffer::Iterator
i = start;
89
90
i.
WriteU8
((
m_dcBit
<< 7) | (
m_sequenceNumber
& 0x0F00) >> 8);
91
i.
WriteU8
(
m_sequenceNumber
& 0x00FF);
92
}
93
94
uint32_t
95
LtePdcpHeader::Deserialize
(
Buffer::Iterator
start)
96
{
97
Buffer::Iterator
i = start;
98
uint8_t byte_1;
99
uint8_t byte_2;
100
101
byte_1 = i.
ReadU8
();
102
byte_2 = i.
ReadU8
();
103
m_dcBit
= (byte_1 & 0x80) > 7;
104
// For now, we just support DATA PDUs
105
NS_ASSERT
(
m_dcBit
==
DATA_PDU
);
106
m_sequenceNumber
= ((byte_1 & 0x0F) << 8) | byte_2;
107
108
return
GetSerializedSize
();
109
}
110
111
};
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::LtePdcpHeader
The packet header for the Packet Data Convergence Protocol (PDCP) packets.
Definition
lte-pdcp-header.h:28
ns3::LtePdcpHeader::GetSequenceNumber
uint16_t GetSequenceNumber() const
Get sequence number.
Definition
lte-pdcp-header.cc:51
ns3::LtePdcpHeader::SetDcBit
void SetDcBit(uint8_t dcBit)
Set DC bit.
Definition
lte-pdcp-header.cc:33
ns3::LtePdcpHeader::Print
void Print(std::ostream &os) const override
Definition
lte-pdcp-header.cc:73
ns3::LtePdcpHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
lte-pdcp-header.cc:95
ns3::LtePdcpHeader::m_dcBit
uint8_t m_dcBit
the DC bit
Definition
lte-pdcp-header.h:83
ns3::LtePdcpHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
lte-pdcp-header.cc:57
ns3::LtePdcpHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
lte-pdcp-header.cc:80
ns3::LtePdcpHeader::LtePdcpHeader
LtePdcpHeader()
Constructor.
Definition
lte-pdcp-header.cc:20
ns3::LtePdcpHeader::SetSequenceNumber
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.
Definition
lte-pdcp-header.cc:39
ns3::LtePdcpHeader::~LtePdcpHeader
~LtePdcpHeader() override
Definition
lte-pdcp-header.cc:26
ns3::LtePdcpHeader::m_sequenceNumber
uint16_t m_sequenceNumber
the sequence number
Definition
lte-pdcp-header.h:84
ns3::LtePdcpHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
lte-pdcp-header.cc:67
ns3::LtePdcpHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
lte-pdcp-header.cc:86
ns3::LtePdcpHeader::GetDcBit
uint8_t GetDcBit() const
Get DC bit.
Definition
lte-pdcp-header.cc:45
ns3::LtePdcpHeader::DATA_PDU
@ DATA_PDU
Definition
lte-pdcp-header.h:68
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
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_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
lte-pdcp-header.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lte
model
lte-pdcp-header.cc
Generated on Fri Nov 8 2024 13:59:03 for ns-3 by
1.11.0