Posted by binod
on February 22, 2008 at 2:58 AM PST
A few months back, we enabled the ability to resolve Sip URIs using DNS in SailFin. This is based on RFC 3263. Lets discuss how DNS can be used to determine both protocol and port number of a UAS from sailfin.
As per RFC 3263, there are two new kind of records that are important for SIP. They are Naming Authority Pointer (NAPTR ) Record and Service Record (SRV ). In this example, NAPTR is used as a mechanism to specify the protocol (TCP or UDP) where as SRV records will be used locate the server and port from SailFin .
Example snippet from DNS zone file
_sip._udp.test.com. 3600 IN SRV 10 0 5090 sailfinserver.test.com.
_sip._tcp.test.com. 3600 IN SRV 10 0 5090 sailfinserver.test.com.
_sips._tcp.test.com. 3600 IN SRV 10 0 5061 sailfinserver.test.com.
_sips._udp.test.com. 3600 IN SRV 10 0 5061 sailfinserver.test.com.
; order pref flags service regexp replacement
test.com. IN NAPTR 0 0 "s" "SIPS+D2T" "" _sips._tcp.test.com.
test.com. IN NAPTR 1 0 "s" "SIP+D2T" "" _sip._tcp.test.com.
test.com. IN NAPTR 2 0 "s" "SIP+D2U" "" _sip._udp.test.com.
sailfinserver.test.com. IN A 192.168.1.100
Lets take the NAPTR record shown above, the third column, in these records suggest that the server support TLS over TCP, TCP and UDP protocols and are preferred in that order. Now, if the client support TCP and UDP, then the preference will be given to TCP as that has the lower order compared to UDP.
The SRV records suggest that the port used by the server for TCP and UDB communication is 5090 and not the usual 5060 and the actual server is sailfinserver.test.com.
Finally we have an A record that resolves the sailfinserver.test.com to the computer's IP address.
SailFin uses dnsjava apis for name resolution. It allows the user to configure a JVM option called dns.server for specifying the name server. We could specify that as a jvm-option in domain.xml
If this is not specified, dnsjava also searches /etc/resolve.conf to find the name server. For experimenting that was better for me, as I always have a local name server running in the laptop. (For a moment forget Sip/SailFin, local name server (bind) performs much better for me than BSNL or opendns. That itself is a reason to run a local name server).
Here is my /etc/resolve.conf file content.
Once these are configured, SailFin will be able to resolve the domain "test.com" and find correct SIP server, protocol, port etc. Here is the example of the INVITE message that I tried.
With these settings, SailFin will resolve "To" address to 192.168.1.100:5090 and will use TCP protocol.I have uploaded the following files in a zip, as an example.
1. sip-proxy.war : A sip application as explained in Sip Proxy example of sailfin.
2. xyz.zone which contains all the DNS records explained above.
3. named.conf of my bind DNS.
4. uac.xml and uas.xml files for running the sipp tests (I have hard coded the test.com in the files)
Steps to try DNS in sailfin.
1. Setup and start the nameserver (bind). The example zip file contains named.conf and the domain zone file.
2. After starting the DNS, dig it and see, if it is working (eg: dig @127.0.0.1 NAPTR test.com). Make sure that the ANSWER from DNS contains the SRV records.
3. Configure either the dns.server jvm-option in sailfin or /etc/resolve.conf
4. Start a SailFin server and deploy the sip proxy servlet.
5. Use Sipp to execute a proxy scenario using the uac.xml and uas.xml. (The only change from the proxy example will be to use the sip proxy files.