A Discrete-Event Network Simulator
API
block-ack-type.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2019 Universita' di Napoli
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Stefano Avallone <stavallo@unina.it>
19  */
20 
21 #include "block-ack-type.h"
22 #include "ns3/fatal-error.h"
23 
24 namespace ns3 {
25 
27  : m_variant (v)
28 {
29  switch (m_variant)
30  {
31  case BASIC:
32  m_bitmapLen.push_back (128);
33  break;
34  case COMPRESSED:
36  m_bitmapLen.push_back (8);
37  break;
38  case MULTI_TID:
39  case MULTI_STA:
40  // m_bitmapLen is left empty.
41  break;
42  default:
43  NS_FATAL_ERROR ("Unknown block ack type");
44  }
45 }
46 
48  : BlockAckType (BASIC)
49 {
50 }
51 
52 BlockAckType::BlockAckType (Variant v, std::vector<uint8_t> l)
53  : m_variant (v),
54  m_bitmapLen (l)
55 {
56 }
57 
59  : m_variant (v)
60 {
61  switch (m_variant)
62  {
63  case BASIC:
64  case COMPRESSED:
66  m_nSeqControls = 1;
67  break;
68  case MULTI_TID:
69  m_nSeqControls = 0;
70  break;
71  default:
72  NS_FATAL_ERROR ("Unknown block ack request type");
73  }
74 }
75 
77  : BlockAckReqType (BASIC)
78 {
79 }
80 
81 BlockAckReqType::BlockAckReqType (Variant v, uint8_t nSeqControls)
82  : m_variant (v),
83  m_nSeqControls (nSeqControls)
84 {
85 }
86 
87 std::ostream &operator << (std::ostream &os, const BlockAckType &type)
88 {
89  switch (type.m_variant)
90  {
92  os << "basic-block-ack";
93  break;
95  os << "compressed-block-ack";
96  break;
98  os << "extended-compressed-block-ack";
99  break;
101  os << "multi-tid-block-ack[" << type.m_bitmapLen.size () << "]";
102  break;
104  os << "multi-sta-block-ack[" << type.m_bitmapLen.size () << "]";
105  break;
106  default:
107  NS_FATAL_ERROR ("Unknown block ack type");
108  }
109  return os;
110 }
111 
112 std::ostream &operator << (std::ostream &os, const BlockAckReqType &type)
113 {
114  switch (type.m_variant)
115  {
117  os << "basic-block-ack-req";
118  break;
120  os << "compressed-block-ack-req";
121  break;
123  os << "extended-compressed-block-ack-req";
124  break;
126  os << "multi-tid-block-ack-req[" << type.m_nSeqControls << "]";
127  break;
128  default:
129  NS_FATAL_ERROR ("Unknown block ack request type");
130  }
131  return os;
132 }
133 
134 } //namespace ns3
enum Variant m_variant
Block Ack Request variant.
BlockAckReqType()
Default constructor for BlockAckReqType.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
The different BlockAckRequest variants.
enum Variant m_variant
Block Ack variant.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
BlockAckType()
Default constructor for BlockAckType.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Variant
The BlockAck variants.
Variant
The BlockAckReq variants.
std::vector< uint8_t > m_bitmapLen
Length (bytes) of included bitmaps.
The different BlockAck variants.
uint8_t m_nSeqControls
Number of included Starting Sequence Control fields.