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 * 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 ARP_QUEUE_DISC_ITEM_H
19#define ARP_QUEUE_DISC_ITEM_H
20
21#include "arp-header.h"
22
23#include "ns3/packet.h"
24#include "ns3/queue-item.h"
25
26namespace ns3
27{
28
29/**
30 * \ingroup arp
31 * \ingroup traffic-control
32 *
33 * ArpQueueDiscItem is a subclass of QueueDiscItem which stores ARP packets.
34 * Header and payload are kept separate to allow the queue disc to hash the
35 * fields of the header, which is added to the packet when the packet is dequeued.
36 */
38{
39 public:
40 /**
41 * \brief Create an ARP queue disc item containing an ARP 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 ARP header
46 */
48 const Address& addr,
49 uint16_t protocol,
50 const ArpHeader& header);
51
52 /** Destructor. */
53 ~ArpQueueDiscItem() override;
54
55 // Delete default constructor, copy constructor and assignment operator to avoid misuse
56 ArpQueueDiscItem() = delete;
59
60 /**
61 * \return the correct packet size (header plus payload).
62 */
63 uint32_t GetSize() const override;
64
65 /**
66 * \return the header stored in this item..
67 */
68 const ArpHeader& GetHeader() const;
69
70 /**
71 * \brief Add the header to the packet
72 */
73 void AddHeader() override;
74
75 /**
76 * \brief Print the item contents.
77 * \param os output stream in which the data should be printed.
78 */
79 void Print(std::ostream& os) const override;
80
81 /**
82 * \brief Inherited from the base class, but we cannot mark ARP packets
83 * \return false
84 */
85 bool Mark() override;
86
87 /**
88 * \brief Computes the hash of the packet's 5-tuple
89 *
90 * \param perturbation hash perturbation value
91 * \return the hash of the packet's 5-tuple
92 */
93 uint32_t Hash(uint32_t perturbation) const override;
94
95 private:
96 ArpHeader m_header; //!< The ARP header.
97 bool m_headerAdded; //!< True if the header has already been added to the packet.
98};
99
100} // namespace ns3
101
102#endif /* ARP_QUEUE_DISC_ITEM_H */
a polymophic address class
Definition: address.h:101
The packet header for an ARP packet.
Definition: arp-header.h:36
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.
Definition: ptr.h:77
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:133
Every class exported by the ns3 library is enclosed in the ns3 namespace.