A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-queue-disc-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
18#ifndef IPV6_QUEUE_DISC_ITEM_H
19#define IPV6_QUEUE_DISC_ITEM_H
20
21#include "ipv6-header.h"
22
23#include "ns3/packet.h"
24#include "ns3/queue-item.h"
25
26namespace ns3
27{
28
29/**
30 * \ingroup ipv6
31 * \ingroup traffic-control
32 *
33 * Ipv6QueueDiscItem is a subclass of QueueDiscItem which stores IPv6 packets.
34 * Header and payload are kept separate to allow the queue disc to manipulate
35 * the header, which is added to the packet when the packet is dequeued.
36 */
38{
39 public:
40 /**
41 * \brief Create an IPv6 queue disc item containing an IPv6 packet.
42 * \param p the packet included in the created item.
43 * \param addr the destination MAC address
44 * \param protocol the protocol number
45 * \param header the IPv6 header
46 */
48 const Address& addr,
49 uint16_t protocol,
50 const Ipv6Header& header);
51
52 ~Ipv6QueueDiscItem() override;
53
54 // Delete default constructor, copy constructor and assignment operator to avoid misuse
58
59 /**
60 * \return the correct packet size (header plus payload).
61 */
62 uint32_t GetSize() const override;
63
64 /**
65 * \return the header stored in this item..
66 */
67 const Ipv6Header& GetHeader() const;
68
69 /**
70 * \brief Add the header to the packet
71 */
72 void AddHeader() override;
73
74 /**
75 * \brief Print the item contents.
76 * \param os output stream in which the data should be printed.
77 */
78 void Print(std::ostream& os) const override;
79
80 /*
81 * The values for the fields of the Ipv6 header are taken from m_header and
82 * thus might differ from those present in the packet in case the header is
83 * modified after being added to the packet. However, this function is likely
84 * to be called before the header is added to the packet (i.e., before the
85 * packet is dequeued from the queue disc)
86 */
87 bool GetUint8Value(Uint8Values field, uint8_t& value) const override;
88
89 /**
90 * \brief Marks the packet by setting ECN_CE bits if the packet has
91 * ECN_ECT0 or ECN_ECT1 set. If ECN_CE is already set, returns true.
92 * \return true if the method results in a marked packet, false otherwise
93 */
94 bool Mark() override;
95
96 /**
97 * \brief Computes the hash of the packet's 5-tuple
98 *
99 * Computes the hash of the source and destination IP addresses, protocol
100 * number and, if the transport protocol is either UDP or TCP, the source
101 * and destination port
102 *
103 * \param perturbation hash perturbation value
104 * \return the hash of the packet's 5-tuple
105 */
106 uint32_t Hash(uint32_t perturbation) const override;
107
108 private:
109 Ipv6Header m_header; //!< The IPv6 header.
110 bool m_headerAdded; //!< True if the header has already been added to the packet.
111};
112
113} // namespace ns3
114
115#endif /* IPV6_QUEUE_DISC_ITEM_H */
a polymophic address class
Definition: address.h:101
Packet header for IPv6.
Definition: ipv6-header.h:35
Ipv6QueueDiscItem is a subclass of QueueDiscItem which stores IPv6 packets.
const Ipv6Header & GetHeader() const
void AddHeader() override
Add the header to the packet.
bool Mark() override
Marks the packet by setting ECN_CE bits if the packet has ECN_ECT0 or ECN_ECT1 set.
bool GetUint8Value(Uint8Values field, uint8_t &value) const override
Retrieve the value of a given field from the packet, if present.
Ipv6QueueDiscItem & operator=(const Ipv6QueueDiscItem &)=delete
uint32_t GetSize() const override
Ipv6QueueDiscItem(const Ipv6QueueDiscItem &)=delete
Ipv6Header m_header
The IPv6 header.
void Print(std::ostream &os) const override
Print the item contents.
uint32_t Hash(uint32_t perturbation) const override
Computes the hash of the packet's 5-tuple.
bool m_headerAdded
True if the header has already been added to the packet.
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
Uint8Values
1-byte fields of the packet whose value can be retrieved, if present
Definition: queue-item.h:82
Every class exported by the ns3 library is enclosed in the ns3 namespace.