TCP/IP Illustrated Episode 29

Host Models

Although it may appear to be a straightforward decision to determine whether a received unicast datagram matches one of a host’s IP addresses and should be processed, this decision depends on the host model of the receiving system [RFC1122] and is most relevant for multihomed hosts. There are two host models, the strong host model and the weak host model. In the strong host model, a datagram is accepted for delivery to the local protocol stack only if the IP address contained in the Destination IP Address field matches one of those configured on the interface upon which the datagram arrived. In systems implementing the weak host model, the opposite is true—a datagram carrying a destination address matching any of the local addresses may arrive on any interface and is processed by the receiving protocol stack, irrespective of the network interface upon which it arrived. Host models also apply to sending behavior. That is, a host using the strong host model sends datagrams from a particular interface only if one of the interface’s configured addresses matches the Source IP Address field in the datagram being sent.

Address Selection

When a host sends an IP datagram, it must decide which of its IP addresses to place in the Source IP Address field of the outgoing datagram, and which destination address to use for a particular destination host if multiple addresses for it are known. In some cases the source address is already known because it is provided by an application or because the packet is being sent in response to a previously received packet on the same connection (see, for example, Chapter 13 for how addresses are managed with TCP).

In modern IP implementations, the IP addresses used in the Source IP Address and Destination IP Address fields of the datagram are selected using a set of procedures called source address selection and destination address selection. Historically, most Internet hosts had only one IP address for external communication, so selecting the addresses was not terribly difficult. With the advent of multiple addresses per interface and the use of IPv6 in which simultaneous use of addresses with multiple scopes is normal, some procedure must be used. The situation is further complicated when communication is to take place between two hosts that implement both IPv4 and IPv6 (“dual-stack” hosts; see [RFC4213]). Failure to select the correct addresses can lead to asymmetric routing, unwanted filtering, or discarding of packets. Fixing such problems can be a challenge.

The Source Address Selection Algorithm

The source address selection algorithm defines a candidate set CS(D) of potential source addresses based on a particular destination address D. There is a restriction that anycast, multicast, and the unspecified address are never in CS(D) for any D. We shall use the notation R(A) to indicate the rank of address A in the set CS(D). A higher rank (i.e., greater value of R(A)) for A versus B in CS(D), denoted R(A) > R(B), means that A is preferred to B for use as a source address for reaching the machine with address D. The notation R(A) *> R(B) means to assign A a higher rank than B in CS(D). The notation I(D) indicates the interface selected (i.e., by the forwarding longest matching prefix algorithm described previously) to reach destination D. The notation @(i) is the set of addresses assigned to interface i. The notation T(A) is the Boolean true if A is a temporary address (see Chapter 6) and false otherwise.

The following rules are applied to establish a partial ordering between addresses A and B in CS(D) for destination D:

1.Prefer same address: if A = D, R(A) *> R(B); if B = D, R(B) *> R(A).
2.Prefer appropriate scope: if S(A) < S(B) and S(A) < S(D), R(B) *> R(A) else R(A) *> R(B); if S(B) < S(A) and S(B) < S(D), R(A) *> R(B) else R(B) *> R(A).
3.Avoid deprecated addresses: if S(A) = S(B), { if Λ(A) < Λ(B), R(B) *> R(A) else R(A) *> R(B) }.
4.Prefer home address: if H(A) and C(A) and ¬(C(B) and H(B)), R(A) *> R(B); if H(B) and C(B) and ¬(C(A) and H(A)), R(B) *> R(A); if (H(A) and ¬C(A)) and (¬H(B) and C(B)), R(A) *> R(B); if (H(B) and ¬C(B)) and (¬H(A) and C(A)), R(B) *> R(A).
5.Prefer outgoing interface: if A ∈ @(I(D)) and B ∈ @(I(D)), R(A) *> R(B); if B ∈@(I(D)) and A ∈ @(I(D)), R(B) *> R(A).
6.Prefer matching label: if L(A) = L(D) and L(B) ≠ L(D), R(A) *> R(B); if L(B) = L(D) and L(A) ≠ L(D), R(B) *> R(A).
7.Prefer nontemporary addresses: if T(B) and ¬T(A), R(A) *> R(B); if T(A) and ¬T(B), R(B) *> R(A).
8.Use longest matching prefix: if CPL(A,D) > CPL(B,D), R(A) *> R(B); if CPL(B,D) > CPL(A,D), R(B) *> R(A).

The Destination Address Selection Algorithm

We now turn to the problem of default destination address selection. It is specified in a way similar to source address selection. Recall that Q(D) is the source address Boolean true if destination B is not reachable and E(A) indicate that destination A is reached using some “encapsulating transport” (e.g., tunneled routing). Using the same structure as before on pairwise elements A and B of the set SD(S), we have the following rules:

1.Avoid unusable destinations: if U(B) or Q(B) = Ø, R(A) *> R(B); if U(A) or Q(A) = Ø, R(B) *> R(A).
2.Prefer matching scope: if S(A) = S(Q(A)) and S(B) ≠ S(Q(B)), R(A) > R(B); if S(B) = S(Q(B)) and S(A) ≠ S(Q(A)), R(B)>R(A).
3.Avoid deprecated addresses: if Λ (Q(A)) < Λ (Q(B)), R(B) *> R(A); if Λ (Q(B)) < Λ (Q(A)), R(A) *> R(B).
4.Prefer home address: if H(Q(A)) and C(Q(A)) and ¬(C(Q(B)) and H(Q(B))), R(A) *> R(B); if (Q(B)) and C(Q(B)) and ¬(C(Q(A)) and H(Q(A))), R(B) *> R(A); if (H(Q(A)) and ¬C(Q(A))) and (¬H(Q(B)) and C(Q(B))), R(A) *> R(B); if (H(Q(B)) and ¬C(Q(B))) and (¬H(Q(A)) and C(Q(A))), R(B) *> R(A).
5.Prefer matching label: if L(Q(A)) = L(A) and L(Q(B)) ≠ L(B), R(A) *> R(B); if L(Q(A)) ≠ L(A) and L(Q(B)) = L(B), R(B) *> R(A).
6.Prefer higher precedence: if P(A) > P(B), R(A) *> R(B); if P(A) < P(B), R(B) *> R(A).
7.Prefer native transport: if E(A) and ¬E(B), R(B) *> R(A); if E(B) and ¬E(A), R(A) *> R(B).
8.Prefer smaller scope: if S(A) < S(B), R(A) *> R(B) else R(B) *> R(A).
9.Use longest matching prefix: if CPL(A, Q(A)) > CPL(B, Q(B)), R(A) *> R(B); if CPL(A, Q(A)) < CPL (B, Q(B)), R(B) *> R(A).
10.Otherwise, leave rank order unchanged.

  • 23
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值