between the local address and the global address SO that incoming pack- ets can have the UDP and IP headers rewritten and routed correctly. However, IP addresses in a SIP message, such as Via and Contact header fields, or IP addresses in SDP message bodies will not be rewritten and will not be routable. To partially solve the message routing problem, SIP has a mechanism for detecting if a NAT is present in a SIP message path. Each proxy or user agent that receives a request checks the received IP address with the address in the Via header field. If the addresses are different, there is a NAT between them. The unroutable Via header field is fixed with a received tag containing the actual global IP address. Outside the NAT, the response is routed using the received IP address. Inside the NAT, the Via address is used. This does solve the message response routing problem (except when the port number is also wrong), but not the media problems. Another problem with NATs is the time span of the NAT address bind- ing. For a TCP connection, this is not an issue-the binding is maintained as long as the connection is open. For a UDP SIP session, the time period is deter- mined by the application. If a binding were removed before a BYE was sent ter- minating the session, the connection would effectively be closed and future signaling impossible. A keep-alive mechanism may be needed to refresh this binding. A SIP ALG coresident with the NAT solves many of these problems. The ALG would rewrite the media IP addresses in the SIP messages and would not allow the NAT to remove the address binding until a BYE was sent or a session timer had expired. However, NATs are often deployed deep inside a service pro- vider's network that is not associated with providing SIP service, and hence has no incentive to upgrading the NATs to allow this service to work. Even without ALGs or upgrades in NATs, it is possible to use SIP to estab- lish a media session through many types of NATs. The protocols described in the next section allow a SIP cl