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
28namespace ns3 {
29
30class Packet;
31
46class QueueItem : public SimpleRefCount<QueueItem>
47{
48public:
54
55 virtual ~QueueItem ();
56
57 // Delete default constructor, copy constructor and assignment operator to avoid misuse
58 QueueItem () = delete;
59 QueueItem (const QueueItem &) = delete;
60 QueueItem & operator = (const QueueItem &) = delete;
61
65 Ptr<Packet> GetPacket (void) const;
66
75 virtual uint32_t GetSize (void) const;
76
82 {
84 };
85
93 virtual bool GetUint8Value (Uint8Values field, uint8_t &value) const;
94
99 virtual void Print (std::ostream &os) const;
100
106 typedef void (* TracedCallback) (Ptr<const QueueItem> item);
107
108private:
113};
114
122std::ostream& operator<< (std::ostream& os, const QueueItem &item);
123
124
133class QueueDiscItem : public QueueItem {
134public:
141 QueueDiscItem (Ptr<Packet> p, const Address & addr, uint16_t protocol);
142
143 virtual ~QueueDiscItem ();
144
145 // Delete default constructor, copy constructor and assignment operator to avoid misuse
146 QueueDiscItem () = delete;
147 QueueDiscItem (const QueueDiscItem &) = delete;
149
154 Address GetAddress (void) const;
155
160 uint16_t GetProtocol (void) const;
161
166 uint8_t GetTxQueueIndex (void) const;
167
172 void SetTxQueueIndex (uint8_t txq);
173
178 Time GetTimeStamp (void) const;
179
184 void SetTimeStamp (Time t);
185
193 virtual void AddHeader (void) = 0;
194
199 virtual void Print (std::ostream &os) const;
200
206 virtual bool Mark (void) = 0;
207
217 virtual uint32_t Hash (uint32_t perturbation = 0) const;
218
219private:
221 uint16_t m_protocol;
222 uint8_t m_txq;
224};
225
226} // namespace ns3
227
228#endif /* QUEUE_ITEM_H */
a polymophic address class
Definition: address.h:91
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:133
QueueDiscItem()=delete
uint8_t m_txq
Transmission queue index.
Definition: queue-item.h:222
virtual void AddHeader(void)=0
Add the header to the packet.
Time m_tstamp
timestamp when the packet was enqueued
Definition: queue-item.h:223
Address m_address
MAC destination address.
Definition: queue-item.h:220
void SetTimeStamp(Time t)
Set the timestamp included in this item.
Definition: queue-item.cc:126
uint16_t m_protocol
L3 Protocol number.
Definition: queue-item.h:221
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-item.cc:133
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
Definition: queue-item.cc:143
Time GetTimeStamp(void) const
Get the timestamp included in this item.
Definition: queue-item.cc:119
uint16_t GetProtocol(void) const
Get the L3 protocol included in this item.
Definition: queue-item.cc:98
virtual ~QueueDiscItem()
Definition: queue-item.cc:85
virtual bool Mark(void)=0
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
Address GetAddress(void) const
Get the MAC address included in this item.
Definition: queue-item.cc:91
QueueDiscItem & operator=(const QueueDiscItem &)=delete
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
Definition: queue-item.cc:112
uint8_t GetTxQueueIndex(void) const
Get the transmission queue index included in this item.
Definition: queue-item.cc:105
QueueDiscItem(const QueueDiscItem &)=delete
Base class to represent items of packet Queues.
Definition: queue-item.h:47
QueueItem()=delete
QueueItem(const QueueItem &)=delete
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
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-item.cc:64
virtual uint32_t GetSize(void) const
Use this method (instead of GetPacket ()->GetSize ()) to get the packet size.
Definition: queue-item.cc:49
QueueItem & operator=(const QueueItem &)=delete
Ptr< Packet > GetPacket(void) const
Definition: queue-item.cc:42
Uint8Values
1-byte fields of the packet whose value can be retrieved, if present
Definition: queue-item.h:82
virtual ~QueueItem()
Definition: queue-item.cc:35
Ptr< Packet > m_packet
The packet contained in the queue item.
Definition: queue-item.h:112
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Forward calls to a chain of Callback.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139