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

(-)a/src/csma/model/csma-net-device.cc (+55 lines)
 Lines 217-226    Link Here 
217
  NS_LOG_FUNCTION_NOARGS ();
217
  NS_LOG_FUNCTION_NOARGS ();
218
  m_channel = 0;
218
  m_channel = 0;
219
  m_node = 0;
219
  m_node = 0;
220
  m_queue = 0;
221
  m_queueInterface = 0;
220
  NetDevice::DoDispose ();
222
  NetDevice::DoDispose ();
221
}
223
}
222
224
223
void
225
void
226
CsmaNetDevice::DoInitialize (void)
227
{
228
  NS_LOG_FUNCTION (this);
229
      
230
  // The traffic control layer, if installed, has aggregated a
231
  // NetDeviceQueueInterface object to this device
232
  m_queueInterface = GetObject<NetDeviceQueueInterface> ();
233
  NetDevice::DoInitialize ();
234
}
235
236
void
224
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
237
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
225
{
238
{
226
  NS_LOG_FUNCTION (mode);
239
  NS_LOG_FUNCTION (mode);
 Lines 553-558    Link Here 
553
  m_backoff.ResetBackoffTime ();
566
  m_backoff.ResetBackoffTime ();
554
  m_txMachineState = READY;
567
  m_txMachineState = READY;
555
568
569
  Ptr<NetDeviceQueue> txq;
570
  if (m_queueInterface)
571
    {
572
      txq = m_queueInterface->GetTxQueue (0);
573
    }
574
556
  //
575
  //
557
  // If there is another packet on the input queue, we need to start trying to 
576
  // If there is another packet on the input queue, we need to start trying to 
558
  // get that out.  If the queue is empty we just wait until someone puts one
577
  // get that out.  If the queue is empty we just wait until someone puts one
 Lines 560-571    Link Here 
560
  //
579
  //
561
  if (m_queue->IsEmpty ())
580
  if (m_queue->IsEmpty ())
562
    {
581
    {
582
      if (txq)
583
        {
584
          txq->Wake ();
585
        }
563
      return;
586
      return;
564
    }
587
    }
565
  else
588
  else
566
    {
589
    {
567
      Ptr<QueueItem> item = m_queue->Dequeue ();
590
      Ptr<QueueItem> item = m_queue->Dequeue ();
568
      NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?");
591
      NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?");
592
      
593
      if (txq && txq->IsStopped ())
594
        {
595
          txq->Start ();
596
        }
569
      m_currentPkt = item->GetPacket ();
597
      m_currentPkt = item->GetPacket ();
570
      m_snifferTrace (m_currentPkt);
598
      m_snifferTrace (m_currentPkt);
571
      m_promiscSnifferTrace (m_currentPkt);
599
      m_promiscSnifferTrace (m_currentPkt);
 Lines 624-640    Link Here 
624
  //
652
  //
625
  NS_ASSERT_MSG (m_currentPkt == 0, "CsmaNetDevice::TransmitReadyEvent(): m_currentPkt nonzero");
653
  NS_ASSERT_MSG (m_currentPkt == 0, "CsmaNetDevice::TransmitReadyEvent(): m_currentPkt nonzero");
626
654
655
  Ptr<NetDeviceQueue> txq;
656
  if (m_queueInterface)
657
    {
658
      txq = m_queueInterface->GetTxQueue (0);
659
    }
660
627
  //
661
  //
628
  // Get the next packet from the queue for transmitting
662
  // Get the next packet from the queue for transmitting
629
  //
663
  //
630
  if (m_queue->IsEmpty ())
664
  if (m_queue->IsEmpty ())
631
    {
665
    {
666
      if (txq)
667
        {
668
          txq->Wake ();
669
        }
632
      return;
670
      return;
633
    }
671
    }
634
  else
672
  else
635
    {
673
    {
636
      Ptr<QueueItem> item = m_queue->Dequeue ();
674
      Ptr<QueueItem> item = m_queue->Dequeue ();
637
      NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?");
675
      NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?");
676
 
677
      if (txq && txq->IsStopped ())
678
        {
679
          txq->Start ();
680
        }
638
      m_currentPkt = item->GetPacket ();
681
      m_currentPkt = item->GetPacket ();
639
      m_snifferTrace (m_currentPkt);
682
      m_snifferTrace (m_currentPkt);
640
      m_promiscSnifferTrace (m_currentPkt);
683
      m_promiscSnifferTrace (m_currentPkt);
 Lines 960-965    Link Here 
960
      return false;
1003
      return false;
961
    }
1004
    }
962
1005
1006
  Ptr<NetDeviceQueue> txq;
1007
  if (m_queueInterface)
1008
    {
1009
      txq = m_queueInterface->GetTxQueue (0);
1010
    }
1011
1012
  NS_ASSERT_MSG (!txq || !txq->IsStopped (), "Send should not be called when the device is stopped");
1013
963
  Mac48Address destination = Mac48Address::ConvertFrom (dest);
1014
  Mac48Address destination = Mac48Address::ConvertFrom (dest);
964
  Mac48Address source = Mac48Address::ConvertFrom (src);
1015
  Mac48Address source = Mac48Address::ConvertFrom (src);
965
  AddHeader (packet, source, destination, protocolNumber);
1016
  AddHeader (packet, source, destination, protocolNumber);
 Lines 973-978    Link Here 
973
  if (m_queue->Enqueue (Create<QueueItem> (packet)) == false)
1024
  if (m_queue->Enqueue (Create<QueueItem> (packet)) == false)
974
    {
1025
    {
975
      m_macTxDropTrace (packet);
1026
      m_macTxDropTrace (packet);
1027
      if (txq)
1028
        {
1029
          txq->Stop ();
1030
        }
976
      return false;
1031
      return false;
977
    }
1032
    }
978
1033
(-)a/src/csma/model/csma-net-device.h (+8 lines)
 Lines 344-349    Link Here 
344
   */
344
   */
345
  virtual void DoDispose (void);
345
  virtual void DoDispose (void);
346
346
347
  // Inherited from Object
348
  virtual void DoInitialize (void);
349
347
  /**
350
  /**
348
   * Adds the necessary headers and trailers to a packet of data in order to
351
   * Adds the necessary headers and trailers to a packet of data in order to
349
   * respect the packet type
352
   * respect the packet type
 Lines 533-538    Link Here 
533
  Ptr<Queue> m_queue;
536
  Ptr<Queue> m_queue;
534
537
535
  /**
538
  /**
539
   * The network device transmission queue interface.
540
   */
541
  Ptr<NetDeviceQueueInterface> m_queueInterface;
542
543
  /**
536
   * Error model for receive packet events.  When active this model will be
544
   * Error model for receive packet events.  When active this model will be
537
   * used to model transmission errors by marking some of the packets 
545
   * used to model transmission errors by marking some of the packets 
538
   * received as corrupt.
546
   * received as corrupt.

Return to bug 2373