19
STUN - Simple Trave rsal of User Datagr am Protocol (UDP) T hrough Network Addr ess Translators (NA Ts) speaker Wen ping Zhang date 2007.1 1.21

STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

Embed Size (px)

Citation preview

Page 1: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker:Wenping Zhang date: 2007.11.21

Page 2: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

2

Outline

Introduction Types of NAT VoIP Protocol and NAT NAT Solutions Overview of Operation Message Header Message Attributes Reference

Page 3: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

3

Introduction A mechanism for a socket behind NAT(s) to get its mapped (IP,p

ort) on Internet.

Check whether UA is behind NAT. If not true, the STUN mechanism is not applied.

When new socket is created, use this socket to request its mapped (IP,port) from STUN server. The response IP is stored in a string buffer. The response port is saved in a table, using source port as key.

When UA wants to stuff local IP or port in a message, it will first look up mapped IP or port in the table.

Page 4: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

4

Types of NAT

Full Cone Restricted Cone Port Restricted Cone Symmetric

Page 5: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

5

Full Cone

Page 6: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

6

Restricted Cone

Page 7: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

7

Port Restricted Cone

Page 8: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

8

Symmetric

Page 9: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

9

VoIP Protocol and NAT

NAT convert IP addresses on IP layer

Problem 1: SIP, H.323, Megaco and MGCP are application layer proto

col but contain IP address/port info in messages, which is not translated by NAT

Problem 2: Private client must send a outgoing packet first (to create a

mapping on NAT) to receive incoming packet

Page 10: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

10

NAT Solutions

Page 11: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

11

Page 12: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

12

Page 13: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

13

Overview of Operation 1/2

STUN is a simple client-server protocol. A client sends a request to a server, and the server r

eturns a response. There are two types of requests

Binding Requests Shared Secret Requests

The client sends a Binding Request to the server, over UDP. The server examines the source IP address and port of the request, and copies them into a response that is sent back to the client.

Page 14: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

14

Overview of Operation 2/2

When the STUN client receives the STUN Binding Response, it compares the IP address and port in the packet with the local IP address and port it bound to when the request was sent.

If these do not match, the STUN client is behind one or more NATs.

Page 15: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

15

Message Header

0x0001 : Binding Request 0x0101 : Binding Response 0x0111 : Binding Error Response 0x0002 : Shared Secret Request 0x0102 : Shared Secret Response 0x0112 : Shared Secret Error Response

Page 16: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

16

Page 17: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

17

Message Attributes

0x0001: MAPPED-ADDRESS 0x0002: RESPONSE-ADDRESS 0x0003: CHANGE-REQUEST 0x0004: SOURCE-ADDRESS 0x0005: CHANGED-ADDRESS 0x0006: USERNAME

0x0007: PASSWORD 0x0008: MESSAGE-INTEGRITY 0x0009: ERROR-CODE 0x000a: UNKNOWN-ATTRIBUTES 0x000b: REFLECTED-FROM

Page 18: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

18

Page 19: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) speaker : Wenping Zhang date : 2007.11.21

19

Reference

RFC 3489 STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)

STUN Client and Server library http://

sourceforge.net/project/showfiles.php?group_id=47735