263 double psr = 1.0; /* Packet Success Rate */ |
272 double psr = 1.0; /* Packet Success Rate */ |
264 NiChanges::iterator j = ni->begin (); |
273 NiChanges::iterator j = ni->begin (); |
265 Time previous = (*j).GetTime (); |
274 Time previous = (*j).GetTime (); |
266 WifiMode payloadMode = event->GetPayloadMode (); |
275 WifiMode payloadMode = event->GetPayloadMode (); |
267 WifiPreamble preamble = event->GetPreambleType (); |
276 WifiPreamble preamble = event->GetPreambleType (); |
|
277 WifiMode MfHeaderMode ; |
|
278 if (preamble==WIFI_PREAMBLE_HT_MF) |
|
279 { |
|
280 MfHeaderMode = WifiPhy::GetMFPlcpHeaderMode (payloadMode, preamble); //return L-SIG mode |
|
281 |
|
282 } |
268 WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble); |
283 WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble); |
269 Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (WifiPhy::GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)); |
284 Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (WifiPhy::GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)); //packet start time+ preamble |
270 Time plcpPayloadStart = plcpHeaderStart + MicroSeconds (WifiPhy::GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)); |
285 Time plcpHsigHeaderStart=plcpHeaderStart+ MicroSeconds (WifiPhy::GetPlcpHeaderDurationMicroSeconds (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 |
|
287 Time plcpPayloadStart =plcpHtTrainingSymbolsStart + MicroSeconds (WifiPhy::GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,event->GetTxVector())); //packet start time+ preamble+L SIG+HT SIG+Training |
271 double noiseInterferenceW = (*j).GetDelta (); |
288 double noiseInterferenceW = (*j).GetDelta (); |
272 double powerW = event->GetRxPowerW (); |
289 double powerW = event->GetRxPowerW (); |
273 |
290 j++; |
274 j++; |
|
275 while (ni->end () != j) |
291 while (ni->end () != j) |
276 { |
292 { |
277 Time current = (*j).GetTime (); |
293 Time current = (*j).GetTime (); |
278 NS_ASSERT (current >= previous); |
294 NS_ASSERT (current >= previous); |
279 |
295 //Case 1: Both prev and curr point to the payload |
280 if (previous >= plcpPayloadStart) |
296 if (previous >= plcpPayloadStart) |
281 { |
297 { |
282 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
298 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
283 noiseInterferenceW, |
299 noiseInterferenceW, |
284 payloadMode), |
300 payloadMode), |
285 current - previous, |
301 current - previous, |
286 payloadMode); |
302 payloadMode); |
287 } |
303 } |
|
304 //Case 2: previous is before payload |
|
305 else if (previous >= plcpHtTrainingSymbolsStart) |
|
306 { |
|
307 //Case 2a: current is after payload |
|
308 if (current >= plcpPayloadStart) |
|
309 { |
|
310 //Case 2ai and 2aii: All formats |
|
311 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
312 noiseInterferenceW, |
|
313 payloadMode), |
|
314 current - plcpPayloadStart, |
|
315 payloadMode); |
|
316 |
|
317 } |
|
318 } |
|
319 //Case 3: previous is in HT-SIG: Non HT will not enter here since it didn't enter in the last two and they are all the same for non HT |
|
320 else if (previous >=plcpHsigHeaderStart) |
|
321 { |
|
322 //Case 3a: cuurent after payload start |
|
323 if (current >=plcpPayloadStart) |
|
324 { |
|
325 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
326 noiseInterferenceW, |
|
327 payloadMode), |
|
328 current - plcpPayloadStart, |
|
329 payloadMode); |
|
330 |
|
331 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
332 noiseInterferenceW, |
|
333 headerMode), |
|
334 plcpHtTrainingSymbolsStart - previous, |
|
335 headerMode); |
|
336 } |
|
337 //case 3b: current after HT training symbols start |
|
338 else if (current >=plcpHtTrainingSymbolsStart) |
|
339 { |
|
340 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
341 noiseInterferenceW, |
|
342 headerMode), |
|
343 plcpHtTrainingSymbolsStart - previous, |
|
344 headerMode); |
|
345 |
|
346 } |
|
347 //Case 3c: current is with previous in HT sig |
|
348 else |
|
349 { |
|
350 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
351 noiseInterferenceW, |
|
352 headerMode), |
|
353 current- previous, |
|
354 headerMode); |
|
355 |
|
356 } |
|
357 } |
|
358 //Case 4: previous in L-SIG: GF will not reach here because it will execute the previous if and exit |
288 else if (previous >= plcpHeaderStart) |
359 else if (previous >= plcpHeaderStart) |
289 { |
360 { |
290 if (current >= plcpPayloadStart) |
361 //Case 4a: current after payload start |
291 { |
362 if (current >=plcpPayloadStart) |
292 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
363 { |
|
364 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
365 noiseInterferenceW, |
|
366 payloadMode), |
|
367 current - plcpPayloadStart, |
|
368 payloadMode); |
|
369 //Case 4ai: Non HT format (No HT-SIG or Training Symbols) |
|
370 if (preamble == WIFI_PREAMBLE_LONG || preamble == WIFI_PREAMBLE_SHORT) //plcpHtTrainingSymbolsStart==plcpHeaderStart) |
|
371 { |
|
372 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
293 noiseInterferenceW, |
373 noiseInterferenceW, |
294 headerMode), |
374 headerMode), |
295 plcpPayloadStart - previous, |
375 plcpPayloadStart - previous, |
296 headerMode); |
376 headerMode); |
297 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
377 } |
298 noiseInterferenceW, |
378 |
299 payloadMode), |
379 else{ |
300 current - plcpPayloadStart, |
380 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
301 payloadMode); |
381 noiseInterferenceW, |
302 } |
382 headerMode), |
303 else |
383 plcpHtTrainingSymbolsStart - plcpHsigHeaderStart, |
|
384 headerMode); |
|
385 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
386 noiseInterferenceW, |
|
387 MfHeaderMode), |
|
388 plcpHsigHeaderStart - previous, |
|
389 MfHeaderMode); |
|
390 } |
|
391 } |
|
392 //Case 4b: current in HT training symbol. non HT will not come here since it went in previous if or if the previous ifis not true this will be not true |
|
393 else if (current >=plcpHtTrainingSymbolsStart) |
|
394 { |
|
395 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
396 noiseInterferenceW, |
|
397 headerMode), |
|
398 plcpHtTrainingSymbolsStart - plcpHsigHeaderStart, |
|
399 headerMode); |
|
400 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
401 noiseInterferenceW, |
|
402 MfHeaderMode), |
|
403 plcpHsigHeaderStart - previous, |
|
404 MfHeaderMode); |
|
405 } |
|
406 //Case 4c: current in H sig.non HT will not come here since it went in previous if or if the previous ifis not true this will be not true |
|
407 else if (current >=plcpHsigHeaderStart) |
|
408 { |
|
409 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
410 noiseInterferenceW, |
|
411 headerMode), |
|
412 current - plcpHsigHeaderStart, |
|
413 headerMode); |
|
414 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
415 noiseInterferenceW, |
|
416 MfHeaderMode), |
|
417 plcpHsigHeaderStart - previous, |
|
418 MfHeaderMode); |
|
419 |
|
420 } |
|
421 //Case 4d: Current with prev in L SIG |
|
422 else |
304 { |
423 { |
305 NS_ASSERT (current >= plcpHeaderStart); |
424 //Case 4di: Non HT format (No HT-SIG or Training Symbols) |
306 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
425 if (preamble == WIFI_PREAMBLE_LONG || preamble == WIFI_PREAMBLE_SHORT) //plcpHtTrainingSymbolsStart==plcpHeaderStart) |
|
426 { |
|
427 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
307 noiseInterferenceW, |
428 noiseInterferenceW, |
308 headerMode), |
429 headerMode), |
309 current - previous, |
430 current - previous, |
310 headerMode); |
431 headerMode); |
|
432 } |
|
433 else |
|
434 { |
|
435 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
436 noiseInterferenceW, |
|
437 MfHeaderMode), |
|
438 current - previous, |
|
439 MfHeaderMode); |
|
440 } |
311 } |
441 } |
312 } |
442 } |
|
443 //Case 5: previous is in the preamble works for all cases |
313 else |
444 else |
314 { |
445 { |
315 if (current >= plcpPayloadStart) |
446 if (current >= plcpPayloadStart) |
316 { |
447 { |
317 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
448 //for all |
318 noiseInterferenceW, |
|
319 headerMode), |
|
320 plcpPayloadStart - plcpHeaderStart, |
|
321 headerMode); |
|
322 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
449 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
323 noiseInterferenceW, |
450 noiseInterferenceW, |
324 payloadMode), |
451 payloadMode), |
325 current - plcpPayloadStart, |
452 current - plcpPayloadStart, |
326 payloadMode); |
453 payloadMode); |
|
454 |
|
455 // Non HT format (No HT-SIG or Training Symbols) |
|
456 if (preamble == WIFI_PREAMBLE_LONG || preamble == WIFI_PREAMBLE_SHORT) |
|
457 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
458 noiseInterferenceW, |
|
459 headerMode), |
|
460 plcpPayloadStart - plcpHeaderStart, |
|
461 headerMode); |
|
462 else |
|
463 // Greenfield or Mixed format |
|
464 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
465 noiseInterferenceW, |
|
466 headerMode), |
|
467 plcpHtTrainingSymbolsStart - plcpHsigHeaderStart, |
|
468 headerMode); |
|
469 if (preamble == WIFI_PREAMBLE_HT_MF) |
|
470 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
471 noiseInterferenceW, |
|
472 MfHeaderMode), |
|
473 plcpHsigHeaderStart-plcpHeaderStart, |
|
474 MfHeaderMode); |
327 } |
475 } |
|
476 else if (current >=plcpHtTrainingSymbolsStart ) |
|
477 { |
|
478 // Non HT format will not come here since it will execute prev if |
|
479 // Greenfield or Mixed format |
|
480 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
481 noiseInterferenceW, |
|
482 headerMode), |
|
483 plcpHtTrainingSymbolsStart - plcpHsigHeaderStart, |
|
484 headerMode); |
|
485 if (preamble == WIFI_PREAMBLE_HT_MF) |
|
486 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
487 noiseInterferenceW, |
|
488 MfHeaderMode), |
|
489 plcpHsigHeaderStart-plcpHeaderStart, |
|
490 MfHeaderMode); |
|
491 } |
|
492 //non HT will not come here |
|
493 else if (current >=plcpHsigHeaderStart) |
|
494 { |
|
495 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
496 noiseInterferenceW, |
|
497 headerMode), |
|
498 current- plcpHsigHeaderStart, |
|
499 headerMode); |
|
500 if (preamble != WIFI_PREAMBLE_HT_GF) |
|
501 { |
|
502 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
503 noiseInterferenceW, |
|
504 MfHeaderMode), |
|
505 plcpHsigHeaderStart-plcpHeaderStart, |
|
506 MfHeaderMode); |
|
507 } |
|
508 } |
|
509 // GF will not come here |
328 else if (current >= plcpHeaderStart) |
510 else if (current >= plcpHeaderStart) |
329 { |
511 { |
|
512 if (preamble == WIFI_PREAMBLE_LONG || preamble == WIFI_PREAMBLE_SHORT) |
|
513 { |
|
514 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
515 noiseInterferenceW, |
|
516 headerMode), |
|
517 current - plcpHeaderStart, |
|
518 headerMode); |
|
519 } |
|
520 else |
|
521 { |
330 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
522 psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
331 noiseInterferenceW, |
523 noiseInterferenceW, |
332 headerMode), |
524 MfHeaderMode), |
333 current - plcpHeaderStart, |
525 current - plcpHeaderStart, |
334 headerMode); |
526 MfHeaderMode); |
|
527 } |
335 } |
528 } |
336 } |
529 } |
337 |
530 |
338 noiseInterferenceW += (*j).GetDelta (); |
531 noiseInterferenceW += (*j).GetDelta (); |
339 previous = (*j).GetTime (); |
532 previous = (*j).GetTime (); |