A-S A:a -S:s B:b -S:s a.A:a -B:b, c.B:b -A,:a - b.A:a -B:b d.B:b -A:a Host A Host B Host A Host B Server S Internet Session A-S: Session B-S: A a -S:s B:b,-S:s 2 2 Session A-S: Session B-S: A,:a,-S:s A2:a2 NAT C B,:b,-S:s Session A-B: Session A-B: A. 1 :a ,-B2:b2 Internal A2:a2-B:b A,:a, network NAT A NAT B B,:b 1 Session A-S: Session B-S: A:a-S:s B:b-S:s Session A-B: Session A-B: A:a -B 2nd2 :b. A,:a,-B:b Host A Host B FIGURE 12.6 A NAT traversal scenario including multiple layers of NATs. © 2009 by Taylor & Francis Group, LLC NAT Traversal Relay B 1 :b 1 NAT A Internal network FIGURE 12.7 A scenario including relay node. The scenario depicted in Figure 12.7 is deployed to explain how relays work. To ensure connectivity, A and B communicate with server S, which will forward packets to the other party. In other words, relaying merges two client server communications into a peer-to-peer one. Relaying is commonly used only as a fallback solution when hole punching fails. 12.4.3 STUN: A Standardized Set of Functionalities to Support NAT Traversal Session Traversal Utilities for NAT (STUN) is a protocol that provides a set of functionalities used for NAT traversal. STUN is not a complete NAT traversal solution by itself, but must work in conjunction with other protocols. Originally defined in RFC 3489 [5] (now referred as "classic STUN" specifi- cation), STUN has been partially redefined by a set of subsequent Internet drafts [6]. Basically, STUN allows a host placed behind NATs to discover its external transport address. In addition, STUN provides a set of extended functionalities, including a keepalive mechanism in order to ensure connec- tivity for the whole duration of an end-to-end session by preventing NAT bindings from expiring. Several techniques described in the following make use of STUN messages. They are generally referred as "STUN usages." Figure 12.8 shows a typical STUN usage scenario with the two main STUN enitities: the STUN client and the STUN server. The STUN entities com- municate by means of STUN