/usr/include/ns3.27/ns3/wifi-mac-queue.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005, 2009 INRIA
* Copyright (c) 2009 MIRKO BANCHI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
* Mirko Banchi <mk.banchi@gmail.com>
* Stefano Avallone <stavallo@unina.it>
*/
#ifndef WIFI_MAC_QUEUE_H
#define WIFI_MAC_QUEUE_H
#include "ns3/queue.h"
#include "wifi-mac-header.h"
namespace ns3 {
class QosBlockedDestinations;
/**
* \ingroup wifi
*
* WifiMacQueueItem stores (const) packets along with their Wifi MAC headers
* and the time when they were enqueued.
*/
class WifiMacQueueItem : public SimpleRefCount<WifiMacQueueItem>
{
public:
/**
* \brief Create a Wifi MAC queue item containing a packet and a Wifi MAC header.
* \param p the const packet included in the created item.
* \param header the Wifi Mac header included in the created item.
*/
WifiMacQueueItem (Ptr<const Packet> p, const WifiMacHeader & header);
virtual ~WifiMacQueueItem ();
/**
* \brief Get the packet stored in this item
* \return the packet stored in this item.
*/
Ptr<const Packet> GetPacket (void) const;
/**
* \brief Get the header stored in this item
* \return the header stored in this item.
*/
const WifiMacHeader & GetHeader (void) const;
/**
* \brief Return the requested address present in the header
* \param type the type of the address to return
* \return the address
*/
Mac48Address GetAddress (enum WifiMacHeader::AddressType type) const;
/**
* \brief Get the timestamp included in this item
* \return the timestamp included in this item.
*/
Time GetTimeStamp (void) const;
/**
* \brief Return the size of the packet included in this item
*
* \return the size of the packet included in this item.
*/
uint32_t GetSize (void) const;
private:
/**
* \brief Default constructor
*
* Defined and unimplemented to avoid misuse
*/
WifiMacQueueItem ();
/**
* \brief Copy constructor
*
* Defined and unimplemented to avoid misuse
*/
WifiMacQueueItem (const WifiMacQueueItem &);
/**
* \brief Assignment operator
*
* Defined and unimplemented to avoid misuse
* \returns
*/
WifiMacQueueItem &operator = (const WifiMacQueueItem &);
Ptr<const Packet> m_packet; //!< The packet contained in this queue item
WifiMacHeader m_header; //!< Wifi MAC header associated with the packet
Time m_tstamp; //!< timestamp when the packet arrived at the queue
};
// The following explicit template instantiation declaration prevents modules
// including this header file from implicitly instantiating Queue<WifiMacQueueItem>.
// This would cause python examples using wifi to crash at runtime with the
// following error message: "Trying to allocate twice the same uid:
// ns3::Queue<WifiMacQueueItem>"
extern template class Queue<WifiMacQueueItem>;
/**
* \ingroup wifi
*
* This queue implements the timeout procedure described in
* (Section 9.19.2.6 "Retransmit procedures" paragraph 6; IEEE 802.11-2012).
*
* When a packet is received by the MAC, to be sent to the PHY,
* it is queued in the internal queue after being tagged by the
* current time.
*
* When a packet is dequeued, the queue checks its timestamp
* to verify whether or not it should be dropped. If
* dot11EDCATableMSDULifetime has elapsed, it is dropped.
* Otherwise, it is returned to the caller.
*/
class WifiMacQueue : public Queue<WifiMacQueueItem>
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
WifiMacQueue ();
~WifiMacQueue ();
/// drop policy
enum DropPolicy
{
DROP_NEWEST,
DROP_OLDEST
};
/**
* Set the maximum delay before the packet is discarded.
*
* \param delay the maximum delay
*/
void SetMaxDelay (Time delay);
/**
* Return the maximum delay before the packet is discarded.
*
* \return the maximum delay
*/
Time GetMaxDelay (void) const;
/**
* Enqueue the given Wifi MAC queue item at the <i>end</i> of the queue.
*
* \param item the Wifi MAC queue item to be enqueued at the end
* \return true if success, false if the packet has been dropped
*/
bool Enqueue (Ptr<WifiMacQueueItem> item);
/**
* Enqueue the given Wifi MAC queue item at the <i>front</i> of the queue.
*
* \param item the Wifi MAC queue item to be enqueued at the front
* \return true if success, false if the packet has been dropped
*/
bool PushFront (Ptr<WifiMacQueueItem> item);
/**
* Dequeue the packet in the front of the queue.
*
* \return the packet
*/
Ptr<WifiMacQueueItem> Dequeue (void);
/**
* Search and return, if present in the queue, the first packet having the
* address indicated by <i>type</i> equal to <i>addr</i>, and tid
* equal to <i>tid</i>. This method removes the packet from the queue.
* It is typically used by ns3::EdcaTxopN in order to perform correct MSDU
* aggregation (A-MSDU).
*
* \param tid the given TID
* \param type the given address type
* \param addr the given destination
*
* \return the packet
*/
Ptr<WifiMacQueueItem> DequeueByTidAndAddress (uint8_t tid,
WifiMacHeader::AddressType type,
Mac48Address addr);
/**
* Return first available packet for transmission. A packet could be no available
* if it is a QoS packet with a tid and an address1 fields equal to <i>tid</i> and <i>addr</i>
* respectively that index a pending agreement in the BlockAckManager object.
* So that packet must not be transmitted until reception of an ADDBA response frame from station
* addressed by <i>addr</i>. This method removes the packet from queue.
*
* \param blockedPackets
*
* \return packet
*/
Ptr<WifiMacQueueItem> DequeueFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets);
/**
* Peek the packet in the front of the queue. The packet is not removed.
*
* \return the packet
*/
Ptr<const WifiMacQueueItem> Peek (void) const;
/**
* Search and return, if present in the queue, the first packet having the
* address indicated by <i>type</i> equal to <i>addr</i>, and tid
* equal to <i>tid</i>. This method does not remove the packet from the queue.
* It is typically used by ns3::EdcaTxopN in order to perform correct MSDU
* aggregation (A-MSDU).
*
* \param tid the given TID
* \param type the given address type
* \param addr the given destination
*
* \return packet
*/
Ptr<const WifiMacQueueItem> PeekByTidAndAddress (uint8_t tid,
WifiMacHeader::AddressType type,
Mac48Address addr);
/**
* Return first available packet for transmission. The packet is not removed from queue.
*
* \param blockedPackets
*
* \return packet
*/
Ptr<const WifiMacQueueItem> PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets);
/**
* Remove the packet in the front of the queue.
*
* \return the packet
*/
Ptr<WifiMacQueueItem> Remove (void);
/**
* If exists, removes <i>packet</i> from queue and returns true. Otherwise it
* takes no effects and return false. Deletion of the packet is
* performed in linear time (O(n)).
*
* \param packet the packet to be removed
*
* \return true if the packet was removed, false otherwise
*/
bool Remove (Ptr<const Packet> packet);
/**
* Return the number of QoS packets having tid equal to <i>tid</i> and address
* specified by <i>type</i> equal to <i>addr</i>.
*
* \param tid the given TID
* \param type the given address type
* \param addr the given destination
*
* \return the number of QoS packets
*/
uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
WifiMacHeader::AddressType type,
Mac48Address addr);
/**
* \return true if the queue is empty; false otherwise
*
* Overrides the IsEmpty method provided by QueueBase
*/
bool IsEmpty (void);
/**
* \return The number of packets currently stored in the Queue
*
* Overrides the GetNPackets method provided by QueueBase
*/
uint32_t GetNPackets (void);
/**
* \return The number of bytes currently occupied by the packets in the Queue
*
* Overrides the GetNBytes method provided by QueueBase
*/
uint32_t GetNBytes (void);
private:
/**
* Remove the item pointed to by the iterator <i>it</i> if it has been in the
* queue for too long. If the item is removed, the iterator is updated to
* point to the item that followed the erased one.
*
* \param it an iterator pointing to the item
* \return true if the item is removed, false otherwise
*/
bool TtlExceeded (ConstIterator &it);
Time m_maxDelay; //!< Time to live for packets in the queue
DropPolicy m_dropPolicy; //!< Drop behavior of queue
NS_LOG_TEMPLATE_DECLARE; //!< redefinition of the log component
};
} //namespace ns3
#endif /* WIFI_MAC_QUEUE_H */
|