A Discrete-Event Network Simulator
API
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 
28 namespace ns3
29 {
30 namespace dot11s
31 {
37 class DestinationAddressUnit : public SimpleRefCount<DestinationAddressUnit>
38 {
39  public:
47  void SetFlags(bool doFlag, bool rfFlag, bool usnFlag);
52  void SetDestinationAddress(Mac48Address dest_address);
57  void SetDestSeqNumber(uint32_t dest_seq_number);
62  bool IsDo() const;
67  bool IsRf() const;
72  bool IsUsn() const;
82  uint32_t GetDestSeqNumber() const;
83 
84  private:
85  bool m_do;
86  bool m_rf;
87  bool m_usn;
89  uint32_t m_destSeqNumber;
90 
98  friend bool operator==(const DestinationAddressUnit& a, const DestinationAddressUnit& b);
99 };
100 
106 {
107  public:
108  IePreq();
109  ~IePreq() override;
119  void AddDestinationAddressElement(bool doFlag,
120  bool rfFlag,
121  Mac48Address dest_address,
122  uint32_t dest_seq_number);
127  void DelDestinationAddressElement(Mac48Address dest_address);
134  std::vector<Ptr<DestinationAddressUnit>> GetDestinationList();
136  void SetUnicastPreq();
140  void SetNeedNotPrep();
141 
142  // Setters for fields:
148  void SetHopcount(uint8_t hopcount);
153  void SetTTL(uint8_t ttl);
158  void SetPreqID(uint32_t id);
163  void SetOriginatorAddress(Mac48Address originator_address);
168  void SetOriginatorSeqNumber(uint32_t originator_seq_number);
173  void SetLifetime(uint32_t lifetime);
178  void SetMetric(uint32_t metric);
183  void SetDestCount(uint8_t dest_count);
184 
185  // Getters for fields:
190  bool IsUnicastPreq() const;
195  bool IsNeedNotPrep() const;
200  uint8_t GetHopCount() const;
205  uint8_t GetTtl() const;
210  uint32_t GetPreqID() const;
220  uint32_t GetOriginatorSeqNumber() const;
225  uint32_t GetLifetime() const;
230  uint32_t GetMetric() const;
235  uint8_t GetDestCount() const;
236 
238  void DecrementTtl();
243  void IncrementMetric(uint32_t metric);
250  bool MayAddAddress(Mac48Address originator);
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:
269  uint8_t m_maxSize;
270 
271  uint8_t m_flags;
272  uint8_t m_hopCount;
273  uint8_t m_ttl;
274  uint32_t m_preqId;
277  uint32_t m_lifetime;
278  uint32_t m_metric;
279  uint8_t m_destCount;
280  std::vector<Ptr<DestinationAddressUnit>> m_destinations;
281 
289  friend bool operator==(const IePreq& a, const IePreq& b);
290 };
291 
293 bool operator==(const IePreq& a, const IePreq& b);
294 std::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.