CSC521 Communication Protocols 網路通訊協定 Ch.6 Mapping Internet Addresses to Physical Addresses (ARP) 吳俊興國立高雄大學資訊工程學系 Internetworking With TCP/IP, Vol I: Sixth Edition, Douglas E. Comer
Outline 1 Introduction 2 The Address Resolution Problem 3 Two Types Of Hardware Addresses 4 Resolution Through Direct Mapping 5 Resolution In A Direct-Mapped Network 6 IPv4 Address Resolution Through Dynamic Binding 7 The ARP Cache 8 ARP Cache Timeout 9 ARP Refinements 10 Relationship Of ARP To Other Protocols 11 ARP Implementation 12 ARP Encapsulation And Identification 13 ARP Message Format 14 Automatic ARP Cache Revalidation 15 Reverse Address Resolution (RARP) 16 ARP Caches In Layer 3 Switches 17 Proxy ARP 18 IPv6 Neighbor Discovery 19 Summary 2
Address Resolution Problem Motivation Must use hardware (physical) addresses to communicate over network Applications only use Internet addresses Address resolution problem The problem of mapping high-level addresses to physical addresses Protocol software needs a mechanism that maps an IP address to equivalent hardware address Example Computers A and B on same network Application on A generates packet for application on B Protocol software on A must use B s hardware address when sending a packet 3
Two Types of Physical Addresses Two types of physical hardware addresses Those that are larger than the host portion of an IP address Those that are smaller than the host portion of an IP address Address resolution: performed at each step along path through Internet Two basic algorithms Direct mapping Dynamic binding Choice depends on type of hardware 4
Resolution Through Direct Mapping Direct Mapping Easy to understand, efficient Only works when hardware address is small Technique: assign computer an IP address that encodes the hardware address Example Hardware: pronet ring network Hardware address: 8 bits Assume IPv4 address 192.5.48.0 (24-bit prefix) Assign computer with hardware address K an IPv4 address 192.5.48.K Resolving an IPv4 address means extracting the hardware address from low-order 8 bits 5
IPv6 Resolution Through Direct Mapping IPv6 IPv6 accommodates all types of hardware addresses Link-Local Address includes 64-bit interface identifier 6
Resolution In A Direct-Mapped Network Direct mapping It means selecting a function f that maps IP addresses to physical addresses The mapping can be performed without reference to external data New computers can be added to a network without changing existing assignments and without propagating new information to existing computers 7
Resolution through Dynamic Binding Needed when hardware addresses are large (e.g., Ethernet) Allows computer A to find computer B s hardware address A starts with B s IP address A knows B is on the local network Technique: broadcast query and obtain response Note: dynamic binding only used across one network at a time Address Resolution Protocol (ARP) Isolates hardware address at low level Allows application programs to use IP addresses Allows a host to find the physical address of a target host on the same physical network, given only the target s IP address IP over Ethernet 32-bit IP address 48-bit Ethernet MAC address 8
Address Resolution Protocol (ARP) 1. Machine A broadcasts ARP request with B s IP address 2. All machines on local net receive broadcast 3. Machine B replies with its physical address 4. Machine A adds B s address information to its table 5. Machine A delivers packet directly to B 9
Retention Problem: Retention of Bindings Cannot afford to send ARP request for each packet Solution Maintain a table of bindings ARP cache Whenever a computer sends an ARP request and receives an ARP reply, it saves the IP address and corresponding hardware address information in its cache temporarily When transmitting a packet, a computer always looks in its cache before sending an ARP request Use ARP one time, place results in table, and then send many packets $arp[-a -d] ARP Caching 10
Automatic ARP Cache Revalidation Stale Problem: Stale Bindings An IP is reassigned to another new host after the old host is left Solution: the Traditional Timer A timer is set when information is added to the cache. When the timer expires, the information is deleted Typical timeout: 20 minutes Jitter Problem: Variance/Delay in Packet Transfer Time Jitter (variance/delay) occurs for the next packet to the destination whose entry is just expired due to timeout since another ARP resolution is required to regain the binding Solution: Early Revalidation before Expiration Another shorter revalidation timer used to proactively update the ARP cache before the entry is timing out Two counters with each entry in the ARP cache the traditional timer a revalidation timer 11
ARP Packet Format When Used With Ethernet ETHERNET ADDRESS TYPE (1) IP ADDRESS TYPE (0800) ETH ADDR LEN (6) IP ADDR LEN (4) OPERATION SENDER S ETH ADDR (first 4 octets) SENDER S ETH ADDR (last 2 octets) SENDER S IP ADDR (first 2 octets) SENDER S IP ADDR (last 2 octets) TARGET S ETH ADDR (first 2 octets) TARGET S ETH ADDR (last 4 octets) TARGET S IP ADDR (all 4 octets) Observation General: can be used with Arbitrary hardware address Arbitrary protocol address (not just IP) Variable length fields (depends on type of addresses) Length fields allow parsing of packet by computer that does not understand the two address types 12
ARP Encapsulation ARP message travels in data portion of network frame Ethernet encapsulation ARP message placed in frame data area Data area padded with zeroes if ARP message is shorter than minimum Ethernet frame Ethernet type 0x0806 used for ARP Ethernet Header IP Header TCP Header App. Data CRC Ethernet Header ARP Packet CRC Preamble Destination Source Frame Frame Data CRC Address Address Type 8 octets 6 octets 6 octets 2 octets 0800:IP 0806: ARP 46 1500 octets 4 octets 13
ARP Request Example ETHERNET ADDRESS TYPE (1) IP ADDRESS TYPE (0800) Ask 192.168.0.1 By 192.168.0.158 ETH ADDR LEN (6) IP ADDR LEN (4) OPERATION SENDER S ETH ADDR (first 4 octets) SENDER S ETH ADDR (last 2 octets) SENDER S IP ADDR (first 2 octets) SENDER S IP ADDR (last 2 octets) TARGET S ETH ADDR (first 2 octets) TARGET S ETH ADDR (last 4 octets) TARGET S IP ADDR (all 4 octets) 14
ARP Reply Example ETHERNET ADDRESS TYPE (1) IP ADDRESS TYPE (0800) Replied by 192.168.0.1 ETH ADDR LEN (6) IP ADDR LEN (4) OPERATION SENDER S ETH ADDR (first 4 octets) SENDER S ETH ADDR (last 2 octets) SENDER S IP ADDR (first 2 octets) SENDER S IP ADDR (last 2 octets) TARGET S ETH ADDR (first 2 octets) TARGET S ETH ADDR (last 4 octets) TARGET S IP ADDR (all 4 octets) 15
Algorithm For Processing ARP Requests Extract sender A s pair, (IP A,ETH A ) and update local ARP table if it exists If this is a request and the target is me Add sender s pair to ARP table if not present Fill in target hardware address Exchange sender and target entries Set operation to reply Send reply back to requester Algorithm Features If A ARPs B, B keeps A s information B will probably send a packet to A soon If A ARPs B, other machines do not keep A s information Avoids clogging ARP caches needlessly 16
Relationship Of ARP To Other Protocols IPv6 does not need ARP it uses direct mapping ARP merely provides one possible mechanism to map an IP address to a hardware address is a low-level protocol associated with the hardware It is not a key part of the TCP/IP protocols 17
Reverse Address Resolution (RARP) Maps Ethernet address to IP address Same packet format as ARP Intended for bootstrap Computer sends its Ethernet address RARP server responds by sending computer s IP address The only difference is that RARP uses Ethernet type 0x8035 Seldom used (replaced by DHCP) No longer important for diskless devices, but has an interesting use in cloud data centers 18
ARP Caches In Layer 3 Switches A layer-3 Ethernet switch if the switch understands IP packets and can examine IP headers when deciding how to process a packet How can a switch reduce broadcast traffic to computers? 19
Proxy ARP The technique in which one machine, usually a router, answers ARP requests intended for another by supplying its own physical address Proxy ARP allows multiple networks to share a single IP prefix 20
IPv6 Neighbor Discovery Protocol (NDP) NDP functionality Router discovery: hosts can locate routers residing on attached links Prefix/parameter discovery: hosts can discover address prefixes/link parameters (e.g., MTU) Address autoconfiguration / resolution: SLAAC and ARP like Duplicate address detection (DAD): check whether an address is already in use Neighbor unreachability detection (NUD): determine that a neighbor is no longer reachable etc Replace ARP with 5 ICMPv6 packet types Router Solicitation (Type 133) Hosts inquire with Router Solicitation messages to locate routers on an attached link Routers which forward packets not addressed to them generate Router Advertisements immediately upon receipt of this message rather than at their next scheduled time Router Advertisement (Type 134) Routers advertise their presence together with various link and Internet parameters Either periodically, or in response to a Router Solicitation message Neighbor Solicitation (Type 135) Used to determine the link layer address of a neighbor, or To verify that a neighbor is still reachable via a cached link layer address Neighbor Advertisement (Type 136) Used to respond to a Neighbor Solicitation message Redirect (Type 137) Routers may inform hosts of a better first hop router for a destination 21
Computer s IP address independent of computer s hardware address Applications use IP addresses Hardware only understands hardware addresses Must map from IP address to hardware address for transmission Two types Direct mapping Dynamic mapping Address Resolution Protocol (ARP) used for dynamic address mapping Important for Ethernet Sender broadcasts ARP request, and target sends ARP reply ARP bindings are cached: stale and jitter problems Other related protocols Reverse ARP was originally used for bootstrap ProxyARP IPv6 NDP Summary 22