LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008,2009 IITP RAS | 3 * Copyright (c) 2008,2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Kirill Andreev <andreev@iitp.ru> | 18 * Author: Kirill Andreev <andreev@iitp.ru> |
19 */ | 19 */ |
20 | 20 |
21 | |
22 #ifndef WIFI_PREQ_INFORMATION_ELEMENT_H | 21 #ifndef WIFI_PREQ_INFORMATION_ELEMENT_H |
23 #define WIFI_PREQ_INFORMATION_ELEMENT_H | 22 #define WIFI_PREQ_INFORMATION_ELEMENT_H |
24 | 23 |
25 #include <vector> | 24 #include <vector> |
26 | 25 |
27 #include "ns3/mac48-address.h" | 26 #include "ns3/mac48-address.h" |
28 #include "ns3/wifi-information-element.h" | 27 #include "ns3/wifi-information-element-vector.h" |
29 | 28 |
30 namespace ns3 { | 29 namespace ns3 { |
31 namespace dot11s { | 30 namespace dot11s { |
32 /** | 31 /** |
33 * \ingroup dot11s | 32 * \ingroup dot11s |
34 * \brief Describes an address unit in PREQ information element | 33 * \brief Describes an address unit in PREQ information element |
35 * See 7.3.2.96 for more details | 34 * See 7.3.2.96 for more details |
36 */ | 35 */ |
37 class DestinationAddressUnit : public RefCountBase | 36 class DestinationAddressUnit : public RefCountBase |
38 { | 37 { |
39 public: | 38 public: |
40 DestinationAddressUnit (); | 39 DestinationAddressUnit (); |
41 void SetFlags (bool doFlag, bool rfFlag, bool usnFlag); | 40 void SetFlags (bool doFlag, bool rfFlag, bool usnFlag); |
42 void SetDestinationAddress (Mac48Address dest_address); | 41 void SetDestinationAddress (Mac48Address dest_address); |
43 void SetDestSeqNumber (uint32_t dest_seq_number); | 42 void SetDestSeqNumber (uint32_t dest_seq_number); |
44 bool IsDo (); | 43 bool IsDo (); |
45 bool IsRf (); | 44 bool IsRf (); |
46 bool IsUsn (); | 45 bool IsUsn (); |
47 Mac48Address GetDestinationAddress () const; | 46 Mac48Address GetDestinationAddress () const; |
48 uint32_t GetDestSeqNumber () const; | 47 uint32_t GetDestSeqNumber () const; |
49 private: | 48 private: |
50 bool m_do; | 49 bool m_do; |
51 bool m_rf; | 50 bool m_rf; |
52 bool m_usn; | 51 bool m_usn; |
53 Mac48Address m_destinationAddress; | 52 Mac48Address m_destinationAddress; |
54 uint32_t m_destSeqNumber; | 53 uint32_t m_destSeqNumber; |
55 | 54 |
56 friend bool operator== (const DestinationAddressUnit & a, const DestinationAdd
ressUnit & b); | 55 friend bool operator== (const DestinationAddressUnit & a, const DestinationAdd
ressUnit & b); |
57 }; | 56 }; |
58 /** | 57 /** |
59 * \ingroup dot11s | 58 * \ingroup dot11s |
60 * \brief See 7.3.2.96 of 802.11s draft 2.07 | 59 * \brief See 7.3.2.96 of 802.11s draft 2.07 |
61 */ | 60 */ |
62 class IePreq : public WifiInformationElement | 61 class IePreq : public WifiInformationElement |
63 { | 62 { |
64 public: | 63 public: |
65 IePreq (); | 64 IePreq (); |
66 ~IePreq (); | 65 ~IePreq (); |
| 66 /** |
| 67 * Add a destination address unit: flags, destination and sequence |
| 68 * number |
| 69 */ |
67 void AddDestinationAddressElement ( | 70 void AddDestinationAddressElement ( |
68 bool doFlag, | 71 bool doFlag, |
69 bool rfFlag, | 72 bool rfFlag, |
70 Mac48Address dest_address, | 73 Mac48Address dest_address, |
71 uint32_t dest_seq_number | 74 uint32_t dest_seq_number |
72 ); | 75 ); |
| 76 /// Delete a destination address unit by destination |
73 void DelDestinationAddressElement (Mac48Address dest_address); | 77 void DelDestinationAddressElement (Mac48Address dest_address); |
74 void ClearDestinationAddressElement (); | 78 /// Clear PREQ: remove all destinations |
| 79 void ClearDestinationAddressElements (); |
| 80 /// Get all destinations, which are stored in PREQ: |
75 std::vector<Ptr<DestinationAddressUnit> > GetDestinationList (); | 81 std::vector<Ptr<DestinationAddressUnit> > GetDestinationList (); |
| 82 /// SetProper flags which indicate that PREQ is unicast |
76 void SetUnicastPreq (); | 83 void SetUnicastPreq (); |
77 /* | 84 /* |
78 * \brief In proactive case: need we send PREP | 85 * \brief In proactive case: need we send PREP |
79 */ | 86 */ |
80 void SetNeedNotPrep (); | 87 void SetNeedNotPrep (); |
| 88 ///\name Setters for fields: |
| 89 ///\{ |
81 void SetHopcount (uint8_t hopcount); | 90 void SetHopcount (uint8_t hopcount); |
82 void SetTTL (uint8_t ttl); | 91 void SetTTL (uint8_t ttl); |
83 void SetPreqID (uint32_t id); | 92 void SetPreqID (uint32_t id); |
84 void SetOriginatorAddress (Mac48Address originator_address); | 93 void SetOriginatorAddress (Mac48Address originator_address); |
85 void SetOriginatorSeqNumber (uint32_t originator_seq_number); | 94 void SetOriginatorSeqNumber (uint32_t originator_seq_number); |
86 void SetLifetime (uint32_t lifetime); | 95 void SetLifetime (uint32_t lifetime); |
87 void SetMetric (uint32_t metric); | 96 void SetMetric (uint32_t metric); |
88 void SetDestCount (uint8_t dest_count); | 97 void SetDestCount (uint8_t dest_count); |
89 | 98 ///\} |
| 99 ///\name Getters for fields: |
| 100 ///\{ |
90 bool IsUnicastPreq () const; | 101 bool IsUnicastPreq () const; |
91 bool IsNeedNotPrep () const; | 102 bool IsNeedNotPrep () const; |
92 uint8_t GetHopCount () const; | 103 uint8_t GetHopCount () const; |
93 uint8_t GetTtl ()const ; | 104 uint8_t GetTtl ()const ; |
94 uint32_t GetPreqID () const; | 105 uint32_t GetPreqID () const; |
95 Mac48Address GetOriginatorAddress () const; | 106 Mac48Address GetOriginatorAddress () const; |
96 uint32_t GetOriginatorSeqNumber () const; | 107 uint32_t GetOriginatorSeqNumber () const; |
97 uint32_t GetLifetime () const; | 108 uint32_t GetLifetime () const; |
98 uint32_t GetMetric () const; | 109 uint32_t GetMetric () const; |
99 uint8_t GetDestCount () const; | 110 uint8_t GetDestCount () const; |
| 111 ///\} |
| 112 /// Handle TTL and Metric: |
100 void DecrementTtl (); | 113 void DecrementTtl (); |
101 void IncrementMetric (uint32_t metric); | 114 void IncrementMetric (uint32_t metric); |
102 /* | 115 /* |
103 * \brief Checks that preq's originator address equals to originator, and | 116 * \brief Checks that preq's originator address equals to originator, and |
104 * this preq is not proactive | 117 * this preq is not proactive |
105 */ | 118 */ |
106 bool MayAddAddress(Mac48Address originator); | 119 bool MayAddAddress (Mac48Address originator); |
107 | 120 bool IsFull () const; |
| 121 /** |
| 122 * \name Inherited from WifiInformationElement |
| 123 * \{ |
| 124 */ |
| 125 virtual WifiElementId ElementId () const; |
| 126 virtual void SerializeInformation (Buffer::Iterator i) const; |
| 127 virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length); |
| 128 virtual uint8_t GetInformationSize () const; |
| 129 virtual void Print (std::ostream& os) const; |
| 130 ///\} |
108 private: | 131 private: |
109 WifiElementId ElementId () const{ | |
110 return IE11S_PREQ; | |
111 } | |
112 void SerializeInformation (Buffer::Iterator i) const; | |
113 uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length); | |
114 uint8_t GetInformationSize () const; | |
115 void PrintInformation (std::ostream& os) const; | |
116 /** | 132 /** |
117 * how many destinations we support | 133 * how many destinations we support |
118 */ | 134 */ |
119 uint8_t m_maxSize; //TODO: make as an attrubute | 135 uint8_t m_maxSize; //TODO: make as an attrubute |
120 /** | 136 /** |
121 * Fields of information element: | 137 * Fields of information element: |
122 */ | 138 */ |
123 uint8_t m_flags; | 139 uint8_t m_flags; |
124 uint8_t m_hopCount; | 140 uint8_t m_hopCount; |
125 uint8_t m_ttl; | 141 uint8_t m_ttl; |
126 uint32_t m_preqId; | 142 uint32_t m_preqId; |
127 Mac48Address m_originatorAddress; | 143 Mac48Address m_originatorAddress; |
128 uint32_t m_originatorSeqNumber; | 144 uint32_t m_originatorSeqNumber; |
129 uint32_t m_lifetime; | 145 uint32_t m_lifetime; |
130 uint32_t m_metric; | 146 uint32_t m_metric; |
131 uint8_t m_destCount; | 147 uint8_t m_destCount; |
132 std::vector<Ptr<DestinationAddressUnit> > m_destinations; | 148 std::vector<Ptr<DestinationAddressUnit> > m_destinations; |
133 | 149 |
134 friend bool operator== (const IePreq & a, const IePreq & b); | 150 friend bool operator== (const IePreq & a, const IePreq & b); |
135 }; | 151 }; |
136 | 152 |
137 bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
& b); | 153 bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
& b); |
138 bool operator== (const IePreq & a, const IePreq & b); | 154 bool operator== (const IePreq & a, const IePreq & b); |
| 155 std::ostream &operator << (std::ostream &os, const IePreq &preq); |
139 | 156 |
140 } // namespace dot11s | 157 } // namespace dot11s |
141 } //namespace ns3 | 158 } //namespace ns3 |
142 #endif | 159 #endif |
143 | 160 |
LEFT | RIGHT |