|
|
| 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 |
|
|
|
| 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 |
} |
|
|
| 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 |
{ |
|
|
| 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 |
|
|
| 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 |
{ |
|
|
| 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 |
|
|
|
| 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)); |
|
|
| 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 |
{ |
|
|
| 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) |
|
|
| 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: |
|
|
| 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 |
|