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

(-)a/src/mesh/model/dot11s/airtime-metric.cc (-1 / +1 lines)
 Lines 95-101    Link Here 
95
  //calculate metric
95
  //calculate metric
96
  uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/
96
  uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/
97
                                 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs
97
                                 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs
98
                                 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), txVector, WIFI_PREAMBLE_LONG)
98
                                 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), txVector, WIFI_PREAMBLE_LONG, mac->GetWifiPhy ()->GetFrequency())
99
                                 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));
99
                                 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));
100
  return metric;
100
  return metric;
101
}
101
}
(-)a/src/wifi/model/mac-low.cc (-15 / +15 lines)
 Lines 982-988    Link Here 
982
    preamble= WIFI_PREAMBLE_HT_MF;
982
    preamble= WIFI_PREAMBLE_HT_MF;
983
  else
983
  else
984
    preamble=WIFI_PREAMBLE_LONG;
984
    preamble=WIFI_PREAMBLE_LONG;
985
  return m_phy->CalculateTxDuration (GetAckSize (), ackTxVector, preamble);
985
  return m_phy->CalculateTxDuration (GetAckSize (), ackTxVector, preamble, m_phy->GetFrequency());
986
}
986
}
987
Time
987
Time
988
MacLow::GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const
988
MacLow::GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const
 Lines 1000-1006    Link Here 
1000
    preamble= WIFI_PREAMBLE_HT_MF;
1000
    preamble= WIFI_PREAMBLE_HT_MF;
1001
  else
1001
  else
1002
    preamble=WIFI_PREAMBLE_LONG;
1002
    preamble=WIFI_PREAMBLE_LONG;
1003
  return m_phy->CalculateTxDuration (GetBlockAckSize (type), blockAckReqTxVector, preamble);
1003
  return m_phy->CalculateTxDuration (GetBlockAckSize (type), blockAckReqTxVector, preamble, m_phy->GetFrequency());
1004
}
1004
}
1005
Time
1005
Time
1006
MacLow::GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const
1006
MacLow::GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const
 Lines 1017-1023    Link Here 
1017
    preamble= WIFI_PREAMBLE_HT_MF;
1017
    preamble= WIFI_PREAMBLE_HT_MF;
1018
  else
1018
  else
1019
    preamble=WIFI_PREAMBLE_LONG;
1019
    preamble=WIFI_PREAMBLE_LONG;
1020
  return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble);
1020
  return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble, m_phy->GetFrequency());
1021
}
1021
}
1022
uint32_t
1022
uint32_t
1023
MacLow::GetCtsSize (void) const
1023
MacLow::GetCtsSize (void) const
 Lines 1105-1111    Link Here 
1105
        {
1105
        {
1106
          preamble = WIFI_PREAMBLE_LONG;
1106
          preamble = WIFI_PREAMBLE_LONG;
1107
        }
1107
        }
1108
      txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble);
1108
      txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency());
1109
      txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
1109
      txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
1110
      txTime += Time (GetSifs () * 2);
1110
      txTime += Time (GetSifs () * 2);
1111
    }
1111
    }
 Lines 1118-1124    Link Here 
1118
  else
1118
  else
1119
    preamble=WIFI_PREAMBLE_LONG;
1119
    preamble=WIFI_PREAMBLE_LONG;
1120
  uint32_t dataSize = GetSize (packet, hdr);
1120
  uint32_t dataSize = GetSize (packet, hdr);
1121
  txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble);
1121
  txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble, m_phy->GetFrequency());
1122
  if (params.MustWaitAck ())
1122
  if (params.MustWaitAck ())
1123
    {
1123
    {
1124
      txTime += GetSifs ();
1124
      txTime += GetSifs ();
 Lines 1145-1151    Link Here 
1145
      else
1145
      else
1146
        preamble=WIFI_PREAMBLE_LONG;
1146
        preamble=WIFI_PREAMBLE_LONG;
1147
      txTime += GetSifs ();
1147
      txTime += GetSifs ();
1148
      txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble);
1148
      txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency());
1149
    }
1149
    }
1150
  return txTime;
1150
  return txTime;
1151
}
1151
}
 Lines 1183-1189    Link Here 
1183
          cts.SetType (WIFI_MAC_CTL_CTS);
1183
          cts.SetType (WIFI_MAC_CTL_CTS);
1184
          WifiTxVector txVector=GetRtsTxVector (packet, &hdr);
1184
          WifiTxVector txVector=GetRtsTxVector (packet, &hdr);
1185
          Time navCounterResetCtsMissedDelay =
1185
          Time navCounterResetCtsMissedDelay =
1186
            m_phy->CalculateTxDuration (cts.GetSerializedSize (), txVector, preamble) +
1186
            m_phy->CalculateTxDuration (cts.GetSerializedSize (), txVector, preamble, m_phy->GetFrequency()) +
1187
            Time (2 * GetSifs ()) + Time (2 * GetSlotTime ());
1187
            Time (2 * GetSifs ()) + Time (2 * GetSlotTime ());
1188
          m_navCounterResetCtsMissed = Simulator::Schedule (navCounterResetCtsMissedDelay,
1188
          m_navCounterResetCtsMissed = Simulator::Schedule (navCounterResetCtsMissedDelay,
1189
                                                            &MacLow::NavCounterResetCtsMissed, this,
1189
                                                            &MacLow::NavCounterResetCtsMissed, this,
 Lines 1385-1397    Link Here 
1385
      duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector);
1385
      duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector);
1386
      duration += GetSifs ();
1386
      duration += GetSifs ();
1387
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1387
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1388
                                              dataTxVector, preamble);
1388
                                              dataTxVector, preamble, m_phy->GetFrequency());
1389
      duration += GetSifs ();
1389
      duration += GetSifs ();
1390
      duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1390
      duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1391
    }
1391
    }
1392
  rts.SetDuration (duration);
1392
  rts.SetDuration (duration);
1393
1393
1394
  Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble);
1394
  Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency());
1395
  Time timerDelay = txDuration + GetCtsTimeout ();
1395
  Time timerDelay = txDuration + GetCtsTimeout ();
1396
1396
1397
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
1397
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
 Lines 1419-1425    Link Here 
1419
  else
1419
  else
1420
    preamble=WIFI_PREAMBLE_LONG;
1420
    preamble=WIFI_PREAMBLE_LONG;
1421
 
1421
 
1422
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble);
1422
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble, m_phy->GetFrequency());
1423
  if (m_txParams.MustWaitNormalAck ())
1423
  if (m_txParams.MustWaitNormalAck ())
1424
    {
1424
    {
1425
      Time timerDelay = txDuration + GetAckTimeout ();
1425
      Time timerDelay = txDuration + GetAckTimeout ();
 Lines 1522-1528    Link Here 
1522
        {
1522
        {
1523
          duration += GetSifs ();
1523
          duration += GetSifs ();
1524
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1524
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1525
                                                  dataTxVector, preamble);
1525
                                                  dataTxVector, preamble, m_phy->GetFrequency());
1526
          if (m_txParams.MustWaitAck ())
1526
          if (m_txParams.MustWaitAck ())
1527
            {
1527
            {
1528
              duration += GetSifs ();
1528
              duration += GetSifs ();
 Lines 1582-1588    Link Here 
1582
      WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
1582
      WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
1583
      duration += GetSifs ();
1583
      duration += GetSifs ();
1584
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket,&m_currentHdr),
1584
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket,&m_currentHdr),
1585
                                              dataTxVector, preamble);
1585
                                              dataTxVector, preamble, m_phy->GetFrequency());
1586
      if (m_txParams.MustWaitBasicBlockAck ())
1586
      if (m_txParams.MustWaitBasicBlockAck ())
1587
        {
1587
        {
1588
          
1588
          
 Lines 1603-1609    Link Here 
1603
        {
1603
        {
1604
          duration += GetSifs ();
1604
          duration += GetSifs ();
1605
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1605
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1606
                                                  dataTxVector, preamble);
1606
                                                  dataTxVector, preamble, m_phy->GetFrequency());
1607
          if (m_txParams.MustWaitCompressedBlockAck ())
1607
          if (m_txParams.MustWaitCompressedBlockAck ())
1608
            {
1608
            {
1609
              duration += GetSifs ();
1609
              duration += GetSifs ();
 Lines 1626-1632    Link Here 
1626
1626
1627
  ForwardDown (packet, &cts, ctsTxVector,preamble);
1627
  ForwardDown (packet, &cts, ctsTxVector,preamble);
1628
1628
1629
  Time txDuration = m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble);
1629
  Time txDuration = m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble, m_phy->GetFrequency());
1630
  txDuration += GetSifs ();
1630
  txDuration += GetSifs ();
1631
  NS_ASSERT (m_sendDataEvent.IsExpired ());
1631
  NS_ASSERT (m_sendDataEvent.IsExpired ());
1632
  
1632
  
 Lines 1697-1703    Link Here 
1697
  newDuration += GetSifs ();
1697
  newDuration += GetSifs ();
1698
  newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1698
  newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1699
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1699
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1700
                                                dataTxVector, preamble);
1700
                                                dataTxVector, preamble, m_phy->GetFrequency());
1701
  duration -= txDuration;
1701
  duration -= txDuration;
1702
  duration -= GetSifs ();
1702
  duration -= GetSifs ();
1703
1703
(-)a/src/wifi/model/minstrel-wifi-manager.cc (-1 / +1 lines)
 Lines 139-145    Link Here 
139
      WifiMode mode = phy->GetMode (i);
139
      WifiMode mode = phy->GetMode (i);
140
      WifiTxVector txVector;
140
      WifiTxVector txVector;
141
      txVector.SetMode(mode);
141
      txVector.SetMode(mode);
142
      AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PREAMBLE_LONG));
142
      AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency()));
143
    }
143
    }
144
  WifiRemoteStationManager::SetupPhy (phy);
144
  WifiRemoteStationManager::SetupPhy (phy);
145
}
145
}
(-)a/src/wifi/model/wifi-phy.cc (-5 / +9 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
 */
20
21
21
#include "wifi-phy.h"
22
#include "wifi-phy.h"
 Lines 329-335    Link Here 
329
}
330
}
330
331
331
double
332
double
332
WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector)
333
WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency)
333
{
334
{
334
  WifiMode payloadMode=txvector.GetMode();
335
  WifiMode payloadMode=txvector.GetMode();
335
336
 Lines 418-425    Link Here 
418
         double Nes=1;
419
         double Nes=1;
419
        // IEEE Std 802.11n, section 20.3.11, equation (20-32)
420
        // IEEE Std 802.11n, section 20.3.11, equation (20-32)
420
        uint32_t numSymbols = lrint (m_Stbc*ceil ((16 + size * 8.0 + 6.0*Nes) / (m_Stbc* numDataBitsPerSymbol)));
421
        uint32_t numSymbols = lrint (m_Stbc*ceil ((16 + size * 8.0 + 6.0*Nes) / (m_Stbc* numDataBitsPerSymbol)));
421
       
422
422
        return numSymbols * symbolDurationUs;
423
        if (frequency >= 2400 && frequency <= 2500) //at 2.4 GHz
424
          return (numSymbols * symbolDurationUs) + 6;
425
        else  //at 5 GHz
426
          return (numSymbols * symbolDurationUs);
423
         
427
         
424
      }
428
      }
425
    case WIFI_MOD_CLASS_DSSS:
429
    case WIFI_MOD_CLASS_DSSS:
 Lines 436-449    Link Here 
436
}
440
}
437
441
438
Time
442
Time
439
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble)
443
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency)
440
{
444
{
441
  WifiMode payloadMode=txvector.GetMode();
445
  WifiMode payloadMode=txvector.GetMode();
442
  double duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
446
  double duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
443
    + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
447
    + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
444
    + GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble)
448
    + GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble)
445
    + GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,txvector)
449
    + GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,txvector)
446
    + GetPayloadDurationMicroSeconds (size, txvector);
450
    + GetPayloadDurationMicroSeconds (size, txvector, frequency);
447
  return MicroSeconds (duration);
451
  return MicroSeconds (duration);
448
}
452
}
449
453
(-)a/src/wifi/model/wifi-phy.h (-2 / +3 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
 */
20
21
21
#ifndef WIFI_PHY_H
22
#ifndef WIFI_PHY_H
 Lines 284-290    Link Here 
284
   * \return the total amount of time this PHY will stay busy for
285
   * \return the total amount of time this PHY will stay busy for
285
   *          the transmission of these bytes.
286
   *          the transmission of these bytes.
286
   */
287
   */
287
  static Time CalculateTxDuration (uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble);
288
  static Time CalculateTxDuration (uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, double frequency);
288
289
289
/** 
290
/** 
290
   * \param payloadMode the WifiMode use for the transmission of the payload
291
   * \param payloadMode the WifiMode use for the transmission of the payload
 Lines 340-346    Link Here 
340
   * 
341
   * 
341
   * \return the duration of the payload in microseconds
342
   * \return the duration of the payload in microseconds
342
   */
343
   */
343
  static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector);
344
  static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency);
344
345
345
  /**
346
  /**
346
   * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
347
   * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
(-)a/src/wifi/model/yans-wifi-phy.cc (-2 / +2 lines)
 Lines 506-512    Link Here 
506
  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble);
506
  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble);
507
  rxPowerDbm += m_rxGainDb;
507
  rxPowerDbm += m_rxGainDb;
508
  double rxPowerW = DbmToW (rxPowerDbm);
508
  double rxPowerW = DbmToW (rxPowerDbm);
509
  Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
509
  Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency());
510
  WifiMode txMode = txVector.GetMode();
510
  WifiMode txMode = txVector.GetMode();
511
  Time endRx = Simulator::Now () + rxDuration;
511
  Time endRx = Simulator::Now () + rxDuration;
512
512
 Lines 631-637    Link Here 
631
      return;
631
      return;
632
    }
632
    }
633
633
634
  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
634
  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency());
635
  if (m_state->IsStateRx ())
635
  if (m_state->IsStateRx ())
636
    {
636
    {
637
      m_endRxEvent.Cancel ();
637
      m_endRxEvent.Cancel ();

Return to bug 1971