The Neighbor Discovery protocol
The Neighbor Discovery protocol [RFC2461] is used to
manage the interactions between different nodes by exchanging messages. These messages
make it possible for hosts to communicate with each other and implement autoconfiguration.
The procedures involved in autoconfiguration are as follows:
1. Parameter Discovery, used to discover particular parameters and/or options
concerning the links, including prefixes.
2. Address Configuration, used for automatic configuration of an interface's addresses.
3. Duplicate Address Detection: an algorithm used to check that an address to be assigned
is not already in use.
For communication purposes, the stations need several types of information in addition
to the destination's link-layer address. This information can be obtained through the
following procedures:
1. Router Discovery, the process by which a host locates the routers
residing on its link (i.e., the on-link routers).
2. Prefix Discovery: the process by which a host discovers the set of on-link prefixes,
or in other words the prefixes that can be reached directly at the data link layer.
3. Address Resolution: the process by which an IP address is resolved to its data
link-layer address.
4. Next-hop Determination: the algorithm used to determine the IP address of the
neighbor which must forward packets to the final destination. The next-hop can be a router or
the destination itself.
5. Neighbor Unreachability Detection: used to check whether a neighbor can be reached.
6. Redirect: : the process whereby a router informs a host of a better first-hop node
to reach a particular destination.
There are five different messages for this protocol:
- Router Solicitation;
- Router Advertisement;
- Neighbor Solicitation;
- Neighbor Advertisement;
- Redirect.
Host autoconfiguration
An interface can be configured manually by the network administrator, or configuration
can be performed automatically. This latter possibility has become extremely important
in IPv6 because of address length and the need to renumber sites more frequently.
In IPv6, each address is associated with a period of validity so that network topology
can be changed automatically. To reduce the impact of renumbering on applications, two
timers are used for each address. Initially, an address is classified as preferred, meaning
that it can be used without restrictions as either a source or destination address. Once the
preferred lifetime expires, the address goes to the deprecated state, i.e., the address is
still valid but its use is discouraged for new communication. When the second timer, called
the valid lifetime, expires, the address becomes invalid and can no longer be used. In this
way, it is extremely likely that the applications which use an address that has gone to the
deprecated state will end before the address becomes invalid.
Autoconfiguration mechanisms can be stateless or stateful. In both cases,
the same basic steps must be carried out in order to configure a station. These
steps are shown schematically in Figure 29.

Figure 29- Host autoconfiguration.
The first step is to create the link-local address and check that it is unique (using DAD).
The link-local address is generated by concatenating the prefix FE80 which identifies this
type of address with an identifier which is unique on the link (the MAC address, for example)
and is connected to the interface to be configured. If the result provided by this operation
is an address that has already been assigned to another interface on the same link, the
administrator must either perform manual configuration, or restart the automatic configuration
process. Once the link-local address has been generated, a verification procedure starts to
check that routers are present on the link. If routers are present, they respond with
Router Advertisement messages (see Figure 35), in which the flags M
(Managed Address Configuration) and O (Other Configuration)
specify the type of autoconfiguration to be used.
The following combinations are possible:
| M |
O |
Configuration type |
| 0 |
x |
stateless |
| 1 |
1 |
stateless,
but the DHCP server must be contacted for other parameters |
| 1 |
0 |
stateful |
The stateless and stateful autoconfiguration mechanisms concern only the hosts, and can be
used at the same time. Once a station has obtained an address in one of the ways described
above, it must check that the address is unique using the DAD mechanism before assigning it
to an interface.
Stateless Autoconfiguration
Stateless autoconfiguration [RFC2462] takes place automatically
as soon as the interface is enabled and follows link-local address generation
as described in the preceding paragraph. The station starts the autoconfiguration
process by registering in the multicast group FF02::1 which identifies all of the
nodes in the same link so that it can receive messages originating from the routers
using this destination address. The station then sends a Router Solicitation message
(see Figure 34) whose destination address field is set to the all-routers multicast
address FF02::2. In this message, the station can specify only the source link-layer
address option shown in Figure 36, which contains the physical address of the sending host.
The routers respond with a Router Advertisement in which the destination address
is determined from the station's link-layer address and the source address is the associated
link-local address. In addition, one or more prefix options can be specified. This option
(see Figure 30) makes it possible to define a prefix (coded as a 128-bit address) whose
length is written in prefix length and whose period of validity is, to use the terminology
discussed earlier, is in Valid and preferred lifetime. If flag A
(Autonomous configuration)
is set to 1, the host can use the stateless configuration protocol to build the address by
concatenating the address supplied to it by the prefix option with the interface ID.
This only applies if the prefix is not too long, and otherwise will be ignored.
Flag L indicates whether the prefix concerned is to be considered as directly reachable,
i.e., on-link.

Figure 30 - Prefix option format.
An example of what we have just described is shown in Figure 31.

Figure 31 - Stateless Autoconfiguration.
Duplicate Address Detection (DAD)
After a station has obtained a unicast address in one of the ways described above,
it must check that it is unique before assigning it to the interface. To do so, the
station sends a Neighbor Solicitation message (Figure 32) in which the source address
field is set to the unspecified address and the destination address field is set to
the solicited-node multicast address. The latter is a special type of multicast address
obtained by concatenating the 96-bit prefix FE02:0:0:0:0::1 and the last 32 bits of
the interface's IPv6 address. If the same unicast address has already been assigned
to another node, the latter will respond with a Neighbor Advertisement (Figure 33).
When the node that initiated the DAD procedure receives this message, it disables
the use of the address that has just been obtained.
Address Resolution
This mechanism consists of sending a Neighbor Solicitation message (Figure 32)
whose destination is given by the solicited-node multicast address described above.
The packet's target address field contains the addresses of the neighbors to be solicited.
The host will respond with a Neighbor Advertisement, indicating its IPv6 address in the
target address field and its physical address in the target link-layer address option
(this option has the same format as the source link shown in Figure 36).
When a Neighbor Advertisement (Figure 33) is received in response, the link-layer address
is stored in a special table called the neighbor cache.

Figure 32 - Neighbor Solicitation message.

Figure 33 - Neighbor Advertisement message.
IPv6 communication algorithm
Each node manages four tables which it consults when it has to send a packet.
These tables are as follows:
- destination cache, Maps the destination IPv6 address to the corresponding
address of the next-hop neighbor
- neighbor cache, Maps IPv6 addresses to the corresponding neighbor's link-layer
address.
- prefix list, Contains the list of on-link prefixes obtained by
Router Advertisement messages.
- router list, Lists the IPv6 addresses of routers that have recently sent Router
Advertisement messages.
All of the entries in these tables are timed, or in other words are removed when the associated
timers expire. Updating is guaranteed by the Neighbor Discovery messages.
When a node has to transmit a packet, the first thing it must do is find the next hop
for the destination concerned. The next hop is a node directly connected to the link
with which the source is associated. In many cases the source will have sent a packet
to the destination in question on an earlier occasion, so that the next-hop address will
already be stored in the destination cache; consequently, the source consults this cache
first. If it does not contain the IPv6 address of the next hop, the next-hop determination
procedure must be used.
This procedure operates as follows. The node which must transmit the packet performs a
longest prefix match 2 against the prefix list to determine whether the node is on-link.
If the destination is on-link, it is also the next hop. Otherwise, the sender selects a
router from the router list and uses it as the next hop for the destination concerned. It
stores this router's IP address in the destination cache so that it can be used again for
the subsequent packets.
The station does not use a special criterion of any kind in selecting the next-hop router.
Consequently, the selected router may not always represent the best route to the destination.
In such cases, the router sends a special message called a redirect message to inform
the source that there is a better next-hop to the destination.
At this point, the neighbor's IPv6 address is known, but its link-layer address must still
be determined in order to send the packet. The link-layer address is stored in the neighbor
cache. If the address is not present in the cache, it can be found by means of the Address
Resolution procedure.
Once the next-hop link-layer address is known, the source can send the packet.
Information about the routers present on the link or about the prefixes which a host
can reach directly without passing through a router (i.e., on-link prefixes) is obtained
by exchanging the Router Solicitation and Advertisement messages whose format is shown
in Figures 34 and 35.

Figure 34 - Router Solicitation message.

Figure 35 - Router Advertisement message.
Routers periodically sent multicast Router Advertisement messages to all nodes on the
network to announce their availability to forward packets and specify several options,
including:
- source link-layer address, which contains the physical address of the sending
interface (Figure 36).
- MTU, sent on links that have a variable MTU.
- prefix information, whose format is shown in Figure 30.

Figure 36 - Source link layer address option.
By receiving Router Advertisement messages from all routers, a station cam keep the
prefix and router lists up to date. In particular, it discovers which prefixes are
on-link from the value of the L bit in prefix option. When this information is not
available because of a fault situation or because the station is being initialized,
the station can send a multicast Router Solicitation message to all routers to prompt them
to return a Router Advertisement before the timeout.
The redirect message, whose format is shown in Figure 37, is sent
by a router to a host to inform the latter that there is a better next-hop for
the destination whose address is shown in the Destination Address field. If the
content of this field is equal to that of the Target Address field, then the next-hop
is the destination itself. As an option, the target link layer address can be added.
This option contains the physical address of the new next-hop so that the host does not
need to resolve the address before forwarding the packet.

Figure 37 - Redirect message.

Figure 38 - Packet transmission algorithm
The Neighbor Unreachability Detection procedure is accomplished by analyzing the replies
that a node can receive from higher level applications after sending a packet (e.g. TCP
acknowledgement messages). If there are no replies (e.g., UDP), the entries in the neighbor
cache are subject to timeout, and a Neighbor Solicitation message is sent when they expire.
If the destination responds, the corresponding entry is retained; if not, it is deleted from
the cache. In general, this procedure is invoked to verify the validity of information which
has been labeled as stale (see Figure 38), meaning that it has been present in the table
for a long time, though it has not yet expired. One of the important items of information
obtained from this mechanism is the indication that a router has changed to a host. When
this occurs, the R flag in the Neighbor Advertisement is set to zero (rather than 1 to
indicate a router).
4 Comparison with IPv4
From the foregoing discussion, it should be clear that the Neighbor Discovery
protocol corresponds to a combination of the IPv4 protocols ARP, ICMPv4 Router
Discovery and ICMP Redirect. Neighbor Discovery provides a multitude of improvements
over the IPv4 set of protocols:
- Router Discovery is part of the base protocol set.
- Router Advertisement carry link-layer addresses;
no additional packet exchange is needed to resolve the router's link-layer address.
- Router Advertisement carry on-link prefixes; there is no need to have
a separate mechanism to configure the netmask.
- Router Advertisement enable address autoconfiguration.
- Routers can advertise an MTU for hosts to use on the link, ensuring that all nodes
use the same MTU value on links lacking a well-defined MTU.
- Address resolution messages are multicast rather than broadcast, greatly reducing
address resolution-related interrupts on nodes other than the target.
- Redirects contain the link-layer address of the new first hop; separate address
resolution is not necessary upon receiving a redirect.
- Multiple prefixes can be associated with the same link. By default, hosts
learn all on-link prefixes from Router Advertisement. Unknown
destination prefixes are assumed from hosts to be off-link; in this case
hosts send traffic to routers and a router can then issue redirects as appropriate.
- Unlike IPv4, the recipient of an IPv6 Redirect assumes that the new next-hop
is on-link. In IPv4, a host ignores redirects specifying a next-hop that is not
on-link according to the link's netmask. The IPv6 redirect mechanism is expected to
be useful on NBMA (Non Broadcast Multiple Access) networks in which it is undesirable
or not possible for nodes to know all prefixes for on-link destinations.
- The use of link-local addresses to uniquely identify routers makes it possible for
hosts to maintain the router associations in the event of site renumbering to use new
global prefixes.
- Address resolution is accomplished by ICMPv6, which means that it is no longer
necessary to have a protocol which differs according to the network technology underlying
IP, as with IPv4. Another basic difference between the IPv6 resolution protocol and ARP
lies in the fact that the resolution is multicast rather than broadcast. This is an
optimization: as the resolution request involves only a group of stations rather than
all of them, only the IP layer of each host in the group must decide whether the request
applies to that station.
- In IPv4, the logical boundaries between networks are binding, and are determined
by the IP network prefix and the netmask. In IPv6, on the other hand, the concept of
the logical subnet loses its importance, and the concept of the link becomes central.
In IPv4, different IP subnets can communicate only through routers, even if they are
part of the same physical network. In IPv6, the logical division into IP subnets does
not count: IP subnets which are part of the same link can communicate directly. Figure
39 shows an example in which the link consists of an Ethernet network. This change in
the communication model should promote convergence between IPv6 and network technologies
such as ATM: a network can continue to be administratively divided into multiple subnets
without preventing direct communication between the terminals connected to it.

Figure 39 - The communication model in IPv4 and IPv6.
[*] Longest prefix match is the
process of determining which prefix covers a given IPv6 address. When multiple prefixes
cover an address, the longest prefix is the one that matches.
|