A Discrete-Event Network Simulator
API
queue-item.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
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: Stefano Avallone <stefano.avallone@unina.it>
19  */
20 #ifndef QUEUE_ITEM_H
21 #define QUEUE_ITEM_H
22 
23 #include "ns3/ptr.h"
24 #include "ns3/simple-ref-count.h"
25 #include <ns3/address.h>
26 #include "ns3/nstime.h"
27 
28 namespace ns3 {
29 
30 class Packet;
31 
46 class QueueItem : public SimpleRefCount<QueueItem>
47 {
48 public:
54 
55  virtual ~QueueItem ();
56 
60  Ptr<Packet> GetPacket (void) const;
61 
70  virtual uint32_t GetSize (void) const;
71 
77  {
79  };
80 
88  virtual bool GetUint8Value (Uint8Values field, uint8_t &value) const;
89 
94  virtual void Print (std::ostream &os) const;
95 
101  typedef void (* TracedCallback) (Ptr<const QueueItem> item);
102 
103 private:
109  QueueItem ();
115  QueueItem (const QueueItem &);
122  QueueItem &operator = (const QueueItem &);
123 
128 };
129 
137 std::ostream& operator<< (std::ostream& os, const QueueItem &item);
138 
139 
148 class QueueDiscItem : public QueueItem {
149 public:
156  QueueDiscItem (Ptr<Packet> p, const Address & addr, uint16_t protocol);
157 
158  virtual ~QueueDiscItem ();
159 
164  Address GetAddress (void) const;
165 
170  uint16_t GetProtocol (void) const;
171 
176  uint8_t GetTxQueueIndex (void) const;
177 
182  void SetTxQueueIndex (uint8_t txq);
183 
188  Time GetTimeStamp (void) const;
189 
194  void SetTimeStamp (Time t);
195 
203  virtual void AddHeader (void) = 0;
204 
209  virtual void Print (std::ostream &os) const;
210 
216  virtual bool Mark (void) = 0;
217 
227  virtual uint32_t Hash (uint32_t perturbation = 0) const;
228 
229 private:
235  QueueDiscItem ();
241  QueueDiscItem (const QueueDiscItem &);
249 
251  uint16_t m_protocol;
252  uint8_t m_txq;
254 };
255 
256 } // namespace ns3
257 
258 #endif /* QUEUE_ITEM_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Base class to represent items of packet Queues.
Definition: queue-item.h:46
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-item.cc:64
Time m_tstamp
timestamp when the packet was enqueued
Definition: queue-item.h:253
QueueItem()
Default constructor.
virtual ~QueueItem()
Definition: queue-item.cc:35
virtual ~QueueDiscItem()
Definition: queue-item.cc:85
uint8_t m_txq
Transmission queue index.
Definition: queue-item.h:252
Forward calls to a chain of Callback.
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
Definition: queue-item.cc:112
Ptr< Packet > m_packet
The packet contained in the queue item.
Definition: queue-item.h:127
uint16_t GetProtocol(void) const
Get the L3 protocol included in this item.
Definition: queue-item.cc:98
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:148
QueueDiscItem & operator=(const QueueDiscItem &)
Assignment operator.
Ptr< Packet > GetPacket(void) const
Definition: queue-item.cc:42
a polymophic address class
Definition: address.h:90
Uint8Values
1-byte fields of the packet whose value can be retrieved, if present
Definition: queue-item.h:76
virtual uint32_t GetSize(void) const
Use this method (instead of GetPacket ()->GetSize ()) to get the packet size.
Definition: queue-item.cc:49
uint16_t m_protocol
L3 Protocol number.
Definition: queue-item.h:251
QueueDiscItem()
Default constructor.
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
Definition: queue-item.cc:143
void SetTimeStamp(Time t)
Set the timestamp included in this item.
Definition: queue-item.cc:126
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
QueueItem & operator=(const QueueItem &)
Assignment operator.
virtual bool GetUint8Value(Uint8Values field, uint8_t &value) const
Retrieve the value of a given field from the packet, if present.
Definition: queue-item.cc:57
Time GetTimeStamp(void) const
Get the timestamp included in this item.
Definition: queue-item.cc:119
uint8_t GetTxQueueIndex(void) const
Get the transmission queue index included in this item.
Definition: queue-item.cc:105
Address GetAddress(void) const
Get the MAC address included in this item.
Definition: queue-item.cc:91
virtual bool Mark(void)=0
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
Address m_address
MAC destination address.
Definition: queue-item.h:250
A template-based reference counting class.
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-item.cc:133
virtual void AddHeader(void)=0
Add the header to the packet.