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

(-)a/src/wifi/model/yans-wifi-phy.cc (-8 / +49 lines)
 Lines 173-179    Link Here 
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> ();
 Lines 540-545    Link Here 
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
 Lines 559-564    Link Here 
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
 Lines 570-575    Link Here 
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
 Lines 587-592    Link Here 
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
                {
 Lines 617-629    Link Here 
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
        }
 Lines 632-643    Link Here 
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
 Lines 947-953    Link Here 
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 ());
 Lines 956-965    Link Here 
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;
 Lines 977-988    Link Here 
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
(-)a/src/wifi/model/yans-wifi-phy.h (-1 / +4 lines)
 Lines 462-470    Link Here 
462
   * The last bit of the packet has arrived.
462
   * The last bit of the packet has arrived.
463
   *
463
   *
464
   * \param packet the packet that the last bit has arrived
464
   * \param packet the packet that the last bit has arrived
465
   * \param preamble the preamble of the arriving packet
466
   * \param packetType The type of the received packet (values: 0 not an A-MPDU, 1 corresponds to any packets in an A-MPDU except the last one, 2 is the last packet in an A-MPDU)
465
   * \param event the corresponding event of the first time the packet arrives
467
   * \param event the corresponding event of the first time the packet arrives
466
   */
468
   */
467
  void EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
469
  void EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event);
468
470
469
private:
471
private:
470
  virtual void DoInitialize (void);
472
  virtual void DoInitialize (void);
 Lines 540-545    Link Here 
540
  InterferenceHelper m_interference;    //!< Pointer to InterferenceHelper
542
  InterferenceHelper m_interference;    //!< Pointer to InterferenceHelper
541
  Time m_channelSwitchDelay;            //!< Time required to switch between channel
543
  Time m_channelSwitchDelay;            //!< Time required to switch between channel
542
  uint16_t m_mpdusNum;                  //!< carries the number of expected mpdus that are part of an A-MPDU
544
  uint16_t m_mpdusNum;                  //!< carries the number of expected mpdus that are part of an A-MPDU
545
  bool m_preambleFirstMpduReceived;     //!< Flag if the preamble of the first MPDU in an A-MPDU has been received
543
};
546
};
544
547
545
} // namespace ns3
548
} // namespace ns3

Return to bug 2066