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