A Discrete-Event Network Simulator
API
ampdu-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013
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: Ghada Badawy <gbadawy@gmail.com>
19  */
20 #include "ampdu-tag.h"
21 #include "ns3/tag.h"
22 #include "ns3/uinteger.h"
23 
24 namespace ns3 {
25 
27 
28 TypeId
30 {
31  static TypeId tid = TypeId ("ns3::AmpduTag")
32  .SetParent<Tag> ()
33  .SetGroupName ("Wifi")
34  .AddConstructor<AmpduTag> ()
35  .AddAttribute ("Ampdu Exists", "The value that indicates that the packet contains an AMPDU",
36  UintegerValue (false),
38  MakeUintegerChecker<uint8_t> ())
39  ;
40  return tid;
41 }
42 
43 TypeId
45 {
46  return GetTypeId ();
47 }
48 
50  : m_ampdu (0)
51 {
52 }
53 
54 void
55 AmpduTag::SetAmpdu (bool supported)
56 {
57  m_ampdu = supported;
58 }
59 
60 void
61 AmpduTag::SetNoOfMpdus (uint8_t noofmpdus)
62 {
63  NS_ASSERT (noofmpdus <= 64);
64  m_noOfMpdus = noofmpdus;
65 }
66 
67 uint32_t
69 {
70  return 2;
71 }
72 
73 void
75 {
76  i.WriteU8 (m_ampdu);
77  i.WriteU8 (m_noOfMpdus);
78 }
79 
80 void
82 {
83  m_ampdu = i.ReadU8 ();
84  m_noOfMpdus = i.ReadU8 ();
85 }
86 
87 bool
89 {
90  return (m_ampdu == 1) ? true : false;
91 }
92 
93 uint8_t
95 {
96  return m_noOfMpdus;
97 }
98 
99 void
100 AmpduTag::Print (std::ostream &os) const
101 {
102  os << "A-MPDU exists=" << m_ampdu;
103 }
104 
105 } // namespace ns3
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void Print(std::ostream &os) const
Definition: ampdu-tag.cc:100
#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
bool GetAmpdu(void) const
Definition: ampdu-tag.cc:88
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
virtual uint32_t GetSerializedSize() const
Definition: ampdu-tag.cc:68
void SetNoOfMpdus(uint8_t noofmpdus)
Definition: ampdu-tag.cc:61
void SetAmpdu(bool supported)
Set m_ampdu to 1.
Definition: ampdu-tag.cc:55
AmpduTag()
Create a AmpduTag with the default =0 no Ampdu.
Definition: ampdu-tag.cc:49
Hold an unsigned integer type.
Definition: uinteger.h:44
The aim of the AmpduTag is to provide means for a MAC to specify that a packet includes A-MPDU since ...
Definition: ampdu-tag.h:35
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: ampdu-tag.cc:44
virtual void Deserialize(TagBuffer i)
Definition: ampdu-tag.cc:81
uint8_t m_ampdu
Flag whether it is an A-MPDU.
Definition: ampdu-tag.h:76
read and write tag data
Definition: tag-buffer.h:51
virtual void Serialize(TagBuffer i) const
Definition: ampdu-tag.cc:74
uint8_t m_noOfMpdus
number of MPDUs in the A-MPDU
Definition: ampdu-tag.h:77
static TypeId GetTypeId(void)
Definition: ampdu-tag.cc:29
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
a unique identifier for an interface.
Definition: type-id.h:57
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
uint8_t GetNoOfMpdus(void) const
Definition: ampdu-tag.cc:94