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

(-)a/src/wifi/model/preamble-detection-model.cc (+36 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 University of Washington
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
7
 * published by the Free Software Foundation;
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#include "preamble-detection-model.h"
22
23
namespace ns3 {
24
25
NS_OBJECT_ENSURE_REGISTERED (PreambleDetectionModel);
26
27
TypeId PreambleDetectionModel::GetTypeId (void)
28
{
29
  static TypeId tid = TypeId ("ns3::PreambleDetectionModel")
30
    .SetParent<Object> ()
31
    .SetGroupName ("Wifi")
32
  ;
33
  return tid;
34
}
35
36
} //namespace ns3
(-)a/src/wifi/model/preamble-detection-model.h (+58 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 University of Washington
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
7
 * published by the Free Software Foundation;
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#ifndef PREAMBLE_DETECTION_MODEL_H
22
#define PREAMBLE_DETECTION_MODEL_H
23
24
#include "ns3/object.h"
25
26
namespace ns3 {
27
28
/**
29
 * \ingroup wifi
30
 * \brief the interface for Wifi's preamble detection models
31
 *
32
 */
33
class PreambleDetectionModel : public Object
34
{
35
public:
36
  /**
37
   * \brief Get the type ID.
38
   * \return the object TypeId
39
   */
40
  static TypeId GetTypeId (void);
41
42
  /**
43
   * A pure virtual method that must be implemented in the subclass.
44
   * This method returns whether the preamble detection was successful.
45
   *
46
   * \param snr the SNR of the received signal.
47
   * \param channelWidth the channel width of the received signal in MHz.
48
   *
49
   * \return true if the preamble has been detected,
50
   *         false otherwise
51
   */
52
  virtual bool IsPreambleDetected (double snr, double channelWidth) const = 0;
53
};
54
55
} //namespace ns3
56
57
#endif /* PREAMBLE_DETECTION_MODEL_H */
58
(-)a/src/wifi/model/simple-preamble-detection-model.cc (+65 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 University of Washington
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
7
 * published by the Free Software Foundation;
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#include "ns3/log.h"
22
#include "ns3/double.h"
23
#include "simple-preamble-detection-model.h"
24
#include "wifi-utils.h"
25
26
namespace ns3 {
27
28
NS_LOG_COMPONENT_DEFINE ("SimplePreambleDetectionModel");
29
30
NS_OBJECT_ENSURE_REGISTERED (SimplePreambleDetectionModel);
31
32
TypeId
33
SimplePreambleDetectionModel::GetTypeId (void)
34
{
35
  static TypeId tid = TypeId ("ns3::SimplePreambleDetectionModel")
36
    .SetParent<PreambleDetectionModel> ()
37
    .SetGroupName ("Wifi")
38
    .AddConstructor<SimplePreambleDetectionModel> ()
39
    .AddAttribute ("Threshold",
40
                   "Preamble is successfully detection if the SNR is at or above this value (expressed in dB).",
41
                   DoubleValue (2),
42
                   MakeDoubleAccessor (&SimplePreambleDetectionModel::m_threshold),
43
                   MakeDoubleChecker<double> ())
44
  ;
45
  return tid;
46
}
47
48
SimplePreambleDetectionModel::SimplePreambleDetectionModel ()
49
{
50
  NS_LOG_FUNCTION (this);
51
}
52
53
SimplePreambleDetectionModel::~SimplePreambleDetectionModel ()
54
{
55
  NS_LOG_FUNCTION (this);
56
}
57
58
bool
59
SimplePreambleDetectionModel::IsPreambleDetected (double snr, double channelWidth) const
60
{
61
  NS_LOG_FUNCTION (this);
62
  return (RatioToDb (snr) >= m_threshold);
63
}
64
65
} //namespace ns3
(-)a/src/wifi/model/simple-preamble-detection-model.h (+63 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 University of Washington
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
7
 * published by the Free Software Foundation;
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#ifndef SIMPLE_PREAMBLE_DETECTION_MODEL_H
22
#define SIMPLE_PREAMBLE_DETECTION_MODEL_H
23
24
#include "preamble-detection-model.h"
25
26
namespace ns3 {
27
/**
28
 * \ingroup wifi
29
 *
30
 * A simple model for detecting PHY preamble.
31
 * This model assumes that a preamble is successfully detected if SNR is at or above a given threshold. By default, this threshold is set to 2 dB.
32
 */
33
class SimplePreambleDetectionModel : public PreambleDetectionModel
34
{
35
public:
36
  /**
37
   * \brief Get the type ID.
38
   * \return the object TypeId
39
   */
40
  static TypeId GetTypeId (void);
41
42
  SimplePreambleDetectionModel ();
43
  ~SimplePreambleDetectionModel ();
44
45
  /**
46
   * This method returns whether the preamble detection was successful.
47
   *
48
   * \param snr the SNR ratio (not dB) of the received signal.
49
   * \param channelWidth the channel width of the received signal in MHz.
50
   *
51
   * \return true if the preamble has been detected,
52
   *         false otherwise
53
   */
54
  bool IsPreambleDetected (double snr, double channelWidth) const;
55
56
57
private:
58
  double m_threshold; ///< SNR threshold in dB used to decide whether a preamble is successfully received
59
};
60
61
} //namespace ns3
62
63
#endif /* SIMPLE_PREAMBLE_DETECTION_MODEL_H */
(-)a/src/wifi/model/spectrum-wifi-phy.cc (-1 / +1 lines)
 Lines 259-265   SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams) Link Here 
259
259
260
  NS_LOG_INFO ("Received Wi-Fi signal");
260
  NS_LOG_INFO ("Received Wi-Fi signal");
261
  Ptr<Packet> packet = wifiRxParams->packet->Copy ();
261
  Ptr<Packet> packet = wifiRxParams->packet->Copy ();
262
  StartReceivePreambleAndHeader (packet, rxPowerW, rxDuration);
262
  StartReceivePreamble (packet, rxPowerW, rxDuration);
263
}
263
}
264
264
265
Ptr<AntennaModel>
265
Ptr<AntennaModel>
(-)a/src/wifi/model/wifi-phy.cc (-27 / +98 lines)
 Lines 30-35    Link Here 
30
#include "ampdu-tag.h"
30
#include "ampdu-tag.h"
31
#include "wifi-utils.h"
31
#include "wifi-utils.h"
32
#include "frame-capture-model.h"
32
#include "frame-capture-model.h"
33
#include "preamble-detection-model.h"
33
#include "wifi-radio-energy-model.h"
34
#include "wifi-radio-energy-model.h"
34
#include "error-rate-model.h"
35
#include "error-rate-model.h"
35
#include "wifi-net-device.h"
36
#include "wifi-net-device.h"
 Lines 299-304   WifiPhy::GetTypeId (void) Link Here 
299
                   PointerValue (),
300
                   PointerValue (),
300
                   MakePointerAccessor (&WifiPhy::m_frameCaptureModel),
301
                   MakePointerAccessor (&WifiPhy::m_frameCaptureModel),
301
                   MakePointerChecker <FrameCaptureModel> ())
302
                   MakePointerChecker <FrameCaptureModel> ())
303
    .AddAttribute ("PreambleDetectionModel",
304
                   "Ptr to an object that implements the preamble detection model",
305
                   PointerValue (),
306
                   MakePointerAccessor (&WifiPhy::m_preambleDetectionModel),
307
                   MakePointerChecker <PreambleDetectionModel> ())
302
    .AddAttribute ("PostReceptionErrorModel",
308
    .AddAttribute ("PostReceptionErrorModel",
303
                   "An optional packet error model can be added to the receive "
309
                   "An optional packet error model can be added to the receive "
304
                   "packet process after any propagation-based (SNR-based) error "
310
                   "packet process after any propagation-based (SNR-based) error "
 Lines 363-368   WifiPhy::WifiPhy () Link Here 
363
    m_rxMpduReferenceNumber (0xffffffff),
369
    m_rxMpduReferenceNumber (0xffffffff),
364
    m_endRxEvent (),
370
    m_endRxEvent (),
365
    m_endPlcpRxEvent (),
371
    m_endPlcpRxEvent (),
372
    m_endPreambleDetectionEvent (),
366
    m_standard (WIFI_PHY_STANDARD_UNSPECIFIED),
373
    m_standard (WIFI_PHY_STANDARD_UNSPECIFIED),
367
    m_isConstructed (false),
374
    m_isConstructed (false),
368
    m_channelCenterFrequency (0),
375
    m_channelCenterFrequency (0),
 Lines 742-747   WifiPhy::SetFrameCaptureModel (const Ptr<FrameCaptureModel> model) Link Here 
742
}
749
}
743
750
744
void
751
void
752
WifiPhy::SetPreambleDetectionModel (const Ptr<PreambleDetectionModel> model)
753
{
754
  m_preambleDetectionModel = model;
755
}
756
757
void
745
WifiPhy::SetWifiRadioEnergyModel (const Ptr<WifiRadioEnergyModel> wifiRadioEnergyModel)
758
WifiPhy::SetWifiRadioEnergyModel (const Ptr<WifiRadioEnergyModel> wifiRadioEnergyModel)
746
{
759
{
747
  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
760
  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
 Lines 1485-1490   WifiPhy::DoChannelSwitch (uint8_t nch) Link Here 
1485
      NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1498
      NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1486
      m_endPlcpRxEvent.Cancel ();
1499
      m_endPlcpRxEvent.Cancel ();
1487
      m_endRxEvent.Cancel ();
1500
      m_endRxEvent.Cancel ();
1501
      m_endPreambleDetectionEvent.Cancel ();
1488
      goto switchChannel;
1502
      goto switchChannel;
1489
      break;
1503
      break;
1490
    case WifiPhyState::TX:
1504
    case WifiPhyState::TX:
 Lines 1493-1498   WifiPhy::DoChannelSwitch (uint8_t nch) Link Here 
1493
      break;
1507
      break;
1494
    case WifiPhyState::CCA_BUSY:
1508
    case WifiPhyState::CCA_BUSY:
1495
    case WifiPhyState::IDLE:
1509
    case WifiPhyState::IDLE:
1510
      if (m_endPreambleDetectionEvent.IsRunning ())
1511
      {
1512
        m_endPreambleDetectionEvent.Cancel ();
1513
        m_endRxEvent.Cancel ();
1514
      }
1496
      goto switchChannel;
1515
      goto switchChannel;
1497
      break;
1516
      break;
1498
    case WifiPhyState::SLEEP:
1517
    case WifiPhyState::SLEEP:
 Lines 1537-1542   WifiPhy::DoFrequencySwitch (uint16_t frequency) Link Here 
1537
      NS_LOG_DEBUG ("drop packet because of channel/frequency switching while reception");
1556
      NS_LOG_DEBUG ("drop packet because of channel/frequency switching while reception");
1538
      m_endPlcpRxEvent.Cancel ();
1557
      m_endPlcpRxEvent.Cancel ();
1539
      m_endRxEvent.Cancel ();
1558
      m_endRxEvent.Cancel ();
1559
      m_endPreambleDetectionEvent.Cancel ();
1540
      goto switchFrequency;
1560
      goto switchFrequency;
1541
      break;
1561
      break;
1542
    case WifiPhyState::TX:
1562
    case WifiPhyState::TX:
 Lines 1545-1550   WifiPhy::DoFrequencySwitch (uint16_t frequency) Link Here 
1545
      break;
1565
      break;
1546
    case WifiPhyState::CCA_BUSY:
1566
    case WifiPhyState::CCA_BUSY:
1547
    case WifiPhyState::IDLE:
1567
    case WifiPhyState::IDLE:
1568
      if (m_endPreambleDetectionEvent.IsRunning ())
1569
      {
1570
        m_endPreambleDetectionEvent.Cancel ();
1571
        m_endRxEvent.Cancel ();
1572
      }
1548
      goto switchFrequency;
1573
      goto switchFrequency;
1549
      break;
1574
      break;
1550
    case WifiPhyState::SLEEP:
1575
    case WifiPhyState::SLEEP:
 Lines 1608-1629   void Link Here 
1608
WifiPhy::SetOffMode (void)
1633
WifiPhy::SetOffMode (void)
1609
{
1634
{
1610
  NS_LOG_FUNCTION (this);
1635
  NS_LOG_FUNCTION (this);
1611
  switch (m_state->GetState ())
1636
  m_endPlcpRxEvent.Cancel ();
1612
    {
1637
  m_endRxEvent.Cancel ();
1613
    case WifiPhyState::RX:
1638
  m_endPreambleDetectionEvent.Cancel ();
1614
      m_endPlcpRxEvent.Cancel ();
1639
  m_state->SwitchToOff ();
1615
      m_endRxEvent.Cancel ();
1616
    case WifiPhyState::TX:
1617
    case WifiPhyState::SWITCHING:
1618
    case WifiPhyState::CCA_BUSY:
1619
    case WifiPhyState::IDLE:
1620
    case WifiPhyState::SLEEP:
1621
      m_state->SwitchToOff ();
1622
      break;
1623
    default:
1624
      NS_ASSERT (false);
1625
      break;
1626
    }
1627
}
1640
}
1628
1641
1629
void
1642
void
 Lines 1706-1711   WifiPhy::GetHePlcpHeaderMode () Link Here 
1706
}
1719
}
1707
1720
1708
Time
1721
Time
1722
WifiPhy::GetPreambleDetectionDuration (void)
1723
{
1724
  return MicroSeconds (4);
1725
}
1726
1727
Time
1709
WifiPhy::GetPlcpTrainingSymbolDuration (WifiTxVector txVector)
1728
WifiPhy::GetPlcpTrainingSymbolDuration (WifiTxVector txVector)
1710
{
1729
{
1711
  uint8_t Ndltf, Neltf;
1730
  uint8_t Ndltf, Neltf;
 Lines 2368-2379   WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m Link Here 
2368
  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, GetFrequency (), mpdutype, 1);
2387
  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, GetFrequency (), mpdutype, 1);
2369
  NS_ASSERT (txDuration.IsStrictlyPositive ());
2388
  NS_ASSERT (txDuration.IsStrictlyPositive ());
2370
2389
2371
  if (m_state->IsStateRx ())
2390
  if (m_endPreambleDetectionEvent.IsRunning ())
2391
    {
2392
      m_endPreambleDetectionEvent.Cancel ();
2393
    }
2394
  if (m_endPlcpRxEvent.IsRunning ())
2372
    {
2395
    {
2373
      m_endPlcpRxEvent.Cancel ();
2396
      m_endPlcpRxEvent.Cancel ();
2397
    }
2398
  if (m_endRxEvent.IsRunning ())
2399
    {
2374
      m_endRxEvent.Cancel ();
2400
      m_endRxEvent.Cancel ();
2401
    }
2402
  if (m_state->IsStateRx ())
2403
    {
2375
      m_interference.NotifyRxEnd ();
2404
      m_interference.NotifyRxEnd ();
2376
    }
2405
    }
2406
2377
  NotifyTxBegin (packet);
2407
  NotifyTxBegin (packet);
2378
  if ((mpdutype == MPDU_IN_AGGREGATE) && (txVector.GetPreambleType () != WIFI_PREAMBLE_NONE))
2408
  if ((mpdutype == MPDU_IN_AGGREGATE) && (txVector.GetPreambleType () != WIFI_PREAMBLE_NONE))
2379
    {
2409
    {
 Lines 2406-2412   WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m Link Here 
2406
}
2436
}
2407
2437
2408
void
2438
void
2409
WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Time rxDuration)
2439
WifiPhy::StartReceiveHeader (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, Ptr<Event> event, Time rxDuration)
2440
{
2441
  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreambleType () << +mpdutype);
2442
  NS_ASSERT (!IsStateRx ());
2443
  NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
2444
2445
  InterferenceHelper::SnrPer snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
2446
  double snr = snrPer.snr;
2447
  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
2448
2449
  if (!m_preambleDetectionModel || (m_preambleDetectionModel->IsPreambleDetected (snr, m_channelWidth)))
2450
  {
2451
    // switch to RX after successful preamble detection
2452
    m_state->SwitchToRx (rxDuration);
2453
    Time remainingPreambleHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector) - GetPreambleDetectionDuration ();
2454
    m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleHeaderDuration, &WifiPhy::StartReceivePacket, this,
2455
                                            packet, txVector, mpdutype, event);
2456
  }
2457
  else
2458
  {
2459
    NS_LOG_DEBUG ("drop packet because PHY preamble detection failed");
2460
    NotifyRxDrop (packet);
2461
    m_plcpSuccess = false;
2462
  }
2463
}
2464
2465
void
2466
WifiPhy::StartReceivePreamble (Ptr<Packet> packet, double rxPowerW, Time rxDuration)
2410
{
2467
{
2411
  WifiPhyTag tag;
2468
  WifiPhyTag tag;
2412
  bool found = packet->RemovePacketTag (tag);
2469
  bool found = packet->RemovePacketTag (tag);
 Lines 2564-2571   WifiPhy::StartReceivePacket (Ptr<Packet> packet, Link Here 
2564
  InterferenceHelper::SnrPer snrPer;
2621
  InterferenceHelper::SnrPer snrPer;
2565
  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
2622
  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
2566
2623
2567
  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
2568
2569
  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
2624
  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
2570
    {
2625
    {
2571
      if (IsModeSupported (txMode) || IsMcsSupported (txMode))
2626
      if (IsModeSupported (txMode) || IsMcsSupported (txMode))
 Lines 2582-2588   WifiPhy::StartReceivePacket (Ptr<Packet> packet, Link Here 
2582
    }
2637
    }
2583
  else //plcp reception failed
2638
  else //plcp reception failed
2584
    {
2639
    {
2585
      NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
2640
      NS_LOG_DEBUG ("drop packet because PHY header reception failed");
2586
      NotifyRxDrop (packet);
2641
      NotifyRxDrop (packet);
2587
      m_plcpSuccess = false;
2642
      m_plcpSuccess = false;
2588
    }
2643
    }
 Lines 3658-3663   void Link Here 
3658
WifiPhy::AbortCurrentReception ()
3713
WifiPhy::AbortCurrentReception ()
3659
{
3714
{
3660
  NS_LOG_FUNCTION (this);
3715
  NS_LOG_FUNCTION (this);
3716
  if (m_endPreambleDetectionEvent.IsRunning ())
3717
    {
3718
      m_endPreambleDetectionEvent.Cancel ();
3719
    }
3661
  if (m_endPlcpRxEvent.IsRunning ())
3720
  if (m_endPlcpRxEvent.IsRunning ())
3662
    {
3721
    {
3663
      m_endPlcpRxEvent.Cancel ();
3722
      m_endPlcpRxEvent.Cancel ();
 Lines 3721-3737   WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, Link Here 
3721
3780
3722
      NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3781
      NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3723
      m_currentEvent = event;
3782
      m_currentEvent = event;
3724
      m_state->SwitchToRx (rxDuration);
3783
3725
      NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3784
      if (preamble == WIFI_PREAMBLE_NONE)
3785
        {
3786
          m_state->SwitchToRx (rxDuration);
3787
        }
3726
      NotifyRxBegin (packet);
3788
      NotifyRxBegin (packet);
3727
      m_interference.NotifyRxStart ();
3789
      m_interference.NotifyRxStart ();
3728
3790
3729
      if (preamble != WIFI_PREAMBLE_NONE)
3791
      if (preamble != WIFI_PREAMBLE_NONE)
3730
        {
3792
        {
3731
          NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3793
          if (m_endPreambleDetectionEvent.IsRunning ())
3732
          Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
3794
            {
3733
          m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
3795
              m_endPreambleDetectionEvent.Cancel ();
3734
                                                  packet, txVector, mpdutype, event);
3796
            }
3797
3798
          Time startOfPreambleDuration = GetPreambleDetectionDuration ();
3799
          Time remainingRxDuration = rxDuration - startOfPreambleDuration;
3800
          m_endPreambleDetectionEvent = Simulator::Schedule (startOfPreambleDuration, &WifiPhy::StartReceiveHeader, this,
3801
                                                             packet, txVector, mpdutype, event, remainingRxDuration);
3802
          if (m_endRxEvent.IsRunning ())
3803
            {
3804
              m_endRxEvent.Cancel ();
3805
            }
3735
        }
3806
        }
3736
3807
3737
      NS_ASSERT (m_endRxEvent.IsExpired ());
3808
      NS_ASSERT (m_endRxEvent.IsExpired ());
(-)a/src/wifi/model/wifi-phy.h (-6 / +35 lines)
 Lines 40-45   class NetDevice; Link Here 
40
class MobilityModel;
40
class MobilityModel;
41
class WifiPhyStateHelper;
41
class WifiPhyStateHelper;
42
class FrameCaptureModel;
42
class FrameCaptureModel;
43
class PreambleDetectionModel;
43
class WifiRadioEnergyModel;
44
class WifiRadioEnergyModel;
44
class UniformRandomVariable;
45
class UniformRandomVariable;
45
46
 Lines 106-120   public: Link Here 
106
  void SetCapabilitiesChangedCallback (Callback<void> callback);
107
  void SetCapabilitiesChangedCallback (Callback<void> callback);
107
108
108
  /**
109
  /**
109
   * Starting receiving the plcp of a packet (i.e. the first bit of the preamble has arrived).
110
   * Starting receiving the PHY preamble of a packet (i.e. the first bit of the preamble has arrived).
110
   *
111
   *
111
   * \param packet the arriving packet
112
   * \param packet the arriving packet
112
   * \param rxPowerW the receive power in W
113
   * \param rxPowerW the receive power in W
113
   * \param rxDuration the duration needed for the reception of the packet
114
   * \param rxDuration the duration needed for the reception of the packet
114
   */
115
   */
115
  void StartReceivePreambleAndHeader (Ptr<Packet> packet,
116
  void StartReceivePreamble (Ptr<Packet> packet,
116
                                      double rxPowerW,
117
                             double rxPowerW,
117
                                      Time rxDuration);
118
                             Time rxDuration);
119
120
  /**
121
   * Starting receiving the PHY header of a packet (i.e. after the end of receiving the preamble).
122
   *
123
   * \param packet the arriving packet
124
   * \param txVector the TXVECTOR of the arriving packet
125
   * \param mpdutype the type of the MPDU as defined in WifiPhy::MpduType.
126
   * \param event the corresponding event of the first time the packet arrives
127
   */
128
  void StartReceiveHeader (Ptr<Packet> packet,
129
                           WifiTxVector txVector,
130
                           MpduType mpdutype,
131
                           Ptr<Event> event,
132
                           Time rxDuration);
118
133
119
  /**
134
  /**
120
   * Starting receiving the payload of a packet (i.e. the first bit of the packet has arrived).
135
   * Starting receiving the payload of a packet (i.e. the first bit of the packet has arrived).
 Lines 245-250   public: Link Here 
245
  static Time CalculatePlcpPreambleAndHeaderDuration (WifiTxVector txVector);
260
  static Time CalculatePlcpPreambleAndHeaderDuration (WifiTxVector txVector);
246
261
247
  /**
262
  /**
263
   *
264
   * \return the preamble detection duration, which is the time correletion needs to detect the start of an incoming frame.
265
   */
266
  Time GetPreambleDetectionDuration (void);
267
268
  /**
248
   * \param txVector the transmission parameters used for this packet
269
   * \param txVector the transmission parameters used for this packet
249
   *
270
   *
250
   * \return the training symbol duration
271
   * \return the training symbol duration
 Lines 1429-1434   public: Link Here 
1429
   */
1450
   */
1430
  void SetFrameCaptureModel (const Ptr<FrameCaptureModel> frameCaptureModel);
1451
  void SetFrameCaptureModel (const Ptr<FrameCaptureModel> frameCaptureModel);
1431
  /**
1452
  /**
1453
   * Sets the preamble detection model.
1454
   *
1455
   * \param preambleDetectionModel the preamble detection model
1456
   */
1457
  void SetPreambleDetectionModel (const Ptr<PreambleDetectionModel> preambleDetectionModel);
1458
  /**
1432
   * Sets the wifi radio energy model.
1459
   * Sets the wifi radio energy model.
1433
   *
1460
   *
1434
   * \param wifiRadioEnergyModel the wifi radio energy model
1461
   * \param wifiRadioEnergyModel the wifi radio energy model
 Lines 1506-1513   protected: Link Here 
1506
  uint32_t m_txMpduReferenceNumber;    //!< A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU
1533
  uint32_t m_txMpduReferenceNumber;    //!< A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU
1507
  uint32_t m_rxMpduReferenceNumber;    //!< A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU
1534
  uint32_t m_rxMpduReferenceNumber;    //!< A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU
1508
1535
1509
  EventId m_endRxEvent;                //!< the end reeive event
1536
  EventId m_endRxEvent;                //!< the end of receive event
1510
  EventId m_endPlcpRxEvent;            //!< the end PLCP receive event
1537
  EventId m_endPlcpRxEvent;            //!< the end of PLCP receive event
1538
  EventId m_endPreambleDetectionEvent;   //!< the end of preamble detection event
1511
1539
1512
private:
1540
private:
1513
  /**
1541
  /**
 Lines 1789-1794   private: Link Here 
1789
1817
1790
  Ptr<Event> m_currentEvent; //!< Hold the current event
1818
  Ptr<Event> m_currentEvent; //!< Hold the current event
1791
  Ptr<FrameCaptureModel> m_frameCaptureModel; //!< Frame capture model
1819
  Ptr<FrameCaptureModel> m_frameCaptureModel; //!< Frame capture model
1820
  Ptr<PreambleDetectionModel> m_preambleDetectionModel; //!< Preamble detection model
1792
  Ptr<WifiRadioEnergyModel> m_wifiRadioEnergyModel; //!< Wifi radio energy model
1821
  Ptr<WifiRadioEnergyModel> m_wifiRadioEnergyModel; //!< Wifi radio energy model
1793
  Ptr<ErrorModel> m_postReceptionErrorModel; //!< Error model for receive packet events
1822
  Ptr<ErrorModel> m_postReceptionErrorModel; //!< Error model for receive packet events
1794
1823
(-)a/src/wifi/model/yans-wifi-channel.cc (-1 / +1 lines)
 Lines 125-131   void Link Here 
125
YansWifiChannel::Receive (Ptr<YansWifiPhy> phy, Ptr<Packet> packet, double rxPowerDbm, Time duration)
125
YansWifiChannel::Receive (Ptr<YansWifiPhy> phy, Ptr<Packet> packet, double rxPowerDbm, Time duration)
126
{
126
{
127
  NS_LOG_FUNCTION (phy << packet << rxPowerDbm << duration.GetSeconds ());
127
  NS_LOG_FUNCTION (phy << packet << rxPowerDbm << duration.GetSeconds ());
128
  phy->StartReceivePreambleAndHeader (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
128
  phy->StartReceivePreamble (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
129
}
129
}
130
130
131
std::size_t
131
std::size_t
(-)a/src/wifi/wscript (+4 lines)
 Lines 85-90   def build(bld): Link Here 
85
        'model/he-capabilities.cc',
85
        'model/he-capabilities.cc',
86
        'model/frame-capture-model.cc',
86
        'model/frame-capture-model.cc',
87
        'model/simple-frame-capture-model.cc',
87
        'model/simple-frame-capture-model.cc',
88
        'model/preamble-detection-model.cc',
89
        'model/simple-preamble-detection-model.cc',
88
        'model/he-operation.cc',
90
        'model/he-operation.cc',
89
        'model/he-configuration.cc',
91
        'model/he-configuration.cc',
90
        'model/extended-capabilities.cc',
92
        'model/extended-capabilities.cc',
 Lines 199-204   def build(bld): Link Here 
199
        'model/he-capabilities.h',
201
        'model/he-capabilities.h',
200
        'model/frame-capture-model.h',
202
        'model/frame-capture-model.h',
201
        'model/simple-frame-capture-model.h',
203
        'model/simple-frame-capture-model.h',
204
        'model/preamble-detection-model.h',
205
        'model/simple-preamble-detection-model.h',
202
        'model/qos-blocked-destinations.h',
206
        'model/qos-blocked-destinations.h',
203
        'model/he-operation.h',
207
        'model/he-operation.h',
204
        'model/he-configuration.h',
208
        'model/he-configuration.h',

Return to bug 3020