Transcript Document

Chapter 8
ARP
and
RARP
Hyung-Min Lee
©Networking Lab., 2001
About ARP and RARP
Logical address
•
•
•
The hosts and routers are recognized at the network level by there logical address.
A logical address is an internetwork address and unique universally.
It is usually implemented in software.
The logical address in the TCP/IP protocol suit are called IP address.(32 bit)
Physical address
•
•
At the physical level, the hosts and routers are recognized by there Physical address.
The Physical address is a local address and unique locally.
It is usually implemented in hardware.(48 bits MAC address)
Static mapping
•
It means creating a table that associates a logical address with a physical address .
Dynamic mapping
•
Each time a machine knows one of the two address(logical or physical), it can use a
protocol to find the other one.(ARP:Address resolution protocol/RARP:Reverse ARP)
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-1 ARP and RARP
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.1
•
•
•
ARP
Anytime a host, or a router, needs to find physical address of another host or router on
its network, it sends an ARP query packet.
The packet includes the physical and IP address of the sender and the IP address of
receiver.
The query is broadcast over the network.
 Only the intended recipient recognizes its IP address and sends back an ARP
response packet.(recipient’s IP and physical address)
The packet is unicast directly to the inquirer using the physical address received in the
query packet.
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-2 ARP operation
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
Packet Format
•
•
•
•
•
•
HTYPE(Hardware type): The type of the network on which ARP is running. (16-bit)
(Ex) Ethernet is given the type 1
PTYPE(Protocol type): Protocol (16-bit field).
(Ex) IPv4 protocol is 080016.
HLEN(Hardware length): The length of the physical address in bytes (8-bit field)
(Ex) Ethernet the value is six
PLEN(Protocol length): The length of the logical address in bytes (8-bit field)
(Ex) IPv4 protocol the value is four.
OPER(Operation): The type of the packet. (16-bit)
Two packet types are defined: ARP request(1), ARP reply(2).
SHA (Sender hardware address): The physical address of the sender.
(variable-length field)
(Ex) Ethernet the value six
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
Packet Format…
•
•
•
SPA(Sender protocol address): The logical address of the sender. (variable-length field)
(Ex) For the IP protocol, this field is four bytes long.
THA(Target hardware address): The physical address of the sender. (variable-length
field)
(Ex) Ethernet this field is six bytes long.
For an ARP request message, this field is all 0,s
TPA(Target protocol address): The logical address of the target. (variable-length
field)
(Ex) For the IP protocol, this field is four bytes long.
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-3 ARP Packet
Hyung-Min Lee
©Networking Lab., 2001
Packet Format…
•Encapsulation:
An ARP packet is encapsulated directly in to a data link frame.
Figure 8-4 Encapsulation of ARP packet.
The type field indicates that the data
carried by the frame is an ARP
packet
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
Operation
•
Step Involved
1.
2.
3.
4.
5.
6.
Hyung-Min Lee
IP asks ARP to create a request ARP message, filling in the sender physical
address, the sender IP address, and the target IP address.(The target physical
address field is filled with 0’s)
The message is passed to the data link layer where it is encapsulated in a frame
using the physical address of the sender as the source address and the physical
broadcast address as the destination address.
Every host or router receives the frame.
The target machine replies with an ARP message that contains its physical
address. The message is unicast.
The sender receives the reply message. It knows the physical address of the target
machine.
The IP datagram, which carries data for the target machine, is now encapsulated
in aframe and is unicast to the destination.
©Networking Lab., 2001
ARP & RARP
Operation..
•
Four Different Cases
1.
2.
3.
4.
Hyung-Min Lee
The sender is a host and wants to send a packet to another host on the same
network. The logical address that must be mapped to a physical address is the
destination IP address in the datagram header.
The sender is a host and wants to send a packet to another host on another
network  The host looks at its routing table and finds the IP address of the
next hop(router) for this destination.
If it does not have a routing table, it
looks for the IP address of the default router. The IP address of the router
becomes the logical address that must be mapped to a physical address.
The sender is a router that has received a datagram destined for a host another
network.  It checks its routing table and finds the IP address of the next router.
The sender is a router that has received a datagram destined for a host in the
same network. The destination IP address of the datagram becomes the logical
address that must be mapped to a physicall address.
©Networking Lab., 2001
Figure 8-5, Part I
Hyung-Min Lee
Four cases using ARP
©Networking Lab., 2001
Figure 8-5, Part II
Four cases using
ARP
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
Proxy ARP
•
•
•
Hyung-Min Lee
A proxy ARP is an ARP that acts on be half of a set of host.
Whenever the the router running a proxy ARP receives an ARP request looking for
the IP address of one of these hosts, the router sends an ARP reply announcing its
own hardware(physical) address.
Later when the router receives the actual IP packet, it will send the packet to the
appropriate host or router.
©Networking Lab., 2001
Figure 8-6
Hyung-Min Lee
Proxy ARP
©Networking Lab., 2001
ARP & RARP
8.2
•
ARP DESIGN
ARP package involves five component:
– A cache table
– A queues
– An output module
– An input module
– A cache-control module
Cache Table
•
•
When a host or router receives the corresponding physical address for IP datagram, the
address can be saved in the cache table.
This address can be used for the datagram destined for the same receiver within the next
few minutes.
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-7 ARP components
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN..
Cache Table..
The cache table is implemented as an array of entries, In our design, each entry contains the
following fields:
• State: This column shows the state of the entry. It can have one of three values:
– FREE: The time-to-live for this entry has expired. The space can be used for a new
entry.
– PENDING: A request for this entry has been sent, but the reply has not yet been
received.
– RESOLVED: The entry is complete. The entry now has the physical address of the
destination. The packets waiting to be sent this destination can use information in
this entry.
•
•
Hardware type: This field is the same as corresponding field in the ARP packet.
Protocol type: This field is the same as corresponding field in the ARP packet.
•
Hardware length: This field is the same as corresponding field in the ARP packet.
•
Protocol length: This field is the same as corresponding field in the ARP packet.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN…
Cache Table..
•
Interface number: A router (or multihomed host) can be connected to different
networks, each with a different interface number. Each networks can have different
hardware and protocol types.
•
Queue number: ARP uses different queues to enqueue the packets waiting for address
resolution. Packets for the same destination are usually enqueued in the same queue.
The queue number refers to the queue whose packets are waiting for this entry to be
resolved.
•
Attempts : This column shows how many times an ARP requesu is sent out for this
entry.
•
•
Time-out : This column shows the lifetime of an entry in seconds.
Hardware address : This column shows the destination hardware address. It remains
empty until resolved by an ARP reply.
•
Protocol address : This column shows the destination IP address.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN…
Queues
•
•
•
The ARP package maintains a set of queues, one for each destination, to hold the IP
packets while ARP tries to resolve the hardware address.
The output module sends unresolved packets into the corresponding queue.
The input module removes a packet from a queue and sends it, with the resolved
physical address, to the data link layer for transmission.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN…
Output Module
1.
2.
3.
4.
5.
Sleep until an IP packet is received from IP software.
Check the cache table to find an entry corresponding to this IP packet.
If (found)
1.
If (the state is RESOLVED)
1.
Extract the value of the hardware address from th entry.
2.
Send the packet and the hardware address to data link layer.
3.
Return.
2.
If (the state is PENDING)
1.
Enqueue the packet to the corresponding queue.
2.
Return.
If (not found)
1.
Create a queue.
2.
Enqueue the packet.
3.
Create a cache entry with state set to PENDING and ATTEMPTS set to 1.
4.
Send an ARP request.
Return.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN…
Input Module
1.
2.
3.
4.
5.
6.
Sleep until an ARP packet(request or reply) arrives.
Check the cache table to find an entry corresponding to this ARP packet.
If (found)
1.
If (the state is PENDING)
1.
Update the entry.
2.
While the queue is not empty.
1. Dequeue one packet.
2. Send the packet and the hardware address to data link.
2.
If (the state is RESOLVED)
1.
Update the entyry.
If (not found)
1.
Create an entry.
2.
Add the entry to the table.
If (the packet is a request)
1.
Send an ARP reply
Return.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.2
ARP DESIGN…
Cache-Control Module
1.
2.
3.
Sleep until the periodic timer matures.
For every entry in the cache table.
1.
If (the state is FREE)
1.
Continue.
2.
If (the state is PENDING)
1.
Increment the value of attempts by 1.
2.
If (attempts greater than maxium)
1. Change the state to FREE
2. Destroy the corresponding queue.
3.
If (not)
1. Send an ARP request.
4.
Continue.
3.
If (the state is RESOLVED)
1.
Decrement the value of time-out by the value of elapsed time.
2. If (time-out less than or equal to zero)
1. Change the state to FREE
2. Destroy the corresponding queue.
Return.
Hyung-Min Lee
©Networking Lab., 2001
ARP & RARP
8.3
•
•
•
•
•
•
•
•
Hyung-Min Lee
RARP
The RARP is designed to resolve the address mapping problem in which a machine
knows its physical address but does not know its logical address.
To create an IP datagram, a host or a router needs to know its own IP address or
address.
The IP address of a machine is usually read from its configuration file stored on a
disk file.
However, a diskless machine is usually booted from ROM, which has minimum
booting information.
The machine can get its physical address (by reading its NIC, for example), which is
unique locally.
It can then use the physical address to get the logical address using the RARP
protocol.
A ARP request is created and broadcast on the local network.
Another machine on the local network that knows all the IP address will respond with
RARP reply.
©Networking Lab., 2001
Figure 8-8 RARP operation
The RARP request packets are broadcast; the RARP reply packets are unicast
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-9 RARP packet : the same as the ARP
Hyung-Min Lee
©Networking Lab., 2001
Figure 8-10 Encapsulation of RARP packet
The RARP packet is encapsulated directly in to a data link frame.
Note that the type field shows that the data carried by the frame is a
RARP packet.
Hyung-Min Lee
©Networking Lab., 2001