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

(-)a/src/wifi/model/interference-helper.cc (-4 / +4 lines)
 Lines 281-290    Link Here 
281
281
282
   }
282
   }
283
  WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble);
283
  WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble);
284
  Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (WifiPhy::GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)); //packet start time+ preamble
284
  Time plcpHeaderStart = (*j).GetTime () + WifiPhy::GetPlcpPreambleDuration (payloadMode, preamble); //packet start time+ preamble
285
  Time plcpHsigHeaderStart=plcpHeaderStart+ MicroSeconds (WifiPhy::GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble));//packet start time+ preamble+L SIG
285
  Time plcpHsigHeaderStart=plcpHeaderStart+ WifiPhy::GetPlcpHeaderDuration (payloadMode, preamble);//packet start time+ preamble+L SIG
286
  Time plcpHtTrainingSymbolsStart = plcpHsigHeaderStart + MicroSeconds (WifiPhy::GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble));//packet start time+ preamble+L SIG+HT SIG
286
  Time plcpHtTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (payloadMode, preamble);//packet start time+ preamble+L SIG+HT SIG
287
  Time plcpPayloadStart =plcpHtTrainingSymbolsStart + MicroSeconds (WifiPhy::GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,event->GetTxVector())); //packet start time+ preamble+L SIG+HT SIG+Training
287
  Time plcpPayloadStart =plcpHtTrainingSymbolsStart + WifiPhy::GetPlcpHtTrainingSymbolDuration (payloadMode, preamble,event->GetTxVector()); //packet start time+ preamble+L SIG+HT SIG+Training
288
  double noiseInterferenceW = (*j).GetDelta ();
288
  double noiseInterferenceW = (*j).GetDelta ();
289
  double powerW = event->GetRxPowerW ();
289
  double powerW = event->GetRxPowerW ();
290
    j++;
290
    j++;
(-)a/src/wifi/model/wifi-mac-header.cc (-1 / +1 lines)
 Lines 313-319    Link Here 
313
void
313
void
314
WifiMacHeader::SetDuration (Time duration)
314
WifiMacHeader::SetDuration (Time duration)
315
{
315
{
316
  int64_t duration_us = duration.GetMicroSeconds ();
316
  int64_t duration_us = ceil((double)duration.GetNanoSeconds ()/1000);
317
  NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff);
317
  NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff);
318
  m_duration = static_cast<uint16_t> (duration_us);
318
  m_duration = static_cast<uint16_t> (duration_us);
319
}
319
}
(-)a/src/wifi/model/wifi-phy.cc (-57 / +57 lines)
 Lines 131-138    Link Here 
131
      }
131
      }
132
}
132
}
133
133
134
uint32_t 
134
Time
135
WifiPhy::GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector)
135
WifiPhy::GetPlcpHtTrainingSymbolDuration (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector)
136
{
136
{
137
  uint8_t Ndltf, Neltf;
137
  uint8_t Ndltf, Neltf;
138
138
 Lines 158-187    Link Here 
158
  switch (preamble)
158
  switch (preamble)
159
    {
159
    {
160
     case WIFI_PREAMBLE_HT_MF:
160
     case WIFI_PREAMBLE_HT_MF:
161
         return 4 + (4 * Ndltf) + (4 * Neltf);
161
         return MicroSeconds(4 + (4 * Ndltf) + (4 * Neltf));
162
     case WIFI_PREAMBLE_HT_GF:
162
     case WIFI_PREAMBLE_HT_GF:
163
	 return (4 * Ndltf) + (4 * Neltf);
163
	 return MicroSeconds((4 * Ndltf) + (4 * Neltf));
164
     default:
164
     default:
165
       // no training for non HT
165
       // no training for non HT
166
         return 0;
166
         return MicroSeconds(0);
167
    }
167
    }
168
}
168
}
169
169
170
//return L-SIG
170
//return L-SIG
171
uint32_t
171
Time
172
WifiPhy::GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
172
WifiPhy::GetPlcpHtSigHeaderDuration (WifiMode payloadMode, WifiPreamble preamble)
173
{
173
{
174
         switch (preamble)
174
         switch (preamble)
175
            {
175
            {
176
             case WIFI_PREAMBLE_HT_MF:
176
             case WIFI_PREAMBLE_HT_MF:
177
               // HT-SIG
177
               // HT-SIG
178
               return 8;
178
               return MicroSeconds(8);
179
             case WIFI_PREAMBLE_HT_GF:
179
             case WIFI_PREAMBLE_HT_GF:
180
               //HT-SIG
180
               //HT-SIG
181
               return 8;
181
               return MicroSeconds(8);
182
             default:
182
             default:
183
               // no HT-SIG for non HT
183
               // no HT-SIG for non HT
184
               return 0;
184
               return MicroSeconds(0);
185
            }
185
            }
186
186
187
}
187
}
 Lines 260-267    Link Here 
260
}
260
}
261
261
262
262
263
uint32_t
263
Time
264
WifiPhy::GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
264
WifiPhy::GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble)
265
{
265
{
266
  switch (payloadMode.GetModulationClass ())
266
  switch (payloadMode.GetModulationClass ())
267
    {
267
    {
 Lines 277-289    Link Here 
277
            // SERVICE field (which strictly speaking belongs to the PLCP
277
            // SERVICE field (which strictly speaking belongs to the PLCP
278
            // header, see Section 18.3.2 and Figure 18-1) is sent using the
278
            // header, see Section 18.3.2 and Figure 18-1) is sent using the
279
            // payload mode.
279
            // payload mode.
280
            return 4;
280
            return MicroSeconds(4);
281
          case 10000000:
281
          case 10000000:
282
            // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
282
            // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
283
            return 8;
283
            return MicroSeconds(8);
284
          case 5000000:
284
          case 5000000:
285
            // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
285
            // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
286
            return 16;
286
            return MicroSeconds(16);
287
          }
287
          }
288
      }
288
      }
289
     //Added by Ghada to support 11n
289
     //Added by Ghada to support 11n
 Lines 293-330    Link Here 
293
            {
293
            {
294
             case WIFI_PREAMBLE_HT_MF:
294
             case WIFI_PREAMBLE_HT_MF:
295
               // L-SIG
295
               // L-SIG
296
               return 4;
296
               return MicroSeconds(4);
297
             case WIFI_PREAMBLE_HT_GF:
297
             case WIFI_PREAMBLE_HT_GF:
298
               //L-SIG
298
               //L-SIG
299
               return 0;
299
               return MicroSeconds(0);
300
             default:
300
             default:
301
               // L-SIG
301
               // L-SIG
302
               return 4;
302
               return MicroSeconds(4);
303
            }
303
            }
304
      }
304
      }
305
    case WIFI_MOD_CLASS_ERP_OFDM:
305
    case WIFI_MOD_CLASS_ERP_OFDM:
306
      return 4;
306
      return MicroSeconds(4);
307
307
308
    case WIFI_MOD_CLASS_DSSS:
308
    case WIFI_MOD_CLASS_DSSS:
309
      if (preamble == WIFI_PREAMBLE_SHORT)
309
      if (preamble == WIFI_PREAMBLE_SHORT)
310
        {
310
        {
311
          // (Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
311
          // (Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
312
          return 24;
312
          return MicroSeconds(24);
313
        }
313
        }
314
      else // WIFI_PREAMBLE_LONG
314
      else // WIFI_PREAMBLE_LONG
315
        {
315
        {
316
          // (Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
316
          // (Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
317
          return 48;
317
          return MicroSeconds(48);
318
        }
318
        }
319
319
320
    default:
320
    default:
321
      NS_FATAL_ERROR ("unsupported modulation class");
321
      NS_FATAL_ERROR ("unsupported modulation class");
322
      return 0;
322
      return MicroSeconds(0);
323
    }
323
    }
324
}
324
}
325
325
326
uint32_t
326
Time
327
WifiPhy::GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
327
WifiPhy::GetPlcpPreambleDuration (WifiMode payloadMode, WifiPreamble preamble)
328
{
328
{
329
  switch (payloadMode.GetModulationClass ())
329
  switch (payloadMode.GetModulationClass ())
330
    {
330
    {
 Lines 336-378    Link Here 
336
          default:
336
          default:
337
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
337
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
338
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
338
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
339
            return 16;
339
            return MicroSeconds(16);
340
          case 10000000:
340
          case 10000000:
341
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
341
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
342
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
342
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
343
            return 32;
343
            return MicroSeconds(32);
344
          case 5000000:
344
          case 5000000:
345
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
345
            // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
346
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
346
            // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
347
            return 64;
347
            return MicroSeconds(64);
348
          }
348
          }
349
      }
349
      }
350
    case WIFI_MOD_CLASS_HT:
350
    case WIFI_MOD_CLASS_HT:
351
      { //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
351
      { //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
352
           return 16;
352
           return MicroSeconds(16);
353
      }
353
      }
354
    case WIFI_MOD_CLASS_ERP_OFDM:
354
    case WIFI_MOD_CLASS_ERP_OFDM:
355
      return 16;
355
      return MicroSeconds(16);
356
356
357
    case WIFI_MOD_CLASS_DSSS:
357
    case WIFI_MOD_CLASS_DSSS:
358
      if (preamble == WIFI_PREAMBLE_SHORT)
358
      if (preamble == WIFI_PREAMBLE_SHORT)
359
        {
359
        {
360
          // (Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
360
          // (Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
361
          return 72;
361
          return MicroSeconds(72);
362
        }
362
        }
363
      else // WIFI_PREAMBLE_LONG
363
      else // WIFI_PREAMBLE_LONG
364
        {
364
        {
365
          // (Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
365
          // (Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
366
          return 144;
366
          return MicroSeconds(144);
367
        }
367
        }
368
    default:
368
    default:
369
      NS_FATAL_ERROR ("unsupported modulation class");
369
      NS_FATAL_ERROR ("unsupported modulation class");
370
      return 0;
370
      return MicroSeconds(0);
371
    }
371
    }
372
}
372
}
373
373
374
double
374
Time
375
WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency)
375
WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txvector, double frequency)
376
{
376
{
377
  WifiMode payloadMode=txvector.GetMode();
377
  WifiMode payloadMode=txvector.GetMode();
378
378
 Lines 385-409    Link Here 
385
      {
385
      {
386
        // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
386
        // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
387
        // corresponds to T_{SYM} in the table)
387
        // corresponds to T_{SYM} in the table)
388
        uint32_t symbolDurationUs;
388
        Time symbolDuration;
389
389
390
        switch (payloadMode.GetBandwidth ())
390
        switch (payloadMode.GetBandwidth ())
391
          {
391
          {
392
          case 20000000:
392
          case 20000000:
393
          default:
393
          default:
394
            symbolDurationUs = 4;
394
            symbolDuration = MicroSeconds(4);
395
            break;
395
            break;
396
          case 10000000:
396
          case 10000000:
397
            symbolDurationUs = 8;
397
            symbolDuration = MicroSeconds(8);
398
            break;
398
            break;
399
          case 5000000:
399
          case 5000000:
400
            symbolDurationUs = 16;
400
            symbolDuration = MicroSeconds(16);
401
            break;
401
            break;
402
          }
402
          }
403
403
404
        // (Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
404
        // (Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
405
        // corresponds to N_{DBPS} in the table
405
        // corresponds to N_{DBPS} in the table
406
        double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
406
        double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDuration.GetNanoSeconds() / 1e9;
407
407
408
        // (Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
408
        // (Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
409
        uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
409
        uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
 Lines 411-432    Link Here 
411
        // Add signal extension for ERP PHY
411
        // Add signal extension for ERP PHY
412
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
412
        if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
413
          {
413
          {
414
            return numSymbols * symbolDurationUs + 6;
414
            return Time (numSymbols * symbolDuration) + MicroSeconds(6);
415
          }
415
          }
416
        else
416
        else
417
          {
417
          {
418
            return numSymbols * symbolDurationUs;
418
            return Time (numSymbols * symbolDuration);
419
          }
419
          }
420
      }
420
      }
421
    case WIFI_MOD_CLASS_HT:
421
    case WIFI_MOD_CLASS_HT:
422
      {
422
      {
423
         double symbolDurationUs;
423
         Time symbolDuration;
424
         double m_Stbc;
424
         double m_Stbc;
425
        //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
425
        //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
426
        //In the future has to create a stationmanager that only uses these data rates if sender and reciever support GI
426
        //In the future has to create a stationmanager that only uses these data rates if sender and reciever support GI
427
         if (payloadMode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || payloadMode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
427
         if (payloadMode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || payloadMode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
428
           {
428
           {
429
             symbolDurationUs=3.6;
429
             symbolDuration = NanoSeconds(3600);
430
           }
430
           }
431
         else
431
         else
432
           {
432
           {
 Lines 446-462    Link Here 
446
                  case 90000000:
446
                  case 90000000:
447
                  case 120000000:
447
                  case 120000000:
448
                  case 150000000:
448
                  case 150000000:
449
                    symbolDurationUs=3.6;
449
                    symbolDuration = NanoSeconds(3600);
450
                    break;               
450
                    break;               
451
                 default:
451
                 default:
452
                    symbolDurationUs=4;
452
                    symbolDuration = MicroSeconds(4);
453
              }
453
              }
454
           }
454
           }
455
         if  (txvector.IsStbc())
455
         if  (txvector.IsStbc())
456
            m_Stbc=2;
456
            m_Stbc=2;
457
         else
457
         else
458
           m_Stbc=1;
458
           m_Stbc=1;
459
         double numDataBitsPerSymbol = payloadMode.GetDataRate () *txvector.GetNss()  * symbolDurationUs / 1e6;
459
         double numDataBitsPerSymbol = payloadMode.GetDataRate () * txvector.GetNss() * symbolDuration.GetNanoSeconds() / 1e9;
460
         //check tables 20-35 and 20-36 in the standard to get cases when nes =2
460
         //check tables 20-35 and 20-36 in the standard to get cases when nes =2
461
         double Nes=1;
461
         double Nes=1;
462
        // IEEE Std 802.11n, section 20.3.11, equation (20-32)
462
        // IEEE Std 802.11n, section 20.3.11, equation (20-32)
 Lines 464-474    Link Here 
464
       
464
       
465
        if (frequency >= 2400 && frequency <= 2500) //at 2.4 GHz
465
        if (frequency >= 2400 && frequency <= 2500) //at 2.4 GHz
466
          {
466
          {
467
            return (numSymbols * symbolDurationUs) + 6;
467
            return Time (numSymbols * symbolDuration) + MicroSeconds(6);
468
          }
468
          }
469
        else  //at 5 GHz
469
        else  //at 5 GHz
470
          {
470
          {
471
            return (numSymbols * symbolDurationUs);
471
            return Time (numSymbols * symbolDuration);
472
          }
472
          }
473
      }
473
      }
474
    case WIFI_MOD_CLASS_DSSS:
474
    case WIFI_MOD_CLASS_DSSS:
 Lines 476-499    Link Here 
476
      NS_LOG_LOGIC (" size=" << size
476
      NS_LOG_LOGIC (" size=" << size
477
                             << " mode=" << payloadMode
477
                             << " mode=" << payloadMode
478
                             << " rate=" << payloadMode.GetDataRate () );
478
                             << " rate=" << payloadMode.GetDataRate () );
479
      return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
479
      return MicroSeconds(lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6))));
480
480
481
    default:
481
    default:
482
      NS_FATAL_ERROR ("unsupported modulation class");
482
      NS_FATAL_ERROR ("unsupported modulation class");
483
      return 0;
483
      return MicroSeconds(0);
484
    }
484
    }
485
}
485
}
486
486
487
Time
487
Time
488
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency)
488
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency)
489
{
489
{
490
  WifiMode payloadMode=txvector.GetMode();
490
  WifiMode payloadMode = txvector.GetMode();
491
  double duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
491
  Time duration = GetPlcpPreambleDuration (payloadMode, preamble)
492
    + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
492
    + GetPlcpHeaderDuration (payloadMode, preamble)
493
    + GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble)
493
    + GetPlcpHtSigHeaderDuration (payloadMode, preamble)
494
    + GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,txvector)
494
    + GetPlcpHtTrainingSymbolDuration (payloadMode, preamble,txvector)
495
    + GetPayloadDurationMicroSeconds (size, txvector, frequency);
495
    + GetPayloadDuration (size, txvector, frequency);
496
  return NanoSeconds (duration*1000);
496
  return duration;
497
}
497
}
498
498
499
499
(-)a/src/wifi/model/wifi-phy.h (-9 / +8 lines)
 Lines 293-299    Link Here 
293
293
294
   * \return the training symbol duration
294
   * \return the training symbol duration
295
   */
295
   */
296
  static uint32_t GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector);
296
  static Time GetPlcpHtTrainingSymbolDuration (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector);
297
/** 
297
/** 
298
   * \param payloadMode the WifiMode use for the transmission of the payload
298
   * \param payloadMode the WifiMode use for the transmission of the payload
299
   * \param preamble the type of preamble
299
   * \param preamble the type of preamble
 Lines 307-314    Link Here 
307
   * 
307
   * 
308
   * \return the duration of the HT-SIG in Mixed Format and greenfield format PLCP header 
308
   * \return the duration of the HT-SIG in Mixed Format and greenfield format PLCP header 
309
   */
309
   */
310
  static uint32_t GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
310
  static Time GetPlcpHtSigHeaderDuration (WifiMode payloadMode, WifiPreamble preamble);
311
312
311
313
  /** 
312
  /** 
314
   * \param payloadMode the WifiMode use for the transmission of the payload
313
   * \param payloadMode the WifiMode use for the transmission of the payload
 Lines 322-347    Link Here 
322
   * \param payloadMode the WifiMode use for the transmission of the payload
321
   * \param payloadMode the WifiMode use for the transmission of the payload
323
   * \param preamble the type of preamble
322
   * \param preamble the type of preamble
324
   * 
323
   * 
325
   * \return the duration of the PLCP header in microseconds
324
   * \return the duration of the PLCP header
326
   */
325
   */
327
  static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
326
  static Time GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble);
328
327
329
  /** 
328
  /** 
330
   * \param payloadMode the WifiMode use for the transmission of the payload
329
   * \param payloadMode the WifiMode use for the transmission of the payload
331
   * \param preamble the type of preamble 
330
   * \param preamble the type of preamble 
332
   * 
331
   * 
333
   * \return the duration of the PLCP preamble in microseconds
332
   * \return the duration of the PLCP preamble
334
   */
333
   */
335
  static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
334
  static Time GetPlcpPreambleDuration (WifiMode payloadMode, WifiPreamble preamble);
336
335
337
  /** 
336
  /** 
338
   * \param size the number of bytes in the packet to send
337
   * \param size the number of bytes in the packet to send
339
   * \param txvector the transmission parameters used for this packet
338
   * \param txvector the transmission parameters used for this packet
340
   * \param frequency the channel center frequency (MHz)
339
   * \param frequency the channel center frequency (MHz)
341
   * 
340
   * 
342
   * \return the duration of the payload in microseconds
341
   * \return the duration of the payload
343
   */
342
   */
344
  static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency);
343
  static Time GetPayloadDuration (uint32_t size, WifiTxVector txvector, double frequency);
345
344
346
  /**
345
  /**
347
   * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
346
   * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
(-)a/src/wifi/test/tx-duration-test.cc (-4 / +28 lines)
 Lines 89-95    Link Here 
89
    {
89
    {
90
      testedFrequency = CHANNEL_36_MHZ;
90
      testedFrequency = CHANNEL_36_MHZ;
91
    }
91
    }
92
  double calculatedDurationMicroSeconds = WifiPhy::GetPayloadDurationMicroSeconds (size, txVector, testedFrequency);
92
  double calculatedDurationMicroSeconds = WifiPhy::GetPayloadDuration (size, txVector, testedFrequency).GetMicroSeconds();
93
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
93
  if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
94
    {
94
    {
95
      std::cerr << " size=" << size
95
      std::cerr << " size=" << size
 Lines 103-109    Link Here 
103
    {
103
    {
104
      // Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
104
      // Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
105
      testedFrequency = CHANNEL_1_MHZ;
105
      testedFrequency = CHANNEL_1_MHZ;
106
      calculatedDurationMicroSeconds = WifiPhy::GetPayloadDurationMicroSeconds (size, txVector, testedFrequency);
106
      calculatedDurationMicroSeconds = WifiPhy::GetPayloadDuration (size, txVector, testedFrequency).GetMicroSeconds();
107
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
107
      if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
108
        {
108
        {
109
          std::cerr << " size=" << size
109
          std::cerr << " size=" << size
 Lines 244-253    Link Here 
244
  retval = retval
244
  retval = retval
245
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,228) 
245
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,228) 
246
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,48)
246
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,48)
247
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,40 )
247
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,40)
248
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,220) 
249
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,40)
250
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,32)
251
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,1746) 
252
    && CheckTxDuration (76, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,126)
253
    && CheckTxDuration (14, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,57.6)
254
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,1738) 
255
    && CheckTxDuration (76, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,118)
256
    && CheckTxDuration (14, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,49.6)
257
    && CheckTxDuration (1536, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,226.8)
258
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,46.8)
259
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,39.6)
248
    && CheckTxDuration (1536, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,218.8)
260
    && CheckTxDuration (1536, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,218.8)
249
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,38.8)
261
    && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,38.8)
250
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,31.6);
262
    && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,31.6)
263
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,128)
264
    && CheckTxDuration (76,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,44)
265
    && CheckTxDuration (14,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,40)
266
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,120)
267
    && CheckTxDuration (76,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,36)
268
    && CheckTxDuration (14,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,32)
269
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,118.8)
270
    && CheckTxDuration (76,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,43.2)
271
    && CheckTxDuration (14,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,39.6)
272
    && CheckTxDuration (1536,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,110.8)
273
    && CheckTxDuration (76,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,35.2)
274
    && CheckTxDuration (14,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,31.6);
251
275
252
    NS_TEST_EXPECT_MSG_EQ (retval, true, "an 802.11n duration failed");
276
    NS_TEST_EXPECT_MSG_EQ (retval, true, "an 802.11n duration failed");
253
}
277
}

Return to bug 2028