src/devices/wifi/block-ack-test-suite.cc
author Mitch Watrous <watrous@u.washington.edu>
Mon, 17 Jan 2011 12:53:20 -0800
changeset 6775 0783f42a364b
parent 6774 034f362af24d
permissions -rw-r--r--
Make test cases not return bool valuesMake all TestSuite instances be static
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     2
/*
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
     3
 * Copyright (c) 2009, 2010 MIRKO BANCHI
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     4
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     8
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    13
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    17
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    18
 * Author: Mirko Banchi <mk.banchi@gmail.com>
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    19
 */
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    20
#include "ns3/test.h"
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    21
#include "ns3/log.h"
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    22
#include "qos-utils.h"
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
    23
#include "ctrl-headers.h"
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    24
#include <list>
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    25
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    26
using namespace ns3;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    27
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("BlockAckTest");
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    29
/**
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    30
 * This simple test verifies the correctness of buffering for packets received
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    31
 * under block ack. In order to completely understand this example is important to cite
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    32
 * section 9.10.3 in IEEE802.11 standard:
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    33
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    34
 * "[...] The sequence number space is considered divided into two parts, one of which
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    35
 * is “old” and one of which is “new” by means of a boundary created by adding half the
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    36
 * sequence number range to the current start of receive window (modulo 2^12)."
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    37
 */
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    38
//-------------------------------------------------------------------------------------
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    39
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    40
/* ----- = old packets
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    41
 * +++++ = new packets
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    42
 *  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    43
 *  CASE A: startSeq < endSeq  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    44
 *                        -  -   +
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    45
 *  initial buffer state: 0 16 56000
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    46
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    47
 * 
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    48
 *    0                            4095
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    49
 *    |------|++++++++++++++++|-----|
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    50
 *           ^                ^
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    51
 *           | startSeq       | endSeq = 4000
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    52
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    53
 *  first received packet's sequence control = 64016 (seqNum = 4001, fragNum = 0) -
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    54
 *  second received packet's sequence control = 63984 (seqNum = 3999, fragNum = 0) +
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    55
 *  4001 is older seq number so this packet should be inserted at the buffer's begin.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    56
 *  3999 is previous element of older of new packets: it should be inserted at the end of buffer.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    57
 *  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    58
 *  expected buffer state: 64016 0 16 56000 63984
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    59
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    60
 */
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    61
class PacketBufferingCaseA : public TestCase
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    62
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    63
public:
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    64
  PacketBufferingCaseA ();
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    65
  virtual ~PacketBufferingCaseA ();
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    66
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
    67
  virtual void DoRun (void);
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    68
  std::list<uint16_t> m_expectedBuffer;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    69
};
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    70
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    71
PacketBufferingCaseA::PacketBufferingCaseA ()
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    72
  : TestCase ("Check correct order of buffering when startSequence < endSeq")
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    73
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    74
  m_expectedBuffer.push_back (64016);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    75
  m_expectedBuffer.push_back (0);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    76
  m_expectedBuffer.push_back (16);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    77
  m_expectedBuffer.push_back (56000);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    78
  m_expectedBuffer.push_back (63984);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    79
}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    80
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    81
PacketBufferingCaseA::~PacketBufferingCaseA ()
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    82
{}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    83
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
    84
void
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    85
PacketBufferingCaseA::DoRun (void)
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    86
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    87
  std::list<uint16_t> m_buffer;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    88
  std::list<uint16_t>::iterator i,j;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    89
  m_buffer.push_back (0);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    90
  m_buffer.push_back (16);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    91
  m_buffer.push_back (56000);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    92
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    93
  uint16_t endSeq = 4000;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    94
  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    95
  uint16_t receivedSeq = 4001 * 16;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    96
  uint32_t mappedSeq = QosUtilsMapSeqControlToUniqueInteger (receivedSeq, endSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    97
  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    98
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
    99
      m_buffer.insert (i, receivedSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   100
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   101
  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   102
  receivedSeq = 3999 * 16;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   103
  mappedSeq = QosUtilsMapSeqControlToUniqueInteger (receivedSeq, endSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   104
  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   105
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   106
      m_buffer.insert (i, receivedSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   107
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   108
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   109
  for (i = m_buffer.begin (), j = m_expectedBuffer.begin (); i != m_buffer.end (); i++, j++)
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   110
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   111
      NS_TEST_EXPECT_MSG_EQ (*i, *j, "error in buffer order");
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   112
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   113
}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   114
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   115
/* ----- = old packets
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   116
 * +++++ = new packets
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   117
 *  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   118
 *  CASE B: startSeq > endSeq
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   119
 *                         -    +    +
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   120
 *  initial buffer state: 256 64000 16
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   121
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   122
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   123
 *    0                            4095
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   124
 *    |++++++|----------------|++++++|
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   125
 *           ^                ^
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   126
 *           | endSeq = 10    | startSeq
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   127
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   128
 *  first received packet's sequence control = 240 (seqNum = 15, fragNum = 0)  -
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   129
 *  second received packet's sequence control = 241 (seqNum = 15, fragNum = 1) -
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   130
 *  third received packet's sequence control = 64800 (seqNum = 4050, fragNum = 0) +
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   131
 *  240 is an old packet should be inserted at the buffer's begin.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   132
 *  241 is an old packet: second segment of the above packet.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   133
 *  4050 is a new packet: it should be inserted between 64000 and 16.
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   134
 *  
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   135
 *  expected buffer state: 240 241 256 64000 64800 16
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   136
 *
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   137
 */
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   138
class PacketBufferingCaseB : public TestCase
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   139
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   140
public:
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   141
  PacketBufferingCaseB ();
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   142
  virtual ~PacketBufferingCaseB ();
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   143
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
   144
  virtual void DoRun (void);
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   145
  std::list<uint16_t> m_expectedBuffer;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   146
};
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   147
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   148
PacketBufferingCaseB::PacketBufferingCaseB ()
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   149
  : TestCase ("Check correct order of buffering when startSequence > endSeq")
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   150
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   151
  m_expectedBuffer.push_back (240);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   152
  m_expectedBuffer.push_back (241);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   153
  m_expectedBuffer.push_back (256);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   154
  m_expectedBuffer.push_back (64000);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   155
  m_expectedBuffer.push_back (64800);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   156
  m_expectedBuffer.push_back (16);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   157
}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   158
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   159
PacketBufferingCaseB::~PacketBufferingCaseB ()
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   160
{}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   161
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
   162
void
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   163
PacketBufferingCaseB::DoRun (void)
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   164
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   165
  std::list<uint16_t> m_buffer;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   166
  std::list<uint16_t>::iterator i,j;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   167
  m_buffer.push_back (256);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   168
  m_buffer.push_back (64000);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   169
  m_buffer.push_back (16);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   170
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   171
  uint16_t endSeq = 10;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   172
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   173
  uint16_t receivedSeq = 15 * 16;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   174
  uint32_t mappedSeq = QosUtilsMapSeqControlToUniqueInteger (receivedSeq, endSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   175
  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   176
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   177
      m_buffer.insert (i, receivedSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   178
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   179
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   180
  receivedSeq = 15 * 16 + 1;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   181
  mappedSeq = QosUtilsMapSeqControlToUniqueInteger (receivedSeq, endSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   182
  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   183
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   184
      m_buffer.insert (i, receivedSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   185
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   186
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   187
  receivedSeq = 4050 * 16;
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   188
  mappedSeq = QosUtilsMapSeqControlToUniqueInteger (receivedSeq, endSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   189
  for (i = m_buffer.begin (); i != m_buffer.end () && QosUtilsMapSeqControlToUniqueInteger ((*i), endSeq) < mappedSeq; i++);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   190
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   191
      m_buffer.insert (i, receivedSeq);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   192
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   193
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   194
  for (i = m_buffer.begin (), j = m_expectedBuffer.begin (); i != m_buffer.end (); i++, j++)
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   195
    {
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   196
      NS_TEST_EXPECT_MSG_EQ (*i, *j, "error in buffer order");
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   197
    }
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   198
}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   199
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   200
//Test for block ack header
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   201
class CtrlBAckResponseHeaderTest : public TestCase
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   202
{
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   203
public:
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   204
  CtrlBAckResponseHeaderTest ();
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   205
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
   206
  virtual void DoRun ();
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   207
  CtrlBAckResponseHeader m_blockAckHdr;
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   208
};
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   209
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   210
CtrlBAckResponseHeaderTest::CtrlBAckResponseHeaderTest ()
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   211
  : TestCase ("Check the correctness of block ack compressed bitmap")
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   212
{}
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   213
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6774
diff changeset
   214
void
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   215
CtrlBAckResponseHeaderTest::DoRun (void)
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   216
{
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   217
  m_blockAckHdr.SetType (COMPRESSED_BLOCK_ACK);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   218
  
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   219
  //Case 1: startSeq < endSeq
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   220
  //          179        242
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   221
  m_blockAckHdr.SetStartingSequence (179);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   222
  for (uint32_t i = 179; i < 220; i++)
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   223
    {
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   224
      m_blockAckHdr.SetReceivedPacket (i);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   225
    }
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   226
  for (uint32_t i = 225; i <= 242; i++)
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   227
    {
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   228
      m_blockAckHdr.SetReceivedPacket (i);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   229
    }
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   230
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.GetCompressedBitmap (), 0xffffc1ffffffffffLL, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   231
  m_blockAckHdr.SetReceivedPacket (1500);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   232
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.GetCompressedBitmap (), 0xffffc1ffffffffffLL, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   233
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (220), false, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   234
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (225), true, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   235
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (1500), false, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   236
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   237
  m_blockAckHdr.ResetBitmap ();
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   238
  
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   239
  //Case 2: startSeq > endSeq
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   240
  //          4090       58
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   241
  m_blockAckHdr.SetStartingSequence (4090);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   242
  for (uint32_t i = 4090; i != 10; i = (i + 1) % 4096)
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   243
    {
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   244
      m_blockAckHdr.SetReceivedPacket (i);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   245
    }
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   246
  for (uint32_t i = 22; i < 25; i++)
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   247
    {
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   248
      m_blockAckHdr.SetReceivedPacket (i);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   249
    }
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   250
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.GetCompressedBitmap (), 0x00000000007000ffffLL, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   251
  m_blockAckHdr.SetReceivedPacket (80);
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   252
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.GetCompressedBitmap (), 0x00000000007000ffffLL, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   253
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (4090), true, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   254
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (4095), true, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   255
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (10), false, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   256
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (35), false, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   257
  NS_TEST_EXPECT_MSG_EQ (m_blockAckHdr.IsPacketReceived (80), false, "error in compressed bitmap");
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   258
}
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   259
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   260
class BlockAckTestSuite : public TestSuite
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   261
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   262
public:
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   263
  BlockAckTestSuite ();
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   264
};
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   265
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   266
BlockAckTestSuite::BlockAckTestSuite ()
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   267
  : TestSuite ("wifi-block-ack", UNIT)
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   268
{
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   269
  AddTestCase (new PacketBufferingCaseA);
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   270
  AddTestCase (new PacketBufferingCaseB);
6590
fc8db935fbfb Add some tests for block ack response header
Mirko Banchi <mk.banchi@gmail.com>
parents: 5967
diff changeset
   271
  AddTestCase (new CtrlBAckResponseHeaderTest);
5967
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   272
}
0ca25e25b116 add block ack test suite
Mirko Banchi <mk.banchi@gmail.com>
parents:
diff changeset
   273
6774
034f362af24d Make all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6590
diff changeset
   274
static BlockAckTestSuite g_blockAckTestSuite;