src/devices/wifi/wifi-mac-queue.h
author Pavel Boyko <boyko@iitp.ru>
Tue, 16 Jun 2009 17:58:16 +0400
changeset 5074 355de6af8ea9
parent 4466 8edb50eea6cb
child 5952 0588b01cd77e
permissions -rw-r--r--
merged with nsnam
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: 2524
diff changeset
     3
 * Copyright (c) 2005, 2009 INRIA
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
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: 2524
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
#ifndef WIFI_MAC_QUEUE_H
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#define WIFI_MAC_QUEUE_H
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    25
#include <list>
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <utility>
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/packet.h"
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include "ns3/nstime.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    29
#include "ns3/object.h"
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
#include "wifi-mac-header.h"
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
2508
18b690d1e74b MacParameters -> WifiMacParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
    34
class WifiMacParameters;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
2059
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    36
/**
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    37
 * \brief a 802.11e-specific queue.
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    38
 *
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    39
 * This queue implements what is needed for the 802.11e standard
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    40
 * Specifically, it refers to 802.11e/D9, section 9.9.1.6, paragraph 6.
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    41
 *
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    42
 * When a packet is received by the MAC, to be sent to the PHY, 
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    43
 * it is queued in the internal queue after being tagged by the 
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    44
 * current time.
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    45
 *
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    46
 * When a packet is dequeued, the queue checks its timestamp 
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    47
 * to verify whether or not it should be dropped. If 
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    48
 * dot11EDCATableMSDULifetime has elapsed, it is dropped.
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    49
 * Otherwise, it is returned to the caller.
d8b7b2de044e doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1924
diff changeset
    50
 */
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    51
class WifiMacQueue : public Object
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    52
{
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
public:
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    54
  static TypeId GetTypeId (void);
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
  WifiMacQueue ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  ~WifiMacQueue ();
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
  void SetMaxSize (uint32_t maxSize);
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  void SetMaxDelay (Time delay);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    60
  uint32_t GetMaxSize (void) const;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2508
diff changeset
    61
  Time GetMaxDelay (void) const;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
    63
  void Enqueue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2059
diff changeset
    64
  Ptr<const Packet> Dequeue (WifiMacHeader *hdr);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    65
  Ptr<const Packet> Peek (WifiMacHeader *hdr);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    66
  /**
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    67
   * Searchs and returns, if is present in this queue, first packet having 
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
    68
   * address indicated by <i>type</i> equals to <i>addr</i>, and tid 
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    69
   * equals to <i>tid</i>. This method removes the packet from this queue. 
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    70
   * Is typically used by ns3::EdcaTxopN in order to perform correct MSDU 
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    71
   * aggregation (A-MSDU).
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    72
   */
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    73
  Ptr<const Packet> DequeueByTidAndAddress (WifiMacHeader *hdr,
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    74
                                            uint8_t tid, 
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
    75
                                            WifiMacHeader::AddressType type,
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    76
                                            Mac48Address addr);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    77
  /**
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    78
   * Searchs and returns, if is present in this queue, first packet having
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
    79
   * address indicated by <i>type</i> equals to <i>addr</i>, and tid 
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    80
   * equals to <i>tid</i>. This method doesn't remove the packet from this queue.
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    81
   * Is typically used by ns3::EdcaTxopN in order to perform correct MSDU
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    82
   * aggregation (A-MSDU).
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    83
   */
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    84
  Ptr<const Packet> PeekByTidAndAddress (WifiMacHeader *hdr,
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    85
                                         uint8_t tid,
4403
54141b0e8f9f rename 'index' variable to 'type'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4402
diff changeset
    86
                                         WifiMacHeader::AddressType type,
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    87
                                         Mac48Address addr);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    88
  /**
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    89
   * If exists, removes <i>packet</i> from queue and returns true. Otherwise it
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    90
   * takes no effects and return false. Deletion of the packet is
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    91
   * performed in linear time (O(n)).  
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    92
   */
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    93
  bool Remove (Ptr<const Packet> packet);
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
    94
  
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  void Flush (void);
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
  bool IsEmpty (void);
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
  uint32_t GetSize (void);
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
private:
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   101
  struct Item;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   102
  
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   103
  typedef std::list<struct Item> PacketQueue;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   104
  typedef std::list<struct Item>::reverse_iterator PacketQueueRI;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   105
  typedef std::list<struct Item>::iterator PacketQueueI;
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   106
  
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
  void Cleanup (void);
4443
b6f14f95c8af mismatching type
Mirko Banchi <mk.banchi@gmail.com>
parents: 4403
diff changeset
   108
  Mac48Address GetAddressForPacket (enum WifiMacHeader::AddressType type, PacketQueueI);
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   109
  
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
  struct Item {
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2059
diff changeset
   111
    Item (Ptr<const Packet> packet, 
4466
8edb50eea6cb const cleanup
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4443
diff changeset
   112
          const WifiMacHeader &hdr, 
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
          Time tstamp);
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2059
diff changeset
   114
    Ptr<const Packet> packet;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
    WifiMacHeader hdr;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
    Time tstamp;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
  };
4402
f6243535620f new methods to look in the packet queue
Mirko Banchi <mk.banchi@gmail.com>
parents: 2524
diff changeset
   118
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  PacketQueue m_queue;
2508
18b690d1e74b MacParameters -> WifiMacParameters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
   120
  WifiMacParameters *m_parameters;
1924
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
  uint32_t m_size;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  uint32_t m_maxSize;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
  Time m_maxDelay;
0471fb5a3df8 add WifiMacQueue to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
};
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
} // namespace ns3
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
#endif /* WIFI_MAC_QUEUE_H */