With several different addresses assigned to one interface, there is a problem what address does a host use for communication? For this purpose, the algorithm for selection of addresses was defined. RFC 3484 describes this algorithm.
The candidate addresses are the fundamental block of Address Selection algorithm. The list of candidate addresses for destination addresses is usually obtained through a DNS query (translation of the domain name to IPv6 address). The list is sorted from the most suitable to the least suitable address from which the most suitable address is selected. In the case that the application has a destination IPv6 address, there is no choice of destination address.
It is necessary to select the most suitable source address to candidate destination address. The list of candidate source addresses contains all global unicast addresses that are assigned to interface through which data will be sent to a target node. It means that each destination address may have different lists of candidate source addresses. In the case of routers, the list of candidate source addresses may contain global unicast addresses of other interfaces on which data is forwarded.
The most suitable source/destination address is selected from the list of candidate source/destination addresses based on rules that are mentioned in the subsection Source Address Selection.
In the case that the communication fails, the address selection can be repeated.
The policy table is used to determine local precedence of address. Individual entries contain Prefix, Precedence and Label, where Precedence is used for sorting destination addresses and Label determines whether the selected pair of addresses fits together. In the case of identical labels both addresses, the pair of addresses is preferred. Precedence and Label are determined by the longest matching prefix.
If the administrator does not configure the policy table, the default policy table is used.
Prefix |
Precedence |
Label |
::1/128 |
50 |
0 |
::/0 |
40 |
1 |
2002::/16 |
30 |
2 |
::/96 |
20 |
3 |
::FFFF:0:0/96 |
10 |
4 |
The Address Selection algorithm has two sets of rules. The first set describes source address selection. The Source Address Selection algorithm produces as output a single source address for use with a given destination address. The algorithm is demonstrated through an example, when there are two source addresses SA and SB for target node. The rules are applied gradually and when the decision is done, the others are ignored. If the decision is not done, implementations should provide a source address selection. The order of rules is:
The algorithm is a symmetric, so each rule is performed once more with swapped roles of source addresses. The most suitable source address for target node is determined by applying the rules.
The suitability of source and destination addresses, among other things, is considered when the destination address selection is done. Therefore, the most suitable source address is determined for each destination address. Then there is the arrangement of destination addresses in the candidate list according to the following rules:
The computer has one network interface to which the following addresses were assigned:
The computer has to send data to the address 2001:718:20:56:E859:A1FF:FE82:AA01 and needs to select the most suitable source address. The default policy table is used during the address selection. The precedence value of 40 and label value of 1 are assigned to all addresses.
Link-Local address is not selected because of rule 2. Its scope is smaller than the global scope of the target node. The most suitable source address is selected using rule 8. The second address is selected as source address because it has the same longest matching prefix 2001:718::/32 as the target node.
Destination address selection is based on the candidate list which the DNS server sent in response to a request for translating a domain name. Candidate list contains the following addresses:
The list also contains a suitable source addresses that are selected based on the source address selection algorithm. The precedence value of 40 and label value of 1 are assigned to both addresses. The algorithm decides on the basis of rule 8 when the second address has the same longest matching prefix 2001:718::/32 as the target node. The candidate list for the destination address is sorted as follows:
Then address 2001:718:10:1:02B5:32FF:FE01:1984 is selected as the source address and address 2001:718::B5:18FF:FE09:1 is selected as the destination address for the connection.