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

(-)a/src/wifi/model/wifi-phy.cc (-18 / +25 lines)
 Lines 300-340    Link Here 
300
  return MicroSeconds (duration);
300
  return MicroSeconds (duration);
301
}
301
}
302
302
303
304
void
303
void
305
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet)
304
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet, 
305
                        Ptr<const Object> nd,
306
                        const Time& duration,
307
                        uint32_t    nReceivers)
306
{
308
{
307
  m_phyTxBeginTrace (packet);
309
  m_phyTxBeginTrace (packet, nd, duration, nReceivers);
308
}
310
}
309
311
310
void
312
void 
311
WifiPhy::NotifyTxEnd (Ptr<const Packet> packet)
313
WifiPhy::NotifyTxEnd (Ptr<const Packet> packet,
314
                      Ptr<const Object> nd)
312
{
315
{
313
  m_phyTxEndTrace (packet);
316
  m_phyTxEndTrace (packet, nd);
314
}
317
}
315
318
316
void
319
void 
317
WifiPhy::NotifyTxDrop (Ptr<const Packet> packet)
320
WifiPhy::NotifyTxDrop (Ptr<const Packet> packet,
321
                      Ptr<const Object> nd)
318
{
322
{
319
  m_phyTxDropTrace (packet);
323
  m_phyTxDropTrace (packet, nd);
320
}
324
}
321
325
322
void
326
void 
323
WifiPhy::NotifyRxBegin (Ptr<const Packet> packet)
327
WifiPhy::NotifyRxBegin (Ptr<const Packet> packet,
328
                        Ptr<const Object> nd) 
324
{
329
{
325
  m_phyRxBeginTrace (packet);
330
  m_phyRxBeginTrace (packet, nd);
326
}
331
}
327
332
328
void
333
void 
329
WifiPhy::NotifyRxEnd (Ptr<const Packet> packet)
334
WifiPhy::NotifyRxEnd (Ptr<const Packet> packet,
335
                      Ptr<const Object> nd) 
330
{
336
{
331
  m_phyRxEndTrace (packet);
337
  m_phyRxEndTrace (packet, nd);
332
}
338
}
333
339
334
void
340
void 
335
WifiPhy::NotifyRxDrop (Ptr<const Packet> packet)
341
WifiPhy::NotifyRxDrop (Ptr<const Packet> packet,
342
                      Ptr<const Object> nd) 
336
{
343
{
337
  m_phyRxDropTrace (packet);
344
  m_phyRxDropTrace (packet, nd);
338
}
345
}
339
346
340
void
347
void
(-)a/src/wifi/model/wifi-phy.h (-23 / +44 lines)
 Lines 380-418    Link Here 
380
  /**
380
  /**
381
   * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
381
   * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
382
   * purposes.
382
   * purposes.
383
   * \param Ptr to packet to be transmitted
384
   * \param Ptr to device used to transmit
385
   * \param Duration for transmission
386
   * \param Number of receivers for the transmission
383
   */
387
   */
384
  void NotifyTxBegin (Ptr<const Packet> packet);
388
  void NotifyTxBegin (Ptr<const Packet> packet, 
385
389
                      Ptr<const Object> nd,
390
                      const Time& duration,
391
                      uint32_t    nReceivers);
386
  /**
392
  /**
387
   * Public method used to fire a PhyTxEnd trace.  Implemented for encapsulation
393
   * Public method used to fire a PhyTxEnd trace.  Implemented for encapsulation
388
   * purposes.
394
   * purposes.
395
   * \param Ptr to packet transmitted
396
   * \param Ptr to device used to transmit
389
   */
397
   */
390
  void NotifyTxEnd (Ptr<const Packet> packet);
398
  void NotifyTxEnd (Ptr<const Packet> packet, Ptr<const Object> nd);
391
392
  /**
399
  /**
393
   * Public method used to fire a PhyTxDrop trace.  Implemented for encapsulation
400
   * Public method used to fire a PhyTxDrop trace.  Implemented for encapsulation
394
   * purposes.
401
   * purposes.
402
   * \param Ptr to packet to be dropped before transmission
403
   * \param Ptr to device used to transmit
395
   */
404
   */
396
  void NotifyTxDrop (Ptr<const Packet> packet);
405
  void NotifyTxDrop (Ptr<const Packet> packet, Ptr<const Object> nd);
397
398
  /**
406
  /**
399
   * Public method used to fire a PhyRxBegin trace.  Implemented for encapsulation
407
   * Public method used to fire a PhyRxBegin trace.  Implemented for encapsulation
400
   * purposes.
408
   * purposes.
409
   * \param Ptr to packet to be received
410
   * \param Ptr to device used to receive
401
   */
411
   */
402
  void NotifyRxBegin (Ptr<const Packet> packet);
412
  void NotifyRxBegin (Ptr<const Packet> packet, Ptr<const Object> nd);
403
404
  /**
413
  /**
405
   * Public method used to fire a PhyRxEnd trace.  Implemented for encapsulation
414
   * Public method used to fire a PhyRxEnd trace.  Implemented for encapsulation
406
   * purposes.
415
   * purposes.
416
   * \param Ptr to packet received
417
   * \param Ptr to device used to receive
407
   */
418
   */
408
  void NotifyRxEnd (Ptr<const Packet> packet);
419
  void NotifyRxEnd (Ptr<const Packet> packet, Ptr<const Object> nd);
409
410
  /**
420
  /**
411
   * Public method used to fire a PhyRxDrop trace.  Implemented for encapsulation
421
   * Public method used to fire a PhyRxDrop trace.  Implemented for encapsulation
412
   * purposes.
422
   * purposes.
423
   * \param Ptr to packet to be dropped on reception
424
   * \param Ptr to device used to receive
413
   */
425
   */
414
  void NotifyRxDrop (Ptr<const Packet> packet);
426
  void NotifyRxDrop (Ptr<const Packet> packet, Ptr<const Object> nd);
415
416
  /**
427
  /**
417
   *
428
   *
418
   * Public method used to fire a PromiscSniffer trace for a wifi packet being received.  Implemented for encapsulation
429
   * Public method used to fire a PromiscSniffer trace for a wifi packet being received.  Implemented for encapsulation
 Lines 456-505    Link Here 
456
  /**
467
  /**
457
   * The trace source fired when a packet begins the transmission process on
468
   * The trace source fired when a packet begins the transmission process on
458
   * the medium.
469
   * the medium.
459
   *
470
   * \param Ptr to packet to be transmitted
471
   * \param Ptr to device used to transmit
472
   * \param Duration for transmission
473
   * \param Number of receivers for the transmission
474
   * 
460
   * \see class CallBackTraceSource
475
   * \see class CallBackTraceSource
461
   */
476
   */
462
  TracedCallback<Ptr<const Packet> > m_phyTxBeginTrace;
477
  TracedCallback<Ptr<const Packet>, Ptr<const Object>, const Time&, uint32_t> m_phyTxBeginTrace;
463
478
464
  /**
479
  /**
465
   * The trace source fired when a packet ends the transmission process on
480
   * The trace source fired when a packet ends the transmission process on
466
   * the medium.
481
   * the medium.
482
   * \param Ptr to packet transmitted
483
   * \param Ptr to device used to transmit
467
   *
484
   *
468
   * \see class CallBackTraceSource
485
   * \see class CallBackTraceSource
469
   */
486
   */
470
  TracedCallback<Ptr<const Packet> > m_phyTxEndTrace;
487
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyTxEndTrace;
471
488
472
  /**
489
  /**
473
   * The trace source fired when the phy layer drops a packet as it tries
490
   * The trace source fired when the phy layer drops a packet as it tries
474
   * to transmit it.
491
   * to transmit it.
492
   * \param Ptr to packet to be dropped before transmission
493
   * \param Ptr to device used to transmit
475
   *
494
   *
476
   * \see class CallBackTraceSource
495
   * \see class CallBackTraceSource
477
   */
496
   */
478
  TracedCallback<Ptr<const Packet> > m_phyTxDropTrace;
497
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyTxDropTrace;
479
480
  /**
498
  /**
481
   * The trace source fired when a packet begins the reception process from
499
   * The trace source fired when a packet begins the reception process from
482
   * the medium.
500
   * the medium.
501
   * \param Ptr to packet to be received
502
   * \param Ptr to device used to receive
483
   *
503
   *
484
   * \see class CallBackTraceSource
504
   * \see class CallBackTraceSource
485
   */
505
   */
486
  TracedCallback<Ptr<const Packet> > m_phyRxBeginTrace;
506
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyRxBeginTrace;
487
488
  /**
507
  /**
489
   * The trace source fired when a packet ends the reception process from
508
   * The trace source fired when a packet ends the reception process from
490
   * the medium.
509
   * the medium.
510
   * \param Ptr to packet received
511
   * \param Ptr to device used to receive
491
   *
512
   *
492
   * \see class CallBackTraceSource
513
   * \see class CallBackTraceSource
493
   */
514
   */
494
  TracedCallback<Ptr<const Packet> > m_phyRxEndTrace;
515
  TracedCallback<Ptr<const Packet> , Ptr<const Object> > m_phyRxEndTrace;
495
496
  /**
516
  /**
497
   * The trace source fired when the phy layer drops a packet it has received.
517
   * The trace source fired when the phy layer drops a packet it has received.
518
   * \param Ptr to packet to be dropped on reception
519
   * \param Ptr to device used to receive
498
   *
520
   *
499
   * \see class CallBackTraceSource
521
   * \see class CallBackTraceSource
500
   */
522
   */
501
  TracedCallback<Ptr<const Packet> > m_phyRxDropTrace;
523
  TracedCallback<Ptr<const Packet> , Ptr<const Object> > m_phyRxDropTrace;
502
503
  /**
524
  /**
504
   * A trace source that emulates a wifi device in monitor mode
525
   * A trace source that emulates a wifi device in monitor mode
505
   * sniffing a packet being received.
526
   * sniffing a packet being received.
(-)a/src/wifi/model/yans-wifi-channel.cc (-1 / +4 lines)
 Lines 74-86    Link Here 
74
  m_delay = delay;
74
  m_delay = delay;
75
}
75
}
76
76
77
void
77
uint32_t
78
YansWifiChannel::Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
78
YansWifiChannel::Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
79
                       WifiMode wifiMode, WifiPreamble preamble) const
79
                       WifiMode wifiMode, WifiPreamble preamble) const
80
{
80
{
81
  Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();
81
  Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();
82
  NS_ASSERT (senderMobility != 0);
82
  NS_ASSERT (senderMobility != 0);
83
  uint32_t j = 0;
83
  uint32_t j = 0;
84
  uint32_t nReceivers = 0;
84
  for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
85
  for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
85
    {
86
    {
86
      if (sender != (*i))
87
      if (sender != (*i))
 Lines 107-117    Link Here 
107
            {
108
            {
108
              dstNode = dstNetDevice->GetObject<NetDevice> ()->GetNode ()->GetId ();
109
              dstNode = dstNetDevice->GetObject<NetDevice> ()->GetNode ()->GetId ();
109
            }
110
            }
111
          nReceivers++;
110
          Simulator::ScheduleWithContext (dstNode,
112
          Simulator::ScheduleWithContext (dstNode,
111
                                          delay, &YansWifiChannel::Receive, this,
113
                                          delay, &YansWifiChannel::Receive, this,
112
                                          j, copy, rxPowerDbm, wifiMode, preamble);
114
                                          j, copy, rxPowerDbm, wifiMode, preamble);
113
        }
115
        }
114
    }
116
    }
117
  return nReceivers;
115
}
118
}
116
119
117
void
120
void
(-)a/src/wifi/model/yans-wifi-channel.h (-1 / +2 lines)
 Lines 76-87    Link Here 
76
   * \param wifiMode the tx mode associated to the packet
76
   * \param wifiMode the tx mode associated to the packet
77
   * \param preamble the preamble associated to the packet
77
   * \param preamble the preamble associated to the packet
78
   *
78
   *
79
   * returns the number of receivers that will receive the packet
79
   * This method should not be invoked by normal users. It is
80
   * This method should not be invoked by normal users. It is
80
   * currently invoked only from WifiPhy::Send. YansWifiChannel
81
   * currently invoked only from WifiPhy::Send. YansWifiChannel
81
   * delivers packets only between PHYs with the same m_channelNumber,
82
   * delivers packets only between PHYs with the same m_channelNumber,
82
   * e.g. PHYs that are operating on the same channel.
83
   * e.g. PHYs that are operating on the same channel.
83
   */
84
   */
84
  void Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
85
  uint32_t Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
85
             WifiMode wifiMode, WifiPreamble preamble) const;
86
             WifiMode wifiMode, WifiPreamble preamble) const;
86
87
87
private:
88
private:
(-)a/src/wifi/model/yans-wifi-phy.cc (-9 / +9 lines)
 Lines 418-424    Link Here 
418
    {
418
    {
419
    case YansWifiPhy::SWITCHING:
419
    case YansWifiPhy::SWITCHING:
420
      NS_LOG_DEBUG ("drop packet because of channel switching");
420
      NS_LOG_DEBUG ("drop packet because of channel switching");
421
      NotifyRxDrop (packet);
421
      NotifyRxDrop (packet, GetDevice ());
422
      /*
422
      /*
423
       * Packets received on the upcoming channel are added to the event list
423
       * Packets received on the upcoming channel are added to the event list
424
       * during the switching state. This way the medium can be correctly sensed
424
       * during the switching state. This way the medium can be correctly sensed
 Lines 437-443    Link Here 
437
    case YansWifiPhy::RX:
437
    case YansWifiPhy::RX:
438
      NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
438
      NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
439
                    rxPowerW << "W)");
439
                    rxPowerW << "W)");
440
      NotifyRxDrop (packet);
440
      NotifyRxDrop (packet, GetDevice ());
441
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
441
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
442
        {
442
        {
443
          // that packet will be noise _after_ the reception of the
443
          // that packet will be noise _after_ the reception of the
 Lines 448-454    Link Here 
448
    case YansWifiPhy::TX:
448
    case YansWifiPhy::TX:
449
      NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
449
      NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
450
                    rxPowerW << "W)");
450
                    rxPowerW << "W)");
451
      NotifyRxDrop (packet);
451
      NotifyRxDrop (packet, GetDevice ());
452
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
452
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
453
        {
453
        {
454
          // that packet will be noise _after_ the transmission of the
454
          // that packet will be noise _after_ the transmission of the
 Lines 464-470    Link Here 
464
          // sync to signal
464
          // sync to signal
465
          m_state->SwitchToRx (rxDuration);
465
          m_state->SwitchToRx (rxDuration);
466
          NS_ASSERT (m_endRxEvent.IsExpired ());
466
          NS_ASSERT (m_endRxEvent.IsExpired ());
467
          NotifyRxBegin (packet);
467
          NotifyRxBegin (packet, GetDevice ());
468
          m_interference.NotifyRxStart ();
468
          m_interference.NotifyRxStart ();
469
          m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
469
          m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
470
                                              packet,
470
                                              packet,
 Lines 474-480    Link Here 
474
        {
474
        {
475
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
475
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
476
                        rxPowerW << "<" << m_edThresholdW << ")");
476
                        rxPowerW << "<" << m_edThresholdW << ")");
477
          NotifyRxDrop (packet);
477
          NotifyRxDrop (packet, GetDevice ());
478
          goto maybeCcaBusy;
478
          goto maybeCcaBusy;
479
        }
479
        }
480
      break;
480
      break;
 Lines 513-524    Link Here 
513
      m_endRxEvent.Cancel ();
513
      m_endRxEvent.Cancel ();
514
      m_interference.NotifyRxEnd ();
514
      m_interference.NotifyRxEnd ();
515
    }
515
    }
516
  NotifyTxBegin (packet);
517
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
516
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
518
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
517
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
519
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
518
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
520
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
519
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
521
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
520
  uint32_t nReceivers = m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
521
  NotifyTxBegin (packet, GetDevice (), txDuration, nReceivers);
522
}
522
}
523
523
524
uint32_t
524
uint32_t
 Lines 782-788    Link Here 
782
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
782
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
783
  if (m_random.GetValue () > snrPer.per)
783
  if (m_random.GetValue () > snrPer.per)
784
    {
784
    {
785
      NotifyRxEnd (packet);
785
      NotifyRxEnd (packet, GetDevice ());
786
      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;
786
      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;
787
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
787
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
788
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
788
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
 Lines 793-799    Link Here 
793
  else
793
  else
794
    {
794
    {
795
      /* failure. */
795
      /* failure. */
796
      NotifyRxDrop (packet);
796
      NotifyRxDrop (packet, GetDevice ());
797
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
797
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
798
    }
798
    }
799
}
799
}

Return to bug 1185