A Discrete-Event Network Simulator
API
qos-utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 MIRKO BANCHI
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mirko Banchi <mk.banchi@gmail.com>
18  */
19 
20 #ifndef QOS_UTILS_H
21 #define QOS_UTILS_H
22 
23 #include "ns3/fatal-error.h"
24 #include "ns3/ptr.h"
25 
26 #include <map>
27 
28 namespace ns3
29 {
30 
31 class Packet;
32 class WifiMacHeader;
33 class QueueItem;
34 class Mac48Address;
35 
36 typedef std::pair<Mac48Address, uint8_t> WifiAddressTidPair;
37 
42 {
49  std::size_t operator()(const WifiAddressTidPair& addressTidPair) const;
50 };
51 
56 {
63  std::size_t operator()(const Mac48Address& address) const;
64 };
65 
72 enum AcIndex : uint8_t
73 {
75  AC_BE = 0,
77  AC_BK = 1,
79  AC_VI = 2,
81  AC_VO = 3,
85  AC_BEACON = 5,
87  AC_UNDEF
88 };
89 
97 inline std::ostream&
98 operator<<(std::ostream& os, const AcIndex& acIndex)
99 {
100  switch (acIndex)
101  {
102  case AC_BE:
103  return (os << "AC BE");
104  case AC_BK:
105  return (os << "AC BK");
106  case AC_VI:
107  return (os << "AC VI");
108  case AC_VO:
109  return (os << "AC VO");
110  case AC_BE_NQOS:
111  return (os << "AC BE NQOS");
112  case AC_BEACON:
113  return (os << "AC BEACON");
114  case AC_UNDEF:
115  return (os << "AC Undefined");
116  default:
117  NS_FATAL_ERROR("Unknown AC index");
118  return (os << "Unknown");
119  }
120 }
121 
126 class WifiAc
127 {
128  public:
135  WifiAc(uint8_t lowTid, uint8_t highTid);
141  uint8_t GetLowTid() const;
147  uint8_t GetHighTid() const;
154  uint8_t GetOtherTid(uint8_t tid) const;
155 
156  private:
157  uint8_t m_lowTid;
158  uint8_t m_highTid;
159 };
160 
170 bool operator>(AcIndex left, AcIndex right);
171 
181 bool operator>=(AcIndex left, AcIndex right);
182 
192 bool operator<(AcIndex left, AcIndex right);
193 
203 bool operator<=(AcIndex left, AcIndex right);
204 
209 extern const std::map<AcIndex, WifiAc> wifiAcList;
210 
219 AcIndex QosUtilsMapTidToAc(uint8_t tid);
220 
232 
244 uint32_t QosUtilsMapSeqControlToUniqueInteger(uint16_t seqControl, uint16_t endSequence);
245 
283 bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber);
284 
293 uint8_t GetTid(Ptr<const Packet> packet, const WifiMacHeader hdr);
294 
339 
340 } // namespace ns3
341 
342 #endif /* QOS_UTILS_H */
an EUI-48 address
Definition: mac48-address.h:46
This class stores the pair of TIDs of an Access Category.
Definition: qos-utils.h:127
WifiAc(uint8_t lowTid, uint8_t highTid)
Constructor.
Definition: qos-utils.cc:54
uint8_t GetOtherTid(uint8_t tid) const
Given a TID belonging to this Access Category, get the other TID of this AC.
Definition: qos-utils.cc:73
uint8_t m_highTid
the TID with higher priority
Definition: qos-utils.h:158
uint8_t GetHighTid() const
Get the TID with higher priority.
Definition: qos-utils.cc:67
uint8_t GetLowTid() const
Get the TID with lower priority.
Definition: qos-utils.cc:61
uint8_t m_lowTid
the TID with lower priority
Definition: qos-utils.h:157
Implements the IEEE 802.11 MAC header.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition: int64x64.h:174
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition: int64x64.h:161
bool operator>(const Length &left, const Length &right)
Check if left has a value greater than right.
Definition: length.cc:421
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:134
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet.
Definition: qos-utils.cc:182
uint32_t QosUtilsMapSeqControlToUniqueInteger(uint16_t seqControl, uint16_t endSequence)
Next function is useful to correctly sort buffered packets under block ack.
Definition: qos-utils.cc:171
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr)
This function is useful to get traffic id of different packet types.
Definition: qos-utils.cc:191
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:156
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
uint8_t SelectQueueByDSField(Ptr< QueueItem > item)
Determine the TX queue for a given packet.
Definition: qos-utils.cc:253
@ AC_BE_NQOS
Non-QoS.
Definition: qos-utils.h:83
@ AC_BE
Best Effort.
Definition: qos-utils.h:75
@ AC_VO
Voice.
Definition: qos-utils.h:81
@ AC_VI
Video.
Definition: qos-utils.h:79
@ AC_BK
Background.
Definition: qos-utils.h:77
@ AC_UNDEF
Total number of ACs.
Definition: qos-utils.h:87
@ AC_BEACON
Beacon queue.
Definition: qos-utils.h:85
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
const std::map< AcIndex, WifiAc > wifiAcList
Map containing the four ACs in increasing order of priority (according to Table 10-1 "UP-to-AC Mappin...
Definition: qos-utils.cc:126
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:34
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
Function object to compute the hash of a MAC address.
Definition: qos-utils.h:56
std::size_t operator()(const Mac48Address &address) const
Functional operator for MAC address hash computation.
Definition: qos-utils.cc:45
Function object to compute the hash of a (MAC address, TID) pair.
Definition: qos-utils.h:42
std::size_t operator()(const WifiAddressTidPair &addressTidPair) const
Functional operator for (MAC address, TID) hash computation.
Definition: qos-utils.cc:34