Prof. Simon Pietro Romano Universit degli Studi di Napoli Federico - - PowerPoint PPT Presentation

prof simon pietro romano
SMART_READER_LITE
LIVE PREVIEW

Prof. Simon Pietro Romano Universit degli Studi di Napoli Federico - - PowerPoint PPT Presentation

Corso di Applicazioni Telematiche A.A. 2010-11 Prof. Simon Pietro Romano Universit degli Studi di Napoli Federico II Facolt di Ingegneria Simon Pietro Romano AT 2011 1 Some background: what is a servlet ? Suns definition: A


slide-1
SLIDE 1

Simon Pietro Romano – AT 2011 1

Corso di Applicazioni Telematiche A.A. 2010-11

  • Prof. Simon Pietro Romano

Università degli Studi di Napoli Federico II Facoltà di Ingegneria

slide-2
SLIDE 2

Simon Pietro Romano – AT 2011 2

Some background: what is a servlet ?

Sun‟s definition: “A Java program that runs as part of a network service, typically an HTTP server and responds to requests from clients”

Note well: “typically” an HTTP server…this leaves space to

  • ther types of servers!
slide-3
SLIDE 3

Simon Pietro Romano – AT 2011 3

HTTP Servlets

  • Used for developing Web Applications
  • Servlets process HTTP Requests
  • Responses are sent back to the client as HTTP responses

containing web pages

  • To provide custom functionality:

– developers just override the doGet() and doPost() methods of the HTTP Servlet class

  • HTTP Servlets, together with their deployment descriptor

(e.g. web.xml file) are:

– packaged into a WAR (Web ARchive) file by the developer – deployed to the server by administrators

  • Container manages servlet‟s life cycle, replication of

Session state, fail-over, authentication, security

slide-4
SLIDE 4

Simon Pietro Romano – AT 2011 4

HTTP Servlet API

destroy() service() init()

servlet

HTTP Response

Client Servlet Methods

HTTP Response doPut() doPost() doGet() Error Response

Rules

HTTP Response Error Response HTTP Request

Web Container

slide-5
SLIDE 5

Simon Pietro Romano – AT 2011 5

Why extending the Servlets model for SIP?

  • Servlets API is an open standard supported by multiple

vendors

  • Containers manage Servlet‟s life cycle, session‟s state,

fault-tolerance, scalability, security

  • Application‟s developers can focus solely on their

application

  • HTTP Servlets are widely used in Web development

– large community of developers already familiar with the concepts of the Servlets API

  • New Services developed as Servlets can interact with

existing components, like HTTP Servlets or EJBs (Enterprise Java Beans)

– converged applications!!

slide-6
SLIDE 6

Simon Pietro Romano – AT 2011 6

SIP servlet goals

  • Application composition

– one servlet can be called right after another servlet completes (execution chain…)

  • Converged applications

– implementing applications that are both HTTP- and SIP- enabled

  • Caveats:

– Neither application composition nor converged applications are well defined in JSR (Java Specification Request), yet:

  • JSR 116 (SIP servlet v1.0):

– http://jcp.org/aboutJava/communityprocess/final/jsr116/index.html

  • JSR 289 (SIP servlet v1.1 Final Release, August 1 2008)

– http://jcp.org/aboutJava/communityprocess/final/jsr289/index.html

– Different SIP containers may act differently with respect to the above features…

slide-7
SLIDE 7

Simon Pietro Romano – AT 2011 7

SIP Servlet Programming model

  • SIP Servlet API:

– a specification developed by the communication industry in an attempt to standardize and speed up the development of services in SIP networks – Similar to the HTTP Servlet API, it is based on two key figures:

  • the SIP Servlet container
  • the SIP servlet
slide-8
SLIDE 8

Simon Pietro Romano – AT 2011 8

SIP Servlet container

  • An Application Server (AS) with a built in SIP stack

that:

– is placed in a SIP network – listens to incoming SIP messages

  • When an incoming message arrives, the AS

triggers one or more applications, which:

– deal with the signalling – implement a certain service

  • Applications include, among other resources, SIP

Servlets

slide-9
SLIDE 9

Simon Pietro Romano – AT 2011 9

SIP servlets

  • Like HTTP servlets, SIP servlets are pieces of java

code contained and managed by the SIP Servlet Container

  • They perform SIP signalling, by:

– either answering incoming requests – or proxying them – or even creating new ones

  • This is a key difference with the HTTP Servlet API:

– HTTP servlets can only answer HTTP requests

slide-10
SLIDE 10

Simon Pietro Romano – AT 2011 10

SIP Servlet API

destroy() service() init() doInvite() doAck() doOptions() doCancel() doRegister() doPrack() doInfo() doNotify() doMessage() doSubscribe() doProvisionalResponse() doSuccessResponse() doErrorResponse() doRedirectResponse()

doResponse() doRequest()

servlet

Create Request() Create Response()

SIP Message

Client SIP Container SIP Servlet Methods

Rules SIP Message

slide-11
SLIDE 11

Simon Pietro Romano – AT 2011 11

HTTP servlets vs SIP servlets: differences

  • HTTP signaling less complex

– Only handles requests and generates responses

  • SIP signaling is much more

complex

– Handle and generate requests and responses, Session management, Proxying

  • SIP servlets - response can be

generated asynchronously

  • Servlet mapping for SIP servlets is

done by a set of rules evaluated at

  • runtime. Client applications are

not aware of applications installed

  • n the server

HTTP SIP

  • HTTP servlets - the

doService() method is expected to send a response within the same method call

  • HTTP request contains the

name of the Servlet to invoke in the request URI

slide-12
SLIDE 12

Simon Pietro Romano – AT 2011 12

HTTP servlets vs SIP servlets: similarities

  • Servlets invocation is triggered by events:

– request response

  • The container:

– hides the low level protocol – exposes high level API – selects the appropriate servlet to invoke – manages servlet‟s life-cycle and session state

  • Developers:

– override methods in the servlet‟s base class – provide specific implementation

  • Servlets are:

– grouped into applications: web archive (“.war”), sip archive (“.sar”) – deployed with a deployment descriptor (“web.xml” for HTTP, “sip.xml” for SIP)

slide-13
SLIDE 13

Simon Pietro Romano – AT 2011 13

SIP Servlet Abstractions

  • SIP Servlet API:

– several abstractions in the form of classes and interfaces

  • Pattern:

– SipServlet extends GenericServlet as a SIP specialization – SipServletRequest extends ServletRequest – SipServletResponse extends ServletResponse – SipServletMessage extends ServletMessage

SipServletResponse SipServletRequest SipServletMessage ServletRequest ServletResponse javax.servlet javax.servlet.sip

slide-14
SLIDE 14

Simon Pietro Romano – AT 2011 14

Servlet Context

  • A sandbox inside the container where applications are executed
  • Every application has its own context where all its servlets run
  • Every context has its own class loader:

– the isolation between applications is guaranteed – servlets of an application use the context primarily as a mechanism for communication between them

slide-15
SLIDE 15

Simon Pietro Romano – AT 2011 15

SipServlet

  • The base class that developers „subclass‟ to

implement their own servlets

  • Defines:

– the lifecycle methods:

  • init,destroy

– the message handling methods:

  • doRequest, doResponse, ...
  • Implements the default behaviour of the

methods above

slide-16
SLIDE 16

Simon Pietro Romano – AT 2011 16

Other classes

  • SipServletRequest and SipServletResponse:

– encapsulate SIP requests and response messages, respectively – both provide access to:

  • relevant request and response information
  • handy methods for their process:

– createResponse, createACK, createCancel, getProxy, send

  • SipServletMessage:

– defines a number of methods which are common to SipServletRequest and SipServletResponse

  • e.g.: setters and getters for message headers and content
  • SipSession

– SipSessions are used to maintain dialog state – every message belongs to a SipSession, i.e. the representation of the SIP dialog or call leg the message is engaged in

slide-17
SLIDE 17

Simon Pietro Romano – AT 2011 17

SipApplicationSession

  • In many SIP applications (e.g. B2BUA) an incoming message sets up a dialog

that leads to the initiation of other dialogs, each of them represented by their

  • wn SipSession:

– such SipSessions are independent, yet related to the same execution of the service – we could think of them as an „application instance‟

  • SipApplicationSession:

– the above identified application instance – holds references to all the SipSessions (as well as HttpSessions in the case of converged applications) – provides methods to store application instance data

slide-18
SLIDE 18

Simon Pietro Romano – AT 2011 18

Factory and Proxy

  • SipFactory

– used to create new application sessions, requests, addresses and URI objects – servlets obtain a reference to it through a ServletContext attribute:

  • javax.servlet.sip.SipFactory
  • Proxy

– represents a proxy operation – offers methods to configure several proxy aspects

  • whether it should be stateless or stateful, parallel or sequential,

record routed or not, etc. – setting the proxy supervision flag configures how controlling servlet is to be invoked for subsequent events related to this proxying transaction:

  • incoming responses, CANCELs and ACKs
slide-19
SLIDE 19

Simon Pietro Romano – AT 2011 19

SIP Servlet life cycle

slide-20
SLIDE 20

Simon Pietro Romano – AT 2011 20

SIP Servlet methods

slide-21
SLIDE 21

Simon Pietro Romano – AT 2011 21

SipSessions and Dialogs

  • SipSession:

– can be roughly considered as the representation of a SIP dialog

  • it maintains dialog state
  • can be used to create subsequent requests inside a dialog via

its createRequest(method)

slide-22
SLIDE 22

Simon Pietro Romano – AT 2011 22

Working as UAC

  • Create an initial request from scratch:

– the servlet has to:

  • retrieve the SipFactory from the ServletContext
  • invoke the createRequest method
  • modify the SipServletRequest as appropriate
  • send the newly created request
  • Create a subsequent request:

– the only thing we need is the SipSession; then we can proceed like this:

//Sending BYE because we're done mySipSession.createRequest("BYE"); //Send the request req.send();

  • Create ACK requests

– use the SipServletResponse method createACK

  • Create CANCELs

– from the request that we want to cancel:

SipServletRequest cancelRequest = inviteRequest.getCancel(); cancelRequest.send();

slide-23
SLIDE 23

Simon Pietro Romano – AT 2011 23

Working as UAS

  • To generate a response to an incoming request UAS servlets simply

have to:

– invoke createResponse() on the request object being processed – modify the SipServletResponse obtained, if needed – invoke its send method protected void doInvite(SipServletRequest req) throws javax.servlet.ServletException, java.io.IOException{ .... SipServletResponse resp = req.createResponse(486,“Pippozzo server is so busy now. Sorry'); resp.send(); .... }

slide-24
SLIDE 24

Simon Pietro Romano – AT 2011 24

Working as Back-to-Back User Agent (B2BUA)

  • Useful any time you need to appropriately
  • rchestrate interaction among two or more parties:

– e.g. 3rd Party Call Control (3PCC)

  • To implement this kind of behaviour a SIP Servlet:

– uses the SipFactory method createRequest(SipServletRequest

  • rigRequest, boolean sameCallId) to:
  • process an initial request coming from the

upstream…

  • …create the request that will be sent downstream
slide-25
SLIDE 25

Simon Pietro Romano – AT 2011 25

Working as Proxy

  • The SIP Servlet API abstracts the proxy operation by means of the Proxy
  • bject

  • btained from the SipServletRequest via the getProxy() method

– any other message involved in the proxy operation carried out by this proxy object wil return the same Proxy instance

  • The Proxy objects offers several setters to configure its behaviour

– recurse:

  • tells the proxy to automatically retry when a 3xx response is received

– recordRoute:

  • whether the application is supposed to stay in the signalling path of the dialog

– parallel:

  • when proxying to multiple destinations this flag indicates whether the proxy

should fork or retry sequentially – stateful:

  • indicates whether the proxying should be carried out statelessly or statefully

– supervised:

  • if set to true

– responses coming from the downstream are delivered to the servlet

  • if set to false:

– they are forwarded upstream (if applies) by the container without application involvement

– sequentialSearchTimeout:

  • how long will the proxy wait for one of its branches to send a final response

before cancelling it

slide-26
SLIDE 26

Simon Pietro Romano – AT 2011 26

Accessing the SIP message content

  • Often, developers need access to the content of the SIP messages
  • The SIP Servlet API provides a set of methods to read and write such

content

  • They are all methods of the SipServletMessage interface:

– to read or set the length of the message:

  • int getContentLength()
  • void setContentLength(int len)

– to read or set the content type:

  • String getContentType()
  • void setContentType(String type)

– to gain direct access to the content:

  • Object getContent()
  • byte[] getRawContent()
  • void setContent(Object obj, String type)
slide-27
SLIDE 27

Simon Pietro Romano – AT 2011 27

SDP Management

  • SIP applications very often have to deal with SDP
  • The JAIN familiy of specifications includes JAIN-SDP (JSR 141)

– designed to help developers with SDP multimedia session descriptions – offers a set of objects and interfaces wich developers can use to create, read or modify the SDP content of SIP messages – a free implementation can be found at https://jain-sip.dev.java.net/

protected void doInvite(SipServletRequest req) throws javax.servlet.ServletException, java.io.IOException{ .... //Save the SDP content in a String String sdpContent = new String(req.getRawContent(),req.getCharacterEncoding()); //Use the static method of SdpFactory to //parse the content SessionDescription requestSDP = SdpFactory.createSessionDescription(sdpContent); .... }

slide-28
SLIDE 28

Simon Pietro Romano – AT 2011 28

Sip-Servlets in a Java EE Architecture

slide-29
SLIDE 29

Simon Pietro Romano – AT 2011 29

SIP Application Server example: Mobicents (www.mobicents.org)

  • An open source VoIP platform certified for JAIN SLEE 1.0 and SIP

Servlets 1.1 compliance

  • Serves as a high-performance core for Service Delivery Platforms

(SDPs) and IP Multimedia Subsystems (IMSs)

– leverages J2EE to enable the convergence of data and video in Next- Generation Intelligent Network (NGIN) applications

  • Enables the composition of predefined Service Building Blocks

(SBBs)

– Call-Control, Billing, User-Provisioning, Administration and Presence- Sensing

slide-30
SLIDE 30

Simon Pietro Romano – AT 2011 30

Mobicents Sip Servlets – Features

  • Implementation of all SIP Servlets v1.1 specification features
  • High Availability
  • Support for MESSAGE, SUBSCRIBE/NOTIFY, INFO, UPDATE,

PUBLISH, REFER SIP extensions

  • Integration with SEAM
  • DNS SRV lookup & STUN support for NAT Traversal
  • Media Support : Integration with Mobicents Media Server
  • JSLEE (Java Service Logic Execution Environment) interoperabilty
  • Management Console
  • NIST SIP stack used as the JAIN SIP Stack as in Mobicents JSLEE

SIP RA

  • High performance figures:

– Soak tests (i.e. running the system at high levels of load for

prolonged periods of time) results:

» 100 calls/sec for 24h for a total of 8.640.000 calls on 2x AMD

2220 SE server with 8GB of RAM

slide-31
SLIDE 31

Simon Pietro Romano – AT 2011 31

Mobicents eclipse plugin

slide-32
SLIDE 32

Simon Pietro Romano – AT 2011 32

SIP Application Server example: WeSIP (http://www.wesip.com)

  • WeSIP is a Converged SIP Servlet Application Server built on top of

OpenSER

– it basically adds a SIP Servlet programming layer to Openser – users can develop their own services and applications using existing OpenSER modules:

  • nat_traversal
  • registrar
  • etc...

– ...while at the same time enjoying the java programming language facilities:

  • Web services (SOAP)
  • Java Beans (EJB)
  • Database Connectivity (JDBC)
  • ....
  • WeSIP helps integrate

OpenSER with other systems and protocols, enabling the offer

  • f a new portfolio of services
slide-33
SLIDE 33

Simon Pietro Romano – AT 2011 33

WeSIP OpenSER Integration

slide-34
SLIDE 34

Simon Pietro Romano – AT 2011 34

CPL http://www.ietf.org/rfc/rfc3880.html

  • CPL stands for Call Processing Language
  • XML call behaviour scripting
  • Protocol Agnostic
  • Loaded and executed in a container
  • Allows basic (non interactive) predefined modification of call

behaviour based on time criteria, address criteria or network signalling criteria

  • With CPL you can do things like “forward all my calls to

voicemail if I’m not available, the caller is my girlfriend and it is Friday”

  • OpenSER provides a CPL implementation module

Alternatives to SIP servlets: CPL

slide-35
SLIDE 35

Simon Pietro Romano – AT 2011 35

SIP CGI http://www.ietf.org/rfc/rfc3050.txt

  • Defines a communication channel between the SIP server and the

application scripts

  • Applications scripts (CGIs) can be written in any language
  • Similar in spirit to the invocation of external applications in OpenSER

via 'exec' module

Alternatives to SIP servlets: SIP CGI

slide-36
SLIDE 36

Simon Pietro Romano – AT 2011 36

CCXML - Call Control XML

  • Scriptable, XML based
  • Protocol agnostic
  • Supports variables and dynamic script retrieval

Jain SLEE – Service Logic Execution Environment

  • Protocol Agnostic
  • Event driven
  • Applications defined as a composition of components

A few more pointers: CCXML and JSLEE

slide-37
SLIDE 37

Simon Pietro Romano – AT 2011 37

JSLEE - Concepts

  • Specification Defined by the JCP, v1.1 (JSR 240)
  • SLEE = Service Logic Execution Environment
  • High throughput, low latency event processing.
  • Built-in support for HA (High Availability) and scalability
  • Asynchronous support & Event oriented
  • Elaborated event distribution mechanism (with priority)
  • Mapping of events and method invocation on components
  • Creates components instances in response to initial events
  • Independent of underlying networks through Resource

Adaptors

  • High performing platform for event driven applications
  • SLEE is complementary to Java EE
  • 37
slide-38
SLIDE 38

Simon Pietro Romano – AT 2011 38

  • SIP, H323 or any protocol

Network

Simplified JSLEE Architecture