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  // m_bitmapLen is left empty.
40  break;
41  default:
42  NS_FATAL_ERROR ("Unknown block ack type");
43  }
44 }
45 
47  : BlockAckType (BASIC)
48 {
49 }
50 
51 BlockAckType::BlockAckType (Variant v, std::vector<uint8_t> l)
52  : m_variant (v),
53  m_bitmapLen (l)
54 {
55 }
56 
58  : m_variant (v)
59 {
60  switch (m_variant)
61  {
62  case BASIC:
63  case COMPRESSED:
65  m_nSeqControls = 1;
66  break;
67  case MULTI_TID:
68  m_nSeqControls = 0;
69  break;
70  default:
71  NS_FATAL_ERROR ("Unknown block ack request type");
72  }
73 }
74 
76  : BlockAckReqType (BASIC)
77 {
78 }
79 
80 BlockAckReqType::BlockAckReqType (Variant v, uint8_t nSeqControls)
81  : m_variant (v),
82  m_nSeqControls (nSeqControls)
83 {
84 }
85 
86 std::ostream &operator << (std::ostream &os, const BlockAckType &type)
87 {
88  switch (type.m_variant)
89  {
91  os << "basic-block-ack";
92  break;
94  os << "compressed-block-ack";
95  break;
97  os << "extended-compressed-block-ack";
98  break;
100  os << "multi-tid-block-ack[" << type.m_bitmapLen.size () << "]";
101  break;
102  default:
103  NS_FATAL_ERROR ("Unknown block ack type");
104  }
105  return os;
106 }
107 
108 std::ostream &operator << (std::ostream &os, const BlockAckReqType &type)
109 {
110  switch (type.m_variant)
111  {
113  os << "basic-block-ack-req";
114  break;
116  os << "compressed-block-ack-req";
117  break;
119  os << "extended-compressed-block-ack-req";
120  break;
122  os << "multi-tid-block-ack-req[" << type.m_nSeqControls << "]";
123  break;
124  default:
125  NS_FATAL_ERROR ("Unknown block ack request type");
126  }
127  return os;
128 }
129 
130 } //namespace ns3
enum Variant m_variant
Block Ack Request variant.
BlockAckReqType()
Constructors.
#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()
Constructors.
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.