src/wifi/model/minstrel-wifi-manager.cc
changeset 10139 17a71cd49da3
parent 8981 7e1c95c4d1a7
child 10218 97da49da2d6c
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
    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 {
   134 {
   136 {
   135   uint32_t nModes = phy->GetNModes ();
   137   uint32_t nModes = phy->GetNModes ();
   136   for (uint32_t i = 0; i < nModes; i++)
   138   for (uint32_t i = 0; i < nModes; i++)
   137     {
   139     {
   138       WifiMode mode = phy->GetMode (i);
   140       WifiMode mode = phy->GetMode (i);
   139       AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, mode, WIFI_PREAMBLE_LONG));
   141       WifiTxVector txVector;
       
   142       txVector.SetMode(mode);
       
   143       AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PREAMBLE_LONG));
   140     }
   144     }
   141   WifiRemoteStationManager::SetupPhy (phy);
   145   WifiRemoteStationManager::SetupPhy (phy);
   142 }
   146 }
   143 
   147 
   144 int64_t
   148 int64_t
   433   station->m_retry = station->m_shortRetry + station->m_longRetry;
   437   station->m_retry = station->m_shortRetry + station->m_longRetry;
   434   station->m_shortRetry = 0;
   438   station->m_shortRetry = 0;
   435   station->m_longRetry = 0;
   439   station->m_longRetry = 0;
   436 }
   440 }
   437 
   441 
   438 WifiMode
   442 WifiTxVector
   439 MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st,
   443 MinstrelWifiManager::DoGetDataTxVector (WifiRemoteStation *st,
   440                                     uint32_t size)
   444                                     uint32_t size)
   441 {
   445 {
   442   MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
   446   MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
   443   if (!station->m_initialized)
   447   if (!station->m_initialized)
   444     {
   448     {
   446 
   450 
   447       /// start the rate at half way
   451       /// start the rate at half way
   448       station->m_txrate = m_nsupported / 2;
   452       station->m_txrate = m_nsupported / 2;
   449     }
   453     }
   450   UpdateStats (station);
   454   UpdateStats (station);
   451   return GetSupported (station, station->m_txrate);
   455   return WifiTxVector (GetSupported (station, station->m_txrate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (station), GetStbc (station));
   452 }
   456 }
   453 
   457 
   454 WifiMode
   458 WifiTxVector
   455 MinstrelWifiManager::DoGetRtsMode (WifiRemoteStation *st)
   459 MinstrelWifiManager::DoGetRtsTxVector (WifiRemoteStation *st)
   456 {
   460 {
   457   MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
   461   MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
   458   NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate);
   462   NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate);
   459 
   463 
   460   return GetSupported (station, 0);
   464   return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (station), GetStbc (station));
   461 }
   465 }
   462 
   466 
   463 bool
   467 bool
   464 MinstrelWifiManager::IsLowLatency (void) const
   468 MinstrelWifiManager::IsLowLatency (void) const
   465 {
   469 {