Mobile End-to-End Communication Services with the Java™ Platform, Micro Edition and Java Platform, Enterprise Edition
Kristoffer Gronowski, Senior Specialist, EricssonOla Dahlqvist, System Architect, EricssonTS-5802
Speaker’s logo here (optional)
2008 JavaOneSM Conference | java.sun.com/javaone | 2
To show how end to end communication between Java ME platform and Java EE platform can be done with the SIP protocol.The samples will demonstrate how it can be done and full code reference URL can be found in the resources slide.
2008 JavaOneSM Conference | java.sun.com/javaone | 3
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 4
BioKristoffer
Server side guyFirst JavaOne℠ conference appearance (1st attendance 1998)11 years developer in Java platform, 8 with SIPExpert group member JSR-289 (SipServlet)Architect and one of the initial 3 developers to write the Sailfin code base.
OlaClient side guyCo-designer of JSR-180 (SIP) in EMP and SonyEricsson phones Member of the RI team for JSR-281Architect for Ericsson Multimedia products building on Java ME & Java EE platforms
2008 JavaOneSM Conference | java.sun.com/javaone | 5
What is SIP?Evolution from HTTP to enable asynchronous communication style.Standardizes session establishment, transfer and renegotiation frameworks.Base for presence (mood indication) application framework.Messaging, chat and file transfer applications.Used for setup of voice and video over IP.Scalable in architecture. Entities are both client and servers.UDP/TCP/TLS based.
2008 JavaOneSM Conference | java.sun.com/javaone | 6
SIP Location lookup registrar case
REGISTER
200 OKMESSAGE
MESSAGE
200 OK
200 OK
2008 JavaOneSM Conference | java.sun.com/javaone | 7
Java Platform SIP Support Java ME Platform• JSR-180 (SIP API)• JSR-281 (IMS API) (Final Approval Ballot)
• Other useful JSR's on the client side• JSR-135 (Mobile Media API)
Java EE Platform• JSR-116 (Sip Servlet 1.0 API)• JSR-289 (Sip Servlet 1.1) (Work in progress)
• Other useful JSR's on the server• JSR-141 (Session Description API)• JSR-309 (Media Server Control API) (Work in progress)
2008 JavaOneSM Conference | java.sun.com/javaone | 8
User AliceApplication
Server(SIP)
Network Address TranslatorThe Problem
User Bob
Home network10.0.0.1
Home RouterNAT
The Internet147.214.199.1
I'm at 10.0.0.12
No Route10.0.0.12
2008 JavaOneSM Conference | java.sun.com/javaone | 9
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 10
Client – Java ME PlatformJSR-180 (SIP API)• Low level API SIP
• Requests modeled as connections• Application can read and write headers and body
• Available in SonyEricsson phones (Java Platform 8 and higher), for example W910i, K850i and Z750i, and Nokia N95
• Part of JSR-248 (Mobile Service Architecture)• Two modes
• Dedicated mode - each Java ME application has it's own SIP stack
• Shared mode - the SIP stack is shared with other Java ME and/or native applications
2008 JavaOneSM Conference | java.sun.com/javaone | 11
Server – Java EE PlatformJSR-289 SipServlet 1.1 Sailfin open source (JSR in PFD)Supports multiple SIP applications and composition.Can act as client, server, proxy or a mix.In container connection to Java EE platform and further integration point WS, REST, EJB, ConnectorsOther communities (jVoiceBridge,e-charts,mobicents) Tools support Netbeans™ integrated development environment & Eclipse
2008 JavaOneSM Conference | java.sun.com/javaone | 12
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 13
Development Tools and Simple Message reflector demo
2008 JavaOneSM Conference | java.sun.com/javaone | 14
JSR-180 Sending request
SipConnectionNotifier scn;//Dedicated Mode initscn = Connector.open("sip:5060;transport=tcp");SipClientConnection sc; //Open connectionsc = Connector.open("sip:[email protected];transport=tcp");sc.initRequest("MESSAGE", scn);f = "sip:X@"+scn.getLocalAddress()+':'+scn.getLocalPort();sc.setHeader("From", f); //Sets the from headersc.send(); //Sends the message outboolean ok = sc.receive(32000); //Wait 32 sec
2008 JavaOneSM Conference | java.sun.com/javaone | 15
JSR-180 Receiving requests
//Blocks and waits for messageSipServerConnection conn = scn.acceptAndOpen();//Read the bodyInputStream is = conn.openContentInputStream();while ((ch = is.read()) != -1) {
msg[index++] = (byte) ch;}is.close(); //Operate on the received messageconn.initResponse(200);conn.send(); //Sends the response out//Close the connectionconn.close(); //Does not close the TCP socket!
2008 JavaOneSM Conference | java.sun.com/javaone | 16
JSR-289 Sip Servlet message handling
//Injecting Sip Factory@Resourceprivate SipFactory sf; //Sip servlet service methodprotected void doMessage(SipServletRequest req) {
//Read the bodyString msg = req.getContent().toString();log("Received message = "+msg);SipServletResponse resp = req.createResponse(200);resp.send();
.
.
.
2008 JavaOneSM Conference | java.sun.com/javaone | 17
JSR-289 Sip Servlet message sending
//Send message in other directionSipURI user = req.getFrom().getURI();String remote = "sip:"+user.getUser()+ '@'+req.getRemoteAddr()+':'+req.getRemotePort();SipServletRequest echo = sf.createRequest( req.getAppSession(),"MESSAGE",req.getTo(),remote);echo.setContent(msg,req.getContentType()); echo.send(); //Send the message
2008 JavaOneSM Conference | java.sun.com/javaone | 18
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 19
IP Multimedia Subsystem (IMS)Purpose• Move voice and multimedia communication to packet-based
technologies, to merge telephony (fixed and mobile) and InternetArchitecture • Control signaling based on SIP• A standardized network infrastructure that serves as a foundation
for higher-level services• IMS solves NAT and QoS
Users • Peer-to-peer multimedia communications
2008 JavaOneSM Conference | java.sun.com/javaone | 20
JSR-281 (IMS API)High-level Java ME API for multimedia session establishmentProvides media capabilities • Real-time Transport Protocol (RTP), voice & video (RFC-3550)• Message Session Relay Protocol (MSRP), chat & file transfer
(RFC-4975)Defines support from platform• Provides an identity• Multi application framework
Successor - JSR-325 “IMS Communication Enablers” • OMA Presence, OMA Instant Messaging, MMTel, Push to Talk etc.
2008 JavaOneSM Conference | java.sun.com/javaone | 21
Example 2Simple JSR-281 & JSR-289 application interactionRecord a video clipSetup a session using the SIP INVITE methodNegotiate and file transfer with MSRPUpload the video clip from Sailfin to YouTube
2008 JavaOneSM Conference | java.sun.com/javaone | 23
JSR-281 Start session//Create service object service = (CoreService)
Connector.open("imscore://com.ericsson.CallApp");service.setListener(this);//Create sessionsession = service.createSession("sip:[email protected]",
"sip:[email protected]");session.setListener(this);//Create mediamedia = (FramedMedia) session.createMedia("FramedMedia",
Media.DIRECTION_SEND);//Start session - initiate SIP session establishmentsession.start();//Once the session is established – send the file messageId = media.sendFile("file:///e:/videos/test.mp4",
"video/mp4", headers);
2008 JavaOneSM Conference | java.sun.com/javaone | 24
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 25
Multimedia Communication Suite (MCS)Features• Presence, Chat, File transfer, Service
capabilitiesClient• Uses IMS support in SonyEricsson
phones and JSR-211 (Content Handler API) to integrate into phone book.
Network Solution• Several core components built on top of
same code that was the initial donation to Sailfin.
2008 JavaOneSM Conference | java.sun.com/javaone | 27
Agenda
IntroductionLow level SIP communication APIsDevelopment tools and demoHigh level communication APIsReal product scenarioFindings and resources
2008 JavaOneSM Conference | java.sun.com/javaone | 28
NAT TraversalConcepts to overcome the problem
Dedicated NetworkProtocol awareComponents
GenericSolution
<client side>
ICE
STUN
TURN
RSIP
IMSMidcom
Internet only
TunnelingVPN
ALG
Focus area Rport
2008 JavaOneSM Conference | java.sun.com/javaone | 29
NAT/FW findingsTopology depends on your operator. (ALG)Ice draft (conn reuse & ping) (draft-ietf-mmusic-ice)STUN probe what is there using UDP (RFC-3489)Rport extension. Don't trust the client. (RFC-3581)Short UDP states (A:ping packets)No inbound TCP connections (draft-ietf-sip-outbound)Media also problematicDo not put the server behind NATIMS = SIP will work
2008 JavaOneSM Conference | java.sun.com/javaone | 30
HintsTCP saves batteriesSign the MIDletCheck if ME JSR is operator lockedUse network analyzers like Wireshark for SIP and mediaStart without NAT if possible (Access Point APN/PDP)• Try the Wireless Toolkit (WTK) behind NAT (beware phone&WTK
can behave differently)
2008 JavaOneSM Conference | java.sun.com/javaone | 31
For More Information
TS• TS-5866 Project SailFin
Pavilion• JSR-281 Demo at Ericsson Booth #618• MCS Demo at Ericsson Booth #618
Links• https://sailfin.dev.java.net Example code and blog on Sailfin• http://www.ericsson.com/mobilityworld SDS IMS Eclipse tool• http://www.tech-invite.com/ All you need to know about SIP
Contact info• [email protected]• [email protected]
2008 JavaOneSM Conference | java.sun.com/javaone | 32
Java ME Platform - Summary
SIP RTPMSRPOS
JSR-180
IMS Communication Services
Abs
tract
ion
CLDC/MIDP
JSR-180 JSR-281
JSR-325IMS Communication Enablers
Communication Application
??
?
?
2008 JavaOneSM Conference | java.sun.com/javaone | 33
Summary
There are many new JSR-180 capable devices 2008On the server side production grade open source serversMiddleboxes NAT/FW makes a real problem, however:Higher level API's and IMS can make it more controllableThis technology is out there and it is built to scale
Reuse the 10+ years experience of SIP as communication protocol researched by the IETF & IMS communities