A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qos-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 MIRKO BANCHI
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: Mirko Banchi <mk.banchi@gmail.com>
19  */
20 #include "qos-tag.h"
21 #include "ns3/tag.h"
22 #include "ns3/uinteger.h"
23 
24 namespace ns3 {
25 
27  ;
28 
29 TypeId
31 {
32  static TypeId tid = TypeId ("ns3::QosTag")
33  .SetParent<Tag> ()
34  .AddConstructor<QosTag> ()
35  .AddAttribute ("tid", "The tid that indicates AC which packet belongs",
36  UintegerValue (0),
37  MakeUintegerAccessor (&QosTag::GetTid),
38  MakeUintegerChecker<uint8_t> ())
39  ;
40  return tid;
41 }
42 
43 TypeId
45 {
46  return GetTypeId ();
47 }
48 
50  : m_tid (0)
51 {
52 }
53 QosTag::QosTag (uint8_t tid)
54  : m_tid (tid)
55 {
56 }
57 
58 void
59 QosTag::SetTid (uint8_t tid)
60 {
61  m_tid = tid;
62 }
63 
64 void
66 {
67  m_tid = up;
68 }
69 
70 uint32_t
72 {
73  return 1;
74 }
75 
76 void
78 {
79  i.WriteU8 (m_tid);
80 }
81 
82 void
84 {
85  m_tid = (UserPriority) i.ReadU8 ();
86 }
87 
88 uint8_t
90 {
91  return m_tid;
92 }
93 
94 void
95 QosTag::Print (std::ostream &os) const
96 {
97  os << "Tid=" << m_tid;
98 }
99 
100 } // namespace ns3
void SetUserPriority(UserPriority up)
Set the TID to the value that corresponds to the requested UserPriority.
Definition: qos-tag.cc:65
virtual void Deserialize(TagBuffer i)
Definition: qos-tag.cc:83
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:179
void SetTid(uint8_t tid)
Set the TID to the given value.
Definition: qos-tag.cc:59
virtual uint32_t GetSerializedSize() const
Definition: qos-tag.cc:71
virtual void Serialize(TagBuffer i) const
Definition: qos-tag.cc:77
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual TypeId GetInstanceTypeId(void) const
Definition: qos-tag.cc:44
virtual void Print(std::ostream &os) const
Definition: qos-tag.cc:95
tag a set of bytes in a packet
Definition: tag.h:36
static TypeId GetTypeId(void)
Definition: qos-tag.cc:30
UserPriority
As per IEEE Std.
Definition: qos-tag.h:39
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:156
QosTag()
Create a QosTag with the default TID = 0 (best effort traffic)
Definition: qos-tag.cc:49
read and write tag data
Definition: tag-buffer.h:51
uint8_t m_tid
Traffic ID.
Definition: qos-tag.h:113
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
uint8_t GetTid(void) const
Return the Type ID.
Definition: qos-tag.cc:89