Address Resolution Protocol ARP Reading Chapter 15 Fall

  • Slides: 17
Download presentation
Address Resolution Protocol (ARP) Reading: Chapter 15 Fall 2004 FSU CIS 5930 Internet Protocols

Address Resolution Protocol (ARP) Reading: Chapter 15 Fall 2004 FSU CIS 5930 Internet Protocols 1

ARP • Mapping between layer 3 and layer 2 addresses – IP and MAC

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 Fall 2004 FSU CIS 5930 Internet Protocols 2

An example ARP-Request to MAC FF: FF: FF: FF 1 MAC address of 129.

An example ARP-Request to MAC FF: FF: FF: FF 1 MAC address of 129. 25. 10. 11 ? Reply to: 49: 72: 16: 08: 64: 14 (129. 25. 10. 72) ARP-Reply to MAC 49: 72: 16: 08: 64: 14 Reply: t: 129. 25. 10. 11 (49: 78: 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: 23: 90 Router R IP: 129. 1. 11. 72 MAC: 10: 11: 72: AB: 02: 01 Fall 2004 Computer A: Computer B: Computer C: IP: 129. 25. 10. 72 MAC: 49: 72: 16: 08: 64: 14 IP: 129. 25. 10. 97 MAC: 49: 72: 16: 08: 80: 70 IP: 129. 25. 10. 81 MAC: 49: 17: 92: 96: 96 FSU CIS 5930 Internet Protocols 3

ARP packet format ARP Protocol Data Unit 0 15 Hardware type (layer 2) Address

ARP packet format ARP Protocol Data Unit 0 15 Hardware type (layer 2) Address length Layer 2 (n) 31 Protocol type (layer 3) Address length Layer 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 Fall 2004 Layer-2 payload FSU CIS 5930 Internet Protocols Layer-3 trailer 4

ARP packet format: example ARP-Request to FF: FF: FF: FF 0 15 0 x

ARP packet format: example ARP-Request to FF: FF: FF: FF 0 15 0 x 00 01 (Ethernet) 6 ARP-Reply to 49: 72: 16: 08: 64: 14 31 0 15 0 x 80 00 (Internet Protocol) 4 0 x 00 01 (ARP-Request) 0 x 00 01 (Ethernet) 6 0 x 80 00 (Internet Protocol) 4 49 72 16 08 Fall 2004 31 0 x 00 02 (ARP-Reply) 49 72 16 08 64 14 129 25 10 72 00 00 10 72 49 78 00 00 21 21 23 90 129 25 10 11 FSU CIS 5930 Internet Protocols 5

Receiving ARP packet and replying • Insert layer 2 address (MAC address) • Swapping

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 Fall 2004 FSU CIS 5930 Internet Protocols 6

Implementation • Neighbors – Computers that can be directly reachable • Data structures –

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 Fall 2004 FSU CIS 5930 Internet Protocols 7

Data structures neigh_tables arp_tbl neigh_table next family: AF_INET. . . constructor. . . gc_timer

Data structures neigh_tables arp_tbl neigh_table next family: AF_INET. . . constructor. . . gc_timer arp_constructor() neigh_periodic_timer() . . . hash_buckets[NEIGH. . ] 0 neighbour 1 hh_cache next ref_cnt hh_type: ETH_P_IP hh_output next neigh_table neigh_parms dev timer neigh_ops ha hh_cache nud_state output arp_queue. . . net_device neigh_timer_ handler() sk_buff hh_data: 00 80 23 32 12 49 72 16 08 64 14 49 78 21 21 23 90 Fall 2004 NEIGH_HASHMASK -1 neighbour FSU CIS 5930 Internet Protocols 8

neighbor • dev: – Pointer to corresponding network device • timer: – Pointer to

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 Fall 2004 FSU CIS 5930 Internet Protocols 9

neigh_table • family – Address family, for IP, it is AF_INET • constructor –

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 Fall 2004 FSU CIS 5930 Internet Protocols 10

neigh_ops • Different neighbor characteristics – Generic, direct, hh, and broken • This structure

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 Fall 2004 FSU CIS 5930 Internet Protocols 11

States No sign of life in reachable_time NUD_STALE Set timer Receive packet NUD_ REACHABLE

States No sign of life in reachable_time NUD_STALE Set timer Receive packet NUD_ REACHABLE receive ARP-Reply NUD_DELAY Time out Receive ARP-Reply NUD_ INCOMPLETE NUD_PROBE NUD_NONE max_probes Requests sent, No reply arp_constructor: initialize an entry, Send an ARP request Permanent Eintrag NUD_ FAILED NUD_NONE NOARPDevice NUD_NOARP neigh_create: Create an entry Garbage Collection completed. Delete entry No Emtru Fall 2004 FSU CIS 5930 Internet Protocols 12

ARP operation Higher Layers IPv 4 ip_queue_xmit ip_finish_output 2 arp. c, neighbour. c neigh_update

ARP operation Higher Layers IPv 4 ip_queue_xmit ip_finish_output 2 arp. c, neighbour. c neigh_update ARP-Reply arp_rcv dev. c ARP-Request arp_tbl neigh_lookup neigh_resolve_ output arp_send dev. c ETH_P_ARP net_rx_action Fall 2004 dev_queue_xmit FSU CIS 5930 Internet Protocols 13

Handling ARP PDUs • arp_rcv() – Some sanity check – NF_ARP_IN – arp_process() •

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 Fall 2004 FSU CIS 5930 Internet Protocols 14

Handling ARP packets • arp_send() – – – Allocating socket buffer Filling hardware header

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 Fall 2004 FSU CIS 5930 Internet Protocols 15

Handling unresolved IP packets • neigh_resolve_output() – Sending the packet if it is OK

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 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() Fall 2004 FSU CIS 5930 Internet Protocols 16

Some other neighbor managing functions • • • neigh_connect() neigh_suspect() neigh_destroy() neigh_sync() neigh_periodic_timer() neigh_timer_handler()

Some other neighbor managing functions • • • neigh_connect() neigh_suspect() neigh_destroy() neigh_sync() neigh_periodic_timer() neigh_timer_handler() Fall 2004 FSU CIS 5930 Internet Protocols 17