A Discrete-Event Network Simulator
API
drop-tail-queue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 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 
19 #ifndef DROPTAIL_H
20 #define DROPTAIL_H
21 
22 #include "ns3/queue.h"
23 
24 namespace ns3 {
25 
31 template <typename Item>
32 class DropTailQueue : public Queue<Item>
33 {
34 public:
39  static TypeId GetTypeId (void);
45  DropTailQueue ();
46 
47  virtual ~DropTailQueue ();
48 
49  virtual bool Enqueue (Ptr<Item> item);
50  virtual Ptr<Item> Dequeue (void);
51  virtual Ptr<Item> Remove (void);
52  virtual Ptr<const Item> Peek (void) const;
53 
54 private:
55  using Queue<Item>::begin;
56  using Queue<Item>::end;
60  using Queue<Item>::DoPeek;
61 
63 };
64 
65 
70 template <typename Item>
71 TypeId
73 {
74  static TypeId tid = TypeId ("ns3::DropTailQueue<" + GetTypeParamName<DropTailQueue<Item> > () + ">")
76  .SetGroupName ("Network")
77  .template AddConstructor<DropTailQueue<Item> > ()
78  .AddAttribute ("MaxSize",
79  "The max queue size",
80  QueueSizeValue (QueueSize ("100p")),
84  ;
85  return tid;
86 }
87 
88 template <typename Item>
90  Queue<Item> (),
91  NS_LOG_TEMPLATE_DEFINE ("DropTailQueue")
92 {
93  NS_LOG_FUNCTION (this);
94 }
95 
96 template <typename Item>
98 {
99  NS_LOG_FUNCTION (this);
100 }
101 
102 template <typename Item>
103 bool
105 {
106  NS_LOG_FUNCTION (this << item);
107 
108  return DoEnqueue (end (), item);
109 }
110 
111 template <typename Item>
112 Ptr<Item>
114 {
115  NS_LOG_FUNCTION (this);
116 
117  Ptr<Item> item = DoDequeue (begin ());
118 
119  NS_LOG_LOGIC ("Popped " << item);
120 
121  return item;
122 }
123 
124 template <typename Item>
125 Ptr<Item>
127 {
128  NS_LOG_FUNCTION (this);
129 
130  Ptr<Item> item = DoRemove (begin ());
131 
132  NS_LOG_LOGIC ("Removed " << item);
133 
134  return item;
135 }
136 
137 template <typename Item>
140 {
141  NS_LOG_FUNCTION (this);
142 
143  return DoPeek (begin ());
144 }
145 
146 // The following explicit template instantiation declarations prevent all the
147 // translation units including this header file to implicitly instantiate the
148 // DropTailQueue<Packet> class and the DropTailQueue<QueueDiscItem> class. The
149 // unique instances of these classes are explicitly created through the macros
150 // NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,Packet) and
151 // NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,QueueDiscItem), which are included
152 // in drop-tail-queue.cc
153 extern template class DropTailQueue<Packet>;
154 extern template class DropTailQueue<QueueDiscItem>;
155 
156 } // namespace ns3
157 
158 #endif /* DROPTAIL_H */
Introspection did not find any typical Config paths.
A FIFO packet queue that drops tail-end packets on overflow.
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
virtual bool Enqueue(Ptr< Item > item)
Place an item into the Queue (each subclass defines the position)
virtual ~DropTailQueue()
static TypeId GetTypeId(void)
Get the type ID.
DropTailQueue()
DropTailQueue Constructor.
virtual Ptr< Item > Remove(void)
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as bot...
virtual Ptr< const Item > Peek(void) const
Get a copy of an item in the queue (each subclass defines the position) without removing it.
virtual Ptr< Item > Dequeue(void)
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Definition: queue.cc:200
QueueSize GetMaxSize(void) const
Definition: queue.cc:217
Template class for packet Queues.
Definition: queue.h:262
Class for representing queue sizes.
Definition: queue-size.h:95
AttributeValue implementation for QueueSize.
Definition: queue-size.h:221
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Definition: queue-size.cc:28
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: queue-size.h:221
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Definition: log.h:239
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetTypeParamName(void)
Helper function to get the name (as a string) of the type parameter of a template class.
Definition: object-base.h:102