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