Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
understanding-SIP.pdf
Скачиваний:
118
Добавлен:
01.03.2016
Размер:
4 Мб
Скачать
☆

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Network Address Translation

239

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 10.1 NAT example.

NAT, however, creates a new mapping between the source inside private address 10.0.0.1 port 42723 and the outside public address 172.34.5.1 port 34123 and rewrites the IP and transport layers with this information. When the SIP response comes back, the NAT uses the mapping created to rewrite the IP and transport layers with this information. As a result, the SIP server thinks the SIP client it is communicating with it at the address 172.34.5.1:34123 while the SIP client thinks it is using the address 10.0.0.1:42723. Since we have seen how SIP imbeds IP addresses and ports into SIP and SDP messages, clearly this will be problematic.

10.5 Types of NAT

NAT can be characterized by the type of address and port mapping they do, as well as the type of filtering they employ. To see the different types of NAT, we will use the notation shown in Figure 10.2 from RFC 4787 [6]. This figure shows a host X behind a NAT communicating with two different hosts, host 1 and host 2. Packets sent by X have a source address and port of X:x and a destination address and port of Y:y. The NAT has a number of IP addresses to use for mapping, and they are shown as X1, X2, ... (some NATs only have a single IP address to use for mapping such as a home NAT). Packets sent from device X to host 1 are sent by X to Y1:y1 from X;x. As received by Y1, the packets appear

240

 

 

SIP: Understanding the Session Initiation Protocol

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 10.2 NAT mapping classifications.

to have been received from X1’:x1’. Packets sent by X to Y2 from the same source port x are received by Y2 and appear to have been received from X2’:x2’. That the packets sent to Y2 are sent from the same IP address and port as Y2 is essential for this classification method. The resulting relationship between X1’:x1’ and X2’:x2’ determines the type of NAT mapping.

Note that NAT classification is not precise, and many NATs change behavior over time and under differing conditions. As a result, trying to predict future NAT behavior based on past behavior is problematic. However, a good understanding of NAT behavior is still essential to understanding how to make SIP and Internet communications traverse NAT.

10.5.1 Endpoint Independent Mapping NAT

Endpoint independent mapping (EIM) NAT is where X1’:x1’ = X2’:x2’ for all Y;y (Y1:y1 and Y2:y2 as shown in Figure 10.2). That is, the mapping used is dependent only on the source address and port (X;x), independent of the destination address and port. This type of mapping is known as endpoint independent mapping (EIM). It is important to note that x1’ does not equal x1, which means that a NAPT can be an endpoint independent NAT. This type of NAT is best for SIP and RTP traversal as we shall see in the next sections.

10.5.2 Address Dependent Mapping NAT

An address dependent mapping (ADM) NAT is where X1’:x1’ = X2’:x2’ if and only if Y2 = Y1 in Figure 10.2. That is, the mapping is dependent on the destina-

Network Address Translation

241

tion IP address of the packet as well as the source address and port. As a result, packets sent by X to different hosts will appear to come from different IP addresses and/or port numbers. This type of NAT is bad for SIP and RTP traversal as we shall see in the following sections.

10.5.3 Address and Port Dependent Mapping NAT

An address and port dependent mapping (ADPM) NAT is where X1’:x1’ = X2’:x2’ if and only if Y2:y2 = Y1:y1 as shown in Figure 10.2. That is, the mapping is dependent on both the destination address and port as well as the source address and port. As a result, packets sent by X to different ports on the same host will appear to come from different IP addresses and/or port numbers. This type of NAT is the most problematic for SIP and RTP traversal.

10.5.4 Hairpinning Support

Hairpinning is shown in Figure 10.3. Any NAT will allow hosts on the inside of the NAT (sometimes described as behind the same NAT) to use the private address of the other host—these packets can be routed by the NAT without any modification. A NAT supports hairpinning if an internal host can send packets to another internal host using the external address of the other host. Packets routed this way double back on the NAT giving a shape similar to a hairpin. To route these packets, the NAT must lookup two mappings to determine the destination. In the example, X has a mapping X:x to X1’:x1’ while Z has a mapping Z;z to X2’:x2’. Hairpinning is supported by the NAT if Z receives a packet sent by X from X;x to X2’:x2’ and vice versa. Support of hairpinning is very beneficial to SIP and RTP traversal. Note that this property is also sometimes called tromboning after the shape of the slide of the instrument.

Figure 10.3 Hairpinning support in NAT.

242

SIP: Understanding the Session Initiation Protocol

10.5.5 IP Address Pooling Options

NATs that have a number of external or public IP addresses available for mapping have options in the way they allocate from this pool of IP addresses. Having multiple IP addresses is common in large service provider or enterprise NATs and is uncommon in small residential NATs. One pooling policy is known as paired IP address pooling. This policy means that only one external IP address is used for an internal IP address. As a result, all packets sent by this host will appear to come from the same IP address to hosts external to the NAT. This property is very good for SIP and RTP traversal. Another policy is known as arbitrary IP address pooling, which means there could be multiple external IP addresses mapped to an internal IP address. This property is very bad for SIP and RTP transport.

10.5.6 Port Assignment Options

While only NATs that have multiple external IP addresses have address pooling options, every NAT has port assignment options. There are a number of behaviors that are part of implemented NATs. Port preservation means the NAT tries to keep the external port the same as the internal source port. This port assignment approach generally only works if the NAT has a large pool of IP addresses. Otherwise, only one inside host can use a particular port. If a NAT implementing port preservation runs out of a particular port to allocate, it can use one of two strategies. One is to switch to a nonport preservation mode. The other is to do port overloading in which the same port can be used more than once on the inside and outside. Port overloading is very bad for the SIP and RTP transport because it leads to nondeterministic behavior. Another port assignment option is port parity, which preserves the oddness or evenness of ports. This is useful for media transport where the RTP media must be an even port while the RTCP control must use an odd port number. Port contiguity is when the NAT attempts to keep sequential inside ports mapped to sequential outside ports. This can help when an RTCP port is inferred to be one higher than the RTP port. For SIP and RTP traversal, the most important property is that the port assignment mode does not change. Since port preservation always runs the risk of having to switch modes or do port overloading, it is not recommended. Switching port mapping modes makes troubleshooting difficult.

10.5.7 Mapping Refresh

Each time a NAT creates a mapping it uses up memory resources in storing the information. It also uses up addressing resources since the external mapped IP address and port cannot be reused for another endpoint. As a result, a NAT must

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]