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