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