|
26 |
|
26 |
|
27 |
NS_LOG_COMPONENT_DEFINE ("SupportedRates"); |
27 |
NS_LOG_COMPONENT_DEFINE ("SupportedRates"); |
28 |
|
28 |
|
|
|
29 |
#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 |
30 |
#define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126 |
31 |
|
29 |
SupportedRates::SupportedRates () |
32 |
SupportedRates::SupportedRates () |
30 |
: extended (this), |
33 |
: extended (this), |
31 |
m_nRates (0) |
34 |
m_nRates (0) |
32 |
{ |
35 |
{ |
|
|
36 |
NS_LOG_FUNCTION (this); |
33 |
} |
37 |
} |
34 |
|
38 |
|
35 |
SupportedRates::SupportedRates (const SupportedRates &rates) |
39 |
SupportedRates::SupportedRates (const SupportedRates &rates) |
36 |
{ |
40 |
{ |
|
|
41 |
NS_LOG_FUNCTION (this); |
37 |
m_nRates = rates.m_nRates; |
42 |
m_nRates = rates.m_nRates; |
38 |
memcpy (m_rates, rates.m_rates, MAX_SUPPORTED_RATES); |
43 |
memcpy (m_rates, rates.m_rates, MAX_SUPPORTED_RATES); |
39 |
//reset the back pointer to this object |
44 |
//reset the back pointer to this object |
|
53 |
void |
58 |
void |
54 |
SupportedRates::AddSupportedRate (uint32_t bs) |
59 |
SupportedRates::AddSupportedRate (uint32_t bs) |
55 |
{ |
60 |
{ |
|
|
61 |
NS_LOG_FUNCTION (this << bs); |
62 |
NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); |
56 |
NS_ASSERT (m_nRates < MAX_SUPPORTED_RATES); |
63 |
NS_ASSERT (m_nRates < MAX_SUPPORTED_RATES); |
57 |
if (IsSupportedRate (bs)) |
64 |
if (bs == BSS_MEMBERSHIP_SELECTOR_HT_PHY) |
58 |
{ |
65 |
{ |
59 |
return; |
66 |
// Encoding defined in Sec. 8.4.2.3, IEEE 802.11-2012 |
|
|
67 |
m_rates[m_nRates] = (BSS_MEMBERSHIP_SELECTOR_HT_PHY | 0x80); |
68 |
m_nRates++; |
69 |
NS_LOG_DEBUG ("add HT_PHY membership selector"); |
60 |
} |
70 |
} |
61 |
m_rates[m_nRates] = bs / 500000; |
71 |
else if (bs == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) |
62 |
m_nRates++; |
72 |
{ |
63 |
NS_LOG_DEBUG ("add rate=" << bs << ", n rates=" << (uint32_t)m_nRates); |
73 |
// Encoding defined in Sec. 8.4.2.3, IEEE 802.11-2012 |
|
|
74 |
m_rates[m_nRates] = (BSS_MEMBERSHIP_SELECTOR_VHT_PHY | 0x80); |
75 |
m_nRates++; |
76 |
NS_LOG_DEBUG ("add VHT_PHY membership selector"); |
77 |
} |
78 |
else |
79 |
{ |
80 |
if (IsSupportedRate (bs)) |
81 |
{ |
82 |
return; |
83 |
} |
84 |
m_rates[m_nRates] = bs / 500000; |
85 |
m_nRates++; |
86 |
NS_LOG_DEBUG ("add rate=" << bs << ", n rates=" << (uint32_t)m_nRates); |
87 |
} |
64 |
} |
88 |
} |
65 |
|
89 |
|
66 |
void |
90 |
void |
67 |
SupportedRates::SetBasicRate (uint32_t bs) |
91 |
SupportedRates::SetBasicRate (uint32_t bs) |
68 |
{ |
92 |
{ |
|
|
93 |
NS_LOG_FUNCTION (this << bs); |
94 |
NS_ASSERT_MSG (IsBssMembershipSelectorRate (bs) == false, "Invalid rate"); |
69 |
uint8_t rate = bs / 500000; |
95 |
uint8_t rate = bs / 500000; |
70 |
for (uint8_t i = 0; i < m_nRates; i++) |
96 |
for (uint8_t i = 0; i < m_nRates; i++) |
71 |
{ |
97 |
{ |
|
84 |
SetBasicRate (bs); |
110 |
SetBasicRate (bs); |
85 |
} |
111 |
} |
86 |
|
112 |
|
|
|
113 |
void |
114 |
SupportedRates::AddBssMembershipSelectorRate (uint32_t bs) |
115 |
{ |
116 |
NS_LOG_FUNCTION (this << bs); |
117 |
if ((bs != BSS_MEMBERSHIP_SELECTOR_HT_PHY) && (bs != BSS_MEMBERSHIP_SELECTOR_VHT_PHY)) |
118 |
{ |
119 |
NS_ASSERT_MSG (false, "Value " << bs << " not a BSS Membership Selector"); |
120 |
} |
121 |
uint32_t rate = (bs | 0x80); |
122 |
for (uint8_t i = 0; i < m_nRates; i++) |
123 |
{ |
124 |
if (rate == m_rates[i]) |
125 |
{ |
126 |
return; |
127 |
} |
128 |
} |
129 |
m_rates[m_nRates] = rate; |
130 |
NS_LOG_DEBUG ("add BSS membership selector rate " << bs << " as rate " << m_nRates); |
131 |
m_nRates++; |
132 |
} |
133 |
|
87 |
bool |
134 |
bool |
88 |
SupportedRates::IsBasicRate (uint32_t bs) const |
135 |
SupportedRates::IsBasicRate (uint32_t bs) const |
89 |
{ |
136 |
{ |
|
|
137 |
NS_LOG_FUNCTION (this << bs); |
90 |
uint8_t rate = (bs / 500000) | 0x80; |
138 |
uint8_t rate = (bs / 500000) | 0x80; |
91 |
for (uint8_t i = 0; i < m_nRates; i++) |
139 |
for (uint8_t i = 0; i < m_nRates; i++) |
92 |
{ |
140 |
{ |
|
101 |
bool |
149 |
bool |
102 |
SupportedRates::IsSupportedRate (uint32_t bs) const |
150 |
SupportedRates::IsSupportedRate (uint32_t bs) const |
103 |
{ |
151 |
{ |
|
|
152 |
NS_LOG_FUNCTION (this << bs); |
104 |
uint8_t rate = bs / 500000; |
153 |
uint8_t rate = bs / 500000; |
105 |
for (uint8_t i = 0; i < m_nRates; i++) |
154 |
for (uint8_t i = 0; i < m_nRates; i++) |
106 |
{ |
155 |
{ |
|
113 |
return false; |
162 |
return false; |
114 |
} |
163 |
} |
115 |
|
164 |
|
|
|
165 |
bool |
166 |
SupportedRates::IsBssMembershipSelectorRate (uint32_t bs) const |
167 |
{ |
168 |
NS_LOG_FUNCTION (this << bs); |
169 |
if ( (bs & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY || (bs & 0x7f) == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) |
170 |
{ |
171 |
return true; |
172 |
} |
173 |
return false; |
174 |
} |
175 |
|
116 |
uint8_t |
176 |
uint8_t |
117 |
SupportedRates::GetNRates (void) const |
177 |
SupportedRates::GetNRates (void) const |
118 |
{ |
178 |
{ |