A Discrete-Event Network Simulator
API
wifi-mac-queue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #ifndef WIFI_MAC_QUEUE_H
23 #define WIFI_MAC_QUEUE_H
24 
25 #include <list>
26 #include <utility>
27 #include "ns3/packet.h"
28 #include "ns3/nstime.h"
29 #include "ns3/object.h"
30 #include "wifi-mac-header.h"
31 
32 namespace ns3 {
33 class QosBlockedDestinations;
34 
50 class WifiMacQueue : public Object
51 {
52 public:
53  static TypeId GetTypeId (void);
54  WifiMacQueue ();
55  ~WifiMacQueue ();
56 
62  void SetMaxSize (uint32_t maxSize);
68  void SetMaxDelay (Time delay);
74  uint32_t GetMaxSize (void) const;
80  Time GetMaxDelay (void) const;
81 
88  void Enqueue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
95  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
124  uint8_t tid,
126  Mac48Address addr);
142  uint8_t tid,
144  Mac48Address addr,
145  Time *timestamp);
154  bool Remove (Ptr<const Packet> packet);
164  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
166  Mac48Address addr);
180  Time &tStamp,
181  const QosBlockedDestinations *blockedPackets);
191  Time &tStamp,
192  const QosBlockedDestinations *blockedPackets);
196  void Flush (void);
197 
203  bool IsEmpty (void);
209  uint32_t GetSize (void);
210 
211 protected:
215  virtual void Cleanup (void);
216 
221  struct Item
222  {
230  Item (Ptr<const Packet> packet,
231  const WifiMacHeader &hdr,
232  Time tstamp);
236  };
237 
241  typedef std::list<struct Item> PacketQueue;
245  typedef std::list<struct Item>::reverse_iterator PacketQueueRI;
249  typedef std::list<struct Item>::iterator PacketQueueI;
257  Mac48Address GetAddressForPacket (enum WifiMacHeader::AddressType type, PacketQueueI it);
258 
259  PacketQueue m_queue;
260  uint32_t m_size;
261  uint32_t m_maxSize;
263 };
264 
265 } // namespace ns3
266 
267 #endif /* WIFI_MAC_QUEUE_H */
Time m_maxDelay
Time to live for packets in the queue.
Keep track of destination address - TID pairs that are waiting for a block ACK response.
uint32_t GetSize(void)
Return the current queue size.
WifiMacHeader hdr
Wifi MAC header associated with the packet.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
Ptr< const Packet > packet
Actual packet.
void Flush(void)
Flush the queue.
virtual void Cleanup(void)
Clean up the queue by removing packets that exceeded the maximum delay.
uint32_t GetNPacketsByTidAndAddress(uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr)
Returns number of QoS packets having tid equals to tid and address specified by type equals to addr...
bool Remove(Ptr< const Packet > packet)
If exists, removes packet from queue and returns true.
void SetMaxSize(uint32_t maxSize)
Set the maximum queue size.
Ptr< const Packet > DequeueFirstAvailable(WifiMacHeader *hdr, Time &tStamp, const QosBlockedDestinations *blockedPackets)
Returns first available packet for transmission.
std::list< struct Item >::reverse_iterator PacketQueueRI
typedef for packet (struct Item) queue reverse iterator.
Ptr< const Packet > DequeueByTidAndAddress(WifiMacHeader *hdr, uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr)
Searchs and returns, if is present in this queue, first packet having address indicated by type equal...
AddressType
Address types.
bool IsEmpty(void)
Return if the queue is empty.
static TypeId GetTypeId(void)
uint32_t GetMaxSize(void) const
Return the maximum queue size.
Ptr< const Packet > Dequeue(WifiMacHeader *hdr)
Dequeue the packet in the front of the queue.
uint32_t m_size
Current queue size.
Ptr< const Packet > Peek(WifiMacHeader *hdr)
Peek the packet in the front of the queue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const Packet > PeekByTidAndAddress(WifiMacHeader *hdr, uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr, Time *timestamp)
Searchs and returns, if is present in this queue, first packet having address indicated by type equal...
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Enqueue the given packet and its corresponding WifiMacHeader at the front of the queue.
an EUI-48 address
Definition: mac48-address.h:43
Time tstamp
timestamp when the packet arrived at the queue
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Mac48Address GetAddressForPacket(enum WifiMacHeader::AddressType type, PacketQueueI it)
Return the appropriate address for the given packet (given by PacketQueue iterator).
Ptr< const Packet > PeekFirstAvailable(WifiMacHeader *hdr, Time &tStamp, const QosBlockedDestinations *blockedPackets)
Returns first available packet for transmission.
void Enqueue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Enqueue the given packet and its corresponding WifiMacHeader at the end of the queue.
Time GetMaxDelay(void) const
Return the maximum delay before the packet is discarded.
A base class which provides memory management and object aggregation.
Definition: object.h:87
A struct that holds information about a packet for putting in a packet queue.
std::list< struct Item > PacketQueue
typedef for packet (struct Item) queue.
a unique identifier for an interface.
Definition: type-id.h:57
std::list< struct Item >::iterator PacketQueueI
typedef for packet (struct Item) queue iterator.
Implements the IEEE 802.11 MAC header.
PacketQueue m_queue
Packet (struct Item) queue.
uint32_t m_maxSize
Queue capacity.
Item(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tstamp)
Create a struct with the given parameters.