A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tim.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Universita' degli Studi di Napoli Federico II
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: Davide Magrin <davide@magr.in>
18 */
19
20#ifndef TIM_H
21#define TIM_H
22
24
25#include <set>
26
27namespace ns3
28{
29
30/**
31 * \brief The Traffic Indication Map Information Element
32 * \ingroup wifi
33 *
34 * The 802.11 Traffic Indication Map (see section 9.4.2.5 of 802.11-2020)
35 *
36 * Note: The current implementation does not support S1G operation, or
37 * multiple BSSID.
38 */
40{
41 public:
42 WifiInformationElementId ElementId() const override;
43 void Print(std::ostream& os) const override;
44
45 /**
46 * Add the provided AID value to the list contained in the Virtual Bitmap
47 *
48 * \param aid the AID value to add to this TIM's Virtual Bitmap
49 */
50 void AddAid(uint16_t aid);
51
52 /**
53 * Add the AID values in the provided iterator range to the list contained
54 * in the Virtual Bitmap
55 *
56 * \tparam Iterator Type of iterator
57 * \param begin Starting position of the iterator range
58 * \param end Ending position of the iterator range
59 */
60 template <typename Iterator>
61 void AddAid(Iterator begin, Iterator end);
62
63 /**
64 * Check whether the bit corresponding to the provided AID is set in the
65 * Virtual Bitmap included in this TIM
66 *
67 * \param aid The AID value to look for
68 * \return True if the AID value is found in the Virtual Bitmap, false otherwise
69 */
70 bool HasAid(uint16_t aid) const;
71
72 /**
73 * Return the AID values, greater than the given AID value, whose corresponding bits are set
74 * in the virtual bitmap.
75 *
76 * \param aid the given AID value
77 * \return the AID values, greater than the given AID value, whose corresponding bits are set
78 * in the virtual bitmap
79 */
80 std::set<uint16_t> GetAidSet(uint16_t aid = 0) const;
81
82 /**
83 * Get the Partial Virtual Bitmap offset, i.e., the number (denoted as N1 by the specs) of
84 * the first octet included in the Partial Virtual Bitmap. Note that the Bitmap Offset
85 * subfield contains the number N1/2.
86 *
87 * \return the Partial Virtual Bitmap offset
88 */
89 uint8_t GetPartialVirtualBitmapOffset() const;
90
91 /**
92 * \return the last non-zero octet in the virtual bitmap (denoted as N2 by the specs)
93 */
94 uint8_t GetLastNonZeroOctetIndex() const;
95
96 uint8_t m_dtimCount{0}; //!< The DTIM Count field
97 uint8_t m_dtimPeriod{0}; //!< The DTIM Period field
98 bool m_hasMulticastPending{false}; //!< Whether there is Multicast / Broadcast data
99
100 private:
101 uint16_t GetInformationFieldSize() const override;
102 void SerializeInformationField(Buffer::Iterator start) const override;
103 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
104
105 /**
106 * Obtain the index of the octet where the provided AID value should be
107 * set in the Virtual Bitmap
108 *
109 * \param aid the provided AID value
110 * \return the index of the octet where the provided AID value should be
111 * set in the Virtual Bitmap
112 */
113 uint8_t GetAidOctetIndex(uint16_t aid) const;
114
115 /**
116 * Obtain an octet with a set bit, corresponding to the provided AID value
117 *
118 * \param aid the provided AID value
119 * \return an octet with a set bit, corresponding to the provided AID value
120 */
121 uint8_t GetAidBit(uint16_t aid) const;
122
123 /**
124 * Obtain the AID value represented by a certain octet index and bit
125 * position inside the Virtual Bitmap
126 *
127 * \param octet the octet index in the Virtual Bitmap
128 * \param position the bit position in the octet of the Virtual Bitmap
129 * \return the corresponding AID value
130 */
131 uint16_t GetAidFromOctetIndexAndBitPosition(uint16_t octet, uint8_t position) const;
132
133 /**
134 * The Bitmap Control field is optional if the TIM is carried in an S1G PPDU, while
135 * it is always present when the TIM is carried in a non-S1G PPDU.
136 *
137 * \return the value of the Bitmap Control field
138 */
139 uint8_t GetBitmapControl() const;
140
141 /**
142 * \return a vector containing the Partial Virtual Bitmap octets
143 */
144 std::vector<uint8_t> GetPartialVirtualBitmap() const;
145
146 std::set<uint16_t> m_aidValues; //!< List of AID values included in this TIM
147};
148
149template <typename Iterator>
150void
151Tim::AddAid(Iterator begin, Iterator end)
152{
153 for (auto& it = begin; it != end; it++)
154 {
155 AddAid(*it);
156 }
157}
158
159} // namespace ns3
160
161#endif /* TIM_H */
iterator in a Buffer instance
Definition: buffer.h:100
The Traffic Indication Map Information Element.
Definition: tim.h:40
std::set< uint16_t > m_aidValues
List of AID values included in this TIM.
Definition: tim.h:146
uint8_t GetAidBit(uint16_t aid) const
Obtain an octet with a set bit, corresponding to the provided AID value.
Definition: tim.cc:138
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition: tim.cc:86
uint8_t m_dtimPeriod
The DTIM Period field.
Definition: tim.h:97
uint8_t GetPartialVirtualBitmapOffset() const
Get the Partial Virtual Bitmap offset, i.e., the number (denoted as N1 by the specs) of the first oct...
Definition: tim.cc:153
std::vector< uint8_t > GetPartialVirtualBitmap() const
Definition: tim.cc:200
uint8_t m_dtimCount
The DTIM Count field.
Definition: tim.h:96
uint16_t GetAidFromOctetIndexAndBitPosition(uint16_t octet, uint8_t position) const
Obtain the AID value represented by a certain octet index and bit position inside the Virtual Bitmap.
Definition: tim.cc:147
void AddAid(uint16_t aid)
Add the provided AID value to the list contained in the Virtual Bitmap.
Definition: tim.cc:49
void Print(std::ostream &os) const override
Generate human-readable form of IE.
Definition: tim.cc:217
uint8_t GetAidOctetIndex(uint16_t aid) const
Obtain the index of the octet where the provided AID value should be set in the Virtual Bitmap.
Definition: tim.cc:129
uint8_t GetLastNonZeroOctetIndex() const
Definition: tim.cc:168
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
Definition: tim.cc:29
std::set< uint16_t > GetAidSet(uint16_t aid=0) const
Return the AID values, greater than the given AID value, whose corresponding bits are set in the virt...
Definition: tim.cc:63
bool m_hasMulticastPending
Whether there is Multicast / Broadcast data.
Definition: tim.h:98
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition: tim.cc:70
bool HasAid(uint16_t aid) const
Check whether the bit corresponding to the provided AID is set in the Virtual Bitmap included in this...
Definition: tim.cc:57
uint8_t GetBitmapControl() const
The Bitmap Control field is optional if the TIM is carried in an S1G PPDU, while it is always present...
Definition: tim.cc:183
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Definition: tim.cc:35
Information element, as defined in 802.11-2007 standard.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.