Home |
Sockets, IP, and Port Addresses Blocking and Non-Blocking Sockets ARP |
ARPEvery Ethernet interface has a 6 byte Ethernet address which is used by the Ethernet hardware to determine if packets are destined for it. At the IP layer, each interface also has a 4 byte IP address. The IP address is passed to the API layer to specify remote (and local) addresses. When a packet is sent, both the Ethernet and IP address fields need to be set up. In order to determine the Ethernet address based on the IP address, an ARP message is broadcast on the local network. The remote machine that has a local IP address which matches the one in the request sends back an ARP reply which contains its Ethernet address. The originator of the ARP request extracts the Ethernet address and uses it to fill in the Ethernet field of the message. When an IP address is resolved, the IP and Ethernet addresses are saved in the ARP cache, so the address does not have to be resolved every time a packet is sent to the IP address. The entries in the ARP cache are deleted every 10 minutes or under application control through function xn_arp_del. The ARP cache can be queried with function xn_arp_cache_lookup and updated with xn_arp_remote. A Gratuitous ARP may be sent on power up (see function xn_arp_send). A host sends an ARP request with its source and target protocol address, both set to its own IP address and its target hardware address set to its Ethernet address so that all other machines on the network will update their cache with this latest Ethernet address if they contain an entry for that IP address. One reason for using a gratuitous ARP is to keep the ARP cache information on all machines up to date when another machine must have its Ethernet hardware replaced.
|