<s>
STUN	B-Protocol
(	O
Session	B-Protocol
Traversal	I-Protocol
Utilities	I-Protocol
for	I-Protocol
NAT	I-Protocol
;	O
originally	O
Simple	O
Traversal	B-Protocol
of	O
User	B-Protocol
Datagram	I-Protocol
Protocol	I-Protocol
(	O
UDP	O
)	O
through	O
Network	B-Protocol
Address	I-Protocol
Translators	I-Protocol
)	O
is	O
a	O
standardized	O
set	O
of	O
methods	O
,	O
including	O
a	O
network	O
protocol	O
,	O
for	O
traversal	B-Protocol
of	O
network	B-Protocol
address	I-Protocol
translator	I-Protocol
(	O
NAT	B-Protocol
)	O
gateways	O
in	O
applications	O
of	O
real-time	O
voice	O
,	O
video	O
,	O
messaging	O
,	O
and	O
other	O
interactive	O
communications	O
.	O
</s>
<s>
STUN	B-Protocol
is	O
a	O
tool	O
used	O
by	O
other	O
protocols	O
,	O
such	O
as	O
Interactive	O
Connectivity	O
Establishment	O
(	O
ICE	O
)	O
,	O
the	O
Session	B-Application
Initiation	I-Application
Protocol	I-Application
(	O
SIP	O
)	O
,	O
and	O
WebRTC	B-Protocol
.	O
</s>
<s>
It	O
provides	O
a	O
tool	O
for	O
hosts	O
to	O
discover	O
the	O
presence	O
of	O
a	O
network	B-Protocol
address	I-Protocol
translator	I-Protocol
,	O
and	O
to	O
discover	O
the	O
mapped	O
,	O
usually	O
public	O
,	O
Internet	B-Protocol
Protocol	I-Protocol
(	O
IP	O
)	O
address	O
and	O
port	B-Protocol
number	I-Protocol
that	O
the	O
NAT	B-Protocol
has	O
allocated	O
for	O
the	O
application	O
's	O
User	B-Protocol
Datagram	I-Protocol
Protocol	I-Protocol
(	O
UDP	O
)	O
flows	O
to	O
remote	O
hosts	O
.	O
</s>
<s>
The	O
protocol	O
requires	O
assistance	O
from	O
a	O
third-party	O
network	O
server	O
(	O
STUN	B-Protocol
server	O
)	O
located	O
on	O
the	O
opposing	O
(	O
public	O
)	O
side	O
of	O
the	O
NAT	B-Protocol
,	O
usually	O
the	O
public	O
Internet	O
.	O
</s>
<s>
STUN	B-Protocol
was	O
first	O
announced	O
in	O
RFC	O
3489	O
;	O
the	O
title	O
was	O
changed	O
in	O
a	O
specification	O
of	O
an	O
updated	O
set	O
of	O
methods	O
published	O
as	O
RFC	O
5389	O
,	O
retaining	O
the	O
same	O
acronym	O
.	O
</s>
<s>
STUN	B-Protocol
was	O
first	O
announced	O
in	O
RFC	O
3489	O
.	O
</s>
<s>
The	O
original	O
specification	O
specified	O
an	O
algorithm	O
to	O
characterize	O
NAT	B-Protocol
behavior	O
according	O
to	O
the	O
address	O
and	O
port	O
mapping	O
behavior	O
.	O
</s>
<s>
This	O
algorithm	O
is	O
not	O
reliably	O
successful	O
and	O
only	O
applicable	O
to	O
a	O
subset	O
of	O
NAT	B-Protocol
devices	I-Protocol
deployed	O
.	O
</s>
<s>
The	O
methods	O
of	O
RFC	O
3489	O
proved	O
too	O
unreliable	O
to	O
cope	O
with	O
the	O
plethora	O
of	O
different	O
NAT	B-Protocol
implementations	O
and	O
application	O
scenarios	O
encountered	O
in	O
production	O
networks	O
.	O
</s>
<s>
The	O
STUN	B-Protocol
protocol	I-Protocol
and	O
method	O
were	O
updated	O
in	O
RFC	O
5389	O
,	O
retaining	O
many	O
of	O
the	O
original	O
specifications	O
as	O
a	O
subset	O
of	O
methods	O
,	O
but	O
removing	O
others	O
.	O
</s>
<s>
STUN	B-Protocol
is	O
a	O
tool	O
for	O
communications	O
protocols	O
to	O
detect	O
and	O
traverse	O
network	B-Protocol
address	I-Protocol
translators	I-Protocol
that	O
are	O
located	O
in	O
the	O
path	O
between	O
two	O
endpoints	O
of	O
communication	O
.	O
</s>
<s>
It	O
is	O
implemented	O
as	O
a	O
light-weight	O
client	B-Operating_System
–	I-Operating_System
server	I-Operating_System
protocol	O
,	O
requiring	O
only	O
simple	O
query	O
and	O
response	O
components	O
with	O
a	O
third-party	O
server	O
located	O
on	O
the	O
common	O
,	O
easily	O
accessible	O
network	O
,	O
typically	O
the	O
Internet	O
.	O
</s>
<s>
The	O
client	O
side	O
is	O
implemented	O
in	O
the	O
user	O
's	O
communications	O
application	O
,	O
such	O
as	O
a	O
Voice	B-Application
over	I-Application
Internet	I-Application
Protocol	I-Application
(	O
VoIP	B-Application
)	O
phone	O
or	O
an	O
instant	O
messaging	O
client	O
.	O
</s>
<s>
The	O
basic	O
protocol	O
operates	O
essentially	O
as	O
follows	O
:	O
The	O
client	O
,	O
typically	O
operating	O
inside	O
a	O
private	B-Protocol
network	I-Protocol
,	O
sends	O
a	O
binding	O
request	O
to	O
a	O
STUN	B-Protocol
server	O
on	O
the	O
public	O
Internet	O
.	O
</s>
<s>
The	O
STUN	B-Protocol
server	O
responds	O
with	O
a	O
success	O
response	O
that	O
contains	O
the	O
IP	B-Protocol
address	I-Protocol
and	O
port	B-Protocol
number	I-Protocol
of	O
the	O
client	O
,	O
as	O
observed	O
from	O
the	O
server	O
's	O
perspective	O
.	O
</s>
<s>
The	O
result	O
is	O
obfuscated	O
through	O
exclusive	O
or	O
(	O
XOR	O
)	O
mapping	O
to	O
avoid	O
translation	O
of	O
the	O
packet	O
content	O
by	O
application	O
layer	O
gateways	O
(	O
ALGs	O
)	O
that	O
perform	O
deep	B-Application
packet	I-Application
inspection	I-Application
in	O
an	O
attempt	O
to	O
perform	O
alternate	O
NAT	B-Protocol
traversal	I-Protocol
methods	O
.	O
</s>
<s>
STUN	B-Protocol
messages	O
are	O
sent	O
in	O
User	B-Protocol
Datagram	I-Protocol
Protocol	I-Protocol
(	O
UDP	O
)	O
packets	O
.	O
</s>
<s>
Since	O
UDP	O
does	O
not	O
provide	O
reliable	B-Protocol
transport	O
,	O
reliability	O
is	O
achieved	O
by	O
application-controlled	O
retransmissions	O
of	O
the	O
STUN	B-Protocol
requests	O
.	O
</s>
<s>
STUN	B-Protocol
servers	O
do	O
not	O
implement	O
any	O
reliability	O
mechanism	O
for	O
their	O
responses	O
.	O
</s>
<s>
In	O
security-sensitive	O
applications	O
,	O
STUN	B-Protocol
may	O
be	O
transported	O
and	O
encrypted	O
by	O
Transport	B-Protocol
Layer	I-Protocol
Security	I-Protocol
(	O
TLS	O
)	O
.	O
</s>
<s>
An	O
application	O
may	O
automatically	O
determine	O
a	O
suitable	O
STUN	B-Protocol
server	O
for	O
communications	O
with	O
a	O
particular	O
peer	O
by	O
querying	O
the	O
Domain	B-Protocol
Name	I-Protocol
System	I-Protocol
(	O
DNS	B-Protocol
)	O
for	O
the	O
stun	B-Protocol
(	O
for	O
UDP	O
)	O
or	O
stuns	B-Protocol
(	O
for	O
TCP/TLS	O
)	O
server	O
(	O
SRV	B-Protocol
)	O
resource	O
record	O
,	O
e.g.	O
,	O
_stun._udp.example.com	O
.	O
</s>
<s>
The	O
standard	O
listening	O
port	B-Protocol
number	I-Protocol
for	O
a	O
STUN	B-Protocol
server	O
is	O
3478	O
for	O
UDP	O
and	O
TCP	O
,	O
and	O
5349	O
for	O
TLS	O
.	O
</s>
<s>
Alternatively	O
,	O
TLS	O
may	O
also	O
be	O
run	O
on	O
the	O
TCP	B-Protocol
port	I-Protocol
if	O
the	O
server	O
implementation	O
can	O
de-multiplex	O
TLS	O
and	O
STUN	B-Protocol
packets	O
.	O
</s>
<s>
In	O
case	O
no	O
STUN	B-Protocol
server	O
is	O
found	O
using	O
DNS	B-Protocol
lookups	O
,	O
the	O
standard	O
recommends	O
that	O
the	O
destination	O
domain	O
name	O
should	O
be	O
queried	O
for	O
address	O
records	O
(	O
A	O
or	O
AAAA	O
)	O
,	O
which	O
would	O
be	O
used	O
with	O
the	O
default	O
port	B-Protocol
numbers	I-Protocol
.	O
</s>
<s>
In	O
addition	O
to	O
using	O
protocol	O
encryption	O
with	O
TLS	O
,	O
STUN	B-Protocol
also	O
has	O
built-in	O
authentication	O
and	O
message-integrity	O
mechanisms	O
via	O
specialized	O
STUN	B-Protocol
packet	O
types	O
.	O
</s>
<s>
When	O
a	O
client	O
has	O
evaluated	O
its	O
external	O
address	O
,	O
it	O
can	O
use	O
this	O
as	O
a	O
candidate	O
for	O
communicating	O
with	O
peers	O
by	O
sharing	O
the	O
external	O
NAT	B-Protocol
address	O
rather	O
than	O
the	O
private	B-Protocol
address	I-Protocol
,	O
which	O
is	O
not	O
reachable	O
from	O
peers	O
on	O
the	O
public	O
network	O
.	O
</s>
<s>
If	O
both	O
communicating	O
peers	O
are	O
located	O
in	O
different	O
private	B-Protocol
networks	I-Protocol
,	O
each	O
behind	O
a	O
NAT	B-Protocol
,	O
the	O
peers	O
must	O
coordinate	O
to	O
determine	O
the	O
best	O
communication	O
path	O
between	O
them	O
.	O
</s>
<s>
Some	O
NAT	B-Protocol
behavior	O
may	O
restrict	O
peer	O
connectivity	O
even	O
when	O
the	O
public	O
binding	O
is	O
known	O
.	O
</s>
<s>
Session	B-Application
Initiation	I-Application
Protocol	I-Application
(	O
SIP	O
)	O
extensions	O
are	O
defined	O
to	O
enable	O
the	O
use	O
of	O
ICE	O
when	O
setting	O
up	O
a	O
call	O
between	O
two	O
hosts	O
.	O
</s>
<s>
Network	B-Protocol
address	I-Protocol
translation	I-Protocol
is	O
implemented	O
via	O
a	O
number	O
of	O
different	O
address	O
and	O
port	O
mapping	O
schemes	O
,	O
none	O
of	O
which	O
is	O
standardized	O
.	O
</s>
<s>
STUN	B-Protocol
is	O
not	O
a	O
self-contained	O
NAT	B-Protocol
traversal	I-Protocol
solution	O
applicable	O
in	O
all	O
NAT	B-Protocol
deployment	O
scenarios	O
and	O
does	O
not	O
work	O
correctly	O
with	O
all	O
of	O
them	O
.	O
</s>
<s>
It	O
is	O
a	O
tool	O
among	O
other	O
methods	O
and	O
it	O
is	O
a	O
tool	O
for	O
other	O
protocols	O
in	O
dealing	O
with	O
NAT	B-Protocol
traversal	I-Protocol
,	O
most	O
notably	O
Traversal	B-Protocol
Using	I-Protocol
Relay	I-Protocol
NAT	I-Protocol
(	O
TURN	B-Protocol
)	O
and	O
Interactive	O
Connectivity	O
Establishment	O
(	O
ICE	O
)	O
.	O
</s>
<s>
STUN	B-Protocol
works	O
with	O
three	O
types	O
of	O
NAT	B-Protocol
:	O
full	O
cone	O
NAT	B-Protocol
,	O
restricted	O
cone	O
NAT	B-Protocol
,	O
and	O
port	O
restricted	O
cone	O
NAT	B-Protocol
.	O
</s>
<s>
In	O
the	O
cases	O
of	O
restricted	O
cone	O
or	O
port	O
restricted	O
cone	O
NATs	O
,	O
the	O
client	O
must	O
send	O
out	O
a	O
packet	O
to	O
the	O
endpoint	O
before	O
the	O
NAT	B-Protocol
will	O
allow	O
packets	O
from	O
the	O
endpoint	O
through	O
to	O
the	O
client	O
.	O
</s>
<s>
STUN	B-Protocol
does	O
not	O
work	O
with	O
symmetric	O
NAT	B-Protocol
(	O
also	O
known	O
as	O
bi-directional	O
NAT	B-Protocol
)	O
which	O
is	O
often	O
found	O
in	O
the	O
networks	O
of	O
large	O
companies	O
.	O
</s>
<s>
Since	O
the	O
IP	B-Protocol
address	I-Protocol
of	O
the	O
STUN	B-Protocol
server	O
is	O
different	O
from	O
that	O
of	O
the	O
endpoint	O
,	O
in	O
the	O
symmetric	O
NAT	B-Protocol
case	O
,	O
the	O
NAT	B-Protocol
mapping	O
will	O
be	O
different	O
for	O
the	O
STUN	B-Protocol
server	O
than	O
for	O
an	O
endpoint	O
.	O
</s>
<s>
TURN	B-Protocol
offers	O
better	O
results	O
with	O
symmetric	O
NAT	B-Protocol
.	O
</s>
