src/devices/wifi/wifi-mac-queue.cc
author Mirko Banchi <mk.banchi@gmail.com>
Wed, 03 Feb 2010 20:34:52 +0100
changeset 5959 66bc2d3da45f
parent 5952 0588b01cd77e
child 5962 65fbfd43d8e7
permissions -rw-r--r--
add WifiMacQueue::GetNPacketsByTidAndAddress method
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"
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
using namespace std;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
4102
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    32
NS_OBJECT_ENSURE_REGISTERED (WifiMacQueue);
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    33
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
    34
WifiMacQueue::Item::Item (Ptr<const Packet> packet, 
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
    35
                          const WifiMacHeader &hdr, 
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
    36
                          Time tstamp)
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
  : packet (packet), hdr (hdr), tstamp (tstamp)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
{}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    40
TypeId 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    41
WifiMacQueue::GetTypeId (void)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    42
{
4102
3a5b1ed17edc Fix WifiMacQueue typeid registration
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2965
diff changeset
    43
  static TypeId tid = TypeId ("ns3::WifiMacQueue")
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    44
    .SetParent<Object> ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    45
    .AddConstructor<WifiMacQueue> ()
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    46
    .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
    47
                   UintegerValue (400),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    48
                   MakeUintegerAccessor (&WifiMacQueue::m_maxSize),
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    49
                   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
    50
    .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
    51
                   TimeValue (Seconds (10.0)),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    52
                   MakeTimeAccessor (&WifiMacQueue::m_maxDelay),
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    53
                   MakeTimeChecker ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    54
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    55
  return tid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    56
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    57
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
WifiMacQueue::WifiMacQueue ()
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  : m_size (0)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
{}
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
WifiMacQueue::~WifiMacQueue ()
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
  Flush ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
}
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
void 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
WifiMacQueue::SetMaxSize (uint32_t maxSize)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
  m_maxSize = maxSize;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    72
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    73
void
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
WifiMacQueue::SetMaxDelay (Time delay)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
  m_maxDelay = delay;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    78
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    79
uint32_t 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    80
WifiMacQueue::GetMaxSize (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    81
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    82
  return m_maxSize;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    83
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
    84
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    85
Time 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    86
WifiMacQueue::GetMaxDelay (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    87
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    88
  return m_maxDelay;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    89
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    90
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
void 
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
    92
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
    93
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  if (m_size == m_maxSize) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
      return;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
    }
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
  Time now = Simulator::Now ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
  m_queue.push_back (Item (packet, hdr, now));
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
  m_size++;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
}
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   103
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
void
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
WifiMacQueue::Cleanup (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
  if (m_queue.empty ()) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
      return;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
    }
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
  Time now = Simulator::Now ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  uint32_t n = 0;
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   114
  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
   115
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
      if (i->tstamp + m_maxDelay > now) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
        {
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   118
          i++;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
        }
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   120
      else
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   121
        {
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   122
          i = m_queue.erase (i);
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   123
          n++;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   124
        }
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
    }
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  m_size -= n;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   129
Ptr<const Packet>
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   130
WifiMacQueue::Dequeue (WifiMacHeader *hdr)
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  if (!m_queue.empty ()) 
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
    {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
      Item i = m_queue.front ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
      m_queue.pop_front ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
      m_size--;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
      *hdr = i.hdr;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
      return i.packet;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
    }
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1977
diff changeset
   141
  return 0;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   144
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   145
WifiMacQueue::Peek (WifiMacHeader *hdr)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   146
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   147
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   148
  if (!m_queue.empty ()) 
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   149
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   150
      Item i = m_queue.front ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   151
      *hdr = i.hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   152
      return i.packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   153
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   154
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   155
}
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
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   158
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
   159
                                      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
   160
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   161
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   162
  Ptr<const Packet> packet = 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   163
  if (!m_queue.empty ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   164
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   165
      PacketQueueI it;
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   166
      NS_ASSERT (type <= 4);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   167
      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
   168
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   169
          if (it->hdr.IsQosData ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   170
            {
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   171
              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
   172
                  it->hdr.GetQosTid () == tid)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   173
                {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   174
                  packet = it->packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   175
                  *hdr = it->hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   176
                  m_queue.erase (it);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   177
                  m_size--;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   178
                  break;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   179
                }
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
  return packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   184
}
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
Ptr<const Packet>
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   187
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
   188
                                   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
   189
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   190
  Cleanup ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   191
  if (!m_queue.empty ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   192
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   193
      PacketQueueI it;
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   194
      NS_ASSERT (type <= 4);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   195
      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
   196
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   197
          if (it->hdr.IsQosData ())
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   198
            {
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   199
              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
   200
                  it->hdr.GetQosTid () == tid)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   201
                {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   202
                  *hdr = it->hdr;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   203
                  return it->packet;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   204
                }
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
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   209
}
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
bool
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
WifiMacQueue::IsEmpty (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
  Cleanup ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
  return m_queue.empty ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
}
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
uint32_t
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
WifiMacQueue::GetSize (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
  return m_size;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
}
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
void
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
WifiMacQueue::Flush (void)
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
{
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
  m_queue.erase (m_queue.begin (), m_queue.end ());
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
  m_size = 0;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
}
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   231
Mac48Address
4443
b6f14f95c8af mismatching type
Mirko Banchi <mk.banchi@gmail.com>
parents: 4403
diff changeset
   232
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
   233
{
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   234
  if (type == WifiMacHeader::ADDR1)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   235
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   236
      return it->hdr.GetAddr1 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   237
    }
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   238
  if (type == WifiMacHeader::ADDR2)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   239
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   240
      return it->hdr.GetAddr2 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   241
    }
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
   242
  if (type == WifiMacHeader::ADDR3)
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   243
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   244
      return it->hdr.GetAddr3 ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   245
    }
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   246
  return 0;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   247
}
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
bool
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   250
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
   251
{
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   252
  PacketQueueI it = m_queue.begin ();
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   253
  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
   254
    {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   255
      if (it->packet == packet)
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   256
        {
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   257
          m_queue.erase (it);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   258
          return true;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   259
        }
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
  return false;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   262
}
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 4102
diff changeset
   263
5952
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   264
void
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   265
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
   266
{
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   267
  Cleanup ();
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   268
  if (m_size == m_maxSize)
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   269
    {
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   270
      return;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   271
    }
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   272
  Time now = Simulator::Now ();
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   273
  m_queue.push_front (Item (packet, hdr, now));
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   274
  m_size++;
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   275
}
0588b01cd77e WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents: 4466
diff changeset
   276
5959
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   277
uint32_t
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   278
WifiMacQueue::GetNPacketsByTidAndAddress (uint8_t tid, WifiMacHeader::AddressType type,
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   279
                                          Mac48Address addr)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   280
{
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   281
  Cleanup ();
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   282
  uint32_t nPackets = 0;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   283
  if (!m_queue.empty ())
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   284
    {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   285
      PacketQueueI it;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   286
      NS_ASSERT (type <= 4);
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   287
      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
   288
        {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   289
          if (GetAddressForPacket (type, it) == addr)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   290
            {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   291
              if (it->hdr.IsQosData () && it->hdr.GetQosTid () == tid)
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   292
                {
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   293
                  nPackets++;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   294
                }
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
  return nPackets;
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   299
}
66bc2d3da45f add WifiMacQueue::GetNPacketsByTidAndAddress method
Mirko Banchi <mk.banchi@gmail.com>
parents: 5952
diff changeset
   300
1977
4303409f3d8e remove uneeded trailing ';'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
   301
} // namespace ns3