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) 2006 INRIA | 3 * Copyright (c) 2006 INRIA |
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
| 21 #include "ns3/log.h" |
21 #include "supported-rates.h" | 22 #include "supported-rates.h" |
22 #include "ns3/log.h" | |
23 | 23 |
24 namespace ns3 { | 24 namespace ns3 { |
25 | 25 |
26 NS_LOG_COMPONENT_DEFINE ("SupportedRates"); | 26 NS_LOG_COMPONENT_DEFINE ("SupportedRates"); |
27 | 27 |
28 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 | 28 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 |
29 #define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126 | 29 #define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126 |
30 #define BSS_MEMBERSHIP_SELECTOR_HE_PHY 125 | 30 #define BSS_MEMBERSHIP_SELECTOR_HE_PHY 125 |
31 | 31 |
32 SupportedRates::SupportedRates () | 32 SupportedRates::SupportedRates () |
(...skipping 21 matching lines...) Expand all Loading... |
54 this->extended.SetSupportedRates (this); | 54 this->extended.SetSupportedRates (this); |
55 return (*this); | 55 return (*this); |
56 } | 56 } |
57 | 57 |
58 void | 58 void |
59 SupportedRates::AddSupportedRate (uint64_t bs) | 59 SupportedRates::AddSupportedRate (uint64_t bs) |
60 { | 60 { |
61 NS_LOG_FUNCTION (this << bs); | 61 NS_LOG_FUNCTION (this << bs); |
62 NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); | 62 NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); |
63 NS_ASSERT (m_nRates < MAX_SUPPORTED_RATES); | 63 NS_ASSERT (m_nRates < MAX_SUPPORTED_RATES); |
64 if (bs == BSS_MEMBERSHIP_SELECTOR_HT_PHY) | 64 if (IsSupportedRate (bs)) |
65 { | 65 { |
66 // Encoding defined in Sec. 8.4.2.3, IEEE 802.11-2012 | 66 return; |
67 m_rates[m_nRates] = (BSS_MEMBERSHIP_SELECTOR_HT_PHY | 0x80); | 67 } |
68 m_nRates++; | 68 m_rates[m_nRates] = static_cast<uint8_t> (bs / 500000); |
69 NS_LOG_DEBUG ("add HT_PHY membership selector"); | 69 m_nRates++; |
70 } | 70 NS_LOG_DEBUG ("add rate=" << bs << ", n rates=" << +m_nRates); |
71 else if (bs == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) | 71 } |
72 { | 72 |
73 // Encoding defined in Sec. 8.4.2.3, IEEE 802.11-2012 | 73 void |
74 m_rates[m_nRates] = (BSS_MEMBERSHIP_SELECTOR_VHT_PHY | 0x80); | 74 SupportedRates::SetBasicRate (uint64_t bs) |
75 m_nRates++; | 75 { |
76 NS_LOG_DEBUG ("add VHT_PHY membership selector"); | 76 NS_LOG_FUNCTION (this << bs); |
77 } | 77 NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); |
78 else if (bs == BSS_MEMBERSHIP_SELECTOR_HE_PHY) | 78 uint8_t rate = static_cast<uint8_t> (bs / 500000); |
79 { | 79 for (uint8_t i = 0; i < m_nRates; i++) |
80 // Encoding defined in Sec. 8.4.2.3, IEEE 802.11-2012 | 80 { |
81 m_rates[m_nRates] = (BSS_MEMBERSHIP_SELECTOR_HE_PHY | 0x80); | 81 if ((rate | 0x80) == m_rates[i]) |
82 m_nRates++; | |
83 NS_LOG_DEBUG ("add HE_PHY membership selector"); | |
84 } | |
85 else | |
86 { | |
87 if (IsSupportedRate (bs)) | |
88 { | 82 { |
89 return; | 83 return; |
90 } | 84 } |
91 m_rates[m_nRates] = static_cast<uint8_t>(bs / 500000); | |
92 m_nRates++; | |
93 NS_LOG_DEBUG ("add rate=" << bs << ", n rates=" << static_cast<uint16_t> (
m_nRates)); | |
94 } | |
95 } | |
96 | |
97 void | |
98 SupportedRates::SetBasicRate (uint32_t bs) | |
99 { | |
100 NS_LOG_FUNCTION (this << bs); | |
101 NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); | |
102 uint8_t rate = static_cast<uint8_t>(bs / 500000); | |
103 for (uint8_t i = 0; i < m_nRates; i++) | |
104 { | |
105 if ((rate | 0x80) == m_rates[i]) | |
106 { | |
107 return; | |
108 } | |
109 if (rate == m_rates[i]) | 85 if (rate == m_rates[i]) |
110 { | 86 { |
111 NS_LOG_DEBUG ("set basic rate=" << bs << ", n rates=" << static_cast<u
int16_t> (m_nRates)); | 87 NS_LOG_DEBUG ("set basic rate=" << bs << ", n rates=" << +m_nRates); |
112 m_rates[i] |= 0x80; | 88 m_rates[i] |= 0x80; |
113 return; | 89 return; |
114 } | 90 } |
115 } | 91 } |
116 AddSupportedRate (bs); | 92 AddSupportedRate (bs); |
117 SetBasicRate (bs); | 93 SetBasicRate (bs); |
118 } | 94 } |
119 | 95 |
120 void | 96 void |
121 SupportedRates::AddBssMembershipSelectorRate (uint32_t bs) | 97 SupportedRates::AddBssMembershipSelectorRate (uint32_t bs) |
122 { | 98 { |
123 NS_LOG_FUNCTION (this << bs); | 99 NS_LOG_FUNCTION (this << bs); |
124 if ((bs != BSS_MEMBERSHIP_SELECTOR_HT_PHY) && (bs != BSS_MEMBERSHIP_SELECTOR_V
HT_PHY) && (bs != BSS_MEMBERSHIP_SELECTOR_HE_PHY)) | 100 if ((bs != BSS_MEMBERSHIP_SELECTOR_HT_PHY) && (bs != BSS_MEMBERSHIP_SELECTOR_V
HT_PHY) && (bs != BSS_MEMBERSHIP_SELECTOR_HE_PHY)) |
125 { | 101 { |
126 NS_ASSERT_MSG (false, "Value " << bs << " not a BSS Membership Selector"); | 102 NS_ASSERT_MSG (false, "Value " << bs << " not a BSS Membership Selector"); |
127 } | 103 } |
128 uint32_t rate = (bs | 0x80); | 104 uint32_t rate = (bs | 0x80); |
129 for (uint8_t i = 0; i < m_nRates; i++) | 105 for (uint8_t i = 0; i < m_nRates; i++) |
130 { | 106 { |
131 if (rate == m_rates[i]) | 107 if (rate == m_rates[i]) |
132 { | 108 { |
133 return; | 109 return; |
134 } | 110 } |
135 } | 111 } |
136 m_rates[m_nRates] = static_cast<uint8_t>(rate); | 112 m_rates[m_nRates] = static_cast<uint8_t> (rate); |
137 NS_LOG_DEBUG ("add BSS membership selector rate " << bs << " as rate " << m_nR
ates); | 113 NS_LOG_DEBUG ("add BSS membership selector rate " << bs << " as rate " << m_nR
ates); |
138 m_nRates++; | 114 m_nRates++; |
139 } | 115 } |
140 | 116 |
141 bool | 117 bool |
142 SupportedRates::IsBasicRate (uint32_t bs) const | 118 SupportedRates::IsBasicRate (uint64_t bs) const |
143 { | 119 { |
144 NS_LOG_FUNCTION (this << bs); | 120 NS_LOG_FUNCTION (this << bs); |
145 uint8_t rate = static_cast<uint8_t>(bs / 500000) | 0x80; | 121 uint8_t rate = static_cast<uint8_t> (bs / 500000) | 0x80; |
146 for (uint8_t i = 0; i < m_nRates; i++) | 122 for (uint8_t i = 0; i < m_nRates; i++) |
147 { | 123 { |
148 if (rate == m_rates[i]) | 124 if (rate == m_rates[i]) |
149 { | 125 { |
150 return true; | 126 return true; |
151 } | 127 } |
152 } | 128 } |
153 return false; | 129 return false; |
154 } | 130 } |
155 | 131 |
156 bool | 132 bool |
157 SupportedRates::IsSupportedRate (uint64_t bs) const | 133 SupportedRates::IsSupportedRate (uint64_t bs) const |
158 { | 134 { |
159 NS_LOG_FUNCTION (this << bs); | 135 NS_LOG_FUNCTION (this << bs); |
160 uint8_t rate = static_cast<uint8_t>(bs / 500000); | 136 uint8_t rate = static_cast<uint8_t> (bs / 500000); |
161 for (uint8_t i = 0; i < m_nRates; i++) | 137 for (uint8_t i = 0; i < m_nRates; i++) |
162 { | 138 { |
163 if (rate == m_rates[i] | 139 if (rate == m_rates[i] |
164 || (rate | 0x80) == m_rates[i]) | 140 || (rate | 0x80) == m_rates[i]) |
165 { | 141 { |
166 return true; | 142 return true; |
167 } | 143 } |
168 } | 144 } |
169 return false; | 145 return false; |
170 } | 146 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 if (i < rates.GetNRates () - 1) | 316 if (i < rates.GetNRates () - 1) |
341 { | 317 { |
342 os << " "; | 318 os << " "; |
343 } | 319 } |
344 } | 320 } |
345 os << "]"; | 321 os << "]"; |
346 return os; | 322 return os; |
347 } | 323 } |
348 | 324 |
349 } //namespace ns3 | 325 } //namespace ns3 |
LEFT | RIGHT |