A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tid-to-link-mapping-element.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022
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: Sharan Naribole <sharan.naribole@gmail.com>
18 */
19
20#ifndef TID_TO_LINK_MAPPING_H
21#define TID_TO_LINK_MAPPING_H
22
23#include "ns3/nstime.h"
24#include "ns3/wifi-information-element.h"
25#include "ns3/wifi-utils.h"
26
27#include <map>
28#include <optional>
29#include <set>
30
31namespace ns3
32{
33
34/// whether to enforce the default link mapping
35constexpr auto DEFAULT_WIFI_TID_LINK_MAPPING{true};
36/// default value for the Direction subfield of the TID-To-Link Control field
38/// size in bytes of the TID-To-Link Control field with default link mapping
40 1; // IEEE 802.11be D2.0 9.4.2.314
41/// size in bytes of the Link Mapping Presence Indicator field (IEEE 802.11be D2.0 9.4.2.314)
43
44/**
45 * \brief TID-to-Link Mapping Information Element
46 * \ingroup wifi
47 *
48 * This class serializes and deserializes
49 * the TID-to-Link Mapping element
50 * IEEE 802.11be D3.1 9.4.2.314
51 *
52 */
54{
55 public:
56 /**
57 * TID-to-Link Mapping Control subfield
58 * IEEE 802.11be D3.1 Figure 9-1002ap
59 */
60 struct Control
61 {
62 friend class TidToLinkMapping;
63
65 bool defaultMapping{DEFAULT_WIFI_TID_LINK_MAPPING}; ///< Default link mapping
66
67 /// \return Serialized size of TID-to-Link Mapping Control in octets
68 uint16_t GetSubfieldSize() const;
69
70 /**
71 * Serialize the TID-to-Link Mapping Control subfield
72 *
73 * \param start iterator pointing to where the subfield should be written to
74 */
75 void Serialize(Buffer::Iterator& start) const;
76 /**
77 * Deserialize the TID-to-Link Mapping Control subfield
78 *
79 * \param start iterator pointing to where the subfield should be read from
80 * \return the number of octets read
81 */
82 uint16_t Deserialize(Buffer::Iterator start);
83
84 private:
85 /**
86 * These members are private to prevent users to manipulate them directly (their values
87 * depend on the values of other fields)
88 */
89 bool mappingSwitchTimePresent{false}; ///< Mapping Switch Time Present
90 bool expectedDurationPresent{false}; ///< Expected Duration Present
91 uint8_t linkMappingSize{1}; ///< length of the Link Mapping Of TID n field in octets
92 std::optional<uint8_t> presenceBitmap; ///< Link Mapping Presence Indicator
93 };
94
95 WifiInformationElementId ElementId() const override;
97
98 /**
99 * Set the Mapping Switch Time field.
100 *
101 * \param mappingSwitchTime the time when the new mapping is established (rounded to a
102 * multiple of a TU)
103 */
104 void SetMappingSwitchTime(Time mappingSwitchTime);
105
106 /// \return the value of the Mapping Switch Time field, if present.
107 std::optional<Time> GetMappingSwitchTime() const;
108
109 /**
110 * Set the Expected Duration field.
111 *
112 * \param expectedDuration the value for the Expected Duration field (rounded to a
113 * multiple of a TU)
114 */
115 void SetExpectedDuration(Time expectedDuration);
116
117 /// \return the value of the Expected Duration field, if present.
118 std::optional<Time> GetExpectedDuration() const;
119
120 /**
121 * Set the Link Mapping field of the given TID such that the given TID is mapped
122 * to the links associated with the given link IDs.
123 *
124 * \param tid the given TID
125 * \param linkIds the IDs of the links which the given TID is mapped to
126 */
127 void SetLinkMappingOfTid(uint8_t tid, std::set<uint8_t> linkIds);
128 /**
129 * Get the Link Mapping field of the given TID.
130 *
131 * \param tid the given TID
132 * \return the IDs of the links which the given TID is mapped to
133 */
134 std::set<uint8_t> GetLinkMappingOfTid(uint8_t tid) const;
135
136 TidToLinkMapping::Control m_control; ///< TID-to-link Mapping Control
137 std::map<uint8_t, uint16_t> m_linkMapping; ///< TID-indexed Link Mapping
138
139 private:
140 std::optional<uint16_t> m_mappingSwitchTime; ///< Mapping Switch Time
141 std::optional<uint32_t> m_expectedDuration; ///< Expected Duration
142
143 uint16_t GetInformationFieldSize() const override;
144 void SerializeInformationField(Buffer::Iterator start) const override;
145 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
146};
147
148} // namespace ns3
149
150#endif /* TID_TO_LINK_MAPPING_H */
iterator in a Buffer instance
Definition: buffer.h:100
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Information element, as defined in 802.11-2007 standard.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr uint16_t WIFI_TID_TO_LINK_MAPPING_CONTROL_BASIC_SIZE_B
size in bytes of the TID-To-Link Control field with default link mapping
constexpr auto DEFAULT_WIFI_TID_LINK_MAP_DIR
default value for the Direction subfield of the TID-To-Link Control field
WifiDirection
Wifi direction.
Definition: wifi-utils.h:43
constexpr uint16_t WIFI_LINK_MAPPING_PRESENCE_IND_SIZE_B
size in bytes of the Link Mapping Presence Indicator field (IEEE 802.11be D2.0 9.4....
constexpr auto DEFAULT_WIFI_TID_LINK_MAPPING
whether to enforce the default link mapping
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.