src/devices/wifi/wifi-mac-queue.cc
author Mirko Banchi <mk.banchi@gmail.com>
Mon, 08 Feb 2010 22:35:08 +0100
changeset 5976 dba5c9b69c3b
parent 5962 65fbfd43d8e7
child 6224 8386567abea1
permissions -rw-r--r--
use NS_LOG_APPEND_CONTEXT instead of MY_DEBUG macro
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
     3
 * Copyright (c) 2005, 2009 INRIA
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
     4
 * Copyright (c) 2009 MIRKO BANCHI
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    20
 * Author: Mirko Banchi <mk.banchi@gmail.com>
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
 */
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/simulator.h"
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "ns3/packet.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    24
#include "ns3/uinteger.h"
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include "wifi-mac-queue.h"
5962
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
    27
#include "qos-blocked-destinations.h"
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
using namespace std;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
namespace ns3 {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
4102
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    33
NS_OBJECT_ENSURE_REGISTERED (WifiMacQueue);
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    34
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
    35
WifiMacQueue::Item::Item (Ptr<const Packet> packet, 
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
    36
                          const WifiMacHeader &hdr, 
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
    37
                          Time tstamp)
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
  : packet (packet), hdr (hdr), tstamp (tstamp)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
{}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    41
TypeId 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    42
WifiMacQueue::GetTypeId (void)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    43
{
4102
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    44
  static TypeId tid = TypeId ("ns3::WifiMacQueue")
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    45
    .SetParent<Object> ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    46
    .AddConstructor<WifiMacQueue> ()
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    47
    .AddAttribute ("MaxPacketNumber", "If a packet arrives when there are already this number of packets, it is dropped.",
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    48
                   UintegerValue (400),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    49
                   MakeUintegerAccessor (&WifiMacQueue::m_maxSize),
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    50
                   MakeUintegerChecker<uint32_t> ())
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    51
    .AddAttribute ("MaxDelay", "If a packet stays longer than this delay in the queue, it is dropped.",
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    52
                   TimeValue (Seconds (10.0)),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    53
                   MakeTimeAccessor (&WifiMacQueue::m_maxDelay),
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    54
                   MakeTimeChecker ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    55
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    56
  return tid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    57
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    58
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
WifiMacQueue::WifiMacQueue ()
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
  : m_size (0)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
{}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
WifiMacQueue::~WifiMacQueue ()
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  Flush ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
void 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
WifiMacQueue::SetMaxSize (uint32_t maxSize)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  m_maxSize = maxSize;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    73
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    74
void
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
WifiMacQueue::SetMaxDelay (Time delay)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  m_maxDelay = delay;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    79
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    80
uint32_t 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    81
WifiMacQueue::GetMaxSize (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    82
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    83
  return m_maxSize;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    84
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    85
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    86
Time 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    87
WifiMacQueue::GetMaxDelay (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    88
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    89
  return m_maxDelay;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    90
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    91
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
void 
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
    93
WifiMacQueue::Enqueue (Ptr<const Packet> packet, const WifiMacHeader &hdr)
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  if (m_size == m_maxSize) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
      return;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
    }
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
  Time now = Simulator::Now ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
  m_queue.push_back (Item (packet, hdr, now));
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  m_size++;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   104
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
void
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
WifiMacQueue::Cleanup (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
  if (m_queue.empty ()) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
      return;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
    }
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  Time now = Simulator::Now ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
  uint32_t n = 0;
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   115
  for (PacketQueueI i = m_queue.begin (); i != m_queue.end ();) 
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
      if (i->tstamp + m_maxDelay > now) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
        {
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   119
          i++;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
        }
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   121
      else
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   122
        {
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   123
          i = m_queue.erase (i);
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   124
          n++;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   125
        }
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
    }
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  m_size -= n;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   130
Ptr<const Packet>
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   131
WifiMacQueue::Dequeue (WifiMacHeader *hdr)
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
  if (!m_queue.empty ()) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
      Item i = m_queue.front ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
      m_queue.pop_front ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
      m_size--;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
      *hdr = i.hdr;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
      return i.packet;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
    }
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   142
  return 0;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   145
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   146
WifiMacQueue::Peek (WifiMacHeader *hdr)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   147
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   148
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   149
  if (!m_queue.empty ()) 
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   150
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   151
      Item i = m_queue.front ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   152
      *hdr = i.hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   153
      return i.packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   154
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   155
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   156
}
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   157
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   158
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   159
WifiMacQueue::DequeueByTidAndAddress (WifiMacHeader *hdr, uint8_t tid, 
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   160
                                      WifiMacHeader::AddressType type, Mac48Address dest)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   161
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   162
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   163
  Ptr<const Packet> packet = 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   164
  if (!m_queue.empty ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   165
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   166
      PacketQueueI it;
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   167
      NS_ASSERT (type <= 4);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   168
      for (it = m_queue.begin (); it != m_queue.end (); ++it)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   169
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   170
          if (it->hdr.IsQosData ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   171
            {
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   172
              if (GetAddressForPacket (type, it) == dest &&
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   173
                  it->hdr.GetQosTid () == tid)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   174
                {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   175
                  packet = it->packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   176
                  *hdr = it->hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   177
                  m_queue.erase (it);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   178
                  m_size--;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   179
                  break;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   180
                }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   181
            }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   182
        }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   183
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   184
  return packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   185
}
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   186
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   187
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   188
WifiMacQueue::PeekByTidAndAddress (WifiMacHeader *hdr, uint8_t tid, 
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   189
                                   WifiMacHeader::AddressType type, Mac48Address dest)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   190
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   191
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   192
  if (!m_queue.empty ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   193
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   194
      PacketQueueI it;
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   195
      NS_ASSERT (type <= 4);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   196
      for (it = m_queue.begin (); it != m_queue.end (); ++it)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   197
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   198
          if (it->hdr.IsQosData ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   199
            {
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   200
              if (GetAddressForPacket (type, it) == dest &&
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   201
                  it->hdr.GetQosTid () == tid)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   202
                {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   203
                  *hdr = it->hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   204
                  return it->packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   205
                }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   206
            }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   207
        }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   208
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   209
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   210
}
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
bool
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
WifiMacQueue::IsEmpty (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
  return m_queue.empty ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
uint32_t
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
WifiMacQueue::GetSize (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
  return m_size;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
void
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
WifiMacQueue::Flush (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
  m_queue.erase (m_queue.begin (), m_queue.end ());
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
  m_size = 0;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   232
Mac48Address
4443
b6f14f95c8af mismatching type
Mirko Banchi <mk.banchi@gmail.com>
parents: 4403
diff changeset
   233
WifiMacQueue::GetAddressForPacket (enum WifiMacHeader::AddressType type, PacketQueueI it)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   234
{
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   235
  if (type == WifiMacHeader::ADDR1)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   236
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   237
      return it->hdr.GetAddr1 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   238
    }
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   239
  if (type == WifiMacHeader::ADDR2)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   240
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   241
      return it->hdr.GetAddr2 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   242
    }
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   243
  if (type == WifiMacHeader::ADDR3)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   244
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   245
      return it->hdr.GetAddr3 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   246
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   247
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   248
}
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   249
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   250
bool
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   251
WifiMacQueue::Remove (Ptr<const Packet> packet)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   252
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   253
  PacketQueueI it = m_queue.begin ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   254
  for (; it != m_queue.end (); it++)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   255
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   256
      if (it->packet == packet)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   257
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   258
          m_queue.erase (it);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   259
          return true;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   260
        }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   261
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   262
  return false;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   263
}
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   264
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   265
void
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   266
WifiMacQueue::PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr)
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   267
{
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   268
  Cleanup ();
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   269
  if (m_size == m_maxSize)
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   270
    {
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   271
      return;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   272
    }
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   273
  Time now = Simulator::Now ();
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   274
  m_queue.push_front (Item (packet, hdr, now));
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   275
  m_size++;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   276
}
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   277
5959
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   278
uint32_t
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   279
WifiMacQueue::GetNPacketsByTidAndAddress (uint8_t tid, WifiMacHeader::AddressType type,
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   280
                                          Mac48Address addr)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   281
{
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   282
  Cleanup ();
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   283
  uint32_t nPackets = 0;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   284
  if (!m_queue.empty ())
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   285
    {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   286
      PacketQueueI it;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   287
      NS_ASSERT (type <= 4);
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   288
      for (it = m_queue.begin (); it != m_queue.end (); it++)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   289
        {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   290
          if (GetAddressForPacket (type, it) == addr)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   291
            {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   292
              if (it->hdr.IsQosData () && it->hdr.GetQosTid () == tid)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   293
                {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   294
                  nPackets++;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   295
                }
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   296
            }
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   297
        }
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   298
    }
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   299
  return nPackets;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   300
}
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   301
5962
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   302
Ptr<const Packet>
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   303
WifiMacQueue::DequeueFirstAvailable (WifiMacHeader *hdr, Time &timestamp,
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   304
                                     const QosBlockedDestinations *blockedPackets)
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   305
{
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   306
  Cleanup ();
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   307
  Ptr<const Packet> packet = 0;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   308
  for (PacketQueueI it = m_queue.begin (); it != m_queue.end (); it++)
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   309
    {
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   310
      if (!it->hdr.IsQosData () ||
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   311
          !blockedPackets->IsBlocked (it->hdr.GetAddr1 (), it->hdr.GetQosTid ()))
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   312
        {
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   313
          *hdr = it->hdr;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   314
          timestamp = it->tstamp;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   315
          packet = it->packet;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   316
          m_queue.erase (it);
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   317
          m_size--;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   318
          return packet;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   319
        }
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   320
    }
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   321
  return packet;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   322
}
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   323
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   324
Ptr<const Packet>
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   325
WifiMacQueue::PeekFirstAvailable (WifiMacHeader *hdr, Time &timestamp,
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   326
                                  const QosBlockedDestinations *blockedPackets)
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   327
{
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   328
  Cleanup ();
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   329
  for (PacketQueueI it = m_queue.begin (); it != m_queue.end (); it++)
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   330
    {
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   331
      if (!it->hdr.IsQosData () ||
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   332
          !blockedPackets->IsBlocked (it->hdr.GetAddr1 (), it->hdr.GetQosTid ()))
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   333
        {
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   334
          *hdr = it->hdr;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   335
          timestamp = it->tstamp;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   336
          return it->packet;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   337
        }
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   338
    }
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   339
  return 0;
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   340
}
65fbfd43d8e7 add support for blocking of qos packets in WifiMacQueue
Mirko Banchi <mk.banchi@gmail.com>
parents: 5959
diff changeset
   341
1977
4303409f3d8e remove uneeded trailing ';'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
   342
} // namespace ns3