A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016
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: Sébastien Deronne <sebastien.deronne@gmail.com>
18 */
19
20#ifndef WIFI_UTILS_H
21#define WIFI_UTILS_H
22
23#include "block-ack-type.h"
24
25#include "ns3/fatal-error.h"
26#include "ns3/ptr.h"
27
28#include <list>
29#include <map>
30#include <set>
31
32namespace ns3
33{
34
35class WifiMacHeader;
36class Packet;
37
42enum class WifiDirection : uint8_t
43{
44 DOWNLINK = 0,
45 UPLINK = 1,
47};
48
56inline std::ostream&
57operator<<(std::ostream& os, const WifiDirection& direction)
58{
59 switch (direction)
60 {
62 return (os << "DOWNLINK");
64 return (os << "UPLINK");
66 return (os << "BOTH_DIRECTIONS");
67 default:
68 NS_FATAL_ERROR("Invalid direction");
69 return (os << "INVALID");
70 }
71}
72
74using WifiTidLinkMapping = std::map<uint8_t, std::set<uint8_t>>;
75
83double DbmToW(double dbm);
91double DbToRatio(double db);
99double WToDbm(double w);
107double RatioToDb(double ratio);
134uint32_t GetMuBarSize(std::list<BlockAckReqType> types);
155bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize);
161void AddWifiMacTrailer(Ptr<Packet> packet);
171uint32_t GetSize(Ptr<const Packet> packet, const WifiMacHeader* hdr, bool isAmpdu);
172
182 const WifiTidLinkMapping& ulLinkMapping);
183
185static constexpr uint16_t SEQNO_SPACE_SIZE = 4096;
186
188static constexpr uint16_t SEQNO_SPACE_HALF_SIZE = SEQNO_SPACE_SIZE / 2;
189
192static constexpr uint8_t SINGLE_LINK_OP_ID = 0;
193
195static constexpr uint8_t WIFI_LINKID_UNDEFINED = 0xff;
196
197} // namespace ns3
198
199#endif /* WIFI_UTILS_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Implements the IEEE 802.11 MAC header.
#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.
static constexpr uint16_t SEQNO_SPACE_HALF_SIZE
Size of the half the space of sequence numbers (used to determine old packets)
Definition: wifi-utils.h:188
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:52
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:46
uint32_t GetRtsSize()
Return the total RTS size (including FCS trailer).
Definition: wifi-utils.cc:103
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:40
uint32_t GetBlockAckRequestSize(BlockAckReqType type)
Return the total BlockAckRequest size (including FCS trailer).
Definition: wifi-utils.cc:76
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:192
uint32_t GetMuBarSize(std::list< BlockAckReqType > types)
Return the total MU-BAR size (including FCS trailer).
Definition: wifi-utils.cc:86
WifiDirection
Wifi direction.
Definition: wifi-utils.h:43
static constexpr uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
Definition: wifi-utils.h:185
bool TidToLinkMappingValidForNegType1(const WifiTidLinkMapping &dlLinkMapping, const WifiTidLinkMapping &ulLinkMapping)
Check if the given TID-to-Link Mappings are valid for a negotiation type of 1.
Definition: wifi-utils.cc:148
uint32_t GetBlockAckSize(BlockAckType type)
Return the total BlockAck size (including FCS trailer).
Definition: wifi-utils.cc:66
void AddWifiMacTrailer(Ptr< Packet > packet)
Add FCS trailer to a packet.
Definition: wifi-utils.cc:125
static constexpr uint8_t WIFI_LINKID_UNDEFINED
Invalid link identifier.
Definition: wifi-utils.h:195
std::map< uint8_t, std::set< uint8_t > > WifiTidLinkMapping
TID-indexed map of the link set to which the TID is mapped.
Definition: wifi-utils.h:74
uint32_t GetAckSize()
Return the total Ack size (including FCS trailer).
Definition: wifi-utils.cc:58
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
Definition: wifi-utils.cc:132
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:34
uint32_t GetCtsSize()
Return the total CTS size (including FCS trailer).
Definition: wifi-utils.cc:111
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Definition: wifi-utils.cc:119
The different BlockAckRequest variants.
The different BlockAck variants.