The Source for Java Technology Collaboration
User: Password:



Ramesh Parthasarathy's Blog

Ramesh Parthasarathy Ramesh Parthasarathy is an engineer at Sun Microsystems, working in Java EE application server development engineering group. He contributes to glassfish project. Besides that, he is also involved in Generic Resource Adapter for JMS project. Prior experiences include developing Java Business Integration (JBI) components for OpenESB.



STUN server in SailFin

Posted by rampsarathy on March 09, 2009 at 12:09 AM | Permalink | Comments (0)

Simple Stun Server in SailFin STUN (Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs), defined by RFC 3489) is a protocol that helps  devices (clients) behind a NAT firewall or router with routing of packets. The protocol helps devices to find out the type of NAT service (Full Cone, Restricted Cone, Port Restricted Cone and  Symmetric) as well as their public address. A STUN client, typically executes on a networked device (mobile phone, soft phone..) and generates STUN requests to a STUN server that is hosted on the public domain.

SailFin can be extended to provide STUN service, BINDING requests primarily. A simple STUN server is now available in Project SailFin and is implemented as a lifecycle module. When the STUN lifecycle module is deployed and enabled, the STUN server starts up and listens for BINDING requests from STUN clients. Soft-phones (like Xlite) can be configured to use the STUN server in SailFin to discover the NAT service and their public address.
Since, SailFin uses the socket connector from Project Grizzly, the STUN  service is also implemented using the Grizzly APIs. The picture below provides an overall view of STUN service in SailFin.


stun in sailfin


The source code for the STUN server implementation in SailFin can be found here
http://fisheye5.cenqua.com/browse/sailfin/value-adds/stun-server

The source code is available under the value-adds/stun-server folder in the SailFin workspace. Or it can be checked out explicitely (cvs co sailfin/value-adds/stun-server) . It can compiled either from the bootstrap folder or from the stun-server folder. On successful compilation , it generates a lifecycle module jar file , stun-server.jar, (under WORKSPACE/value-adds/stun-server/build/dist)  that can be deployed to SailFin. This is a self contained jar file that contains the STUN server implementation and the implementation of the lifecycle interface to manage the start/stop of the server.
When using  SailFin's build workspace, the "setup" target (under stun-server module) would deploy the lifecycle module to the SailFin server in the workspace.

 Alternatively, the lifecycle jar file (stun-server.jar) can be deployed to any SailFin instance using the "create-lifecycle-module" command and providing " org.jvnet.glassfish.comms.stun.StunServerLifecycle" as the classname and the path to stun-server.jar as the classpath.

After deploying the lifecycle module, and restarting the server, the STUN server should be available on port 3478. The SailFin instance can now be used as a STUN service provider apart from being a SIP server.

You could also enable FINEST logging for the stun server by adding the property "<property name="stun" value="FINEST"/>" to the module-log-levels section of the SailFin configuration. This should log the STUN messages (received and sent) in the server.log file.

Please note that this is a basic implementation that supports BINDING requests only (not all flags/attributes are supported today). If you find an issue where a softphone works with a public stun server and has an issue working with SailFin, please create an issue in the SailFin project.








April 2009
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    


Search this blog:
  

Categories
J2EE
Archives

March 2009
September 2008
July 2008
June 2008
May 2007
March 2007
February 2007
January 2007
December 2006

Recent Entries

STUN server in SailFin

Generic JMS RA 2.0

Overload Protection in SailFin



Powered by
Movable Type 3.01D


 Feed java.net RSS Feeds