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, 2009 INRIA | 3 * Copyright (c) 2006, 2009 INRIA |
4 * Copyright (c) 2009 MIRKO BANCHI | 4 * Copyright (c) 2009 MIRKO BANCHI |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 bool | 194 bool |
195 ApWifiMac::GetShortSlotTimeEnabled (void) const | 195 ApWifiMac::GetShortSlotTimeEnabled (void) const |
196 { | 196 { |
197 if (m_nonErpStations.size () != 0) | 197 if (m_nonErpStations.size () != 0) |
198 { | 198 { |
199 return false; | 199 return false; |
200 } | 200 } |
201 if (m_erpSupported == true && GetShortSlotTimeSupported () == true) | 201 if (m_erpSupported == true && GetShortSlotTimeSupported () == true) |
202 { | 202 { |
203 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i !=
m_staList.end (); i++) | 203 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin
(); i != m_staList.end (); i++) |
204 { | 204 { |
205 if (m_stationManager->GetShortSlotTimeSupported (*i) == false) | 205 if (m_stationManager->GetShortSlotTimeSupported (i->second) == false) |
206 { | 206 { |
207 return false; | 207 return false; |
208 } | 208 } |
209 } | 209 } |
210 return true; | 210 return true; |
211 } | 211 } |
212 return false; | 212 return false; |
213 } | 213 } |
214 | 214 |
215 bool | 215 bool |
(...skipping 10 matching lines...) Expand all Loading... |
226 } | 226 } |
227 return true; | 227 return true; |
228 } | 228 } |
229 return false; | 229 return false; |
230 } | 230 } |
231 | 231 |
232 bool | 232 bool |
233 ApWifiMac::IsNonGfHtStasPresent (void) const | 233 ApWifiMac::IsNonGfHtStasPresent (void) const |
234 { | 234 { |
235 bool isNonGfHtStasPresent = false; | 235 bool isNonGfHtStasPresent = false; |
236 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_st
aList.end (); i++) | 236 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin ();
i != m_staList.end (); i++) |
237 { | 237 { |
238 if (m_stationManager->GetGreenfieldSupported (*i) == false) | 238 if (m_stationManager->GetGreenfieldSupported (i->second) == false) |
239 { | 239 { |
240 isNonGfHtStasPresent = true; | 240 isNonGfHtStasPresent = true; |
241 break; | 241 break; |
242 } | 242 } |
243 } | 243 } |
244 m_stationManager->SetUseGreenfieldProtection (isNonGfHtStasPresent); | 244 m_stationManager->SetUseGreenfieldProtection (isNonGfHtStasPresent); |
245 return isNonGfHtStasPresent; | 245 return isNonGfHtStasPresent; |
246 } | 246 } |
247 | 247 |
248 uint8_t | 248 uint8_t |
249 ApWifiMac::GetVhtOperationalChannelWidth (void) const | 249 ApWifiMac::GetVhtOperationalChannelWidth (void) const |
250 { | 250 { |
251 uint8_t channelWidth = m_phy->GetChannelWidth (); | 251 uint8_t channelWidth = m_phy->GetChannelWidth (); |
252 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_st
aList.end (); i++) | 252 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin ();
i != m_staList.end (); i++) |
253 { | 253 { |
254 if (m_stationManager->GetVhtSupported (*i)) | 254 if (m_stationManager->GetVhtSupported (i->second)) |
255 { | 255 { |
256 if (m_stationManager->GetChannelWidthSupported (*i) < channelWidth) | 256 if (m_stationManager->GetChannelWidthSupported (i->second) < channelWi
dth) |
257 { | 257 { |
258 channelWidth = m_stationManager->GetChannelWidthSupported (*i); | 258 channelWidth = m_stationManager->GetChannelWidthSupported (i->seco
nd); |
259 } | 259 } |
260 } | 260 } |
261 } | 261 } |
262 return channelWidth; | 262 return channelWidth; |
263 } | 263 } |
264 | 264 |
265 void | 265 void |
266 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, | 266 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, |
267 Mac48Address to) | 267 Mac48Address to) |
268 { | 268 { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 NS_ASSERT (nss > 0 && nss < 5); | 548 NS_ASSERT (nss > 0 && nss < 5); |
549 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy-
>GetShortGuardInterval () ? 400 : 800, nss); | 549 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy-
>GetShortGuardInterval () ? 400 : 800, nss); |
550 if (dataRate > maxSupportedRate) | 550 if (dataRate > maxSupportedRate) |
551 { | 551 { |
552 maxSupportedRate = dataRate; | 552 maxSupportedRate = dataRate; |
553 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate)
; | 553 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate)
; |
554 } | 554 } |
555 } | 555 } |
556 uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams (); | 556 uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams (); |
557 uint8_t nMcs = m_phy->GetNMcs (); | 557 uint8_t nMcs = m_phy->GetNMcs (); |
558 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i !=
m_staList.end (); i++) | 558 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin
(); i != m_staList.end (); i++) |
559 { | 559 { |
560 if (m_stationManager->GetHtSupported (*i)) | 560 if (m_stationManager->GetHtSupported (i->second)) |
561 { | 561 { |
562 uint64_t maxSupportedRateByHtSta = 0; //in bit/s | 562 uint64_t maxSupportedRateByHtSta = 0; //in bit/s |
563 for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcs
Supported (*i))); j++) | 563 for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcs
Supported (i->second))); j++) |
564 { | 564 { |
565 WifiMode mcs = m_phy->GetMcs (j); | 565 WifiMode mcs = m_phy->GetMcs (j); |
566 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT) | 566 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT) |
567 { | 567 { |
568 continue; | 568 continue; |
569 } | 569 } |
570 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; | 570 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; |
571 NS_ASSERT (nss > 0 && nss < 5); | 571 NS_ASSERT (nss > 0 && nss < 5); |
572 uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChan
nelWidthSupported (*i), m_stationManager->GetShortGuardInterval (*i) ? 400 : 800
, nss); | 572 uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChan
nelWidthSupported (i->second), m_stationManager->GetShortGuardInterval (i->secon
d) ? 400 : 800, nss); |
573 if (dataRate > maxSupportedRateByHtSta) | 573 if (dataRate > maxSupportedRateByHtSta) |
574 { | 574 { |
575 maxSupportedRateByHtSta = dataRate; | 575 maxSupportedRateByHtSta = dataRate; |
576 } | 576 } |
577 } | 577 } |
578 if (maxSupportedRateByHtSta < maxSupportedRate) | 578 if (maxSupportedRateByHtSta < maxSupportedRate) |
579 { | 579 { |
580 maxSupportedRate = maxSupportedRateByHtSta; | 580 maxSupportedRate = maxSupportedRateByHtSta; |
581 } | 581 } |
582 if (m_stationManager->GetNMcsSupported (*i) < nMcs) | 582 if (m_stationManager->GetNMcsSupported (i->second) < nMcs) |
583 { | 583 { |
584 nMcs = m_stationManager->GetNMcsSupported (*i); | 584 nMcs = m_stationManager->GetNMcsSupported (i->second); |
585 } | 585 } |
586 if (m_stationManager->GetNumberOfSupportedStreams (*i) < maxSpatia
lStream) | 586 if (m_stationManager->GetNumberOfSupportedStreams (i->second) < ma
xSpatialStream) |
587 { | 587 { |
588 maxSpatialStream = m_stationManager->GetNumberOfSupportedStrea
ms (*i); | 588 maxSpatialStream = m_stationManager->GetNumberOfSupportedStrea
ms (i->second); |
589 } | 589 } |
590 } | 590 } |
591 } | 591 } |
592 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t>(maxSupporte
dRate / 1e6)); //in Mbit/s | 592 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t>(maxSupporte
dRate / 1e6)); //in Mbit/s |
593 operation.SetTxMcsSetDefined (nMcs > 0); | 593 operation.SetTxMcsSetDefined (nMcs > 0); |
594 operation.SetTxMaxNSpatialStreams (maxSpatialStream); | 594 operation.SetTxMaxNSpatialStreams (maxSpatialStream); |
595 //To be filled in once supported | 595 //To be filled in once supported |
596 operation.SetObssNonHtStasPresent (0); | 596 operation.SetObssNonHtStasPresent (0); |
597 operation.SetDualBeacon (0); | 597 operation.SetDualBeacon (0); |
598 operation.SetDualCtsProtection (0); | 598 operation.SetDualCtsProtection (0); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 hdr.SetAddr3 (GetAddress ()); | 729 hdr.SetAddr3 (GetAddress ()); |
730 hdr.SetDsNotFrom (); | 730 hdr.SetDsNotFrom (); |
731 hdr.SetDsNotTo (); | 731 hdr.SetDsNotTo (); |
732 hdr.SetNoOrder (); | 732 hdr.SetNoOrder (); |
733 Ptr<Packet> packet = Create<Packet> (); | 733 Ptr<Packet> packet = Create<Packet> (); |
734 MgtAssocResponseHeader assoc; | 734 MgtAssocResponseHeader assoc; |
735 StatusCode code; | 735 StatusCode code; |
736 if (success) | 736 if (success) |
737 { | 737 { |
738 code.SetSuccess (); | 738 code.SetSuccess (); |
739 m_staList.push_back (to); | 739 uint16_t aid = GetNextAssociationId (); |
| 740 m_staList.insert (std::make_pair (aid, to)); |
| 741 assoc.SetAssociationId (aid); |
740 } | 742 } |
741 else | 743 else |
742 { | 744 { |
743 code.SetFailure (); | 745 code.SetFailure (); |
744 } | 746 } |
745 assoc.SetSupportedRates (GetSupportedRates ()); | 747 assoc.SetSupportedRates (GetSupportedRates ()); |
746 assoc.SetStatusCode (code); | 748 assoc.SetStatusCode (code); |
747 assoc.SetCapabilities (GetCapabilities ()); | 749 assoc.SetCapabilities (GetCapabilities ()); |
748 if (m_erpSupported) | 750 if (m_erpSupported) |
749 { | 751 { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 m_nonErpStations.push_back (hdr->GetAddr2 ()); | 1142 m_nonErpStations.push_back (hdr->GetAddr2 ()); |
1141 } | 1143 } |
1142 // send assoc response with success status. | 1144 // send assoc response with success status. |
1143 SendAssocResp (hdr->GetAddr2 (), true); | 1145 SendAssocResp (hdr->GetAddr2 (), true); |
1144 } | 1146 } |
1145 return; | 1147 return; |
1146 } | 1148 } |
1147 else if (hdr->IsDisassociation ()) | 1149 else if (hdr->IsDisassociation ()) |
1148 { | 1150 { |
1149 m_stationManager->RecordDisassociated (from); | 1151 m_stationManager->RecordDisassociated (from); |
1150 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (
); i != m_staList.end (); i++) | 1152 for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staLis
t.begin (); j != m_staList.end (); j++) |
1151 { | 1153 { |
1152 if ((*i) == from) | 1154 if (j->second == from) |
1153 { | 1155 { |
1154 m_staList.erase (i); | 1156 m_staList.erase (j); |
1155 break; | 1157 break; |
1156 } | 1158 } |
1157 } | 1159 } |
1158 for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.
begin (); j != m_nonErpStations.end (); j++) | 1160 for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.
begin (); j != m_nonErpStations.end (); j++) |
1159 { | 1161 { |
1160 if ((*j) == from) | 1162 if ((*j) == from) |
1161 { | 1163 { |
1162 m_nonErpStations.erase (j); | 1164 m_nonErpStations.erase (j); |
1163 break; | 1165 break; |
1164 } | 1166 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 { | 1256 { |
1255 m_stationManager->SetRifsPermitted (true); | 1257 m_stationManager->SetRifsPermitted (true); |
1256 } | 1258 } |
1257 else | 1259 else |
1258 { | 1260 { |
1259 m_stationManager->SetRifsPermitted (false); | 1261 m_stationManager->SetRifsPermitted (false); |
1260 } | 1262 } |
1261 return rifsMode; | 1263 return rifsMode; |
1262 } | 1264 } |
1263 | 1265 |
| 1266 uint16_t |
| 1267 ApWifiMac::GetNextAssociationId (void) |
| 1268 { |
| 1269 //Return the first free AID value between 1 and 2007 |
| 1270 for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++) |
| 1271 { |
| 1272 if (m_staList.find (nextAid) == m_staList.end ()) |
| 1273 { |
| 1274 return nextAid; |
| 1275 } |
| 1276 } |
| 1277 NS_ASSERT_MSG (false, "No free association ID available!"); |
| 1278 return 0; |
| 1279 } |
| 1280 |
1264 } //namespace ns3 | 1281 } //namespace ns3 |
LEFT | RIGHT |