A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
queue-item.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stefano.avallone@unina.it>
18 */
19#ifndef QUEUE_ITEM_H
20#define QUEUE_ITEM_H
21
22#include "ns3/nstime.h"
23#include "ns3/ptr.h"
24#include "ns3/simple-ref-count.h"
25#include <ns3/address.h>
26
27namespace ns3
28{
29
30class Packet;
31
46class QueueItem : public SimpleRefCount<QueueItem>
47{
48 public:
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() const;
66
75 virtual uint32_t GetSize() 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
107
108 private:
113};
114
122std::ostream& operator<<(std::ostream& os, const QueueItem& item);
123
133{
134 public:
141 QueueDiscItem(Ptr<Packet> p, const Address& addr, uint16_t protocol);
142
143 ~QueueDiscItem() override;
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() const;
155
160 uint16_t GetProtocol() const;
161
166 uint8_t GetTxQueueIndex() const;
167
172 void SetTxQueueIndex(uint8_t txq);
173
178 Time GetTimeStamp() const;
179
184 void SetTimeStamp(Time t);
185
193 virtual void AddHeader() = 0;
194
199 void Print(std::ostream& os) const override;
200
207 virtual bool Mark() = 0;
208
218 virtual uint32_t Hash(uint32_t perturbation = 0) const;
219
220 private:
222 uint16_t m_protocol;
223 uint8_t m_txq;
225};
226
227} // namespace ns3
228
229#endif /* QUEUE_ITEM_H */
a polymophic address class
Definition: address.h:101
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:133
void Print(std::ostream &os) const override
Print the item contents.
Definition: queue-item.cc:134
QueueDiscItem()=delete
uint8_t m_txq
Transmission queue index.
Definition: queue-item.h:223
Time m_tstamp
timestamp when the packet was enqueued
Definition: queue-item.h:224
Address m_address
MAC destination address.
Definition: queue-item.h:221
void SetTimeStamp(Time t)
Set the timestamp included in this item.
Definition: queue-item.cc:127
uint16_t m_protocol
L3 Protocol number.
Definition: queue-item.h:222
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
Definition: queue-item.cc:143
Address GetAddress() const
Get the MAC address included in this item.
Definition: queue-item.cc:92
~QueueDiscItem() override
Definition: queue-item.cc:86
uint8_t GetTxQueueIndex() const
Get the transmission queue index included in this item.
Definition: queue-item.cc:106
virtual void AddHeader()=0
Add the header to the packet.
QueueDiscItem & operator=(const QueueDiscItem &)=delete
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
Definition: queue-item.cc:113
uint16_t GetProtocol() const
Get the L3 protocol included in this item.
Definition: queue-item.cc:99
virtual bool Mark()=0
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
Time GetTimeStamp() const
Get the timestamp included in this item.
Definition: queue-item.cc:120
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:58
Ptr< Packet > GetPacket() const
Definition: queue-item.cc:43
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-item.cc:65
QueueItem & operator=(const QueueItem &)=delete
virtual uint32_t GetSize() const
Use this method (instead of GetPacket ()->GetSize ()) to get the packet size.
Definition: queue-item.cc:50
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:36
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:105
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:159