Arp¶
Package: inet.networklayer.arp.ipv4
simple module Arp
Implements the Address Resolution Protocol for IPv4 and IEEE 802 6-byte MAC addresses.
ARP packets are represented by the ArpPacket class.
Communication Between ARP and IPv4 modules:
IPv4 module calls the ARP::getMACAddressFor(ipv4Address) method to get the MACAddress
of the next hop. If this method could not resolve an IPv4 address to a MAC address, then IPv4
uses the Arp::startAddressResolution() method.
ARP emits an arpResolutionCompleted signal when it adds/modifies an entry in the ARP table.
ARP emits an arpResolutionFailed signal when an ARP request fails (ARP request sent
retryCount times and retryTimeout elapsed).
ARP resolution is used on broadcast interfaces only,
that is, on interfaces that have the isBroadcast() flag set in
NetworkInterface (see InterfaceTable). Since routing files
(.irt or .mrt files, given as parameters to Ipv4RoutingTable)
may modify the default interface configuration, you must ensure that
these files don’t contain the word BROADCAST e.g. for PPP
interfaces.
Usage diagram¶
Inheritance diagram¶
Used in compound modules¶
Name |
Type |
Description |
|---|---|---|
compound module |
Provides a network layer that connects the simulation to a real network on the host computer using a TUN device. Allows simulated applications to send and receive packets through the host’s networking stack at the IP layer. Contains standard components like routing table and ARP, and uses ExtUpperIpv4 with a TUN device for external connectivity. |
|
compound module |
Network layer of an IPv4 node. |
Extends¶
Name |
Type |
Description |
|---|---|---|
simple module |
Base module for all INET simple modules. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
displayStringTextFormat |
string |
“size:{arpCacheSize} sent:{numRequestsSent}\nrepl:{numRepliesSent} fail:{numFailedResolutions}” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
interfaceTableModule |
string |
The path to the InterfaceTable module |
|
routingTableModule |
string |
||
retryTimeout |
double |
1s |
Number of seconds ARP waits between retries to resolve an IPv4 address |
retryCount |
int |
3 |
Number of times ARP will attempt to resolve an IPv4 address |
cacheTimeout |
double |
120s |
Number of seconds unused entries in the cache will time out |
proxyArpInterfaces |
string |
“*” |
List of interfaces that proxy ARP is enabled on (all interfaces by default) |
Properties¶
Name |
Value |
Description |
|---|---|---|
class |
Arp |
|
display |
i=block/layer |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
netwIn |
input |
Incoming ARP requests and replies |
|
netwOut |
output |
Outgoing ARP requests/replies, and datagrams with resolved next hop |
|
ifIn |
input |
||
ifOut |
output |
Signals¶
Name |
Type |
Unit |
Description |
|---|---|---|---|
arpReplySent |
|||
arpRequestSent |
|||
arpResolutionCompleted |
inet::IArp::Notification |
||
arpResolutionFailed |
inet::IArp::Notification |
||
arpResolutionInitiated |
inet::IArp::Notification |
Statistics¶
Name |
Title |
Source |
Record |
Unit |
Interpolation Mode |
Description |
|---|---|---|---|---|---|---|
arpReplySent |
ARP replies sent |
arpReplySent |
count,”sum(packetBytes)”,”vector(packetBytes)” |
|||
arpRequestSent |
ARP request sent |
arpRequestSent |
count,”sum(packetBytes)”,”vector(packetBytes)” |
|||
arpResolutionCompleted |
ARP completed resolutions |
count |
||||
arpResolutionFailed |
ARP failed resolutions |
count |
||||
arpResolutionInitiated |
ARP initiated resolutions |
count |
Source code¶
//
// Implements the Address Resolution Protocol for IPv4 and IEEE 802 6-byte
// MAC addresses.
//
// ARP packets are represented by the ~ArpPacket class.
//
// Communication Between ARP and IPv4 modules:
// IPv4 module calls the `ARP::getMACAddressFor(ipv4Address)` method to get the MACAddress
// of the next hop. If this method could not resolve an IPv4 address to a MAC address, then IPv4
// uses the `Arp::startAddressResolution()` method.
// ARP emits an `arpResolutionCompleted` signal when it adds/modifies an entry in the ARP table.
// ARP emits an `arpResolutionFailed` signal when an ARP request fails (ARP request sent
// `retryCount` times and `retryTimeout` elapsed).
//
// ARP resolution is used on <i>broadcast</i> interfaces only,
// that is, on interfaces that have the `isBroadcast()` flag set in
// `NetworkInterface` (see ~InterfaceTable). Since routing files
// (`.irt` or `.mrt` files, given as parameters to ~Ipv4RoutingTable)
// may modify the default interface configuration, you must ensure that
// these files don't contain the word `BROADCAST` e.g. for PPP
// interfaces.
//
simple Arp extends SimpleModule like IArp
{
parameters:
@class(Arp);
string interfaceTableModule; // The path to the InterfaceTable module
string routingTableModule;
double retryTimeout @unit(s) = default(1s); // Number of seconds ARP waits between retries to resolve an IPv4 address
int retryCount = default(3); // Number of times ARP will attempt to resolve an IPv4 address
double cacheTimeout @unit(s) = default(120s); // Number of seconds unused entries in the cache will time out
string proxyArpInterfaces = default("*"); // List of interfaces that proxy ARP is enabled on (all interfaces by default)
displayStringTextFormat = default("size:{arpCacheSize} sent:{numRequestsSent}\nrepl:{numRepliesSent} fail:{numFailedResolutions}");
@display("i=block/layer");
@signal[arpRequestSent](type=inet::Packet);
@signal[arpReplySent](type=inet::Packet);
@signal[arpResolutionInitiated](type=inet::IArp::Notification);
@signal[arpResolutionCompleted](type=inet::IArp::Notification);
@signal[arpResolutionFailed](type=inet::IArp::Notification);
@statistic[arpRequestSent](title="ARP request sent"; source=arpRequestSent; record=count,"sum(packetBytes)","vector(packetBytes)");
@statistic[arpReplySent](title="ARP replies sent"; source=arpReplySent; record=count,"sum(packetBytes)","vector(packetBytes)");
@statistic[arpResolutionInitiated](title="ARP initiated resolutions"; record=count);
@statistic[arpResolutionCompleted](title="ARP completed resolutions"; record=count);
@statistic[arpResolutionFailed](title="ARP failed resolutions"; record=count);
gates:
input netwIn @labels(ArpPacket+Ieee802Ctrl); // Incoming ARP requests and replies
output netwOut @labels(ArpPacket+Ieee802Ctrl,Ipv4Header+Ieee802Ctrl); // Outgoing ARP requests/replies, and datagrams with resolved next hop
input ifIn @labels(ArpPacket,Ieee802Ctrl);
output ifOut @labels(ArpPacket,Ieee802Ctrl);
}