A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
queue-item.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stefano.avallone@unina.it>
7 */
8
9#include "queue-item.h"
10
11#include "ns3/log.h"
12#include "ns3/packet.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("QueueItem");
18
20{
21 NS_LOG_FUNCTION(this << p);
22 m_packet = p;
23}
24
26{
27 NS_LOG_FUNCTION(this);
28 m_packet = nullptr;
29}
30
33{
34 NS_LOG_FUNCTION(this);
35 return m_packet;
36}
37
40{
41 NS_LOG_FUNCTION(this);
43 return m_packet->GetSize();
44}
45
46bool
48{
49 NS_LOG_FUNCTION(this);
50 return false;
51}
52
53void
54QueueItem::Print(std::ostream& os) const
55{
56 os << GetPacket();
57}
58
59std::ostream&
60operator<<(std::ostream& os, const QueueItem& item)
61{
62 item.Print(os);
63 return os;
64}
65
66QueueDiscItem::QueueDiscItem(Ptr<Packet> p, const Address& addr, uint16_t protocol)
67 : QueueItem(p),
68 m_address(addr),
69 m_protocol(protocol),
70 m_txq(0)
71{
72 NS_LOG_FUNCTION(this << p << addr << protocol);
73}
74
79
82{
83 NS_LOG_FUNCTION(this);
84 return m_address;
85}
86
87uint16_t
89{
90 NS_LOG_FUNCTION(this);
91 return m_protocol;
92}
93
94uint8_t
96{
97 NS_LOG_FUNCTION(this);
98 return m_txq;
99}
100
101void
103{
104 NS_LOG_FUNCTION(this << (uint16_t)txq);
105 m_txq = txq;
106}
107
108Time
110{
111 NS_LOG_FUNCTION(this);
112 return m_tstamp;
113}
114
115void
117{
118 NS_LOG_FUNCTION(this << t);
119 m_tstamp = t;
120}
121
122void
123QueueDiscItem::Print(std::ostream& os) const
124{
125 os << GetPacket() << " "
126 << "Dst addr " << m_address << " "
127 << "proto " << m_protocol << " "
128 << "txq " << +m_txq;
129}
130
132QueueDiscItem::Hash(uint32_t perturbation) const
133{
134 NS_LOG_WARN("The Hash method should be redefined by subclasses");
135 return 0;
136}
137
138} // namespace ns3
a polymophic address class
Definition address.h:90
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition packet.h:850
Smart pointer class similar to boost::intrusive_ptr.
void Print(std::ostream &os) const override
Print the item contents.
QueueDiscItem()=delete
uint8_t m_txq
Transmission queue index.
Definition queue-item.h:212
Time m_tstamp
timestamp when the packet was enqueued
Definition queue-item.h:213
Address m_address
MAC destination address.
Definition queue-item.h:210
void SetTimeStamp(Time t)
Set the timestamp included in this item.
uint16_t m_protocol
L3 Protocol number.
Definition queue-item.h:211
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
Address GetAddress() const
Get the MAC address included in this item.
Definition queue-item.cc:81
~QueueDiscItem() override
Definition queue-item.cc:75
uint8_t GetTxQueueIndex() const
Get the transmission queue index included in this item.
Definition queue-item.cc:95
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
uint16_t GetProtocol() const
Get the L3 protocol included in this item.
Definition queue-item.cc:88
Time GetTimeStamp() const
Get the timestamp included in this item.
Base class to represent items of packet Queues.
Definition queue-item.h:36
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:47
Ptr< Packet > GetPacket() const
Definition queue-item.cc:32
virtual void Print(std::ostream &os) const
Print the item contents.
Definition queue-item.cc:54
virtual uint32_t GetSize() const
Use this method (instead of GetPacket ()->GetSize ()) to get the packet size.
Definition queue-item.cc:39
Uint8Values
1-byte fields of the packet whose value can be retrieved, if present
Definition queue-item.h:71
virtual ~QueueItem()
Definition queue-item.cc:25
Ptr< Packet > m_packet
The packet contained in the queue item.
Definition queue-item.h:101
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
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:148