LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 CTTC | 3 * Copyright (c) 2009 CTTC |
4 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari | 4 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
5 * Copyright (c) 2017 Orange Labs | 5 * Copyright (c) 2017 Orange Labs |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
9 * published by the Free Software Foundation; | 9 * published by the Free Software Foundation; |
10 * | 10 * |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 uint32_t numMaskBands = maskBand.second - maskBand.first + 1; | 487 uint32_t numMaskBands = maskBand.second - maskBand.first + 1; |
488 NS_ASSERT (numSubBands && numBands && numMaskBands); | 488 NS_ASSERT (numSubBands && numBands && numMaskBands); |
489 NS_LOG_LOGIC ("Power per band " << txPowerPerBandW << "W"); | 489 NS_LOG_LOGIC ("Power per band " << txPowerPerBandW << "W"); |
490 | 490 |
491 //Different power levels | 491 //Different power levels |
492 double txPowerRefDbm = (10.0 * std::log10 (txPowerPerBandW * 1000.0)); | 492 double txPowerRefDbm = (10.0 * std::log10 (txPowerPerBandW * 1000.0)); |
493 double txPowerInnerBandMinDbm = txPowerRefDbm - 20; | 493 double txPowerInnerBandMinDbm = txPowerRefDbm - 20; |
494 double txPowerMiddleBandMinDbm = txPowerRefDbm - 28; | 494 double txPowerMiddleBandMinDbm = txPowerRefDbm - 28; |
495 double txPowerOuterBandMinDbm = txPowerRefDbm + lowestPointDbr; //TODO also ta
ke into account dBm/MHz constraints | 495 double txPowerOuterBandMinDbm = txPowerRefDbm + lowestPointDbr; //TODO also ta
ke into account dBm/MHz constraints |
496 | 496 |
| 497 //Determine parameters that will be used to compute non-truncated global spect
rum mask |
| 498 uint32_t nInbandChannelBands = numMaskBands - (nGuardBands + 1); |
| 499 NS_ASSERT (nInbandChannelBands >= (allocatedSubBands.back ().second - allocate
dSubBands.front ().first)); |
| 500 uint32_t nIdealGuardBands = nInbandChannelBands * 2; //should ideally have as
much band on left and right to fully model out of band transmission constraints |
| 501 NS_ASSERT (nIdealGuardBands >= nGuardBands && (nIdealGuardBands - nGuardBands)
% 2 == 0); |
| 502 uint32_t numIdealMaskBands = nInbandChannelBands + nIdealGuardBands + 1; |
| 503 NS_ASSERT (numIdealMaskBands >= numMaskBands); |
| 504 uint32_t truncationShift = (nIdealGuardBands - nGuardBands) / 2; //shift to ap
ply when allocating power to truncated spectrum mask |
| 505 |
497 //Different widths (in number of bands) | 506 //Different widths (in number of bands) |
498 uint32_t outerSlopeWidth = nGuardBands / 4; // nGuardBands is the total left+r
ight guard band. The left/right outer part is half of the left/right guard band. | 507 uint32_t outerSlopeWidth = nIdealGuardBands / 4; //nIdealGuardBands is the tot
al left+right ideal guard band (wrt to in-band channel width). The left/right ou
ter part is half of the left/right guard band. |
499 uint32_t middleSlopeWidth = outerSlopeWidth - (innerSlopeWidth / 2); | 508 uint32_t middleSlopeWidth = outerSlopeWidth - (innerSlopeWidth / 2); |
500 StartStop outerBandLeft (maskBand.first, //to handle cases where allocated cha
nnel is under WifiPhy configured channel width. | 509 StartStop outerBandLeft (maskBand.first, //to handle cases where allocated cha
nnel is under WifiPhy configured channel width (especially true for mask.second) |
501 maskBand.first + outerSlopeWidth - 1); | 510 maskBand.first + outerSlopeWidth - 1); |
502 StartStop middleBandLeft (outerBandLeft.second + 1, | 511 StartStop middleBandLeft (outerBandLeft.second + 1, |
503 outerBandLeft.second + middleSlopeWidth); | 512 outerBandLeft.second + middleSlopeWidth); |
504 StartStop innerBandLeft (allocatedSubBands.front ().first - innerSlopeWidth, | 513 StartStop innerBandLeft (allocatedSubBands.front ().first + truncationShift -
innerSlopeWidth, |
505 allocatedSubBands.front ().first - 1); //better to pl
ace slope based on allocated subcarriers | 514 allocatedSubBands.front ().first + truncationShift -
1); //better to place slope based on (shifted) allocated subcarriers |
506 StartStop flatJunctionLeft (middleBandLeft.second + 1, | 515 StartStop flatJunctionLeft (middleBandLeft.second + 1, |
507 innerBandLeft.first - 1); //in order to handle shi
ft due to guard subcarriers | 516 innerBandLeft.first - 1); //in order to handle shi
ft due to guard subcarriers |
508 StartStop outerBandRight (maskBand.second - outerSlopeWidth + 1, | 517 StartStop outerBandRight (maskBand.second + 2 * truncationShift - outerSlopeWi
dth + 1, |
509 maskBand.second); //start from outer edge to be able
to compute flat junction width | 518 maskBand.second + 2 * truncationShift); //start from
outer edge (of ideal mask) to be able to compute flat junction width |
510 StartStop middleBandRight (outerBandRight.first - middleSlopeWidth, | 519 StartStop middleBandRight (outerBandRight.first - middleSlopeWidth, |
511 outerBandRight.first - 1); | 520 outerBandRight.first - 1); |
512 StartStop innerBandRight (allocatedSubBands.back ().second + 1, | 521 StartStop innerBandRight (allocatedSubBands.back ().second + truncationShift +
1, |
513 allocatedSubBands.back ().second + innerSlopeWidth); | 522 allocatedSubBands.back ().second + truncationShift +
innerSlopeWidth); |
514 StartStop flatJunctionRight (innerBandRight.second + 1, | 523 StartStop flatJunctionRight (innerBandRight.second + 1, |
515 middleBandRight.first - 1); | 524 middleBandRight.first - 1); |
516 NS_LOG_DEBUG ("outerBandLeft=[" << outerBandLeft.first << ";" << outerBandLeft
.second << "] " << | 525 NS_LOG_DEBUG ("outerBandLeft=[" << outerBandLeft.first << ";" << outerBandLeft
.second << "] " << |
517 "middleBandLeft=[" << middleBandLeft.first << ";" << middleBandL
eft.second << "] " << | 526 "middleBandLeft=[" << middleBandLeft.first << ";" << middleBandL
eft.second << "] " << |
518 "flatJunctionLeft=[" << flatJunctionLeft.first << ";" << flatJun
ctionLeft.second << "] " << | 527 "flatJunctionLeft=[" << flatJunctionLeft.first << ";" << flatJun
ctionLeft.second << "] " << |
519 "innerBandLeft=[" << innerBandLeft.first << ";" << innerBandLeft
.second << "] " << | 528 "innerBandLeft=[" << innerBandLeft.first << ";" << innerBandLeft
.second << "] " << |
520 "subBands=[" << allocatedSubBands.front ().first << ";" << alloc
atedSubBands.back ().second << "] " << | 529 "subBands=[" << allocatedSubBands.front ().first + truncationShi
ft << ";" << allocatedSubBands.back ().second + truncationShift << "] " << |
521 "innerBandRight=[" << innerBandRight.first << ";" << innerBandRi
ght.second << "] " << | 530 "innerBandRight=[" << innerBandRight.first << ";" << innerBandRi
ght.second << "] " << |
522 "flatJunctionRight=[" << flatJunctionRight.first << ";" << flatJ
unctionRight.second << "] " << | 531 "flatJunctionRight=[" << flatJunctionRight.first << ";" << flatJ
unctionRight.second << "] " << |
523 "middleBandRight=[" << middleBandRight.first << ";" << middleBan
dRight.second << "] " << | 532 "middleBandRight=[" << middleBandRight.first << ";" << middleBan
dRight.second << "] " << |
524 "outerBandRight=[" << outerBandRight.first << ";" << outerBandRi
ght.second << "] "); | 533 "outerBandRight=[" << outerBandRight.first << ";" << outerBandRi
ght.second << "] "); |
525 NS_ASSERT (numMaskBands == ((allocatedSubBands.back ().second - allocatedSubBa
nds.front ().first + 1) //equivalent to allocatedBand (includes notches and DC) | 534 NS_ASSERT (numIdealMaskBands == ((allocatedSubBands.back ().second - allocated
SubBands.front ().first + 1) //equivalent to allocatedBand (includes notches an
d DC) |
526 + 2 * (innerSlopeWidth + middleSlopeWidth + outerSl
opeWidth) | 535 + 2 * (innerSlopeWidth + middleSlopeWidth + ou
terSlopeWidth) |
527 + (flatJunctionLeft.second - flatJunctionLeft.first
+ 1) //flat junctions | 536 + (flatJunctionLeft.second - flatJunctionLeft.
first + 1) //flat junctions |
528 + (flatJunctionRight.second - flatJunctionRight.fir
st + 1))); | 537 + (flatJunctionRight.second - flatJunctionRigh
t.first + 1))); |
529 | 538 |
530 //Different slopes | 539 //Different slopes |
531 double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr | 540 double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr |
532 double middleSlope = 8.0 / middleSlopeWidth; //20 to 28dBr | 541 double middleSlope = 8.0 / middleSlopeWidth; //20 to 28dBr |
533 double outerSlope = (txPowerMiddleBandMinDbm - txPowerOuterBandMinDbm) / outer
SlopeWidth; | 542 double outerSlope = (txPowerMiddleBandMinDbm - txPowerOuterBandMinDbm) / outer
SlopeWidth; |
534 | 543 |
535 //Build spectrum mask | 544 //Build spectrum mask |
536 Values::iterator vit = c->ValuesBegin (); | 545 Values::iterator vit = c->ValuesBegin (); |
537 Bands::const_iterator bit = c->ConstBandsBegin (); | 546 Bands::const_iterator bit = c->ConstBandsBegin (); |
538 double txPowerW = 0.0; | 547 double txPowerW = 0.0; |
539 for (size_t i = 0; i < numBands; i++, vit++, bit++) | 548 for (size_t i = 0; i < numBands; i++, vit++, bit++) |
540 { | 549 { |
| 550 uint32_t iShift = i + truncationShift; |
541 if (i < maskBand.first || i > maskBand.second) //outside the spectrum mask | 551 if (i < maskBand.first || i > maskBand.second) //outside the spectrum mask |
542 { | 552 { |
543 txPowerW = 0.0; | 553 txPowerW = 0.0; |
544 } | 554 } |
545 else if (i <= outerBandLeft.second && i >= outerBandLeft.first) //better t
o put greater first (less computation) | 555 else if (iShift <= outerBandLeft.second && iShift >= outerBandLeft.first)
//better to put greater first (less computation) |
546 { | 556 { |
547 txPowerW = DbmToW (txPowerOuterBandMinDbm + ((i - outerBandLeft.first)
* outerSlope)); | 557 txPowerW = DbmToW (txPowerOuterBandMinDbm + ((iShift - outerBandLeft.f
irst) * outerSlope)); |
548 } | 558 } |
549 else if (i <= middleBandLeft.second && i >= middleBandLeft.first) | 559 else if (iShift <= middleBandLeft.second && iShift >= middleBandLeft.first
) |
550 { | 560 { |
551 txPowerW = DbmToW (txPowerMiddleBandMinDbm + ((i - middleBandLeft.firs
t) * middleSlope)); | 561 txPowerW = DbmToW (txPowerMiddleBandMinDbm + ((iShift - middleBandLeft
.first) * middleSlope)); |
552 } | 562 } |
553 else if (i <= flatJunctionLeft.second && i >= flatJunctionLeft.first) | 563 else if (iShift <= flatJunctionLeft.second && iShift >= flatJunctionLeft.f
irst) |
554 { | 564 { |
555 txPowerW = DbmToW (txPowerInnerBandMinDbm); | 565 txPowerW = DbmToW (txPowerInnerBandMinDbm); |
556 } | 566 } |
557 else if (i <= innerBandLeft.second && i >= innerBandLeft.first) | 567 else if (iShift <= innerBandLeft.second && iShift >= innerBandLeft.first) |
558 { | 568 { |
559 txPowerW = DbmToW (txPowerInnerBandMinDbm + ((i - innerBandLeft.first)
* innerSlope)); | 569 txPowerW = DbmToW (txPowerInnerBandMinDbm + ((iShift - innerBandLeft.f
irst) * innerSlope)); |
560 } | 570 } |
561 else if (i <= allocatedSubBands.back ().second && i >= allocatedSubBands.f
ront ().first) //roughly in allocated band | 571 else if (i <= allocatedSubBands.back ().second && i >= allocatedSubBands.f
ront ().first) //roughly in allocated band |
562 { | 572 { |
563 bool insideSubBand = false; | 573 bool insideSubBand = false; |
564 for (uint32_t j = 0; !insideSubBand && j < numSubBands; j++) //continu
e until inside a sub-band | 574 for (uint32_t j = 0; !insideSubBand && j < numSubBands; j++) //continu
e until inside a sub-band |
565 { | 575 { |
566 insideSubBand = (i <= allocatedSubBands[j].second) && (i >= alloca
tedSubBands[j].first); | 576 insideSubBand = (i <= allocatedSubBands[j].second) && (i >= alloca
tedSubBands[j].first); |
567 } | 577 } |
568 if (insideSubBand) | 578 if (insideSubBand) |
569 { | 579 { |
570 txPowerW = txPowerPerBandW; | 580 txPowerW = txPowerPerBandW; |
571 } | 581 } |
572 else | 582 else |
573 { | 583 { |
574 txPowerW = DbmToW (txPowerInnerBandMinDbm); //consider that nulled
as much as possible inband but power leakage -> -20dBr | 584 txPowerW = DbmToW (txPowerInnerBandMinDbm); //consider that nulled
as much as possible inband but power leakage -> -20dBr |
575 } | 585 } |
576 } | 586 } |
577 else if (i <= innerBandRight.second && i >= innerBandRight.first) | 587 else if (iShift <= innerBandRight.second && iShift >= innerBandRight.first
) |
578 { | 588 { |
579 txPowerW = DbmToW (txPowerRefDbm - ((i - innerBandRight.first + 1) * i
nnerSlope)); // +1 so as to be symmetric with left slope | 589 txPowerW = DbmToW (txPowerRefDbm - ((iShift - innerBandRight.first + 1
) * innerSlope)); // +1 so as to be symmetric with left slope |
580 } | 590 } |
581 else if (i <= flatJunctionRight.second && i >= flatJunctionRight.first) | 591 else if (iShift <= flatJunctionRight.second && iShift >= flatJunctionRight
.first) |
582 { | 592 { |
583 txPowerW = DbmToW (txPowerInnerBandMinDbm); | 593 txPowerW = DbmToW (txPowerInnerBandMinDbm); |
584 } | 594 } |
585 else if (i <= middleBandRight.second && i >= middleBandRight.first) | 595 else if (iShift <= middleBandRight.second && iShift >= middleBandRight.fir
st) |
586 { | 596 { |
587 txPowerW = DbmToW (txPowerInnerBandMinDbm - ((i - middleBandRight.firs
t + 1) * middleSlope)); // +1 so as to be symmetric with left slope | 597 txPowerW = DbmToW (txPowerInnerBandMinDbm - ((iShift - middleBandRight
.first + 1) * middleSlope)); // +1 so as to be symmetric with left slope |
588 } | 598 } |
589 else if (i <= outerBandRight.second && i >= outerBandRight.first) | 599 else if (iShift <= outerBandRight.second && iShift >= outerBandRight.first
) |
590 { | 600 { |
591 txPowerW = DbmToW (txPowerMiddleBandMinDbm - ((i - outerBandRight.firs
t + 1) * outerSlope)); // +1 so as to be symmetric with left slope | 601 txPowerW = DbmToW (txPowerMiddleBandMinDbm - ((i - outerBandRight.firs
t + 1) * outerSlope)); // +1 so as to be symmetric with left slope |
592 } | 602 } |
593 else | 603 else |
594 { | 604 { |
595 NS_FATAL_ERROR ("Should have handled all cases"); | 605 NS_FATAL_ERROR ("Should have handled all cases"); |
596 } | 606 } |
597 double txPowerDbr = 10 * std::log10 (txPowerW / txPowerPerBandW); | 607 double txPowerDbr = 10 * std::log10 (txPowerW / txPowerPerBandW); |
598 NS_LOG_LOGIC (uint32_t(i) << " -> " << txPowerDbr); | 608 NS_LOG_LOGIC (uint32_t(i) << " -> " << txPowerDbr); |
599 *vit = txPowerW / (bit->fh - bit->fl); | 609 *vit = txPowerW / (bit->fh - bit->fl); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 (*rf)[channel + 3] = 1; | 721 (*rf)[channel + 3] = 1; |
712 (*rf)[channel + 4] = 1; | 722 (*rf)[channel + 4] = 1; |
713 (*rf)[channel + 5] = 1; | 723 (*rf)[channel + 5] = 1; |
714 (*rf)[channel + 6] = 1; | 724 (*rf)[channel + 6] = 1; |
715 | 725 |
716 return rf; | 726 return rf; |
717 } | 727 } |
718 | 728 |
719 | 729 |
720 } // namespace ns3 | 730 } // namespace ns3 |
LEFT | RIGHT |