A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
arp-queue-disc-item.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#ifndef ARP_QUEUE_DISC_ITEM_H
8#define ARP_QUEUE_DISC_ITEM_H
9
10#include "arp-header.h"
11
12#include "ns3/packet.h"
13#include "ns3/queue-item.h"
14
15namespace ns3
16{
17
18/**
19 * \ingroup arp
20 * \ingroup traffic-control
21 *
22 * ArpQueueDiscItem is a subclass of QueueDiscItem which stores ARP packets.
23 * Header and payload are kept separate to allow the queue disc to hash the
24 * fields of the header, which is added to the packet when the packet is dequeued.
25 */
27{
28 public:
29 /**
30 * \brief Create an ARP queue disc item containing an ARP 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 ARP header
35 */
37 const Address& addr,
38 uint16_t protocol,
39 const ArpHeader& header);
40
41 /** Destructor. */
42 ~ArpQueueDiscItem() override;
43
44 // Delete default constructor, copy constructor and assignment operator to avoid misuse
45 ArpQueueDiscItem() = delete;
48
49 /**
50 * \return the correct packet size (header plus payload).
51 */
52 uint32_t GetSize() const override;
53
54 /**
55 * \return the header stored in this item..
56 */
57 const ArpHeader& GetHeader() const;
58
59 /**
60 * \brief Add the header to the packet
61 */
62 void AddHeader() override;
63
64 /**
65 * \brief Print the item contents.
66 * \param os output stream in which the data should be printed.
67 */
68 void Print(std::ostream& os) const override;
69
70 /**
71 * \brief Inherited from the base class, but we cannot mark ARP packets
72 * \return false
73 */
74 bool Mark() override;
75
76 /**
77 * \brief Computes the hash of the packet's 5-tuple
78 *
79 * \param perturbation hash perturbation value
80 * \return the hash of the packet's 5-tuple
81 */
82 uint32_t Hash(uint32_t perturbation) const override;
83
84 private:
85 ArpHeader m_header; //!< The ARP header.
86 bool m_headerAdded; //!< True if the header has already been added to the packet.
87};
88
89} // namespace ns3
90
91#endif /* ARP_QUEUE_DISC_ITEM_H */
a polymophic address class
Definition address.h:90
The packet header for an ARP packet.
Definition arp-header.h:25
ArpQueueDiscItem is a subclass of QueueDiscItem which stores ARP packets.
void AddHeader() override
Add the header to the packet.
ArpHeader m_header
The ARP header.
const ArpHeader & GetHeader() const
bool m_headerAdded
True if the header has already been added to the packet.
uint32_t Hash(uint32_t perturbation) const override
Computes the hash of the packet's 5-tuple.
ArpQueueDiscItem & operator=(const ArpQueueDiscItem &)=delete
void Print(std::ostream &os) const override
Print the item contents.
ArpQueueDiscItem(const ArpQueueDiscItem &)=delete
bool Mark() override
Inherited from the base class, but we cannot mark ARP packets.
uint32_t GetSize() const override
~ArpQueueDiscItem() override
Destructor.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.