From e6b1539f7bcbbe60fc2f20c1555b86bf3eeddb2e Mon Sep 17 00:00:00 2001 From: Mirko Banchi Date: Wed, 3 Feb 2010 20:34:49 +0100 Subject: [PATCH] WifiMacQueue now supports head pushing --- src/devices/wifi/edca-txop-n.cc | 12 ++++++++++++ src/devices/wifi/edca-txop-n.h | 1 + src/devices/wifi/wifi-mac-queue.cc | 26 ++++++++++++++++++++------ src/devices/wifi/wifi-mac-queue.h | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/devices/wifi/edca-txop-n.cc b/src/devices/wifi/edca-txop-n.cc index 68b9f8db0..0a773dd10 100644 --- a/src/devices/wifi/edca-txop-n.cc +++ b/src/devices/wifi/edca-txop-n.cc @@ -687,4 +687,16 @@ EdcaTxopN::SetMsduAggregator (Ptr aggr) m_aggregator = aggr; } +void +EdcaTxopN::PushFront (Ptr packet, const WifiMacHeader &hdr) +{ + NS_LOG_FUNCTION (this << packet << &hdr); + WifiMacTrailer fcs; + uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize (); + WifiRemoteStation *station = GetStation (hdr.GetAddr1 ()); + station->PrepareForQueue (packet, fullPacketSize); + m_queue->PushFront (packet, hdr); + StartAccessIfNeeded (); +} + } //namespace ns3 diff --git a/src/devices/wifi/edca-txop-n.h b/src/devices/wifi/edca-txop-n.h index 298eb2700..a52d8fe85 100644 --- a/src/devices/wifi/edca-txop-n.h +++ b/src/devices/wifi/edca-txop-n.h @@ -130,6 +130,7 @@ public: void Queue (Ptr packet, const WifiMacHeader &hdr); void SetMsduAggregator (Ptr aggr); + void PushFront (Ptr packet, const WifiMacHeader &hdr); private: /** diff --git a/src/devices/wifi/wifi-mac-queue.cc b/src/devices/wifi/wifi-mac-queue.cc index 731e17398..7c39895b8 100644 --- a/src/devices/wifi/wifi-mac-queue.cc +++ b/src/devices/wifi/wifi-mac-queue.cc @@ -111,18 +111,19 @@ WifiMacQueue::Cleanup (void) Time now = Simulator::Now (); uint32_t n = 0; - PacketQueueI end = m_queue.begin (); - for (PacketQueueI i = m_queue.begin (); i != m_queue.end (); i++) + for (PacketQueueI i = m_queue.begin (); i != m_queue.end ();) { if (i->tstamp + m_maxDelay > now) { - end = i; - break; + i++; + } + else + { + i = m_queue.erase (i); + n++; } - n++; } m_size -= n; - m_queue.erase (m_queue.begin (), end); } Ptr @@ -260,4 +261,17 @@ WifiMacQueue::Remove (Ptr packet) return false; } +void +WifiMacQueue::PushFront (Ptr packet, const WifiMacHeader &hdr) +{ + Cleanup (); + if (m_size == m_maxSize) + { + return; + } + Time now = Simulator::Now (); + m_queue.push_front (Item (packet, hdr, now)); + m_size++; +} + } // namespace ns3 diff --git a/src/devices/wifi/wifi-mac-queue.h b/src/devices/wifi/wifi-mac-queue.h index 10b3c1eeb..944abec9d 100644 --- a/src/devices/wifi/wifi-mac-queue.h +++ b/src/devices/wifi/wifi-mac-queue.h @@ -61,6 +61,7 @@ public: Time GetMaxDelay (void) const; void Enqueue (Ptr packet, const WifiMacHeader &hdr); + void PushFront (Ptr packet, const WifiMacHeader &hdr); Ptr Dequeue (WifiMacHeader *hdr); Ptr Peek (WifiMacHeader *hdr); /**