Examining the STUN settings of a SIP phone
Emin Gabrielyan
2007-04-02
Switzernet Sàrl
4. Headers received from the SIP phone
STUN stands for Simple Traversal of UDP through NATs.
STUN is a protocol for the user agent to discover its own public IP address. You need a STUN server (not part of a SIP server). The user agent will then try to change the contact and SDP information itself [SER-Getting-Started, p.12].
Below is a screenshot of a configuration page of a SIP phone without using a STUN server:
[htm]
Configuration of the SIP phone with a STUN server:
[htm]
Our SIP phone is configured to use a SER server. The original configuration of the SIP phone using PortaOne as its SIP server is saved [htm].
OpenSER server receives SIP messages from the SIP phone. Xlog command is used to print the header fields [RFC-3261, pdf, unix-txt, dos-txt, p.11] of received SIP messages.
The following commands are inserted in the main routing logic of the OpenSer configuration file:
xlog("L_INFO","+---------------------------------+\n");
xlog("L_INFO","| Starting the main routing logic |\n");
xlog("L_INFO","+---------------------------------+\n");
xlog("L_INFO","$rm\n");
xlog("L_INFO","Via: $hdr(Via[*])\n");
xlog("L_INFO","Max-Forwards: $hdr(Max-Forwards[*])\n");
xlog("L_INFO","To: $hdr(To[*])\n");
xlog("L_INFO","From: $hdr(From[*])\n");
xlog("L_INFO","User-Agent: $hdr(User-Agent[*])\n");
xlog("L_INFO","Call-ID: $hdr(Call-ID[*])\n");
xlog("L_INFO","CSeq: $hdr(CSeq[*])\n");
xlog("L_INFO","Contact: $hdr(Contact[*])\n");
xlog("L_INFO","Content-Type: $hdr(Content-Type[*])\n");
xlog("L_INFO","Content-Length: $hdr(Content-Length[*])\n");
[running openser.cfg, unix-txt, dos-txt], [original openser.cfg, unix-txt, dos-txt], [difference txt]
For xlog tags consult the README of the xlog module [xlog, unix-txt, dos-txt] or a doc page of developers [htm]
The SIP phone sends REGISTER messages to the SER server. The server prints the specified header fields. When the STUN server is not specified in the SIP phone [sip-phone-config], the phone cannot discover its public IP address. The Via and Contact fields [RFC-3261, p.11] of the SIP message contain therefore the SIP phone’s IP address behind the NAT:
0(31481) Via: SIP/2.0/UDP 192.168.1.49;branch=z9hG4bK77253b16d8fe1706
0(31481) Call-ID: 5acfee1690243802@192.168.1.49
0(31481) CSeq: 101 REGISTER
0(31481) Contact: <sip:41215500308@192.168.1.49>
[log]
When the STUN server is specified in the SIP phone [htm], the SIP phone can discover its public IP address thanks to the STUN server and provides therefore in transmitted SIP messages the discovered public IP address and port instead of its actual IP address behind the NAT:
0(31390) Via: SIP/2.0/UDP 128.179.67.121:20835;branch=z9hG4bKa7056a06196de4f5
0(31390) Call-ID: 0ecb7d6a97b4aab2@192.168.1.48
0(31390) CSeq: 100 REGISTER
0(31390) Contact: <sip:41215500308@128.179.67.121:20835>
[log]
STUN – Simple Traversal of UDP through NAT
UDP – User Datagram Protocol
NAT – Network Address Translation
SER – SIP Express Router
SIP – Service Initiated Protocol
SDP – Service Description Protocol