A Discrete-Event Network Simulator
API
eps-bearer-tag.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011,2012 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: Marco Miozzo <marco.miozzo@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 
23 #include "eps-bearer-tag.h"
24 #include "ns3/tag.h"
25 #include "ns3/uinteger.h"
26 
27 namespace ns3 {
28 
29 NS_OBJECT_ENSURE_REGISTERED (EpsBearerTag);
30 
31 TypeId
33 {
34  static TypeId tid = TypeId ("ns3::EpsBearerTag")
35  .SetParent<Tag> ()
36  .SetGroupName("Lte")
37  .AddConstructor<EpsBearerTag> ()
38  .AddAttribute ("rnti", "The rnti that indicates the UE which packet belongs",
39  UintegerValue (0),
41  MakeUintegerChecker<uint16_t> ())
42  .AddAttribute ("bid", "The EPS bearer id within the UE to which the packet belongs",
43  UintegerValue (0),
45  MakeUintegerChecker<uint8_t> ())
46  ;
47  return tid;
48 }
49 
50 TypeId
52 {
53  return GetTypeId ();
54 }
55 
57  : m_rnti (0),
58  m_bid (0)
59 {
60 }
61 EpsBearerTag::EpsBearerTag (uint16_t rnti, uint8_t bid)
62  : m_rnti (rnti),
63  m_bid (bid)
64 {
65 }
66 
67 void
68 EpsBearerTag::SetRnti (uint16_t rnti)
69 {
70  m_rnti = rnti;
71 }
72 
73 void
74 EpsBearerTag::SetBid (uint8_t bid)
75 {
76  m_bid = bid;
77 }
78 
79 uint32_t
81 {
82  return 3;
83 }
84 
85 void
87 {
88  i.WriteU16 (m_rnti);
89  i.WriteU8 (m_bid);
90 }
91 
92 void
94 {
95  m_rnti = (uint16_t) i.ReadU16 ();
96  m_bid = (uint8_t) i.ReadU8 ();
97 }
98 
99 uint16_t
101 {
102  return m_rnti;
103 }
104 
105 uint8_t
107 {
108  return m_bid;
109 }
110 
111 void
112 EpsBearerTag::Print (std::ostream &os) const
113 {
114  os << "rnti=" << m_rnti << ", bid=" << (uint16_t) m_bid;
115 }
116 
117 } // namespace ns3
Tag used to define the RNTI and EPS bearer ID for packets interchanged between the EpcEnbApplication ...
static TypeId GetTypeId(void)
Get the type ID.
virtual void Deserialize(TagBuffer i)
uint16_t m_rnti
RNTI value.
virtual void Print(std::ostream &os) const
virtual uint32_t GetSerializedSize() const
uint16_t GetRnti(void) const
Get RNTI function.
uint8_t m_bid
Bearer Id value.
virtual void Serialize(TagBuffer i) const
void SetRnti(uint16_t rnti)
Set the RNTI to the given value.
uint8_t GetBid(void) const
Get Bearer Id function.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetBid(uint8_t bid)
Set the bearer id to the given value.
EpsBearerTag()
Create an empty EpsBearerTag.
read and write tag data
Definition: tag-buffer.h:52
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Definition: tag-buffer.h:205
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition: tag-buffer.h:180
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
tag a set of bytes in a packet
Definition: tag.h:37
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: uinteger.h:45
#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.