|
|
| 173 |
m_channelNumber (1), |
173 |
m_channelNumber (1), |
| 174 |
m_endRxEvent (), |
174 |
m_endRxEvent (), |
| 175 |
m_channelStartingFrequency (0), |
175 |
m_channelStartingFrequency (0), |
| 176 |
m_mpdusNum(0) |
176 |
m_mpdusNum(0), |
|
|
177 |
m_preambleFirstMpduReceived (false) |
| 177 |
{ |
178 |
{ |
| 178 |
NS_LOG_FUNCTION (this); |
179 |
NS_LOG_FUNCTION (this); |
| 179 |
m_random = CreateObject<UniformRandomVariable> (); |
180 |
m_random = CreateObject<UniformRandomVariable> (); |
|
|
| 540 |
case YansWifiPhy::SWITCHING: |
541 |
case YansWifiPhy::SWITCHING: |
| 541 |
NS_LOG_DEBUG ("drop packet because of channel switching"); |
542 |
NS_LOG_DEBUG ("drop packet because of channel switching"); |
| 542 |
NotifyRxDrop (packet); |
543 |
NotifyRxDrop (packet); |
|
|
544 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 545 |
{ |
| 546 |
m_preambleFirstMpduReceived = false; |
| 547 |
} |
| 543 |
/* |
548 |
/* |
| 544 |
* Packets received on the upcoming channel are added to the event list |
549 |
* Packets received on the upcoming channel are added to the event list |
| 545 |
* during the switching state. This way the medium can be correctly sensed |
550 |
* during the switching state. This way the medium can be correctly sensed |
|
|
| 559 |
NS_LOG_DEBUG ("drop packet because already in Rx (power=" << |
564 |
NS_LOG_DEBUG ("drop packet because already in Rx (power=" << |
| 560 |
rxPowerW << "W)"); |
565 |
rxPowerW << "W)"); |
| 561 |
NotifyRxDrop (packet); |
566 |
NotifyRxDrop (packet); |
|
|
567 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 568 |
{ |
| 569 |
m_preambleFirstMpduReceived = false; |
| 570 |
} |
| 562 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
571 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
| 563 |
{ |
572 |
{ |
| 564 |
// that packet will be noise _after_ the reception of the |
573 |
// that packet will be noise _after_ the reception of the |
|
|
| 570 |
NS_LOG_DEBUG ("drop packet because already in Tx (power=" << |
579 |
NS_LOG_DEBUG ("drop packet because already in Tx (power=" << |
| 571 |
rxPowerW << "W)"); |
580 |
rxPowerW << "W)"); |
| 572 |
NotifyRxDrop (packet); |
581 |
NotifyRxDrop (packet); |
|
|
582 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 583 |
{ |
| 584 |
m_preambleFirstMpduReceived = false; |
| 585 |
} |
| 573 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
586 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
| 574 |
{ |
587 |
{ |
| 575 |
// that packet will be noise _after_ the transmission of the |
588 |
// that packet will be noise _after_ the transmission of the |
|
|
| 587 |
{ |
600 |
{ |
| 588 |
//received the first MPDU in an MPDU |
601 |
//received the first MPDU in an MPDU |
| 589 |
m_mpdusNum = ampduTag.GetNoOfMpdus()-1; |
602 |
m_mpdusNum = ampduTag.GetNoOfMpdus()-1; |
|
|
603 |
m_preambleFirstMpduReceived = true; |
| 590 |
} |
604 |
} |
| 591 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
605 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 592 |
{ |
606 |
{ |
|
|
| 617 |
NotifyRxBegin (packet); |
631 |
NotifyRxBegin (packet); |
| 618 |
m_interference.NotifyRxStart (); |
632 |
m_interference.NotifyRxStart (); |
| 619 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
633 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
| 620 |
packet, |
634 |
packet, preamble, packetType, event); |
| 621 |
event); |
|
|
| 622 |
} |
635 |
} |
| 623 |
else |
636 |
else |
| 624 |
{ |
637 |
{ |
| 625 |
NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")"); |
638 |
NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")"); |
| 626 |
NotifyRxDrop (packet); |
639 |
NotifyRxDrop (packet); |
|
|
640 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 641 |
{ |
| 642 |
m_preambleFirstMpduReceived = false; |
| 643 |
} |
| 627 |
goto maybeCcaBusy; |
644 |
goto maybeCcaBusy; |
| 628 |
} |
645 |
} |
| 629 |
} |
646 |
} |
|
|
| 632 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
649 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
| 633 |
rxPowerW << "<" << m_edThresholdW << ")"); |
650 |
rxPowerW << "<" << m_edThresholdW << ")"); |
| 634 |
NotifyRxDrop (packet); |
651 |
NotifyRxDrop (packet); |
|
|
652 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 653 |
{ |
| 654 |
m_preambleFirstMpduReceived = false; |
| 655 |
} |
| 635 |
goto maybeCcaBusy; |
656 |
goto maybeCcaBusy; |
| 636 |
} |
657 |
} |
| 637 |
break; |
658 |
break; |
| 638 |
case YansWifiPhy::SLEEP: |
659 |
case YansWifiPhy::SLEEP: |
| 639 |
NS_LOG_DEBUG ("drop packet because in sleep mode"); |
660 |
NS_LOG_DEBUG ("drop packet because in sleep mode"); |
| 640 |
NotifyRxDrop (packet); |
661 |
NotifyRxDrop (packet); |
|
|
662 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 663 |
{ |
| 664 |
m_preambleFirstMpduReceived = false; |
| 665 |
} |
| 641 |
break; |
666 |
break; |
| 642 |
} |
667 |
} |
| 643 |
|
668 |
|
|
|
| 947 |
} |
972 |
} |
| 948 |
|
973 |
|
| 949 |
void |
974 |
void |
| 950 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event) |
975 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event) |
| 951 |
{ |
976 |
{ |
| 952 |
NS_LOG_FUNCTION (this << packet << event); |
977 |
NS_LOG_FUNCTION (this << packet << event); |
| 953 |
NS_ASSERT (IsStateRx ()); |
978 |
NS_ASSERT (IsStateRx ()); |
|
|
| 956 |
struct InterferenceHelper::SnrPer snrPer; |
981 |
struct InterferenceHelper::SnrPer snrPer; |
| 957 |
snrPer = m_interference.CalculateSnrPer (event); |
982 |
snrPer = m_interference.CalculateSnrPer (event); |
| 958 |
m_interference.NotifyRxEnd (); |
983 |
m_interference.NotifyRxEnd (); |
| 959 |
|
984 |
|
| 960 |
NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) << |
985 |
if(preamble == WIFI_PREAMBLE_NONE && m_preambleFirstMpduReceived == false) |
|
|
986 |
{ |
| 987 |
NS_LOG_DEBUG ("Drop MPDU because no preamble has been received"); |
| 988 |
NotifyRxDrop (packet); |
| 989 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
| 990 |
} |
| 991 |
else |
| 992 |
{ |
| 993 |
NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) << |
| 961 |
", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ()); |
994 |
", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ()); |
| 962 |
if (m_random->GetValue () > snrPer.per) |
995 |
|
|
|
996 |
if (m_random->GetValue () > snrPer.per) |
| 963 |
{ |
997 |
{ |
| 964 |
NotifyRxEnd (packet); |
998 |
NotifyRxEnd (packet); |
| 965 |
uint32_t dataRate500KbpsUnits; |
999 |
uint32_t dataRate500KbpsUnits; |
|
|
| 977 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); |
1011 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); |
| 978 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ()); |
1012 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ()); |
| 979 |
} |
1013 |
} |
| 980 |
else |
1014 |
else |
| 981 |
{ |
1015 |
{ |
| 982 |
/* failure. */ |
1016 |
/* failure. */ |
| 983 |
NotifyRxDrop (packet); |
1017 |
NotifyRxDrop (packet); |
| 984 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
1018 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
| 985 |
} |
1019 |
} |
|
|
1020 |
|
| 1021 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 1022 |
{ |
| 1023 |
m_preambleFirstMpduReceived = false; |
| 1024 |
} |
| 1025 |
|
| 1026 |
} |
| 986 |
} |
1027 |
} |
| 987 |
|
1028 |
|
| 988 |
int64_t |
1029 |
int64_t |