A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
wifi-mac-queue.h
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 "ns3/cognitive-packet-tags.h"
31 #include "wifi-mac-header.h"
32 
33 namespace ns3 {
34 
35 class WifiMacParameters;
36 class QosBlockedDestinations;
37 
53 class WifiMacQueue : public Object
54 {
55 public:
56  static TypeId GetTypeId (void);
57  WifiMacQueue ();
58  ~WifiMacQueue ();
59 
60  void SetMaxSize (uint32_t maxSize);
61  void SetMaxDelay (Time delay);
62  uint32_t GetMaxSize (void) const;
63  Time GetMaxDelay (void) const;
64 
65  void Enqueue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
66  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
67  Ptr<const Packet> Dequeue (WifiMacHeader *hdr);
68  Ptr<const Packet> DequeueForChannel (WifiMacHeader *hdr, uint16_t channel);
69  Ptr<const Packet> Peek (WifiMacHeader *hdr);
78  uint8_t tid,
79  WifiMacHeader::AddressType type,
80  Mac48Address addr);
89  uint8_t tid,
90  WifiMacHeader::AddressType type,
91  Mac48Address addr);
97  bool Remove (Ptr<const Packet> packet);
102  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
103  WifiMacHeader::AddressType type,
104  Mac48Address addr);
113  Time &tStamp,
114  const QosBlockedDestinations *blockedPackets);
119  Time &tStamp,
120  const QosBlockedDestinations *blockedPackets);
121  void Flush (void);
122 
123  bool IsEmpty (void);
124  bool IsEmpty (uint16_t channel);
125  uint32_t GetSize (void);
126 private:
127  struct Item;
128 
129  typedef std::list<struct Item> PacketQueue;
130  typedef std::list<struct Item>::reverse_iterator PacketQueueRI;
131  typedef std::list<struct Item>::iterator PacketQueueI;
132 
133  void Cleanup (void);
134  Mac48Address GetAddressForPacket (enum WifiMacHeader::AddressType type, PacketQueueI);
135 
136  struct Item
137  {
138  Item (Ptr<const Packet> packet,
139  const WifiMacHeader &hdr,
140  Time tstamp);
141  Item (Ptr<const Packet> packet,
142  const WifiMacHeader &hdr,
143  Time tstamp, uint16_t channel);
144  Ptr<const Packet> packet;
145  WifiMacHeader hdr;
146  Time tstamp;
147  uint16_t channel;
148  };
149 
150  PacketQueue m_queue;
151  WifiMacParameters *m_parameters;
152  uint32_t m_size;
153  uint32_t m_maxSize;
154  Time m_maxDelay;
155 };
156 
157 } // namespace ns3
158 
159 #endif /* WIFI_MAC_QUEUE_H */
keep track of time unit.
Definition: nstime.h:149
Ptr< const Packet > PeekByTidAndAddress(WifiMacHeader *hdr, uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr)
uint32_t GetNPacketsByTidAndAddress(uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr)
bool Remove(Ptr< const Packet > packet)
Ptr< const Packet > DequeueFirstAvailable(WifiMacHeader *hdr, Time &tStamp, const QosBlockedDestinations *blockedPackets)
Ptr< const Packet > DequeueByTidAndAddress(WifiMacHeader *hdr, uint8_t tid, WifiMacHeader::AddressType type, Mac48Address addr)
an EUI-48 address
Definition: mac48-address.h:41
Ptr< const Packet > PeekFirstAvailable(WifiMacHeader *hdr, Time &tStamp, const QosBlockedDestinations *blockedPackets)
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:44