1

My understanding is that with APIPA, clients can automatically self-configure an IP address and subnet mask when a DHCP server isn't available. I understand that this approach isn't really practical for a number of reasons but I'm curious: Is there anything built into the protocol to check if a given IP address is in use else?

For example, let's say my host chooses to use 169.254.0.2. What if another host in the broadcast domain already has that address? Would my host even check prior to completing self-allocation?

5

It is almost impossible for two devices to choose the same IP for themselves.

Each device picks up an address and then tests to see if it is already in use, by broadcasting ARP Probe packets. All conflict cases are well covered, such as repeating requests when no answers arrive, ARP request for the same IP by another device, and others.

Finally the device announces itself to the network via ARP with its chosen IP, guaranteed by the algorithm to be unique (or almost guaranteed).

For details, see RFC 5227 that contains the standard that all ad-hoc networks must follow.

Link-local address is a variant of this algorithm, first implemented in MacOS 9 in 1998, where each device picks a random address as its first try. The standard here is RFC 3927.

  • 1
    I wouldn't use the word "impossible", for two reasons: bad implementations could mess up the detection and think an address is free when it is not, or two hosts choose the same address on different network segments (say, two separate network switches, for example), then those segments get connected (someone connects a cable between the two switches). That said, it is extremely unlikely. – Moshe Katz Nov 25 '20 at 21:49
  • @MosheKatz: That's why I said "almost guaranteed". This algorithm was designed for small networks with perfect LAN connections, where it works very well. – harrymc Nov 26 '20 at 7:11
  • now it says "almost impossible" to match that. – Moshe Katz Nov 26 '20 at 15:12
3

The protocol is defined in RFC 3927, with section 2 being dedicated to address selection. In subsection 2.2 you will find:

2.2. Claiming a Link-Local Address

After it has selected an IPv4 Link-Local address, a host MUST test to see if the IPv4 Link-Local address is already in use before beginning to use it. [...]

2.2.1. Probe details

On a link-layer such as IEEE 802 that supports ARP, conflict detection is done using ARP probes. [...]

A host probes to see if an address is already in use by broadcasting an ARP Request for the desired address. The client MUST fill in the 'sender hardware address' field of the ARP Request with the hardware address of the interface through which it is sending the packet. The 'sender IP address' field MUST be set to all zeroes, to avoid polluting ARP caches in other hosts on the same link in the case where the address turns out to be already in use by another host. The 'target hardware address' field is ignored and SHOULD be set to all zeroes. The 'target IP address' field MUST be set to the address being probed. An ARP Request constructed this way with an all-zero 'sender IP address' is referred to as an "ARP Probe". [..]

[...] the host should send PROBE_NUM probe packets, each of these probe packets spaced randomly, PROBE_MIN to PROBE_MAX seconds apart. If during this period, from the beginning of the probing process until ANNOUNCE_WAIT seconds after the last probe packet is sent, the host receives any ARP packet (Request or Reply) on the interface where the probe is being performed where the packet's 'sender IP address' is the address being probed for, then the host MUST treat this address as being in use by some other host, and MUST select a new pseudo-random address and repeat the process. [...]

If, by ANNOUNCE_WAIT seconds after the transmission of the last ARP Probe no conflicting ARP Reply or ARP Probe has been received, then the host has successfully claimed the desired IPv4 Link-Local address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.