00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2005 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef WIFI_MAC_QUEUE_H 00021 #define WIFI_MAC_QUEUE_H 00022 00023 #include <deque> 00024 #include <utility> 00025 #include "ns3/packet.h" 00026 #include "ns3/nstime.h" 00027 #include "ns3/object.h" 00028 #include "wifi-mac-header.h" 00029 00030 namespace ns3 { 00031 00032 class WifiMacParameters; 00033 00034 /** 00035 * \brief a 802.11e-specific queue. 00036 * 00037 * This queue implements what is needed for the 802.11e standard 00038 * Specifically, it refers to 802.11e/D9, section 9.9.1.6, paragraph 6. 00039 * 00040 * When a packet is received by the MAC, to be sent to the PHY, 00041 * it is queued in the internal queue after being tagged by the 00042 * current time. 00043 * 00044 * When a packet is dequeued, the queue checks its timestamp 00045 * to verify whether or not it should be dropped. If 00046 * dot11EDCATableMSDULifetime has elapsed, it is dropped. 00047 * Otherwise, it is returned to the caller. 00048 */ 00049 class WifiMacQueue : public Object 00050 { 00051 public: 00052 static TypeId GetTypeId (void); 00053 WifiMacQueue (); 00054 ~WifiMacQueue (); 00055 00056 void SetMaxSize (uint32_t maxSize); 00057 void SetMaxDelay (Time delay); 00058 uint32_t GetMaxSize (void) const; 00059 Time GetMaxDelay (void) const; 00060 00061 void Enqueue (Ptr<const Packet> packet, WifiMacHeader const &hdr); 00062 Ptr<const Packet> Dequeue (WifiMacHeader *hdr); 00063 00064 void Flush (void); 00065 00066 bool IsEmpty (void); 00067 uint32_t GetSize (void); 00068 00069 private: 00070 void Cleanup (void); 00071 struct Item { 00072 Item (Ptr<const Packet> packet, 00073 WifiMacHeader const&hdr, 00074 Time tstamp); 00075 Ptr<const Packet> packet; 00076 WifiMacHeader hdr; 00077 Time tstamp; 00078 }; 00079 typedef std::deque<struct Item> PacketQueue; 00080 typedef std::deque<struct Item>::reverse_iterator PacketQueueRI; 00081 typedef std::deque<struct Item>::iterator PacketQueueI; 00082 PacketQueue m_queue; 00083 WifiMacParameters *m_parameters; 00084 uint32_t m_size; 00085 uint32_t m_maxSize; 00086 Time m_maxDelay; 00087 }; 00088 00089 } // namespace ns3 00090 00091 00092 #endif /* WIFI_MAC_QUEUE_H */