A Discrete-Event Network Simulator
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
13namespace ns3
14{
15
16NS_LOG_COMPONENT_DEFINE("LtePdcpHeader");
17
18NS_OBJECT_ENSURE_REGISTERED(LtePdcpHeader);
19
21 : m_dcBit(0xff),
22 m_sequenceNumber(0xfffa)
23{
24}
25
27{
28 m_dcBit = 0xff;
29 m_sequenceNumber = 0xfffb;
30}
31
32void
34{
35 m_dcBit = dcBit & 0x01;
36}
37
38void
39LtePdcpHeader::SetSequenceNumber(uint16_t sequenceNumber)
40{
41 m_sequenceNumber = sequenceNumber & 0x0FFF;
42}
43
44uint8_t
46{
47 return m_dcBit;
48}
49
50uint16_t
55
58{
59 static TypeId tid = TypeId("ns3::LtePdcpHeader")
61 .SetGroupName("Lte")
62 .AddConstructor<LtePdcpHeader>();
63 return tid;
64}
65
68{
69 return GetTypeId();
70}
71
72void
73LtePdcpHeader::Print(std::ostream& os) const
74{
75 os << "D/C=" << (uint16_t)m_dcBit;
76 os << " SN=" << m_sequenceNumber;
77}
78
81{
82 return 2;
83}
84
85void
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
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
106 m_sequenceNumber = ((byte_1 & 0x0F) << 8) | byte_2;
107
108 return GetSerializedSize();
109}
110
111}; // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
Protocol header serialization and deserialization.
Definition header.h:33
The packet header for the Packet Data Convergence Protocol (PDCP) packets.
uint16_t GetSequenceNumber() const
Get sequence number.
void SetDcBit(uint8_t dcBit)
Set DC bit.
void Print(std::ostream &os) const override
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t m_dcBit
the DC bit
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
LtePdcpHeader()
Constructor.
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.
uint16_t m_sequenceNumber
the sequence number
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const override
uint8_t GetDcBit() const
Get DC bit.
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_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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.