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

(-)a/examples/wireless/power-adaptation-distance.cc (-1 / +1 lines)
 Lines 172-178    Link Here 
172
      WifiMode mode = phy->GetMode (i);
172
      WifiMode mode = phy->GetMode (i);
173
      WifiTxVector txVector;
173
      WifiTxVector txVector;
174
      txVector.SetMode (mode);
174
      txVector.SetMode (mode);
175
      timeTable.push_back (std::make_pair (phy->CalculateTxDuration (packetSize, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency (), NORMAL_MPDU, 0), mode));
175
      timeTable.push_back (std::make_pair (phy->CalculateTxDuration (packetSize, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency ()), mode));
176
    }
176
    }
177
}
177
}
178
178
(-)a/examples/wireless/power-adaptation-interference.cc (-1 / +1 lines)
 Lines 168-174    Link Here 
168
      WifiMode mode = phy->GetMode (i);
168
      WifiMode mode = phy->GetMode (i);
169
      WifiTxVector txVector;
169
      WifiTxVector txVector;
170
      txVector.SetMode (mode);
170
      txVector.SetMode (mode);
171
      timeTable.push_back (std::make_pair (phy->CalculateTxDuration (packetSize, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency (), NORMAL_MPDU, 0), mode));
171
      timeTable.push_back (std::make_pair (phy->CalculateTxDuration (packetSize, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency ()), mode));
172
    }
172
    }
173
}
173
}
174
174
(-)a/src/mesh/model/dot11s/airtime-metric.cc (-1 / +1 lines)
 Lines 96-102    Link Here 
96
  //calculate metric
96
  //calculate metric
97
  uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/
97
  uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/
98
                                 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs
98
                                 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs
99
                                 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), txVector, WIFI_PREAMBLE_LONG, mac->GetWifiPhy ()->GetFrequency(), NORMAL_MPDU, 0)
99
                                 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), txVector, WIFI_PREAMBLE_LONG, mac->GetWifiPhy ()->GetFrequency())
100
                                 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));
100
                                 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));
101
  return metric;
101
  return metric;
102
}
102
}
(-)a/src/wifi/examples/test-interference-helper.cc (-2 / +2 lines)
 Lines 106-112    Link Here 
106
  WifiTxVector txVector;
106
  WifiTxVector txVector;
107
  txVector.SetTxPowerLevel (m_input.txPowerLevelA);
107
  txVector.SetTxPowerLevel (m_input.txPowerLevelA);
108
  txVector.SetMode (WifiMode (m_input.txModeA));
108
  txVector.SetMode (WifiMode (m_input.txModeA));
109
  m_txA->SendPacket (p, txVector, m_input.preamble, NORMAL_MPDU);
109
  m_txA->SendPacket (p, txVector, m_input.preamble);
110
}
110
}
111
111
112
void
112
void
 Lines 116-122    Link Here 
116
  WifiTxVector txVector;
116
  WifiTxVector txVector;
117
  txVector.SetTxPowerLevel (m_input.txPowerLevelB);
117
  txVector.SetTxPowerLevel (m_input.txPowerLevelB);
118
  txVector.SetMode (WifiMode (m_input.txModeB));
118
  txVector.SetMode (WifiMode (m_input.txModeB));
119
  m_txB->SendPacket (p, txVector, m_input.preamble, NORMAL_MPDU);
119
  m_txB->SendPacket (p, txVector, m_input.preamble);
120
}
120
}
121
121
122
InterferenceExperiment::InterferenceExperiment ()
122
InterferenceExperiment::InterferenceExperiment ()
(-)a/src/wifi/examples/wifi-phy-test.cc (-3 / +3 lines)
 Lines 74-80    Link Here 
74
  WifiTxVector txVector;
74
  WifiTxVector txVector;
75
  txVector.SetTxPowerLevel (m_input.txPowerLevel);
75
  txVector.SetTxPowerLevel (m_input.txPowerLevel);
76
  txVector.SetMode (mode);
76
  txVector.SetMode (mode);
77
  m_tx->SendPacket (p, txVector, WIFI_PREAMBLE_LONG, NORMAL_MPDU);
77
  m_tx->SendPacket (p, txVector, WIFI_PREAMBLE_LONG);
78
}
78
}
79
79
80
void
80
void
 Lines 182-188    Link Here 
182
  WifiTxVector txVector;
182
  WifiTxVector txVector;
183
  txVector.SetTxPowerLevel (m_input.txPowerLevelA);
183
  txVector.SetTxPowerLevel (m_input.txPowerLevelA);
184
  txVector.SetMode (WifiMode (m_input.txModeA));
184
  txVector.SetMode (WifiMode (m_input.txModeA));
185
  m_txA->SendPacket (p, txVector, WIFI_PREAMBLE_LONG, NORMAL_MPDU);
185
  m_txA->SendPacket (p, txVector, WIFI_PREAMBLE_LONG);
186
}
186
}
187
187
188
void
188
void
 Lines 193-199    Link Here 
193
  WifiTxVector txVector;
193
  WifiTxVector txVector;
194
  txVector.SetTxPowerLevel (m_input.txPowerLevelB);
194
  txVector.SetTxPowerLevel (m_input.txPowerLevelB);
195
  txVector.SetMode (WifiMode (m_input.txModeB));
195
  txVector.SetMode (WifiMode (m_input.txModeB));
196
  m_txB->SendPacket (p, txVector, WIFI_PREAMBLE_LONG, NORMAL_MPDU);
196
  m_txB->SendPacket (p, txVector, WIFI_PREAMBLE_LONG);
197
}
197
}
198
198
199
void
199
void
(-)a/src/wifi/model/mac-low.cc (-21 / +22 lines)
 Lines 1252-1258    Link Here 
1252
MacLow::GetAckDuration (WifiTxVector ackTxVector) const
1252
MacLow::GetAckDuration (WifiTxVector ackTxVector) const
1253
{
1253
{
1254
  NS_ASSERT (ackTxVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT); //ACK should always use non-HT PPDU (HT PPDU cases not supported yet)
1254
  NS_ASSERT (ackTxVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT); //ACK should always use non-HT PPDU (HT PPDU cases not supported yet)
1255
  return m_phy->CalculateTxDuration (GetAckSize (), ackTxVector, WIFI_PREAMBLE_LONG, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1255
  return m_phy->CalculateTxDuration (GetAckSize (), ackTxVector, WIFI_PREAMBLE_LONG, m_phy->GetFrequency ());
1256
}
1256
}
1257
1257
1258
Time
1258
Time
 Lines 1271-1277    Link Here 
1271
    {
1271
    {
1272
      preamble = WIFI_PREAMBLE_LONG;
1272
      preamble = WIFI_PREAMBLE_LONG;
1273
    }
1273
    }
1274
  return m_phy->CalculateTxDuration (GetBlockAckSize (type), blockAckReqTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1274
  return m_phy->CalculateTxDuration (GetBlockAckSize (type), blockAckReqTxVector, preamble, m_phy->GetFrequency ());
1275
}
1275
}
1276
1276
1277
Time
1277
Time
 Lines 1285-1291    Link Here 
1285
MacLow::GetCtsDuration (WifiTxVector ctsTxVector) const
1285
MacLow::GetCtsDuration (WifiTxVector ctsTxVector) const
1286
{
1286
{
1287
  NS_ASSERT (ctsTxVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT); //CTS should always use non-HT PPDU (HT PPDU cases not supported yet)
1287
  NS_ASSERT (ctsTxVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT); //CTS should always use non-HT PPDU (HT PPDU cases not supported yet)
1288
  return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, WIFI_PREAMBLE_LONG, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1288
  return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, WIFI_PREAMBLE_LONG, m_phy->GetFrequency ());
1289
}
1289
}
1290
1290
1291
uint32_t
1291
uint32_t
 Lines 1385-1391    Link Here 
1385
          //Otherwise, RTS should always use non-HT PPDU (HT PPDU cases not supported yet)
1385
          //Otherwise, RTS should always use non-HT PPDU (HT PPDU cases not supported yet)
1386
          preamble = WIFI_PREAMBLE_LONG;
1386
          preamble = WIFI_PREAMBLE_LONG;
1387
        }
1387
        }
1388
      txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1388
      txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency ());
1389
      txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
1389
      txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
1390
      txTime += Time (GetSifs () * 2);
1390
      txTime += Time (GetSifs () * 2);
1391
    }
1391
    }
 Lines 1411-1417    Link Here 
1411
      preamble = WIFI_PREAMBLE_LONG;
1411
      preamble = WIFI_PREAMBLE_LONG;
1412
    }
1412
    }
1413
  uint32_t dataSize = GetSize (packet, hdr);
1413
  uint32_t dataSize = GetSize (packet, hdr);
1414
  txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1414
  txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble, m_phy->GetFrequency ());
1415
  if (params.MustWaitAck ())
1415
  if (params.MustWaitAck ())
1416
    {
1416
    {
1417
      txTime += GetSifs ();
1417
      txTime += GetSifs ();
 Lines 1451-1457    Link Here 
1451
          preamble = WIFI_PREAMBLE_LONG;
1451
          preamble = WIFI_PREAMBLE_LONG;
1452
        }
1452
        }
1453
      txTime += GetSifs ();
1453
      txTime += GetSifs ();
1454
      txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1454
      txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency ());
1455
    }
1455
    }
1456
  return txTime;
1456
  return txTime;
1457
}
1457
}
 Lines 1489-1495    Link Here 
1489
          cts.SetType (WIFI_MAC_CTL_CTS);
1489
          cts.SetType (WIFI_MAC_CTL_CTS);
1490
          WifiTxVector txVector = GetRtsTxVector (packet, &hdr);
1490
          WifiTxVector txVector = GetRtsTxVector (packet, &hdr);
1491
          Time navCounterResetCtsMissedDelay =
1491
          Time navCounterResetCtsMissedDelay =
1492
            m_phy->CalculateTxDuration (cts.GetSerializedSize (), txVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0) +
1492
            m_phy->CalculateTxDuration (cts.GetSerializedSize (), txVector, preamble, m_phy->GetFrequency ()) +
1493
            Time (2 * GetSifs ()) + Time (2 * GetSlotTime ());
1493
            Time (2 * GetSifs ()) + Time (2 * GetSlotTime ());
1494
          m_navCounterResetCtsMissed = Simulator::Schedule (navCounterResetCtsMissedDelay,
1494
          m_navCounterResetCtsMissed = Simulator::Schedule (navCounterResetCtsMissedDelay,
1495
                                                            &MacLow::NavCounterResetCtsMissed, this,
1495
                                                            &MacLow::NavCounterResetCtsMissed, this,
 Lines 1585-1591    Link Here 
1585
                ", seq=0x" << std::hex << m_currentHdr.GetSequenceControl () << std::dec);
1585
                ", seq=0x" << std::hex << m_currentHdr.GetSequenceControl () << std::dec);
1586
  if (!m_ampdu || hdr->IsRts ())
1586
  if (!m_ampdu || hdr->IsRts ())
1587
    {
1587
    {
1588
      m_phy->SendPacket (packet, txVector, preamble, NORMAL_MPDU);
1588
      m_phy->SendPacket (packet, txVector, preamble);
1589
    }
1589
    }
1590
  else
1590
  else
1591
    {
1591
    {
 Lines 1634-1639    Link Here 
1634
              ampdutag.SetNoOfMpdus (queueSize);
1634
              ampdutag.SetNoOfMpdus (queueSize);
1635
            }
1635
            }
1636
          newPacket->AddPacketTag (ampdutag);
1636
          newPacket->AddPacketTag (ampdutag);
1637
          
1637
          if (delay == Seconds (0))
1638
          if (delay == Seconds (0))
1638
            {
1639
            {
1639
              if (!vhtSingleMpdu)
1640
              if (!vhtSingleMpdu)
 Lines 1649-1655    Link Here 
1649
            }
1650
            }
1650
          else
1651
          else
1651
            {
1652
            {
1652
              Simulator::Schedule (delay, &MacLow::SendPacket, this, newPacket, txVector, preamble, mpdutype);
1653
              Simulator::Schedule (delay, &MacLow::SendMpdu, this, newPacket, txVector, preamble, mpdutype);
1653
            }
1654
            }
1654
          if (queueSize > 1)
1655
          if (queueSize > 1)
1655
            {
1656
            {
 Lines 1661-1667    Link Here 
1661
}
1662
}
1662
1663
1663
void
1664
void
1664
MacLow::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype)
1665
MacLow::SendMpdu (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype)
1665
{
1666
{
1666
  NS_LOG_DEBUG ("Sending MPDU as part of A-MPDU");
1667
  NS_LOG_DEBUG ("Sending MPDU as part of A-MPDU");
1667
  m_phy->SendPacket (packet, txVector, preamble, mpdutype);
1668
  m_phy->SendPacket (packet, txVector, preamble, mpdutype);
 Lines 1794-1800    Link Here 
1794
      duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector);
1795
      duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector);
1795
      duration += GetSifs ();
1796
      duration += GetSifs ();
1796
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1797
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr),
1797
                                              dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1798
                                              dataTxVector, preamble, m_phy->GetFrequency ());
1798
      duration += GetSifs ();
1799
      duration += GetSifs ();
1799
      if (m_txParams.MustWaitBasicBlockAck ())
1800
      if (m_txParams.MustWaitBasicBlockAck ())
1800
        {
1801
        {
 Lines 1813-1819    Link Here 
1813
      if (m_txParams.HasNextPacket ())
1814
      if (m_txParams.HasNextPacket ())
1814
        {
1815
        {
1815
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1816
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1816
                                                  dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1817
                                                  dataTxVector, preamble, m_phy->GetFrequency ());
1817
          if (m_txParams.MustWaitAck ())
1818
          if (m_txParams.MustWaitAck ())
1818
            {
1819
            {
1819
              duration += GetSifs ();
1820
              duration += GetSifs ();
 Lines 1823-1829    Link Here 
1823
    }
1824
    }
1824
  rts.SetDuration (duration);
1825
  rts.SetDuration (duration);
1825
1826
1826
  Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1827
  Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency ());
1827
  Time timerDelay = txDuration + GetCtsTimeout ();
1828
  Time timerDelay = txDuration + GetCtsTimeout ();
1828
1829
1829
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
1830
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
 Lines 1865-1871    Link Here 
1865
      preamble = WIFI_PREAMBLE_LONG;
1866
      preamble = WIFI_PREAMBLE_LONG;
1866
    }
1867
    }
1867
1868
1868
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1869
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble, m_phy->GetFrequency ());
1869
  if (m_txParams.MustWaitNormalAck ())
1870
  if (m_txParams.MustWaitNormalAck ())
1870
    {
1871
    {
1871
      Time timerDelay = txDuration + GetAckTimeout ();
1872
      Time timerDelay = txDuration + GetAckTimeout ();
 Lines 1983-1989    Link Here 
1983
        {
1984
        {
1984
          duration += GetSifs ();
1985
          duration += GetSifs ();
1985
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1986
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
1986
                                                  dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
1987
                                                  dataTxVector, preamble, m_phy->GetFrequency ());
1987
          if (m_txParams.MustWaitAck ())
1988
          if (m_txParams.MustWaitAck ())
1988
            {
1989
            {
1989
              duration += GetSifs ();
1990
              duration += GetSifs ();
 Lines 2051-2057    Link Here 
2051
      WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
2052
      WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
2052
      duration += GetSifs ();
2053
      duration += GetSifs ();
2053
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket,&m_currentHdr),
2054
      duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket,&m_currentHdr),
2054
                                              dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
2055
                                              dataTxVector, preamble, m_phy->GetFrequency ());
2055
      if (m_txParams.MustWaitBasicBlockAck ())
2056
      if (m_txParams.MustWaitBasicBlockAck ())
2056
        {
2057
        {
2057
2058
 Lines 2074-2080    Link Here 
2074
        {
2075
        {
2075
          duration += GetSifs ();
2076
          duration += GetSifs ();
2076
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
2077
          duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (),
2077
                                                  dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
2078
                                                  dataTxVector, preamble, m_phy->GetFrequency ());
2078
          if (m_txParams.MustWaitCompressedBlockAck ())
2079
          if (m_txParams.MustWaitCompressedBlockAck ())
2079
            {
2080
            {
2080
              duration += GetSifs ();
2081
              duration += GetSifs ();
 Lines 2098-2104    Link Here 
2098
2099
2099
  ForwardDown (packet, &cts, ctsTxVector,preamble);
2100
  ForwardDown (packet, &cts, ctsTxVector,preamble);
2100
2101
2101
  Time txDuration = m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
2102
  Time txDuration = m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble, m_phy->GetFrequency ());
2102
  txDuration += GetSifs ();
2103
  txDuration += GetSifs ();
2103
  NS_ASSERT (m_sendDataEvent.IsExpired ());
2104
  NS_ASSERT (m_sendDataEvent.IsExpired ());
2104
2105
 Lines 2209-2215    Link Here 
2209
  if (m_txParams.HasNextPacket ())
2210
  if (m_txParams.HasNextPacket ())
2210
    {
2211
    {
2211
      newDuration += GetSifs ();
2212
      newDuration += GetSifs ();
2212
      newDuration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
2213
      newDuration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency ());
2213
      if (m_txParams.MustWaitCompressedBlockAck ())
2214
      if (m_txParams.MustWaitCompressedBlockAck ())
2214
        {
2215
        {
2215
          newDuration += GetSifs ();
2216
          newDuration += GetSifs ();
 Lines 2223-2229    Link Here 
2223
        }
2224
        }
2224
    }
2225
    }
2225
2226
2226
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0);
2227
  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble, m_phy->GetFrequency ());
2227
  duration -= txDuration;
2228
  duration -= txDuration;
2228
  duration -= GetSifs ();
2229
  duration -= GetSifs ();
2229
2230
 Lines 2836-2842    Link Here 
2836
    }
2837
    }
2837
2838
2838
  //An HT STA shall not transmit a PPDU that has a duration that is greater than aPPDUMaxTime (10 milliseconds)
2839
  //An HT STA shall not transmit a PPDU that has a duration that is greater than aPPDUMaxTime (10 milliseconds)
2839
  if (m_phy->CalculateTxDuration (aggregatedPacket->GetSize () + peekedPacket->GetSize () + peekedHdr.GetSize () + WIFI_MAC_FCS_LENGTH, dataTxVector, preamble, m_phy->GetFrequency (), NORMAL_MPDU, 0) > MilliSeconds (10))
2840
  if (m_phy->CalculateTxDuration (aggregatedPacket->GetSize () + peekedPacket->GetSize () + peekedHdr.GetSize () + WIFI_MAC_FCS_LENGTH, dataTxVector, preamble, m_phy->GetFrequency ()) > MilliSeconds (10))
2840
    {
2841
    {
2841
      NS_LOG_DEBUG ("no more packets can be aggregated to satisfy PPDU <= aPPDUMaxTime");
2842
      NS_LOG_DEBUG ("no more packets can be aggregated to satisfy PPDU <= aPPDUMaxTime");
2842
      return true;
2843
      return true;
(-)a/src/wifi/model/mac-low.h (-2 / +2 lines)
 Lines 887-893    Link Here 
887
  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
887
  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
888
                    WifiTxVector txVector, WifiPreamble preamble);
888
                    WifiTxVector txVector, WifiPreamble preamble);
889
  /**
889
  /**
890
   * Forward the packet down to WifiPhy for transmission. This is called for each MPDU when MPDU aggregation is used.
890
   * Forward the MPDU down to WifiPhy for transmission. This is called for each MPDU when MPDU aggregation is used.
891
   *
891
   *
892
   * \param packet
892
   * \param packet
893
   * \param hdr
893
   * \param hdr
 Lines 895-901    Link Here 
895
   * \param preamble
895
   * \param preamble
896
   * \param mpdutype
896
   * \param mpdutype
897
   */
897
   */
898
  void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype);
898
  void SendMpdu (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype);
899
  /**
899
  /**
900
   * Return a TXVECTOR for the RTS frame given the destination.
900
   * Return a TXVECTOR for the RTS frame given the destination.
901
   * The function consults WifiRemoteStationManager, which controls the rate
901
   * The function consults WifiRemoteStationManager, which controls the rate
(-)a/src/wifi/model/minstrel-wifi-manager.cc (-1 / +1 lines)
 Lines 138-144    Link Here 
138
      WifiMode mode = phy->GetMode (i);
138
      WifiMode mode = phy->GetMode (i);
139
      WifiTxVector txVector;
139
      WifiTxVector txVector;
140
      txVector.SetMode (mode);
140
      txVector.SetMode (mode);
141
      AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency (), NORMAL_MPDU, 0));
141
      AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, WIFI_PREAMBLE_LONG, phy->GetFrequency ()));
142
    }
142
    }
143
  WifiRemoteStationManager::SetupPhy (phy);
143
  WifiRemoteStationManager::SetupPhy (phy);
144
}
144
}
(-)a/src/wifi/model/wifi-phy.cc (-10 / +22 lines)
 Lines 395-400    Link Here 
395
}
395
}
396
396
397
Time
397
Time
398
WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency)
399
{
400
  return GetPayloadDuration (size, txVector, preamble, frequency, NORMAL_MPDU, 0);
401
}
402
403
Time
398
WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
404
WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
399
{
405
{
400
  WifiMode payloadMode = txVector.GetMode ();
406
  WifiMode payloadMode = txVector.GetMode ();
 Lines 426-438    Link Here 
426
        //(Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
432
        //(Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
427
        //corresponds to N_{DBPS} in the table
433
        //corresponds to N_{DBPS} in the table
428
        double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), 0, 1) * symbolDuration.GetNanoSeconds () / 1e9;
434
        double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), 0, 1) * symbolDuration.GetNanoSeconds () / 1e9;
429
        //(Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
435
        double numSymbols;
430
        uint32_t numSymbols;
431
436
432
        if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
437
        if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
433
          {
438
          {
434
            //First packet in an A-MPDU
439
            //First packet in an A-MPDU
435
            numSymbols = ceil ((16 + size * 8.0 + 6) / numDataBitsPerSymbol);
440
            numSymbols = ((16 + size * 8.0 + 6) / numDataBitsPerSymbol);
436
            if (incFlag == 1)
441
            if (incFlag == 1)
437
              {
442
              {
438
                m_totalAmpduSize += size;
443
                m_totalAmpduSize += size;
 Lines 454-459    Link Here 
454
            //last packet in an A-MPDU
459
            //last packet in an A-MPDU
455
            uint32_t totalAmpduSize = m_totalAmpduSize + size;
460
            uint32_t totalAmpduSize = m_totalAmpduSize + size;
456
            numSymbols = lrint (ceil ((16 + totalAmpduSize * 8.0 + 6) / numDataBitsPerSymbol));
461
            numSymbols = lrint (ceil ((16 + totalAmpduSize * 8.0 + 6) / numDataBitsPerSymbol));
462
            NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
457
            numSymbols -= m_totalAmpduNumSymbols;
463
            numSymbols -= m_totalAmpduNumSymbols;
458
            if (incFlag == 1)
464
            if (incFlag == 1)
459
              {
465
              {
 Lines 474-484    Link Here 
474
        //Add signal extension for ERP PHY
480
        //Add signal extension for ERP PHY
475
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
481
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
476
          {
482
          {
477
            return Time (numSymbols * symbolDuration) + MicroSeconds (6);
483
            return NanoSeconds (numSymbols * symbolDuration.GetNanoSeconds ()) + MicroSeconds (6);
478
          }
484
          }
479
        else
485
        else
480
          {
486
          {
481
            return Time (numSymbols * symbolDuration);
487
            return NanoSeconds (numSymbols * symbolDuration.GetNanoSeconds ());
482
          }
488
          }
483
      }
489
      }
484
    case WIFI_MOD_CLASS_HT:
490
    case WIFI_MOD_CLASS_HT:
 Lines 520-532    Link Here 
520
          }
526
          }
521
527
522
        //IEEE Std 802.11n, section 20.3.11, equation (20-32)
528
        //IEEE Std 802.11n, section 20.3.11, equation (20-32)
523
        uint32_t numSymbols;
524
        double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () * symbolDuration.GetNanoSeconds () / 1e9;
529
        double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () * symbolDuration.GetNanoSeconds () / 1e9;
530
        double numSymbols;
525
531
526
        if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
532
        if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
527
          {
533
          {
528
            //First packet in an A-MPDU
534
            //First packet in an A-MPDU
529
            numSymbols = ceil (m_Stbc * (16 + size * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol));
535
            numSymbols = (m_Stbc * (16 + size * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol));
530
            if (incFlag == 1)
536
            if (incFlag == 1)
531
              {
537
              {
532
                m_totalAmpduSize += size;
538
                m_totalAmpduSize += size;
 Lines 536-542    Link Here 
536
        else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
542
        else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
537
          {
543
          {
538
            //consecutive packets in an A-MPDU
544
            //consecutive packets in an A-MPDU
539
            numSymbols = m_Stbc * ((size * 8.0 ) / (m_Stbc * numDataBitsPerSymbol));
545
            numSymbols = (m_Stbc * size * 8.0) / (m_Stbc * numDataBitsPerSymbol);
540
            if (incFlag == 1)
546
            if (incFlag == 1)
541
              {
547
              {
542
                m_totalAmpduSize += size;
548
                m_totalAmpduSize += size;
 Lines 568-578    Link Here 
568
574
569
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && frequency >= 2400 && frequency <= 2500 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
575
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && frequency >= 2400 && frequency <= 2500 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
570
          {
576
          {
571
            return Time (numSymbols * symbolDuration) + MicroSeconds (6);
577
            return NanoSeconds (numSymbols * symbolDuration.GetNanoSeconds ()) + MicroSeconds (6);
572
          }
578
          }
573
        else //at 5 GHz
579
        else //at 5 GHz
574
          {
580
          {
575
            return Time (numSymbols * symbolDuration);
581
            return NanoSeconds (numSymbols * symbolDuration.GetNanoSeconds ());
576
          }
582
          }
577
      }
583
      }
578
    case WIFI_MOD_CLASS_DSSS:
584
    case WIFI_MOD_CLASS_DSSS:
 Lines 609-614    Link Here 
609
  return duration;
615
  return duration;
610
}
616
}
611
617
618
Time
619
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency)
620
{
621
  return CalculateTxDuration (size, txVector, preamble, frequency, NORMAL_MPDU, 0);
622
}
623
612
void
624
void
613
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet)
625
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet)
614
{
626
{
(-)a/src/wifi/model/wifi-phy.h (-1 / +27 lines)
 Lines 235-240    Link Here 
235
   *        this packet, and txPowerLevel, a power level to use to send this packet. The real transmission
235
   *        this packet, and txPowerLevel, a power level to use to send this packet. The real transmission
236
   *        power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
236
   *        power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
237
   * \param preamble the type of preamble to use to send this packet.
237
   * \param preamble the type of preamble to use to send this packet.
238
   */
239
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble) = 0;
240
  /**
241
   * \param packet the packet to send
242
   * \param txVector the TXVECTOR that has tx parameters such as mode, the transmission mode to use to send
243
   *        this packet, and txPowerLevel, a power level to use to send this packet. The real transmission
244
   *        power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
245
   * \param preamble the type of preamble to use to send this packet.
238
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
246
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
239
   */
247
   */
240
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype) = 0;
248
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype) = 0;
 Lines 315-320    Link Here 
315
   * \param txVector the TXVECTOR used for the transmission of this packet
323
   * \param txVector the TXVECTOR used for the transmission of this packet
316
   * \param preamble the type of preamble to use for this packet.
324
   * \param preamble the type of preamble to use for this packet.
317
   * \param frequency the channel center frequency (MHz)
325
   * \param frequency the channel center frequency (MHz)
326
   *
327
   * \return the total amount of time this PHY will stay busy for the transmission of these bytes.
328
   */
329
  Time CalculateTxDuration (uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency);
330
  /**
331
   * \param size the number of bytes in the packet to send
332
   * \param txVector the TXVECTOR used for the transmission of this packet
333
   * \param preamble the type of preamble to use for this packet.
334
   * \param frequency the channel center frequency (MHz)
318
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
335
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
319
   * \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time.
336
   * \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time.
320
   *
337
   *
 Lines 401-406    Link Here 
401
   * \param txVector the TXVECTOR used for the transmission of this packet
418
   * \param txVector the TXVECTOR used for the transmission of this packet
402
   * \param preamble the type of preamble to use for this packet
419
   * \param preamble the type of preamble to use for this packet
403
   * \param frequency the channel center frequency (MHz)
420
   * \param frequency the channel center frequency (MHz)
421
   *
422
   * \return the duration of the payload
423
   */
424
  Time GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency);
425
  /**
426
   * \param size the number of bytes in the packet to send
427
   * \param txVector the TXVECTOR used for the transmission of this packet
428
   * \param preamble the type of preamble to use for this packet
429
   * \param frequency the channel center frequency (MHz)
404
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
430
   * \param mpdutype the type of the MPDU as defined in WifiPhy::mpduType.
405
   * \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time
431
   * \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time
406
   *
432
   *
 Lines 1327-1333    Link Here 
1327
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t,
1353
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t,
1328
                 WifiPreamble, WifiTxVector, struct mpduInfo> m_phyMonitorSniffTxTrace;
1354
                 WifiPreamble, WifiTxVector, struct mpduInfo> m_phyMonitorSniffTxTrace;
1329
1355
1330
  uint32_t m_totalAmpduNumSymbols; //!< Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1356
  double m_totalAmpduNumSymbols;   //!< Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1331
  uint32_t m_totalAmpduSize;       //!< Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1357
  uint32_t m_totalAmpduSize;       //!< Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1332
};
1358
};
1333
1359
(-)a/src/wifi/model/yans-wifi-phy.cc (+6 lines)
 Lines 767-772    Link Here 
767
}
767
}
768
768
769
void
769
void
770
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble)
771
{
772
  SendPacket (packet, txVector, preamble, NORMAL_MPDU);
773
}
774
775
void
770
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype)
776
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype)
771
{
777
{
772
  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)mpdutype);
778
  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)mpdutype);
(-)a/src/wifi/model/yans-wifi-phy.h (+1 lines)
 Lines 279-284    Link Here 
279
279
280
  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
280
  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
281
  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
281
  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
282
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble);
282
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype);
283
  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype);
283
  virtual void RegisterListener (WifiPhyListener *listener);
284
  virtual void RegisterListener (WifiPhyListener *listener);
284
  virtual void UnregisterListener (WifiPhyListener *listener);
285
  virtual void UnregisterListener (WifiPhyListener *listener);
(-)a/src/wifi/test/tx-duration-test.cc (-4 / +4 lines)
 Lines 100-106    Link Here 
100
    {
100
    {
101
      testedFrequency = CHANNEL_36_MHZ;
101
      testedFrequency = CHANNEL_36_MHZ;
102
    }
102
    }
103
  double calculatedDurationMicroSeconds = (double)phy->GetPayloadDuration (size, txVector, preamble, testedFrequency, NORMAL_MPDU, 0).GetMicroSeconds  ();
103
  double calculatedDurationMicroSeconds = (double)phy->GetPayloadDuration (size, txVector, preamble, testedFrequency).GetMicroSeconds  ();
104
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
104
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
105
    {
105
    {
106
      std::cerr << " size=" << size
106
      std::cerr << " size=" << size
 Lines 115-121    Link Here 
115
    {
115
    {
116
      //Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
116
      //Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
117
      testedFrequency = CHANNEL_1_MHZ;
117
      testedFrequency = CHANNEL_1_MHZ;
118
      calculatedDurationMicroSeconds = (double)phy->GetPayloadDuration (size, txVector, preamble, testedFrequency, NORMAL_MPDU, 0).GetMicroSeconds ();
118
      calculatedDurationMicroSeconds = (double)phy->GetPayloadDuration (size, txVector, preamble, testedFrequency).GetMicroSeconds ();
119
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
119
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
120
        {
120
        {
121
          std::cerr << " size=" << size
121
          std::cerr << " size=" << size
 Lines 148-154    Link Here 
148
    {
148
    {
149
      testedFrequency = CHANNEL_36_MHZ;
149
      testedFrequency = CHANNEL_36_MHZ;
150
    }
150
    }
151
  double calculatedDurationMicroSeconds = ((double)phy->CalculateTxDuration (size, txVector, preamble, testedFrequency, NORMAL_MPDU, 0).GetNanoSeconds ()) / 1000;
151
  double calculatedDurationMicroSeconds = ((double)phy->CalculateTxDuration (size, txVector, preamble, testedFrequency).GetNanoSeconds ()) / 1000;
152
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
152
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
153
    {
153
    {
154
      std::cerr << " size=" << size
154
      std::cerr << " size=" << size
 Lines 164-170    Link Here 
164
    {
164
    {
165
      //Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
165
      //Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
166
      testedFrequency = CHANNEL_1_MHZ;
166
      testedFrequency = CHANNEL_1_MHZ;
167
      calculatedDurationMicroSeconds = ((double)phy->CalculateTxDuration (size, txVector, preamble, testedFrequency, NORMAL_MPDU, 0).GetNanoSeconds ()) / 1000;
167
      calculatedDurationMicroSeconds = ((double)phy->CalculateTxDuration (size, txVector, preamble, testedFrequency).GetNanoSeconds ()) / 1000;
168
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
168
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
169
        {
169
        {
170
          std::cerr << " size=" << size
170
          std::cerr << " size=" << size

Return to bug 2193