add support for blocking of qos packets in WifiMacQueue
This commit is contained in:
66
src/devices/wifi/qos-blocked-destinations.cc
Normal file
66
src/devices/wifi/qos-blocked-destinations.cc
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005, 2009 INRIA
|
||||
* Copyright (c) 2009 MIRKO BANCHI
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mirko Banchi <mk.banchi@gmail.com>
|
||||
*/
|
||||
#include "qos-blocked-destinations.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
QosBlockedDestinations::QosBlockedDestinations ()
|
||||
{}
|
||||
|
||||
QosBlockedDestinations::~QosBlockedDestinations ()
|
||||
{}
|
||||
|
||||
bool
|
||||
QosBlockedDestinations::IsBlocked (Mac48Address dest, uint8_t tid) const
|
||||
{
|
||||
for (BlockedPacketsCI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++)
|
||||
{
|
||||
if (i->first == dest && i->second == tid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
QosBlockedDestinations::Block (Mac48Address dest, uint8_t tid)
|
||||
{
|
||||
if (!IsBlocked (dest, tid))
|
||||
{
|
||||
m_blockedQosPackets.push_back (std::make_pair (dest, tid));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QosBlockedDestinations::Unblock (Mac48Address dest, uint8_t tid)
|
||||
{
|
||||
for (BlockedPacketsI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++)
|
||||
{
|
||||
if (i->first == dest && i->second == tid)
|
||||
{
|
||||
m_blockedQosPackets.erase (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
48
src/devices/wifi/qos-blocked-destinations.h
Normal file
48
src/devices/wifi/qos-blocked-destinations.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005, 2009 INRIA
|
||||
* Copyright (c) 2009 MIRKO BANCHI
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mirko Banchi <mk.banchi@gmail.com>
|
||||
*/
|
||||
#ifndef QOS_BLOCKED_DESTINATIONS_H
|
||||
#define QOS_BLOCKED_DESTINATIONS_H
|
||||
|
||||
#include <list>
|
||||
#include "ns3/mac48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class QosBlockedDestinations
|
||||
{
|
||||
public:
|
||||
QosBlockedDestinations ();
|
||||
~QosBlockedDestinations ();
|
||||
|
||||
void Block (Mac48Address dest, uint8_t tid);
|
||||
void Unblock (Mac48Address dest, uint8_t tid);
|
||||
bool IsBlocked (Mac48Address dest, uint8_t tid) const;
|
||||
|
||||
private:
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> > BlockedPackets;
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> >::iterator BlockedPacketsI;
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> >::const_iterator BlockedPacketsCI;
|
||||
BlockedPackets m_blockedQosPackets;
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* QOS_BLOCKED_DESTINATIONS_H */
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
#include "wifi-mac-queue.h"
|
||||
#include "qos-blocked-destinations.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -298,4 +299,44 @@ WifiMacQueue::GetNPacketsByTidAndAddress (uint8_t tid, WifiMacHeader::AddressTyp
|
||||
return nPackets;
|
||||
}
|
||||
|
||||
Ptr<const Packet>
|
||||
WifiMacQueue::DequeueFirstAvailable (WifiMacHeader *hdr, Time ×tamp,
|
||||
const QosBlockedDestinations *blockedPackets)
|
||||
{
|
||||
Cleanup ();
|
||||
Ptr<const Packet> packet = 0;
|
||||
for (PacketQueueI it = m_queue.begin (); it != m_queue.end (); it++)
|
||||
{
|
||||
if (!it->hdr.IsQosData () ||
|
||||
!blockedPackets->IsBlocked (it->hdr.GetAddr1 (), it->hdr.GetQosTid ()))
|
||||
{
|
||||
*hdr = it->hdr;
|
||||
timestamp = it->tstamp;
|
||||
packet = it->packet;
|
||||
m_queue.erase (it);
|
||||
m_size--;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
Ptr<const Packet>
|
||||
WifiMacQueue::PeekFirstAvailable (WifiMacHeader *hdr, Time ×tamp,
|
||||
const QosBlockedDestinations *blockedPackets)
|
||||
{
|
||||
Cleanup ();
|
||||
for (PacketQueueI it = m_queue.begin (); it != m_queue.end (); it++)
|
||||
{
|
||||
if (!it->hdr.IsQosData () ||
|
||||
!blockedPackets->IsBlocked (it->hdr.GetAddr1 (), it->hdr.GetQosTid ()))
|
||||
{
|
||||
*hdr = it->hdr;
|
||||
timestamp = it->tstamp;
|
||||
return it->packet;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
namespace ns3 {
|
||||
|
||||
class WifiMacParameters;
|
||||
class QosBlockedDestinations;
|
||||
|
||||
/**
|
||||
* \brief a 802.11e-specific queue.
|
||||
@@ -99,12 +100,26 @@ public:
|
||||
uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
|
||||
WifiMacHeader::AddressType type,
|
||||
Mac48Address addr);
|
||||
|
||||
/**
|
||||
* Returns first available packet for transmission. A packet could be no available
|
||||
* if it's a QoS packet with a tid and an address1 fields equal to <i>tid</i> and <i>addr</i>
|
||||
* respectively that index a pending agreement in the BlockAckManager object.
|
||||
* So that packet must not be transmitted until reception of an ADDBA response frame from station
|
||||
* addressed by <i>addr</i>. This method removes the packet from queue.
|
||||
*/
|
||||
Ptr<const Packet> DequeueFirstAvailable (WifiMacHeader *hdr,
|
||||
Time &tStamp,
|
||||
const QosBlockedDestinations *blockedPackets);
|
||||
/**
|
||||
* Returns first available packet for transmission. The packet isn't removed from queue.
|
||||
*/
|
||||
Ptr<const Packet> PeekFirstAvailable (WifiMacHeader *hdr,
|
||||
Time &tStamp,
|
||||
const QosBlockedDestinations *blockedPackets);
|
||||
void Flush (void);
|
||||
|
||||
bool IsEmpty (void);
|
||||
uint32_t GetSize (void);
|
||||
|
||||
private:
|
||||
struct Item;
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ def build(bld):
|
||||
'originator-block-ack-agreement.cc',
|
||||
'dcf.cc',
|
||||
'ctrl-headers.cc',
|
||||
'qos-blocked-destinations.cc',
|
||||
'block-ack-agreement.cc',
|
||||
'block-ack-manager.cc',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user