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  * Authors: Ghada Badawy <gbadawy@gmail.com>
19  * Sébastien Deronne <sebastien.deronne@gmail.com>
20  */
21 
22 #include "ampdu-tag.h"
23 #include "ns3/tag.h"
24 #include "ns3/uinteger.h"
25 
26 namespace ns3 {
27 
29 
30 TypeId
32 {
33  static TypeId tid = TypeId ("ns3::AmpduTag")
34  .SetParent<Tag> ()
35  .SetGroupName ("Wifi")
36  .AddConstructor<AmpduTag> ()
37  .AddAttribute ("AmpduExists", "The value that indicates that the packet contains an AMPDU",
38  UintegerValue (false),
40  MakeUintegerChecker<uint8_t> ())
41  ;
42  return tid;
43 }
44 
45 TypeId
47 {
48  return GetTypeId ();
49 }
50 
52  : m_ampdu (0),
53  m_nbOfMpdus (0),
54  m_duration (Seconds(0))
55 {
56 }
57 
58 void
59 AmpduTag::SetAmpdu (bool supported)
60 {
61  m_ampdu = supported;
62 }
63 
64 void
66 {
67  NS_ASSERT (nbofmpdus <= 64);
68  m_nbOfMpdus = nbofmpdus;
69 }
70 
71 void
73 {
75  m_duration = duration;
76 }
77 
78 uint32_t
80 {
81  return (2 + sizeof (Time));
82 }
83 
84 void
86 {
87  i.WriteU8 (m_ampdu);
88  i.WriteU8 (m_nbOfMpdus);
89  int64_t duration = m_duration.GetTimeStep ();
90  i.Write ((const uint8_t *)&duration, sizeof(int64_t));
91 }
92 
93 void
95 {
96  m_ampdu = i.ReadU8 ();
97  m_nbOfMpdus = i.ReadU8 ();
98  int64_t duration;
99  i.Read ((uint8_t *)&duration, 8);
100  m_duration = Time (duration);
101 }
102 
103 bool
105 {
106  return (m_ampdu == 1) ? true : false;
107 }
108 
109 uint8_t
111 {
112  return m_nbOfMpdus;
113 }
114 
115 Time
117 {
118  return m_duration;
119 }
120 
121 void
122 AmpduTag::Print (std::ostream &os) const
123 {
124  os << "A-MPDU exists=" << m_ampdu
125  << " Remaining number of MPDUs=" << m_nbOfMpdus
126  << " Remaining A-MPDU duration=" << m_duration;
127 }
128 
129 } //namespace ns3
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint8_t GetRemainingNbOfMpdus(void) const
Definition: ampdu-tag.cc:110
#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:122
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:719
bool GetAmpdu(void) const
Definition: ampdu-tag.cc:104
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
virtual uint32_t GetSerializedSize() const
Definition: ampdu-tag.cc:79
void SetAmpdu(bool supported)
Set m_ampdu to 1.
Definition: ampdu-tag.cc:59
AmpduTag()
Create a AmpduTag with the default =0 no Ampdu.
Definition: ampdu-tag.cc:51
Hold an unsigned integer type.
Definition: uinteger.h:44
uint8_t m_nbOfMpdus
Remaining number of MPDUs in the A-MPDU.
Definition: ampdu-tag.h:92
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:38
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.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:377
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:46
virtual void Deserialize(TagBuffer i)
Definition: ampdu-tag.cc:94
uint8_t m_ampdu
Flag whether it is an A-MPDU.
Definition: ampdu-tag.h:91
read and write tag data
Definition: tag-buffer.h:51
virtual void Serialize(TagBuffer i) const
Definition: ampdu-tag.cc:85
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
static TypeId GetTypeId(void)
Definition: ampdu-tag.cc:31
void SetRemainingNbOfMpdus(uint8_t nbofmpdus)
Definition: ampdu-tag.cc:65
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:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
Time GetRemainingAmpduDuration(void) const
Definition: ampdu-tag.cc:116
Time m_duration
Remaining duration of the A-MPDU in nanoseconds.
Definition: ampdu-tag.h:93
void SetRemainingAmpduDuration(Time duration)
Definition: ampdu-tag.cc:72