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

(-)a/src/wifi/model/yans-wifi-phy.cc (-8 / +37 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 587-592    Link Here 
587
                {
592
                {
588
                  //received the first MPDU in an MPDU
593
                  //received the first MPDU in an MPDU
589
                  m_mpdusNum = ampduTag.GetNoOfMpdus()-1;
594
                  m_mpdusNum = ampduTag.GetNoOfMpdus()-1;
595
                  m_preambleFirstMpduReceived = true;
590
                }
596
                }
591
              else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
597
              else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
592
                {
598
                {
 Lines 617-624    Link Here 
617
              NotifyRxBegin (packet);
623
              NotifyRxBegin (packet);
618
              m_interference.NotifyRxStart ();
624
              m_interference.NotifyRxStart ();
619
              m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
625
              m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
620
                                                  packet,
626
                                                  packet, preamble, packetType, event);
621
                                                  event);
622
            }
627
            }
623
          else
628
          else
624
            {
629
            {
 Lines 632-643    Link Here 
632
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
637
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
633
                        rxPowerW << "<" << m_edThresholdW << ")");
638
                        rxPowerW << "<" << m_edThresholdW << ")");
634
          NotifyRxDrop (packet);
639
          NotifyRxDrop (packet);
640
          if (preamble == WIFI_PREAMBLE_NONE && packetType == 2)
641
            {
642
              m_preambleFirstMpduReceived = false;
643
            }
635
          goto maybeCcaBusy;
644
          goto maybeCcaBusy;
636
        }
645
        }
637
      break;
646
      break;
638
    case YansWifiPhy::SLEEP:
647
    case YansWifiPhy::SLEEP:
639
      NS_LOG_DEBUG ("drop packet because in sleep mode");
648
      NS_LOG_DEBUG ("drop packet because in sleep mode");
640
      NotifyRxDrop (packet);
649
      NotifyRxDrop (packet);
650
      if (preamble == WIFI_PREAMBLE_NONE && packetType == 2)
651
        {
652
          m_preambleFirstMpduReceived = false;
653
        }
641
      break;
654
      break;
642
    }
655
    }
643
656
 Lines 947-953    Link Here 
947
}
960
}
948
961
949
void
962
void
950
YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
963
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event)
951
{
964
{
952
  NS_LOG_FUNCTION (this << packet << event);
965
  NS_LOG_FUNCTION (this << packet << event);
953
  NS_ASSERT (IsStateRx ());
966
  NS_ASSERT (IsStateRx ());
 Lines 956-965    Link Here 
956
  struct InterferenceHelper::SnrPer snrPer;
969
  struct InterferenceHelper::SnrPer snrPer;
957
  snrPer = m_interference.CalculateSnrPer (event);
970
  snrPer = m_interference.CalculateSnrPer (event);
958
  m_interference.NotifyRxEnd ();
971
  m_interference.NotifyRxEnd ();
959
972
    
960
  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
973
  if(preamble == WIFI_PREAMBLE_NONE && m_preambleFirstMpduReceived == false)
974
  {
975
    NS_LOG_DEBUG ("Drop MPDU because no preamble has been received");
976
    NotifyRxDrop (packet);
977
    m_state->SwitchFromRxEndError (packet, snrPer.snr);
978
  }
979
  else
980
  {
981
    NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
961
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
982
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
962
  if (m_random->GetValue () > snrPer.per)
983
  
984
    if (m_random->GetValue () > snrPer.per)
963
    {
985
    {
964
      NotifyRxEnd (packet);
986
      NotifyRxEnd (packet);
965
      uint32_t dataRate500KbpsUnits;
987
      uint32_t dataRate500KbpsUnits;
 Lines 977-988    Link Here 
977
      NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
999
      NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
978
      m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
1000
      m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
979
    }
1001
    }
980
  else
1002
    else
981
    {
1003
    {
982
      /* failure. */
1004
      /* failure. */
983
      NotifyRxDrop (packet);
1005
      NotifyRxDrop (packet);
984
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
1006
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
985
    }
1007
    }
1008
        
1009
    if (preamble == WIFI_PREAMBLE_NONE && packetType == 2)
1010
    {
1011
      m_preambleFirstMpduReceived = false;
1012
    }
1013
    
1014
  }
986
}
1015
}
987
1016
988
int64_t
1017
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