A Discrete-Event Network Simulator
API
lte-pdcp-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-pdcp-header.h"
24
25namespace ns3 {
26
27NS_LOG_COMPONENT_DEFINE ("LtePdcpHeader");
28
29NS_OBJECT_ENSURE_REGISTERED (LtePdcpHeader);
30
32 : m_dcBit (0xff),
33 m_sequenceNumber (0xfffa)
34{
35}
36
38{
39 m_dcBit = 0xff;
40 m_sequenceNumber = 0xfffb;
41}
42
43void
45{
46 m_dcBit = dcBit & 0x01;
47}
48
49void
50LtePdcpHeader::SetSequenceNumber (uint16_t sequenceNumber)
51{
52 m_sequenceNumber = sequenceNumber & 0x0FFF;
53}
54
55uint8_t
57{
58 return m_dcBit;
59}
60
61uint16_t
63{
64 return m_sequenceNumber;
65}
66
67
70{
71 static TypeId tid = TypeId ("ns3::LtePdcpHeader")
72 .SetParent<Header> ()
73 .SetGroupName("Lte")
74 .AddConstructor<LtePdcpHeader> ()
75 ;
76 return tid;
77}
78
81{
82 return GetTypeId ();
83}
84
85void LtePdcpHeader::Print (std::ostream &os) const
86{
87 os << "D/C=" << (uint16_t)m_dcBit;
88 os << " SN=" << m_sequenceNumber;
89}
90
92{
93 return 2;
94}
95
97{
99
100 i.WriteU8 ( (m_dcBit << 7) | (m_sequenceNumber & 0x0F00) >> 8 );
101 i.WriteU8 ( (m_sequenceNumber & 0x00FF) );
102}
103
105{
107 uint8_t byte_1;
108 uint8_t byte_2;
109
110 byte_1 = i.ReadU8 ();
111 byte_2 = i.ReadU8 ();
112 m_dcBit = (byte_1 & 0x80) > 7;
113 // For now, we just support DATA PDUs
115 m_sequenceNumber = ((byte_1 & 0x0F) << 8) | byte_2;
116
117 return GetSerializedSize ();
118}
119
120}; // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
Protocol header serialization and deserialization.
Definition: header.h:43
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.
uint8_t m_dcBit
the DC bit
virtual uint32_t Deserialize(Buffer::Iterator start)
LtePdcpHeader()
Constructor.
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.
virtual void Print(std::ostream &os) const
uint16_t m_sequenceNumber
the sequence number
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSerializedSize(void) const
uint8_t GetDcBit() const
Get DC bit.
virtual void Serialize(Buffer::Iterator start) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:206
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1852