180 likes | 420 Views
Address Resolution Protocol (ARP). Reading: Chapter 15. ARP. Mapping between layer 3 and layer 2 addresses IP and MAC addresses Given an IP address, what is the corresponding MAC address? Built on top of data-link layer Encapsulated and transmitted in data-link layer data frames. 1.
E N D
Address Resolution Protocol (ARP) Reading: Chapter 15 FSU CIS 5930 Internet Protocols
ARP • Mapping between layer 3 and layer 2 addresses • IP and MAC addresses • Given an IP address, what is the corresponding MAC address? • Built on top of data-link layer • Encapsulated and transmitted in data-link layer data frames FSU CIS 5930 Internet Protocols
1 ARP-Reply to MAC 49:72:16:08:64:14 ARP-Request to MAC FF:FF:FF:FF:FF:FF MAC address of 129.25.10.11 ?Reply to: 49:72:16:08:64:14 (129.25.10.72) Reply:t: 129.25.10.11 (49:78:21:21:23:90)Requested by:: 129.25.10.72 (49:72:16:08:64:14) 2 IP: 129.25.10.11 MAC: 49:78:21:21:23:90 Router R IP: 129.1.11.72 MAC: 10:11:72:AB:02:01 Computer C: IP: 129.25.10.81 MAC: 49:17:92:96:96:96 Computer A: IP: 129.25.10.72 MAC: 49:72:16:08:64:14 Computer B: IP: 129.25.10.97 MAC: 49:72:16:08:80:70 An example FSU CIS 5930 Internet Protocols
ARP Protocol Data Unit 0 15 31 Hardware type (layer 2) Protocol type (layer 3) Address lengthLayer 2 (n) Address lengthLayer 3 (m) Operation Source address (layer 2): n bytes Source address (layer 3): m bytes Destiniation address (layer 2): n bytes Destination address (layer 3): m bytes Layer-2 header Layer-3 trailer Layer-2 payload ARP packet format FSU CIS 5930 Internet Protocols
ARP-Request to FF:FF:FF:FF:FF:FF ARP-Reply to 49:72:16:08:64:14 0 15 31 0 15 31 0x00 01 (Ethernet) 0x80 00 (Internet Protocol) 0x00 01 (Ethernet) 0x80 00 (Internet Protocol) 6 4 0x00 01 (ARP-Request) 6 4 0x00 02 (ARP-Reply) 49 72 16 08 49 72 16 08 64 14 129 25 64 14 129 25 10 72 00 00 10 72 49 78 00 00 00 00 21 21 23 90 129 25 10 11 129 25 10 11 ARP packet format: example FSU CIS 5930 Internet Protocols
Receiving ARP packet and replying • Insert layer 2 address (MAC address) • Swapping source – destination address fields • Changing operation field (reply) • Sending ARP reply • Source’s IP/MAC pair also inserted into ARP cache at receiver FSU CIS 5930 Internet Protocols
Implementation • Neighbors • Computers that can be directly reachable • Data structures • arp_tbl • neigh_table • neighbor • neigh_ops • Functions • Sending/receiving ARP packets • Managing ARP data structures FSU CIS 5930 Internet Protocols
neigh_table neigh_tables arp_tbl neigh_table neigh_table next family: AF_INET ... arp_constructor() constructor ... neigh_periodic_timer() gc_timer ... neighbour neighbour 0 hash_buckets[NEIGH..] neighbour 1 next neigh_table net_device neigh_parms dev neigh_timer_handler() timer neigh_ops ha hh_cache hh_cache nud_state next output sk_buff ref_cnt arp_queue hh_type: ETH_P_IP ... hh_output hh_data:00 80 23 32 12 49 72 16 08 64 14 49 78 21 21 23 90 neighbour NEIGH_-HASHMASK -1 Data structures FSU CIS 5930 Internet Protocols
neighbor • dev: • Pointer to corresponding network device • timer: • Pointer to timer to initiate handling routine neigh_timer_handler() • ha: • Hardware address of the neighbor • hh: • Hardware header • nud_state: • State concerning the neighboring computer • output: • Function to send data packet to the neighbor • arp_queue • Queue of packets waiting to be transmitted • opts: • Pointer to a neigh_ops structure FSU CIS 5930 Internet Protocols
neigh_table • family • Address family, for IP, it is AF_INET • constructor • Function to construct a neighbor structure • gc_timer • Garbage collection timer • hash_buckets[NEIGH_HASHMASK+1] • Hash table for maintaining neighbor info FSU CIS 5930 Internet Protocols
neigh_ops • Different neighbor characteristics • Generic, direct, hh, and broken • This structure defines the corresponding functions for different devices • destructor, solicit, error_report, output, connected_output, hh_output, queue_xmit FSU CIS 5930 Internet Protocols
NUD_STALE No sign of life in reachable_time Set timer Receive packet NUD_REACHABLE NUD_DELAY receive ARP-Reply Time out Receive ARP-Reply NUD_INCOMPLETE NUD_PROBE NUD_NONE max_probesRequests sent, No reply arp_constructor:initialize an entry, Send an ARP request Permanent Eintrag NUD_NONE NUD_FAILED NOARP- Device NUD_NOARP neigh_create: Create an entry Garbage Collection completed. Delete entry No Emtru States FSU CIS 5930 Internet Protocols
Higher Layers IPv4 IPv4 ip_queue_xmit ip_finish_output2 arp.c, neighbour.c arp_tbl neigh_update arp.c, neighbour.c neigh_lookup ARP-Reply neigh_resolve_output ARP-Request arp_rcv arp_send dev.c dev.c ETH_P_ARP net_rx_action dev_queue_xmit ARP operation FSU CIS 5930 Internet Protocols
Handling ARP PDUs • arp_rcv() • Some sanity check • NF_ARP_IN • arp_process() • arp_process() • Some more sanity check • For both request/reply • Update ARP cache (neigh_lookup()) • For request • arp_send() to send a reply FSU CIS 5930 Internet Protocols
Handling ARP packets • arp_send() • Allocating socket buffer • Filling hardware header • Filling ARP data • NF_ARP_OUT • dev_queue_xmit() • neigh_update() • Updating neighbor entry state • Setting up corresponding output function, etc FSU CIS 5930 Internet Protocols
Handling unresolved IP packets • neigh_resolve_output() • Sending the packet if it is OK (e.g., REACHALBE state) • Otherwise (e.g., INCOMPLETE state) • Storing the pkt in arp_queue queue by neigh_event_send() • neigh_event_send() • Checking if the pkt can be sent • If not, storing IP packet and sending ARP request (arp_solicit()) • arp_solicit() • Send ARP request by arp_send() FSU CIS 5930 Internet Protocols
Some other neighbor managing functions • neigh_connect() • neigh_suspect() • neigh_destroy() • neigh_sync() • neigh_periodic_timer() • neigh_timer_handler() FSU CIS 5930 Internet Protocols