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