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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef WIFI_MAC_QUEUE_H
24 #define WIFI_MAC_QUEUE_H
25 
26 #include <list>
27 #include <utility>
28 #include "ns3/packet.h"
29 #include "ns3/nstime.h"
30 #include "ns3/object.h"
31 #include "wifi-mac-header.h"
32 
33 namespace ns3 {
34 class QosBlockedDestinations;
35 
51 class WifiMacQueue : public Object
52 {
53 public:
54  static TypeId GetTypeId (void);
55  WifiMacQueue ();
56  ~WifiMacQueue ();
57 
59  {
62  };
63 
69  void SetMaxSize (uint32_t maxSize);
75  void SetMaxDelay (Time delay);
81  uint32_t GetMaxSize (void) const;
87  Time GetMaxDelay (void) const;
88 
95  void Enqueue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
102  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
134  uint8_t tid,
136  Mac48Address addr);
153  uint8_t tid,
155  Mac48Address addr,
156  Time *timestamp);
166  bool Remove (Ptr<const Packet> packet);
177  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
179  Mac48Address addr);
194  Time &tStamp,
195  const QosBlockedDestinations *blockedPackets);
206  Time &tStamp,
207  const QosBlockedDestinations *blockedPackets);
211  void Flush (void);
212 
218  bool IsEmpty (void);
224  uint32_t GetSize (void);
225 
226 
227 protected:
231  virtual void Cleanup (void);
232 
237  struct Item
238  {
247  const WifiMacHeader &hdr,
248  Time tstamp);
252  };
253 
257  typedef std::list<struct Item> PacketQueue;
261  typedef std::list<struct Item>::reverse_iterator PacketQueueRI;
265  typedef std::list<struct Item>::iterator PacketQueueI;
274  Mac48Address GetAddressForPacket (enum WifiMacHeader::AddressType type, PacketQueueI it);
275 
276  PacketQueue m_queue;
277  uint32_t m_size;
278  uint32_t m_maxSize;
281 };
282 
283 } //namespace ns3
284 
285 #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).
enum DropPolicy m_dropPolicy
Drop behavior of queue.
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:58
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.