src/devices/wifi/qos-utils.cc
author Mirko Banchi <mk.banchi@gmail.com>
Wed, 03 Feb 2010 20:34:51 +0100
changeset 5956 e9918be47f78
parent 5774 0fad665ff307
child 6331 eee2eab36748
permissions -rw-r--r--
MacLow now buffers QoS MPDUs under Block Ack
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     2
/*
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     3
 * Copyright (c) 2009 MIRKO BANCHI
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     4
 *
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     8
 *
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    13
 *
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    17
 *
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    18
 * Author: Mirko Banchi <mk.banchi@gmail.com>
5956
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    19
 * Author: Cecchi Niccolò <insa@igeek.it>
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    20
 */
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    21
#include "qos-utils.h"
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    22
#include "qos-tag.h"
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    23
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    24
namespace ns3 {
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    25
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    26
AccessClass
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    27
QosUtilsMapTidToAc (uint8_t tid)
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    28
{
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    29
  switch (tid) {
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    30
  case 0 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    31
    return AC_BE;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    32
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    33
  case 1 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    34
    return AC_BK;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    35
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    36
  case 2 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    37
    return AC_BK;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    38
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    39
  case 3 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    40
    return AC_BE;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    41
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    42
  case 4 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    43
    return AC_VI;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    44
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    45
  case 5 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    46
    return AC_VI;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    47
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    48
  case 6 :
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    49
    return AC_VO;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    50
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    51
  case 7 : 
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    52
    return AC_VO;
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    53
    break;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    54
  }
5143
8b5055542351 Removed unneded changes from wifi
Kirill Andreev <andreev@iitp.ru>
parents: 5115
diff changeset
    55
  return AC_UNDEF;
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    56
}
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    57
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    58
uint8_t
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    59
QosUtilsGetTidForPacket (Ptr<const Packet> packet)
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    60
{
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    61
  QosTag qos;
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    62
  uint8_t tid = 8;
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4404
diff changeset
    63
  if (packet->PeekPacketTag (qos))
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    64
    {
5774
0fad665ff307 fixed bug 668
Nicola Baldo <nbaldo@cttc.es>
parents: 5143
diff changeset
    65
      if (qos.GetTid () < 8)
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    66
        {
5774
0fad665ff307 fixed bug 668
Nicola Baldo <nbaldo@cttc.es>
parents: 5143
diff changeset
    67
          tid = qos.GetTid ();
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    68
        }
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    69
    }
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    70
  return tid;
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    71
}
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    72
5956
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    73
uint32_t
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    74
QosUtilsMapSeqControlToUniqueInteger (uint16_t seqControl, uint16_t endSequence)
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    75
{
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    76
  uint32_t integer = 0;
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    77
  uint16_t numberSeq = (seqControl>>4) & 0x0fff;
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    78
  integer = (4096 - (endSequence + 1) + numberSeq) % 4096;
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    79
  integer *= 16;
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    80
  integer += (seqControl & 0x000f);
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    81
  return integer; 
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    82
}
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    83
e9918be47f78 MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents: 5774
diff changeset
    84
4404
e10005ac0701 shared facility for qos support
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    85
} //namespace ns3