Address Resolution Protocol (ARP)

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

description

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. - PowerPoint PPT Presentation

Transcript of Address Resolution Protocol (ARP)

Page 1: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 1

Address Resolution Protocol (ARP)

Reading: Chapter 15

Page 2: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 2

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

Page 3: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 3

An example

Computer A:IP: 129.25.10.72MAC: 49:72:16:08:64:14

Computer B:IP: 129.25.10.97MAC: 49:72:16:08:80:70

Computer C:IP: 129.25.10.81MAC: 49:17:92:96:96:96

IP: 129.1.11.72MAC: 10:11:72:AB:02:01

IP: 129.25.10.11MAC: 49:78:21:21:23:90

Router R

MAC address of 129.25.10.11 ?Reply to: 49:72:16:08:64:14 (129.25.10.72)

MAC address of 129.25.10.11 ?Reply to: 49:72:16:08:64:14 (129.25.10.72)

ARP-Request to MAC FF:FF:FF:FF:FF:FF

Reply:t: 129.25.10.11 (49:78:21:21:23:90)Requested by:: 129.25.10.72 (49:72:16:08:64:14)

Reply:t: 129.25.10.11 (49:78:21:21:23:90)Requested by:: 129.25.10.72 (49:72:16:08:64:14)

ARP-Reply to MAC 49:72:16:08:64:14

1

2

Page 4: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 4

ARP packet format

0 15 31

ARP Protocol Data Unit

Hardware type (layer 2)Hardware type (layer 2) Protocol type (layer 3)Protocol type (layer 3)

Address lengthLayer 2 (n)

Address lengthLayer 2 (n)

Address lengthLayer 3 (m)

Address lengthLayer 3 (m) OperationOperation

Source address (layer 2): n bytesSource address (layer 2): n bytes

Source address (layer 3): m bytesSource address (layer 3): m bytes

Destiniation address (layer 2): n bytesDestiniation address (layer 2): n bytes

Destination address (layer 3): m bytesDestination address (layer 3): m bytes

Layer-2 headerLayer-2 header Layer-2 payloadLayer-2 payload Layer-3 trailerLayer-3 trailer

Page 5: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 5

ARP packet format: example

0 15 31

ARP-Request to FF:FF:FF:FF:FF:FF

0x00 01 (Ethernet)0x00 01 (Ethernet) 0x80 00 (Internet Protocol)0x80 00 (Internet Protocol)

66 44 0x00 01 (ARP-Request)0x00 01 (ARP-Request)

49 72 16 0849 72 16 08

64 1464 14 129 25129 25

10 7210 72 00 0000 00

00 00 00 0000 00 00 00

129 25 10 11 129 25 10 11

0 15 31

ARP-Reply to 49:72:16:08:64:14

0x00 01 (Ethernet)0x00 01 (Ethernet) 0x80 00 (Internet Protocol)0x80 00 (Internet Protocol)

66 44 0x00 02 (ARP-Reply)0x00 02 (ARP-Reply)

49 72 16 0849 72 16 08

64 1464 14 129 25129 25

10 7210 72 49 7849 78

21 21 23 9021 21 23 90

129 25 10 11 129 25 10 11

Page 6: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 6

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

Page 7: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 7

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

Page 8: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 8

Data structures

nextnext

family: AF_INETfamily: AF_INET

......

constructorconstructor

neigh_table

......

gc_timergc_timer

nextnext

neigh_tableneigh_table

neigh_parmsneigh_parms

devdev

neighbour

timertimer

neigh_opsneigh_ops

haha

arp_constructor()

neigh_tableneigh_table

0

arp_tblarp_tbl

neigh_tablesneigh_tablesneigh_tableneigh_table

......

hash_buckets[NEIGH..]hash_buckets[NEIGH..]

hh_cachehh_cache

nud_statenud_state

outputoutput

arp_queuearp_queue

......

neighbourneighbour neighbourneighbour

neigh_periodic_timer()

1

neighbourneighbourNEIGH_-HASHMASK -1

net_devicenet_device

neigh_timer_handler()

sk_buffsk_buffnextnext

ref_cntref_cnt

hh_type: ETH_P_IPhh_type: ETH_P_IP

hh_outputhh_output

hh_cache

hh_data:00 80 23 32 12

49 72 16 08 64 1449 78 21 21 23 90

hh_data:00 80 23 32 12

49 72 16 08 64 1449 78 21 21 23 90

Page 9: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 9

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

Page 10: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 10

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

Page 11: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 11

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

Page 12: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 12

States

NUD_NONENUD_NONE

NUD_NOARPNUD_NOARP

NUD_NONENUD_NONE

NoEmtruNo

Emtru

NUD_INCOMPLETE

NUD_INCOMPLETE

arp_constructor:initialize an entry,Send an ARP request

neigh_create: Create an entry

NUD_REACHABLE

NUD_REACHABLE

Receive ARP-Reply

PermanentEintrag

NOARP-Device

Receive packet

NUD_STALENUD_STALE

NUD_DELAYNUD_DELAY

NUD_PROBENUD_PROBE

NUD_FAILEDNUD_

FAILED

receive ARP-Reply

No sign of life in reachable_time Set timer

Timeout

max_probes Requests sent,No reply

Garbage Collection completed. Delete entry

Page 13: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 13

ARP operation

arp.c, neighbour.c arp.c, neighbour.c

IPv4IPv4

Higher LayersHigher Layers

dev.cdev.c

net_rx_action

IPv4IPv4

ip_finish_output2

arp.c, neighbour.c

dev.cdev.c

ip_queue_xmit

dev_queue_xmit

neigh_resolve_output

arp_rcv arp_send

neigh_lookup

arp_tblneigh_update

ETH_P_ARP

ARP-Reply

ARP-Request

Page 14: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 14

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

Page 15: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 15

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

Page 16: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 16

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()

Page 17: Address Resolution Protocol (ARP)

Fall 2004 FSU CIS 5930 Internet Protocols 17

Some other neighbor managing functions

• neigh_connect()• neigh_suspect()• neigh_destroy()• neigh_sync()• neigh_periodic_timer()• neigh_timer_handler()