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) 2009 Duy Nguyen | 3 * Copyright (c) 2009 Duy Nguyen |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "minstrel-wifi-manager.h" | 31 #include "minstrel-wifi-manager.h" |
32 #include "wifi-phy.h" | 32 #include "wifi-phy.h" |
33 #include "ns3/simulator.h" | 33 #include "ns3/simulator.h" |
34 #include "ns3/log.h" | 34 #include "ns3/log.h" |
35 #include "ns3/uinteger.h" | 35 #include "ns3/uinteger.h" |
36 #include "ns3/double.h" | 36 #include "ns3/double.h" |
37 #include "ns3/wifi-mac.h" | 37 #include "ns3/wifi-mac.h" |
38 #include "ns3/assert.h" | 38 #include "ns3/assert.h" |
39 #include <vector> | 39 #include <vector> |
| 40 |
| 41 #define Min(a,b) ((a < b) ? a : b) |
40 | 42 |
41 NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager"); | 43 NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager"); |
42 | 44 |
43 | 45 |
44 namespace ns3 { | 46 namespace ns3 { |
45 | 47 |
46 | 48 |
47 struct MinstrelWifiRemoteStation : public WifiRemoteStation | 49 struct MinstrelWifiRemoteStation : public WifiRemoteStation |
48 { | 50 { |
49 Time m_nextStatsUpdate; ///< 10 times every second | 51 Time m_nextStatsUpdate; ///< 10 times every second |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 { | 126 { |
125 } | 127 } |
126 | 128 |
127 void | 129 void |
128 MinstrelWifiManager::SetupPhy (Ptr<WifiPhy> phy) | 130 MinstrelWifiManager::SetupPhy (Ptr<WifiPhy> phy) |
129 { | 131 { |
130 uint32_t nModes = phy->GetNModes (); | 132 uint32_t nModes = phy->GetNModes (); |
131 for (uint32_t i = 0; i < nModes; i++) | 133 for (uint32_t i = 0; i < nModes; i++) |
132 { | 134 { |
133 WifiMode mode = phy->GetMode (i); | 135 WifiMode mode = phy->GetMode (i); |
134 AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, mode, WIFI_PREAMB
LE_LONG)); | 136 WifiTxVector txVector; |
| 137 txVector.SetMode(mode); |
| 138 AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PR
EAMBLE_LONG)); |
135 } | 139 } |
136 WifiRemoteStationManager::SetupPhy (phy); | 140 WifiRemoteStationManager::SetupPhy (phy); |
137 } | 141 } |
138 | 142 |
139 int64_t | 143 int64_t |
140 MinstrelWifiManager::AssignStreams (int64_t stream) | 144 MinstrelWifiManager::AssignStreams (int64_t stream) |
141 { | 145 { |
142 NS_LOG_FUNCTION (this << stream); | 146 NS_LOG_FUNCTION (this << stream); |
143 m_uniformRandomVariable->SetStream (stream); | 147 m_uniformRandomVariable->SetStream (stream); |
144 return 1; | 148 return 1; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 427 } |
424 | 428 |
425 void | 429 void |
426 MinstrelWifiManager::UpdateRetry (MinstrelWifiRemoteStation *station) | 430 MinstrelWifiManager::UpdateRetry (MinstrelWifiRemoteStation *station) |
427 { | 431 { |
428 station->m_retry = station->m_shortRetry + station->m_longRetry; | 432 station->m_retry = station->m_shortRetry + station->m_longRetry; |
429 station->m_shortRetry = 0; | 433 station->m_shortRetry = 0; |
430 station->m_longRetry = 0; | 434 station->m_longRetry = 0; |
431 } | 435 } |
432 | 436 |
433 WifiMode | 437 WifiTxVector |
434 MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st, | 438 MinstrelWifiManager::DoGetDataTxVector (WifiRemoteStation *st, |
435 uint32_t size) | 439 uint32_t size) |
436 { | 440 { |
437 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; | 441 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
438 if (!station->m_initialized) | 442 if (!station->m_initialized) |
439 { | 443 { |
440 CheckInit (station); | 444 CheckInit (station); |
441 | 445 |
442 /// start the rate at half way | 446 /// start the rate at half way |
443 station->m_txrate = m_nsupported / 2; | 447 station->m_txrate = m_nsupported / 2; |
444 } | 448 } |
445 UpdateStats (station); | 449 UpdateStats (station); |
446 return GetSupported (station, station->m_txrate); | 450 return WifiTxVector (GetSupported (station, station->m_txrate), GetDefaultTxPo
werLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (
GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOf
TransmitAntennas (station), GetStbc (station)); |
447 } | 451 } |
448 | 452 |
449 WifiMode | 453 WifiTxVector |
450 MinstrelWifiManager::DoGetRtsMode (WifiRemoteStation *st) | 454 MinstrelWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
451 { | 455 { |
452 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; | 456 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
453 NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate); | 457 NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate); |
454 | 458 |
455 return GetSupported (station, 0); | 459 return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel (), Get
ShortRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfRece
iveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntenna
s (station), GetStbc (station)); |
456 } | 460 } |
457 | 461 |
458 bool | 462 bool |
459 MinstrelWifiManager::IsLowLatency (void) const | 463 MinstrelWifiManager::IsLowLatency (void) const |
460 { | 464 { |
461 return true; | 465 return true; |
462 } | 466 } |
463 uint32_t | 467 uint32_t |
464 MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station) | 468 MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station) |
465 { | 469 { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 std::cout << "index(" << i << ") = " << m_minstrelTable[i].perfectTxTime <
< "\n"; | 794 std::cout << "index(" << i << ") = " << m_minstrelTable[i].perfectTxTime <
< "\n"; |
791 } | 795 } |
792 } | 796 } |
793 | 797 |
794 } // namespace ns3 | 798 } // namespace ns3 |
795 | 799 |
796 | 800 |
797 | 801 |
798 | 802 |
799 | 803 |
LEFT | RIGHT |