Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(147)

Side by Side Diff: src/point-to-point/model/point-to-point-net-device.cc

Issue 298220043: Byte queue limits (Closed)
Patch Set: Updated version Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /* 2 /*
3 * Copyright (c) 2007, 2008 University of Washington 3 * Copyright (c) 2007, 2008 University of Washington
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation; 7 * published by the Free Software Foundation;
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 { 334 {
335 NS_LOG_DEBUG ("The device queue is being started (" << m_queue->GetNPa ckets () << 335 NS_LOG_DEBUG ("The device queue is being started (" << m_queue->GetNPa ckets () <<
336 " packets and " << m_queue->GetNBytes () << " bytes insi de)"); 336 " packets and " << m_queue->GetNBytes () << " bytes insi de)");
337 txq->Start (); 337 txq->Start ();
338 } 338 }
339 } 339 }
340 Ptr<Packet> p = item->GetPacket (); 340 Ptr<Packet> p = item->GetPacket ();
341 m_snifferTrace (p); 341 m_snifferTrace (p);
342 m_promiscSnifferTrace (p); 342 m_promiscSnifferTrace (p);
343 TransmitStart (p); 343 TransmitStart (p);
344 if (txq)
345 {
346 // Inform BQL
347 txq->NotifyTransmittedBytes (m_currentPkt->GetSize ());
348 }
344 } 349 }
345 350
346 bool 351 bool
347 PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch) 352 PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
348 { 353 {
349 NS_LOG_FUNCTION (this << &ch); 354 NS_LOG_FUNCTION (this << &ch);
350 355
351 m_channel = ch; 356 m_channel = ch;
352 357
353 m_channel->Attach (this); 358 m_channel->Attach (this);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // 589 //
585 AddHeader (packet, protocolNumber); 590 AddHeader (packet, protocolNumber);
586 591
587 m_macTxTrace (packet); 592 m_macTxTrace (packet);
588 593
589 // 594 //
590 // We should enqueue and dequeue the packet to hit the tracing hooks. 595 // We should enqueue and dequeue the packet to hit the tracing hooks.
591 // 596 //
592 if (m_queue->Enqueue (Create<QueueItem> (packet))) 597 if (m_queue->Enqueue (Create<QueueItem> (packet)))
593 { 598 {
599 // Inform BQL
600 if (txq)
601 {
602 txq->NotifyQueuedBytes (packet->GetSize ());
603 }
594 // 604 //
595 // If the channel is ready for transition we send the packet right now 605 // If the channel is ready for transition we send the packet right now
596 //· 606 //·
597 if (m_txMachineState == READY) 607 if (m_txMachineState == READY)
598 { 608 {
599 packet = m_queue->Dequeue ()->GetPacket (); 609 packet = m_queue->Dequeue ()->GetPacket ();
600 // We have enqueued a packet and dequeued a (possibly different) packe t. We 610 // We have enqueued a packet and dequeued a (possibly different) packe t. We
601 // need to check if there is still room for another packet only if the queue 611 // need to check if there is still room for another packet only if the queue
602 // is in byte mode (the enqueued packet might be larger than the deque ued 612 // is in byte mode (the enqueued packet might be larger than the deque ued
603 // packet, thus leaving no room for another packet) 613 // packet, thus leaving no room for another packet)
604 if (txq) 614 if (txq)
605 { 615 {
606 if (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES && 616 if (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES &&
607 m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ()) 617 m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ())
608 { 618 {
609 NS_LOG_DEBUG ("The device queue is being stopped (" << m_queue ->GetNPackets () << 619 NS_LOG_DEBUG ("The device queue is being stopped (" << m_queue ->GetNPackets () <<
610 " packets and " << m_queue->GetNBytes () << " by tes inside)"); 620 " packets and " << m_queue->GetNBytes () << " by tes inside)");
611 txq->Stop (); 621 txq->Stop ();
612 } 622 }
613 } 623 }
614 m_snifferTrace (packet); 624 m_snifferTrace (packet);
615 m_promiscSnifferTrace (packet); 625 m_promiscSnifferTrace (packet);
616 return TransmitStart (packet); 626 bool ret = TransmitStart (packet);
627 if (txq)
628 {
629 // Inform BQL
630 txq->NotifyTransmittedBytes (m_currentPkt->GetSize ());
631 }
632 return ret;
617 } 633 }
618 // We have enqueued a packet but we have not dequeued any packet. Thus, we 634 // We have enqueued a packet but we have not dequeued any packet. Thus, we
619 // need to check whether the queue is able to store another packet. If not , 635 // need to check whether the queue is able to store another packet. If not ,
620 // we stop the queue 636 // we stop the queue
621 if (txq) 637 if (txq)
622 { 638 {
623 if ((m_queue->GetMode () == Queue::QUEUE_MODE_PACKETS && 639 if ((m_queue->GetMode () == Queue::QUEUE_MODE_PACKETS &&
624 m_queue->GetNPackets () >= m_queue->GetMaxPackets ()) || 640 m_queue->GetNPackets () >= m_queue->GetMaxPackets ()) ||
625 (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES && 641 (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES &&
626 m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ())) 642 m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ()))
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 { 772 {
757 case 0x0800: return 0x0021; //IPv4 773 case 0x0800: return 0x0021; //IPv4
758 case 0x86DD: return 0x0057; //IPv6 774 case 0x86DD: return 0x0057; //IPv6
759 default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!"); 775 default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
760 } 776 }
761 return 0; 777 return 0;
762 } 778 }
763 779
764 780
765 } // namespace ns3 781 } // namespace ns3
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b