A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-preq.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#ifndef WIFI_PREQ_INFORMATION_ELEMENT_H
10#define WIFI_PREQ_INFORMATION_ELEMENT_H
11
12#include "ns3/mac48-address.h"
13#include "ns3/mesh-information-element-vector.h"
14
15#include <vector>
16
17namespace ns3
18{
19namespace dot11s
20{
21/**
22 * \ingroup dot11s
23 * \brief Describes an address unit in PREQ information element
24 * See 7.3.2.96 for more details
25 */
26class DestinationAddressUnit : public SimpleRefCount<DestinationAddressUnit>
27{
28 public:
30 /**
31 * Set flags function
32 * \param doFlag the DO flag
33 * \param rfFlag the RF flag
34 * \param usnFlag the USN flag
35 */
36 void SetFlags(bool doFlag, bool rfFlag, bool usnFlag);
37 /**
38 * Set destination address function
39 * \param dest_address the destination MAC address
40 */
41 void SetDestinationAddress(Mac48Address dest_address);
42 /**
43 * Set destination sequence number
44 * \param dest_seq_number the destination sequence number
45 */
46 void SetDestSeqNumber(uint32_t dest_seq_number);
47 /**
48 * Is do function
49 * \returns true if DO flag is set
50 */
51 bool IsDo() const;
52 /**
53 * is RF function
54 * \returns true if RF flag is set
55 */
56 bool IsRf() const;
57 /**
58 * Is USN function
59 * \returns true if USN flag set
60 */
61 bool IsUsn() const;
62 /**
63 * Get destination address function
64 * \returns the MAC address
65 */
67 /**
68 * Get destination sequence number
69 * \returns the destination sequence number
70 */
72
73 private:
74 bool m_do; ///< DO
75 bool m_rf; ///< RF
76 bool m_usn; ///< USN
77 Mac48Address m_destinationAddress; ///< destination address
78 uint32_t m_destSeqNumber; ///< destination sequence number
79
80 /**
81 * equality operator
82 *
83 * \param a lhs
84 * \param b rhs
85 * \returns true if equal
86 */
87 friend bool operator==(const DestinationAddressUnit& a, const DestinationAddressUnit& b);
88};
89
90/**
91 * \ingroup dot11s
92 * \brief See 7.3.2.96 of 802.11s draft 2.07
93 */
95{
96 public:
97 IePreq();
98 ~IePreq() override;
99 /**
100 * Add a destination address unit: flags, destination and sequence
101 * number
102 *
103 * \param doFlag
104 * \param rfFlag
105 * \param dest_address
106 * \param dest_seq_number
107 */
108 void AddDestinationAddressElement(bool doFlag,
109 bool rfFlag,
110 Mac48Address dest_address,
111 uint32_t dest_seq_number);
112 /**
113 * Delete a destination address unit by destination
114 * \param dest_address the destination address
115 */
117 /// Clear PREQ: remove all destinations
119 /**
120 * Get all destinations, which are stored in PREQ:
121 * \returns the list of destination addresses
122 */
123 std::vector<Ptr<DestinationAddressUnit>> GetDestinationList();
124 /// Set flag indicating that PREQ is unicast
125 void SetUnicastPreq();
126 /**
127 * \brief Set Proactive PREP subfield to off
128 */
129 void SetNeedNotPrep();
130
131 // Setters for fields:
132 /**
133 * Set number of hops from originator to mesh STA transmitting this
134 * element
135 * \param hopcount the hop count
136 */
137 void SetHopcount(uint8_t hopcount);
138 /**
139 * Set remaining number of hops allowed for this element
140 * \param ttl the TTL
141 */
142 void SetTTL(uint8_t ttl);
143 /**
144 * Set path discovery id field
145 * \param id some unique id for this path discovery
146 */
147 void SetPreqID(uint32_t id);
148 /**
149 * Set originator address value
150 * \param originator_address the originator MAC address
151 */
152 void SetOriginatorAddress(Mac48Address originator_address);
153 /**
154 * Set originator sequence number
155 * \param originator_seq_number
156 */
157 void SetOriginatorSeqNumber(uint32_t originator_seq_number);
158 /**
159 * Set lifetime in TUs for the forwarding information to be considered valid
160 * \param lifetime the lifetime in TUs
161 */
162 void SetLifetime(uint32_t lifetime);
163 /**
164 * Set metric value
165 * \param metric the metric
166 */
167 void SetMetric(uint32_t metric);
168 /**
169 * Set destination count value
170 * \param dest_count the destination count
171 */
172 void SetDestCount(uint8_t dest_count);
173
174 // Getters for fields:
175 /**
176 * Is unicast PREQ function
177 * \returns true if unicast PREQ
178 */
179 bool IsUnicastPreq() const;
180 /**
181 * Check whether Proactive PREP subfield to off
182 * \returns true if need not Proactive PREP subfield is off
183 */
184 bool IsNeedNotPrep() const;
185 /**
186 * Get hop count value
187 * \returns the hop count
188 */
189 uint8_t GetHopCount() const;
190 /**
191 * Get TTL value
192 * \returns the TTL
193 */
194 uint8_t GetTtl() const;
195 /**
196 * Get path discovery id field
197 * \returns the path discovery ID
198 */
199 uint32_t GetPreqID() const;
200 /**
201 * Get originator address value
202 * \returns the originator MAC address
203 */
205 /**
206 * Get originator sequence number value
207 * \returns the originator sequence number
208 */
210 /**
211 * Get lifetime value
212 * \returns the lifetime in TUs
213 */
214 uint32_t GetLifetime() const;
215 /**
216 * Get metric value
217 * \returns the metric
218 */
219 uint32_t GetMetric() const;
220 /**
221 * Get destination count
222 * \returns the destination count
223 */
224 uint8_t GetDestCount() const;
225
226 /// Handle TTL
227 void DecrementTtl();
228 /**
229 * Handle Metric:
230 * \param metric the mteric to increment
231 */
232 void IncrementMetric(uint32_t metric);
233 /**
234 * \brief Checks that preq's originator address equals to originator, and
235 * this preq is not proactive
236 * \param originator the originator address
237 * \returns true if it may add
238 */
239 bool MayAddAddress(Mac48Address originator);
240 /**
241 * Is full function
242 * \returns true if full
243 */
244 bool IsFull() const;
245
246 // Inherited from WifiInformationElement
247 WifiInformationElementId ElementId() const override;
248 void SerializeInformationField(Buffer::Iterator i) const override;
249 uint16_t DeserializeInformationField(Buffer::Iterator i, uint16_t length) override;
250 uint16_t GetInformationFieldSize() const override;
251 void Print(std::ostream& os) const override;
252
253 private:
254 /**
255 * how many destinations we support
256 * \todo make as an attribute
257 */
258 uint8_t m_maxSize;
259
260 uint8_t m_flags; ///< flags
261 uint8_t m_hopCount; ///< hop count
262 uint8_t m_ttl; ///< TTL
263 uint32_t m_preqId; ///< PREQ ID
264 Mac48Address m_originatorAddress; ///< originator address
265 uint32_t m_originatorSeqNumber; ///< originator sequence number
266 uint32_t m_lifetime; ///< lifetime
267 uint32_t m_metric; ///< metric
268 uint8_t m_destCount; ///< destination count
269 std::vector<Ptr<DestinationAddressUnit>> m_destinations; ///< the destinations
270
271 /**
272 * equality operator
273 *
274 * \param a lhs
275 * \param b rhs
276 * \returns true if equal
277 */
278 friend bool operator==(const IePreq& a, const IePreq& b);
279};
280
282bool operator==(const IePreq& a, const IePreq& b);
283std::ostream& operator<<(std::ostream& os, const IePreq& preq);
284
285} // namespace dot11s
286} // namespace ns3
287#endif
iterator in a Buffer instance
Definition buffer.h:89
an EUI-48 address
A template-based reference counting class.
Information element, as defined in 802.11-2007 standard.
Describes an address unit in PREQ information element See 7.3.2.96 for more details.
bool IsUsn() const
Is USN function.
uint32_t GetDestSeqNumber() const
Get destination sequence number.
friend bool operator==(const DestinationAddressUnit &a, const DestinationAddressUnit &b)
equality operator
bool IsRf() const
is RF function
void SetDestSeqNumber(uint32_t dest_seq_number)
Set destination sequence number.
Mac48Address m_destinationAddress
destination address
uint32_t m_destSeqNumber
destination sequence number
Mac48Address GetDestinationAddress() const
Get destination address function.
void SetFlags(bool doFlag, bool rfFlag, bool usnFlag)
Set flags function.
void SetDestinationAddress(Mac48Address dest_address)
Set destination address function.
bool IsDo() const
Is do function.
See 7.3.2.96 of 802.11s draft 2.07.
uint32_t GetOriginatorSeqNumber() const
Get originator sequence number value.
uint32_t m_originatorSeqNumber
originator sequence number
void DelDestinationAddressElement(Mac48Address dest_address)
Delete a destination address unit by destination.
uint8_t m_destCount
destination count
void SetHopcount(uint8_t hopcount)
Set number of hops from originator to mesh STA transmitting this element.
uint8_t GetDestCount() const
Get destination count.
void SetNeedNotPrep()
Set Proactive PREP subfield to off.
bool IsUnicastPreq() const
Is unicast PREQ function.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
uint8_t GetHopCount() const
Get hop count value.
void SetUnicastPreq()
Set flag indicating that PREQ is unicast.
std::vector< Ptr< DestinationAddressUnit > > GetDestinationList()
Get all destinations, which are stored in PREQ:
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number.
uint32_t GetMetric() const
Get metric value.
void SetTTL(uint8_t ttl)
Set remaining number of hops allowed for this element.
uint32_t m_preqId
PREQ ID.
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address value.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
friend bool operator==(const IePreq &a, const IePreq &b)
equality operator
Mac48Address GetOriginatorAddress() const
Get originator address value.
void DecrementTtl()
Handle TTL.
uint32_t GetPreqID() const
Get path discovery id field.
uint8_t m_hopCount
hop count
void ClearDestinationAddressElements()
Clear PREQ: remove all destinations.
void SetDestCount(uint8_t dest_count)
Set destination count value.
void SetMetric(uint32_t metric)
Set metric value.
bool IsFull() const
Is full function.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint16_t DeserializeInformationField(Buffer::Iterator i, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool MayAddAddress(Mac48Address originator)
Checks that preq's originator address equals to originator, and this preq is not proactive.
uint32_t m_metric
metric
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint8_t GetTtl() const
Get TTL value.
void SetPreqID(uint32_t id)
Set path discovery id field.
void IncrementMetric(uint32_t metric)
Handle Metric:
Mac48Address m_originatorAddress
originator address
uint8_t m_maxSize
how many destinations we support
uint32_t GetLifetime() const
Get lifetime value.
std::vector< Ptr< DestinationAddressUnit > > m_destinations
the destinations
void AddDestinationAddressElement(bool doFlag, bool rfFlag, Mac48Address dest_address, uint32_t dest_seq_number)
Add a destination address unit: flags, destination and sequence number.
bool IsNeedNotPrep() const
Check whether Proactive PREP subfield to off.
void SetLifetime(uint32_t lifetime)
Set lifetime in TUs for the forwarding information to be considered valid.
uint32_t m_lifetime
lifetime
bool operator==(const MeshHeader &a, const MeshHeader &b)
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
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.