A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
arp-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#ifndef ARP_HEADER_H
10
#define ARP_HEADER_H
11
12
#include "ns3/address.h"
13
#include "ns3/header.h"
14
#include "ns3/ipv4-address.h"
15
16
namespace
ns3
17
{
18
/**
19
* @ingroup arp
20
* @brief The packet header for an ARP packet
21
*/
22
class
ArpHeader
:
public
Header
23
{
24
public
:
25
/**
26
* @brief Enumeration listing the possible ARP types
27
*
28
* These ARP types are part of the standard ARP packet format as defined in Section
29
* "Definitions" of \RFC{826}.
30
*/
31
enum
ArpType_e
: uint16_t
32
{
33
ARP_TYPE_REQUEST
= 1,
34
ARP_TYPE_REPLY
= 2
35
};
36
37
/**
38
* @brief Enumeration listing the supported hardware types
39
*
40
* \RFC{826} specifies that the Hardware Type field in the ARP packet indicates the type
41
of hardware used.
42
* For the full list of Hardware Types, refer to:
43
* https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml
44
*/
45
enum class
HardwareType
: uint16_t
46
{
47
UNKNOWN
= 0,
48
ETHERNET
= 1,
49
EUI_64
= 27,
50
};
51
52
/**
53
* @brief Set the ARP request parameters
54
* @param sourceHardwareAddress the source hardware address
55
* @param sourceProtocolAddress the source IP address
56
* @param destinationHardwareAddress the destination hardware address (usually the
57
* broadcast address)
58
* @param destinationProtocolAddress the destination IP address
59
*/
60
void
SetRequest
(
Address
sourceHardwareAddress,
61
Ipv4Address
sourceProtocolAddress,
62
Address
destinationHardwareAddress,
63
Ipv4Address
destinationProtocolAddress);
64
/**
65
* @brief Set the ARP reply parameters
66
* @param sourceHardwareAddress the source hardware address
67
* @param sourceProtocolAddress the source IP address
68
* @param destinationHardwareAddress the destination hardware address (usually the
69
* broadcast address)
70
* @param destinationProtocolAddress the destination IP address
71
*/
72
void
SetReply
(
Address
sourceHardwareAddress,
73
Ipv4Address
sourceProtocolAddress,
74
Address
destinationHardwareAddress,
75
Ipv4Address
destinationProtocolAddress);
76
77
/**
78
* @brief Determines the hardware type based on the length of the address.
79
*
80
* This method determines the hardware type based on the length of the address.
81
* It supports two common hardware address lengths:
82
* - 6 bytes: Assumed to be Ethernet.
83
* - 8 bytes: Assumed to be EUI-64.
84
*
85
* If the length of the address does not match these common lengths, the method defaults
86
* to Unknown hardware type.
87
*
88
* @param address The address whose length is used to determine the hardware type.
89
* @return The corresponding hardware type.
90
*/
91
HardwareType
DetermineHardwareType
(
const
Address
& address)
const
;
92
93
/**
94
* @brief Check if the ARP is a request
95
* @returns true if it is a request
96
*/
97
bool
IsRequest
()
const
;
98
99
/**
100
* @brief Check if the ARP is a reply
101
* @returns true if it is a reply
102
*/
103
bool
IsReply
()
const
;
104
105
/**
106
* @brief Get the hardware type
107
* @return the hardware type
108
*/
109
HardwareType
GetHardwareType
()
const
;
110
111
/**
112
* @brief Returns the source hardware address
113
* @returns the source hardware address
114
*/
115
Address
GetSourceHardwareAddress
()
const
;
116
117
/**
118
* @brief Returns the destination hardware address
119
* @returns the destination hardware address
120
*/
121
Address
GetDestinationHardwareAddress
()
const
;
122
123
/**
124
* @brief Returns the source IP address
125
* @returns the source IP address
126
*/
127
Ipv4Address
GetSourceIpv4Address
()
const
;
128
129
/**
130
* @brief Returns the destination IP address
131
* @returns the destination IP address
132
*/
133
Ipv4Address
GetDestinationIpv4Address
()
const
;
134
135
/**
136
* @brief Get the type ID.
137
* @return the object TypeId
138
*/
139
static
TypeId
GetTypeId
();
140
TypeId
GetInstanceTypeId
()
const override
;
141
void
Print
(std::ostream& os)
const override
;
142
uint32_t
GetSerializedSize
()
const override
;
143
void
Serialize
(
Buffer::Iterator
start)
const override
;
144
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
145
146
HardwareType
m_hardwareType
;
//!< hardware type
147
ArpType_e
m_type
;
//!< type of the ICMP packet
148
Address
m_macSource
;
//!< hardware source address
149
Address
m_macDest
;
//!< hardware destination address
150
Ipv4Address
m_ipv4Source
;
//!< IP source address
151
Ipv4Address
m_ipv4Dest
;
//!< IP destination address
152
};
153
154
/**
155
* @brief Stream insertion operator.
156
*
157
* @param os The reference to the output stream
158
* @param hardwareType the hardware type
159
* @return The reference to the output stream.
160
*/
161
std::ostream&
operator<<
(std::ostream& os,
ArpHeader::HardwareType
hardwareType);
162
163
}
// namespace ns3
164
165
#endif
/* ARP_HEADER_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::ArpHeader
The packet header for an ARP packet.
Definition
arp-header.h:23
ns3::ArpHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
arp-header.cc:194
ns3::ArpHeader::m_macSource
Address m_macSource
hardware source address
Definition
arp-header.h:148
ns3::ArpHeader::GetHardwareType
HardwareType GetHardwareType() const
Get the hardware type.
Definition
arp-header.cc:85
ns3::ArpHeader::Print
void Print(std::ostream &os) const override
Definition
arp-header.cc:137
ns3::ArpHeader::m_type
ArpType_e m_type
type of the ICMP packet
Definition
arp-header.h:147
ns3::ArpHeader::SetReply
void SetReply(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP reply parameters.
Definition
arp-header.cc:39
ns3::ArpHeader::IsReply
bool IsReply() const
Check if the ARP is a reply.
Definition
arp-header.cc:78
ns3::ArpHeader::IsRequest
bool IsRequest() const
Check if the ARP is a request.
Definition
arp-header.cc:71
ns3::ArpHeader::GetDestinationHardwareAddress
Address GetDestinationHardwareAddress() const
Returns the destination hardware address.
Definition
arp-header.cc:99
ns3::ArpHeader::GetDestinationIpv4Address
Ipv4Address GetDestinationIpv4Address() const
Returns the destination IP address.
Definition
arp-header.cc:113
ns3::ArpHeader::SetRequest
void SetRequest(Address sourceHardwareAddress, Ipv4Address sourceProtocolAddress, Address destinationHardwareAddress, Ipv4Address destinationProtocolAddress)
Set the ARP request parameters.
Definition
arp-header.cc:23
ns3::ArpHeader::m_macDest
Address m_macDest
hardware destination address
Definition
arp-header.h:149
ns3::ArpHeader::HardwareType
HardwareType
Enumeration listing the supported hardware types.
Definition
arp-header.h:46
ns3::ArpHeader::HardwareType::EUI_64
@ EUI_64
ns3::ArpHeader::HardwareType::UNKNOWN
@ UNKNOWN
ns3::ArpHeader::HardwareType::ETHERNET
@ ETHERNET
ns3::ArpHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
arp-header.cc:175
ns3::ArpHeader::m_ipv4Dest
Ipv4Address m_ipv4Dest
IP destination address.
Definition
arp-header.h:151
ns3::ArpHeader::GetSourceIpv4Address
Ipv4Address GetSourceIpv4Address() const
Returns the source IP address.
Definition
arp-header.cc:106
ns3::ArpHeader::DetermineHardwareType
HardwareType DetermineHardwareType(const Address &address) const
Determines the hardware type based on the length of the address.
Definition
arp-header.cc:55
ns3::ArpHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
arp-header.cc:130
ns3::ArpHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
arp-header.cc:120
ns3::ArpHeader::m_hardwareType
HardwareType m_hardwareType
hardware type
Definition
arp-header.h:146
ns3::ArpHeader::m_ipv4Source
Ipv4Address m_ipv4Source
IP source address.
Definition
arp-header.h:150
ns3::ArpHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
arp-header.cc:161
ns3::ArpHeader::GetSourceHardwareAddress
Address GetSourceHardwareAddress() const
Returns the source hardware address.
Definition
arp-header.cc:92
ns3::ArpHeader::ArpType_e
ArpType_e
Enumeration listing the possible ARP types.
Definition
arp-header.h:32
ns3::ArpHeader::ARP_TYPE_REQUEST
@ ARP_TYPE_REQUEST
Definition
arp-header.h:33
ns3::ArpHeader::ARP_TYPE_REPLY
@ ARP_TYPE_REPLY
Definition
arp-header.h:34
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
internet
model
arp-header.h
Generated on Wed Jan 15 2025 18:37:05 for ns-3 by
1.11.0