View | Details | Raw Unified | Return to bug 2496
Collapse All | Expand All

(-)a/src/wifi/model/ap-wifi-mac.cc (-1 / +1 lines)
 Lines 355-361    Link Here 
355
    {
355
    {
356
      for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
356
      for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
357
        {
357
        {
358
          rates.SetBasicRate (m_phy->GetBssMembershipSelector (i));
358
          rates.AddBssMembershipSelectorRate (m_phy->GetBssMembershipSelector (i));
359
        }
359
        }
360
    }
360
    }
361
  // 
361
  // 
(-)a/src/wifi/model/sta-wifi-mac.cc (-1 / +1 lines)
 Lines 785-791    Link Here 
785
    {
785
    {
786
      for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
786
      for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
787
        {
787
        {
788
          rates.SetBasicRate (m_phy->GetBssMembershipSelector (i));
788
          rates.AddBssMembershipSelectorRate (m_phy->GetBssMembershipSelector (i));
789
        }
789
        }
790
    }
790
    }
791
  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
791
  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
(-)a/src/wifi/model/supported-rates.cc (-5 / +65 lines)
 Lines 26-39    Link Here 
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
 Lines 53-71    Link Here 
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
    {
 Lines 84-92    Link Here 
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
    {
 Lines 101-106    Link Here 
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
    {
 Lines 113-118    Link Here 
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
{
(-)a/src/wifi/model/supported-rates.h (-4 / +24 lines)
 Lines 129-137    Link Here 
129
   * \param bs the rate to be set
129
   * \param bs the rate to be set
130
   */
130
   */
131
  void SetBasicRate (uint32_t bs);
131
  void SetBasicRate (uint32_t bs);
132
133
  /**
132
  /**
134
   * Check if the given rate is supported.
133
   * Add a special value to the supported rate set, corresponding to
134
   * a BSS membership selector
135
   *
136
   * \param bs the special membership selector value (not a valid rate)
137
   */
138
  void AddBssMembershipSelectorRate (uint32_t bs);
139
  /**
140
   * Check if the given rate is supported.  The rate is encoded as it is
141
   * serialized to the Supported Rates Information Element (i.e. as a
142
   * multiple of 500 Kbits/sec, possibly with MSB set to 1).
135
   *
143
   *
136
   * \param bs the rate to be checked
144
   * \param bs the rate to be checked
137
   *
145
   *
 Lines 139-152    Link Here 
139
   */
147
   */
140
  bool IsSupportedRate (uint32_t bs) const;
148
  bool IsSupportedRate (uint32_t bs) const;
141
  /**
149
  /**
142
   * Check if the given rate is a basic rate.
150
   * Check if the given rate is a basic rate.  The rate is encoded as it is
151
   * serialized to the Supported Rates Information Element (i.e. as a
152
   * multiple of 500 Kbits/sec, with MSB set to 1).
143
   *
153
   *
144
   * \param bs the rate to be checked
154
   * \param bs the rate to be checked
145
   *
155
   *
146
   * \return true if the rate is a basic rate, false otherwise
156
   * \return true if the rate is a basic rate, false otherwise
147
   */
157
   */
148
  bool IsBasicRate (uint32_t bs) const;
158
  bool IsBasicRate (uint32_t bs) const;
149
159
  /**
160
   * Check if the given rate is a BSS membership selector value.  The rate
161
   * is encoded as it is serialized to the Supporting Rates Information
162
   * Element (i.e. with the MSB set to 1).
163
   *
164
   * \param bs the rate to be checked
165
   *
166
   * \return true if the rate is a BSS membership selector, false otherwise
167
   */
168
  bool IsBssMembershipSelectorRate (uint32_t bs) const;
150
  /**
169
  /**
151
   * Return the number of supported rates.
170
   * Return the number of supported rates.
152
   *
171
   *
 Lines 155-160    Link Here 
155
  uint8_t GetNRates (void) const;
174
  uint8_t GetNRates (void) const;
156
  /**
175
  /**
157
   * Return the rate at the given index.
176
   * Return the rate at the given index.
177
   * Return the rate (converted back to raw value) at the given index.
158
   *
178
   *
159
   * \param i the given index
179
   * \param i the given index
160
   * \return the rate
180
   * \return the rate

Return to bug 2496