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