A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
141  uint8_t tid,
143  Mac48Address addr);
152  bool Remove (Ptr<const Packet> packet);
162  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
164  Mac48Address addr);
178  Time &tStamp,
179  const QosBlockedDestinations *blockedPackets);
189  Time &tStamp,
190  const QosBlockedDestinations *blockedPackets);
194  void Flush (void);
195 
201  bool IsEmpty (void);
207  uint32_t GetSize (void);
208 protected:
212  virtual void Cleanup (void);
213 
214  struct Item;
215 
219  typedef std::list<struct Item> PacketQueue;
223  typedef std::list<struct Item>::reverse_iterator PacketQueueRI;
227  typedef std::list<struct Item>::iterator PacketQueueI;
236 
241  struct Item
242  {
250  Item (Ptr<const Packet> packet,
251  const WifiMacHeader &hdr,
252  Time tstamp);
256  };
257 
259  uint32_t m_size;
260  uint32_t m_maxSize;
262 };
263 
264 } // namespace ns3
265 
266 #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.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
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.
Ptr< const Packet > PeekByTidAndAddress(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...
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.
AddressType
Address types.
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...
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.
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:41
Time tstamp
timestamp when the packet arrived at the queue
This queue implements the timeout procedure described in IEEE Std.
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:63
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:49
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.