Post on 23-Dec-2015
Vakgroep Informatietechnologie
Deel III: Paradigma’s Software Ontwikkeling
4. Ontwerp van Telecom Services
Prof.Dr.Ir. Filip De Turck
Vakgroep Informatietechnologie
Domotica Telecom Services
Software Ontwikkeling I
Home Use case
Television
Television
Service GatewaySiemens Pylix / Porta
RFID reader
RFID reader
User with tag and PDA
1
Multimedia Content Provider
1
1
Software Ontwikkeling I
Need for User Priorities
Television
Television
RFID reader
RFID reader
User with tag and PDA
2
Multimedia Content Provider
1
2
2
User with tag and PDA
1
User Priority
1 3
2 5
Service GatewaySiemens Pylix / Porta
Home Use Case (with user priorities) :
User Policies are not
supported in OSGi
-> research topic
Software Ontwikkeling I
Need for Service Priorities
User with PDA
Television
Television
Service Gateway
RFID reader
RFID reader
1
Multimedia Content Provider
End user Service
Priority
Video on demand
1
Surveillance 9
User without valid RFiD tag
Home Surveillance
Service
1DANGER
DANGER
Home Use Case (with user priorities) :
Software Ontwikkeling I
User with PDA
Television
Television
Service Gateway
RFID reader
RFID reader
1
Multimedia Content Provider
End user Service
Priority
Video on demand
1
Surveillance 9
User without valid RFiD tag
Home Surveillance
Service
1DANGER
DANGER
Home Use Case (with service priorities) :
Software Ontwikkeling I
Technical realization of user and service policy enforcement
Television
Service Gateway Multimedia Content Provider
End user Service
Priority
Video on demand
1
Surveillance 9
Home Surveillance
Service
UPnP Media Streamer
UPnP Media Render
OSGi Service Gateway
Software Ontwikkeling I
Home networks
Intelligente Router Gateway tot het home netwerk Besturing security systeem
Software + framework Complete afscherming
gebruiker (black box)
Home netwerk Apparaten Protocollen
Vermelde technologieën X10 OSGi
Software
Elektriciteitsnet
X10
USB
Software Ontwikkeling I
X10
Intelligente router
Apparaat
X10 Controller
X10 Module
Lichtnet
opdracht
adres commando Voor mij?
Software Ontwikkeling I
Cross compiling
Makefile
CC=/usr/crossdev/mips/bin/mips-linux-gccLD=/usr/crossdev/mips/bin/mips-linux-ldall: testtest: test.c $(CC) -g -c test.c $(LD) -o test test.o –lc –lx10# $(CC) -static -o test test.c libx10.aclean: rm -f test *.o
Software Ontwikkeling I
Example Code#include <stdio.h>#include "x10_api.h"
void new_error_handler(int code, char *arg, struct x10_status_t *status);
void function_hook(unsigned char house, int unit, int function, int dim_level, struct x10_status_t *status);
int main(int argc,char **argv) { struct x10_status_t *status; int return_code;
/* We open the API */ if(!(status=x10_open("/dev/ttyS0", new_error_handler,
function_hook, 10000000))) { fprintf(stderr,"Could not open the serial port %s !\
n",argv[1]); exit(1); }
printf("\n\nNow turning ON the A5 module ...\n"); return_code = x10_send_cmd('A', 5, X10_CMD_ON, 0, status); printf("x10_send_cmd return code = %d\n",return_code);
x10_close(status);}
Vakgroep Informatietechnologie
Enabling Java-based VoIP backend platformsthrough JVM performance tuning
Software Ontwikkeling I
Outline
Introduction Java 4 Telecom Evaluation Setup Java Virtual Machine
Default behavior Possible Optimizations Optimized Behavior
Results Conclusions
Software Ontwikkeling I
Introduction
Software backend platforms are increasingly popular in VoIP offerings.
Java is currently one of the most popular programming languages for implementing business logic.
Is Java suitable for implementing VoIP and telecom related applications?
Java Application Servers for Telecom related applications are emerging: SIP Servlet JAIN SLEE
Software Ontwikkeling I
Telecom Applications: VoIP
Telecom related applications have very specific requirements Low Latency High Throughput
Example: Softswitch How fast can it set up a call? How many calls can in set up per second?
Java 4 Telecom?
Software Ontwikkeling I
Java Virtual Machine: Features
Java Byte Code is executed by a virtual Machine This makes it platform independent
Java features automatic Memory Management and a Garbage Collector This simplifies the task of the developer
Software Ontwikkeling I
Java Virtual Machine: Problems
Java Byte Code is executed by a virtual Machine This can be a performance penalty
Java features automatic Memory Management and a Garbage Collector This can cause a performance penalty due to
unpredictable behavior of the system.
Software Ontwikkeling I
Evaluation: Proxy 200 benchmark
OK [200]
BYE
ACK
OK [200]
Ringing [180]
Trying [100]Invite
Invite
Ringing [180]
OK [200]
ACK
BYE
OK [200]
Media transfer
Alice Proxy Bob
Measured Time Interval
No Media Session started when
benchmarking
Software Ontwikkeling I
Evaluation Setup: Hardware
Alice
Bob
Proxy
Perform routing
Internet
Dual Opteron1.6Ghz 2GB RAMLinux kernel 2.6
Software Ontwikkeling I
Evaluation Setup: Software
SIP Servlet BEA Weblogic SIP Server
JAIN SLEE Open Cloud Rhino
Benchmark software SIPp (test tool / traffic generator for the SIP
protocol)
Software Ontwikkeling I
SIP Servlet: Architecture
Container basedLife cycle managementManage network listen
points
Very similar to HTTP-Servlet
SIP Protocol SpecificRequest Response
Model Container
JAIN SIP Servlet API
SIP Stack
…
Application
Ser
vlet
…
Ser
vlet
ApplicationApplication
Ser
vlet
…
Ser
vlet
Ser
vlet
Ser
vlet
Application client
SIP Servlet Server
Container
JAIN SIP Servlet API
SIP Stack
…
Application
Ser
vlet
…
Ser
vlet
ApplicationApplication
Ser
vlet
…
Ser
vlet
Ser
vlet
Ser
vlet
Container
JAIN SIP Servlet API
SIP Stack
…
ApplicationApplication
Ser
vlet
…
Ser
vlet
ApplicationApplication
Ser
vlet
…
Ser
vlet
Ser
vlet
Ser
vlet
Ser
vlet
Ser
vlet
Application client
SIP Servlet Server
Software Ontwikkeling I
JAIN SLEE: Architecture
Container basedLife cycle management
Protocol AgnosticResource Adaptors
allow protocols to be “plugged in”
Manage network Listen Points
Event driven and asynchronous
JAIN SLEEContainer
JAIN SLEE SBB API
SIP RA
JAIN SIP
…
Proxy
SB
B
Act
ivity
ctx
…
Proxy
SB
B
Act
ivity
ctx
…
Application
JCC RA
JAIN JCC
JAIN SLEE Server
JAIN SLEEContainer
JAIN SLEE SBB API
SIP RA
JAIN SIP
…
Proxy
SB
B
Act
ivity
ctx
…
Proxy
SB
B
Act
ivity
ctx
…
Application
JCC RA
JAIN JCC JAIN SLEEContainerJAIN SLEEContainer
JAIN SLEE SBB API
SIP RA
JAIN SIP
SIP RA
JAIN SIP
…
ProxyProxy
SB
B
Act
ivity
ctx
…
Proxy
SB
B
Act
ivity
ctx
…
Application
JCC RA
JAIN JCC
JCC RA
JAIN JCC
JAIN SLEE Server
Application client
Software Ontwikkeling I
0 50 100 150 200 2500
20
40
60
80
100
120
140
160
180
200R
espo
nse
time
(ms)
Call Rate (caps)
Response time as a function of call rate and system load
0 50 100 150 200 2500
10
20
30
40
50
60
70
80
90
100
Sys
tem
Loa
d (%
)
Average response time
50th percentile95th percentile
System load
Results: SIP Servlet (default)
25 ms
50 ms
Software Ontwikkeling I
Cause of the problems?
Memory Management and Garbage Collector
Legend
Heap Usage
GC-Time
GC-occurrence
Tenured Gen.
Young Gen.
long lasting GC
heap resizing
low response time
Image created with gcviewer (http://www.tagtraum.com/gcviewer.html)
Software Ontwikkeling I
Solution: Virtual Machine Tuning
Memory Organization
Garbage Collection
Software Ontwikkeling I
Young generation
Tenured generation
Ede
n
Sur
vivo
rS
urvi
vor
Virt
ual
Virt
ual
Virt
ual
Ten
ured
Per
m
Perm generationTiny Survivor Spaces
Virt
ual
Virt
ual
Ten
ured
Per
m
Ede
n
Memory Tuning
Fixed Young Generation Size
Total Heap Size large enough
Other Generation Sizes NOT Fixed
Software Ontwikkeling I
Default
All generations
Parallel &Concurrent
All generations
Concurrent
Only for tenuredgeneration
Parallel
Only for younggeneration
Garbage Collector Tuning
Long GC pauses
Multi-threaded GC
GC partially parallel with Application Execution
Performance implications:More resources are spent on Garbage Collection
Software Ontwikkeling I
Tuning Options
-Xmx512m -XX:MaxNewSize=32m -XX:NewSize=32m
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10
-XX:+UseTLAB
-XX:MaxTenuringThreshold=0 -XX:SurvivorRatio=128
Sizing of the memory
generations
Selection of the Garbage Collector
Allow multi-threaded memory
allocation
Move long living objects to Tenured
Generation
Software Ontwikkeling I
Problems solved?
Legend
Heap Usage
GC-Time
GC-occurrence
Tenured Gen.
Young Gen.
No long lasting GC
No heap resizing
low response time
Image created with gcviewer (http://www.tagtraum.com/gcviewer.html)
Software Ontwikkeling I
Results: SIP Servlet
0 50 100 150 200 2500
20
40
60
80
100
120
140
160
180
200R
espo
nse
time
(ms)
Call Rate (caps)
Response time as a function of call rate and system load
0 50 100 150 200 2500
10
20
30
40
50
60
70
80
90
100
Sys
tem
Loa
d (%
)
Average response time
50th percentile95th percentile
System load
25 ms
50 ms
Higher CPU load
Improved Latencies
Software Ontwikkeling I
Results: JAIN SLEE (untuned)
0 50 100 150 200 2500
20
40
60
80
100
120
140
160
180
200R
espo
nse
time
(ms)
Call Rate (caps)
Response time as a function of call rate and system load
0 50 100 150 200 2500
10
20
30
40
50
60
70
80
90
100
Sys
tem
Loa
d (%
)
Average response time
50th percentile95th percentile
System load
25 ms
50 ms
Software Ontwikkeling I
Results: JAIN SLEE
0 50 100 150 200 2500
20
40
60
80
100
120
140
160
180
200R
espo
nse
time
(ms)
Call Rate (caps)
Response time as a function of call rate and system load
0 50 100 150 200 2500
10
20
30
40
50
60
70
80
90
100
Sys
tem
Loa
d (%
)
Average response time
50th percentile95th percentile
System load
25 ms
50 ms
Software Ontwikkeling I
Conclusions
Java Technologies can simplify the Design and Management of Telecom and VoIP related applications
Java Virtual Machine Tuning can improve the Java Garbage Collection significantly
Java Application Servers combined with appropriate tuning can meet strict Low Latency Requirements
Vakgroep Informatietechnologie
Telecom Services on handheld devices
Software Ontwikkeling I
Handheld devices – different OS
In-house / specificWindows Mobile
Symbian OSEmbedded Linux
Palm OSBlackBerry
Software Ontwikkeling I
Handheld devices – J2ME
Device / Hardware
Native Operating System
Configuration
ProfileOptional
Packages
Vendor-specificclasses
Applications
• modular and scalable architecture
• Configuration: CLDC / CDC
• Profiles: MIDP / FP / P (basis) P
• Mobile phones: MIDP 2.0
CLDC 1.1
“MIDlet (suite)”
• WMA, MMAPI, Bluetooth APIs
• Nokia UI
Software Ontwikkeling I
Handheld devices – J2ME
Development steps for a MIDP application
1. Compilation using an ordinary Java compiler
2. Conversion of the classes to CLDC format (preverification)
3. Creation of the manifest file
4. Packaging into a JAR-file (+ creation of the JAD-file)
5. Installation onto the target device
- through WAP
- through PC-connection (e.g. Nokia’s PC Suite)
SUN’s WTK
IDE Netbeans Mobility Pack
Software Ontwikkeling I
Handheld devices – J2MECode Examples
• Webaccess - through HttpConnection String getViaHttpConnection(String url) throws IOException { HttpConnection c = null; InputStream is = null; StringBuffer str = new StringBuffer(); try { c = (HttpConnection)Connector.open(url); // Getting the InputStream will open the connection and read the HTTP headers.
// They are stored until requested. is = c.openInputStream(); // Get the length and process the data int len = (int)c.getLength(); int ch; while ((ch = is.read()) != -1) { str.append((char)ch); } } finally { if (is != null) is.close(); if (c != null) c.close(); }
Software Ontwikkeling I
Handheld devices – J2MECode Examples
• SIP - JSR 180 “SIP API for J2ME”
- defined as Optional Package
- minimum requirements: CLDC 1.0
public void sendTextMessage(String msg) {
SipClientConnection sc = null;
try {
// open SIP connection
sc = (SipClientConnection) Connector.open("sip:sip.example@host.com:5060");
// initialize SIP request MESSAGE
sc.initRequest("MESSAGE", null);
// set some headers
sc.setHeader("From", "sip:user@host.com");
sc.setHeader("Subject", "testing...");
...
Software Ontwikkeling I
Handheld devices – J2MECode Examples
...// write message bodysc.setHeader("Content-Type", "text/plain");sc.setHeader("Content-Length", Integer.toString(msg.length()));OutputStream os = sc.openContentOutputStream();os.write(msg.getBytes());os.close();// close stream and send the message to the network// wait max 15 seconds for responsesc.receive(15000);// response receivedif(sc.getStatusCode() == 200) {
// handle 200 OK response } else {
// handle other responses } sc.close();
} catch(Exception ex){// handle Exceptions }
}
Software Ontwikkeling I
Handheld devices – J2MECode Examples
Video Service - JSR 135 MMAPI (Mobile Media API)- provides a framework for playing media content - designed to run with any protocol and format
The method below plays a video file the on mobile device:... Player p;VideoControl vc;try {
p = Manager.createPlayer(“rtsp://server/somemovie.mpg");p.realize();// get video controlvc = (VideoControl) p.getControl("VideoControl"); .... p.start();
} catch(IOException ioe) { } catch(MediaException me) { } ...
Note: This will only work on devices which support real time input streams!
Software Ontwikkeling I
Handheld devices -Windows CE
Windows CE = a modular OS that serves as the foundation of several classes of devices
Windows Mobile = a subset of platforms based on Windows CE
- high market share in the PDA market (~50%)
- 2003 - Pocket PC
- Smartphone
- Pocket PC Phone Edition
- 5.0 - Pocket PC
- Smartphone
- Portable Media Center
The Operating System
Software Ontwikkeling I
Handheld devices - Windows CE
Software development
• native code - Visual C++
- high performance
- direct hardware access
- smallest footprint
• managed code through the .NET CF
- Visual Basic and Visual C#
- Rapid Application Development
- No bad pointers or memory leaks
Software Ontwikkeling I
Handheld devices - Windows CE
- subset of the .NET framework
- base class libraries + few additional libraries
- 2 versions : 1.0 (2003 / 2003 SE) & 2.0 (5.0)
.NET Compact Framework
VisualC#
code
VisualC#
code
Visual Basiccode
Visual Basiccode
Compiler
Compiler
Common Intermediate
Language
Common Intermediate
Language
Common Intermediate
Runtime
Common Intermediate
Runtime
01110100101011010101
Common Language Infrastructure
Software Ontwikkeling I
Handheld devices - Windows CECode Examples
• Webaccess - through System.Net.WebClient The following example takes the URI of a resource, retrieves it, and displays the response.
…if (args == null || args.Length == 0) { throw new ApplicationException ("Specify the URI of the resource to retrieve."); } WebClient client = new WebClient ();
// Add a user agent header in case the requested URI contains a query. client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead (args[0]); StreamReader reader = new StreamReader (data); string s = reader.ReadToEnd (); Console.WriteLine (s); data.Close (); reader.Close (); }…
Software Ontwikkeling I
Handheld devices - Windows CECode Examples
• SIP
• Since Windows CE 4.2 : VoIP TUI is a fully functional, customizable, and extensible suite of common telephony features for users.
• Third party SIP API : http://www.independentsoft.com/
RTC API Core
SIP
Transmission Control Protocol/Internet Protocol (TCP/ IP)
Media Manager
Windows CE .NET VoIP Middleware(incl. VoIPMgr)
DatabasesProvisioners
MS RTP
Windows CE .NET VoIP UIWindows CE .NET User
Application3rd Party User Applications
Point-To-Point Protocol (PPP)
Serial Drivers
Network Driver Interface Specification(NDIS)
Hardware
Software Ontwikkeling I
Handheld devices - Windows CECode Examples
using Independentsoft.Sip;
using Independentsoft.Sip.Sdp;
…
client = new SipClient("sipdomain.com","Bob","password");
client.ReceiveRequest += new ReceiveRequestEventHandler(OnReceiveRequest);client.ReceiveResponse += new ReceiveResponseEventHandler(OnReceiveResponse);
client.Connect();client.Register("sip:test.com", "sip:Bob@test.com", "sip:Bob@test.com");
Console.WriteLine("Send message to Alice or press \"q\" to exit.");string message = "";
while(message != "q"){Console.Write("Bob:");message = Console.ReadLine(); client.SendMessage("sip:Bob@test.com","sip:Alice@test.com",message);}
client.Disconnect();}
private static void OnReceiveRequest(object sender, RequestEventArgs e) { client.AcceptRequest(e.Request);
if(e.Request.Method == SipMethod.Message){Console.WriteLine("Alice:"+e.Request.Body);}
…
Software Ontwikkeling I
Handheld devices - Windows CE
Code Examples• Video service - through e.g. DirectX 9.0 SDK
using Microsoft.DirectX.AudioVideoPlayback;public class MyVideoPlayer : System.Windows.Forms.Form{ ... private void OpenFile() { try { Video ourVideo = new Video("C:\\Example.avi"); ... } } ... }
Software Ontwikkeling I
Handheld devices – Symbian OS
• multitasking OS designed for 2.5G and 3G mobile phones
• very high market share in the smartphone market (~70%)
• the successor of the Epoc OS
• started as version 6.0 and currently into version 9.2
• advanced, open standard OS to its licensees
• (Sony) Ericsson, Nokia, Panasonic, Samsung and Siemens
• software development: J2ME and Symbian C++
The Operating System
Software Ontwikkeling I
Handheld devices – Symbian OS
• ≠ standard C++
• offers highest performance and functionality on Symbian OS
• 4 standardized software frameworks
Resolution (pixels) User Interaction
UIQ 208-240 x 320pen-based
(+ small keyboard)
Series 60 176 x 208 central navigation key
Series 80 / 9200 Series 640 x 200 full keyboard
Series 90 640 x 320 pen-based
Symbian C++
• code not complete portable between the different frameworks ( ~ 80 %)
Software Ontwikkeling I
Handheld devices – Symbian OS
Code Examples
• Webaccess
void CHttpClient::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod) { ... TUriParser8 uri; uri.Parse(aUri); RHTTPTransaction trans = iSession.OpenTransactionL(uri, *iTransObs, aMethod); ... };
- creating a transaction
- opening a session
class CHttpClient : public CBase, ... {...
private: RHTTPSession iSession; ... };
CHttpClient::CHttpClient() {... iSession.OpenL();
...}
Software Ontwikkeling I
Handheld devices – Symbian OS
Code Examples
• SIP - Nokia plugin for Series 60, 2nd Edition
- integrated in Series 60 Platform, 3rd Edition (v9.1)
iSIP = CSIP::NewL(KAppUid, *iMySIPObserver); iConnection = CSIPConnection::NewL(*iSIP, KIapIdentifier, *iMyConnectionObserver);
- initiation of the SIP client API
- registration of a SIP user
CleanupStack::PushL(aor);
CSIPAddress* addr = CSIPAddress::DecodeL(_L8("sip:user@host.com"));
CleanupStack::PushL(addr);
CSIPContactHeader* contact = CSIPContactHeader::NewL(addr);
CleanupStack::Pop(addr);
CleanupStack::PushL(contact);
CSIPRefresh* refresh = CSIPRefresh::NewLC(); iRegistration =
CSIPRegistrationBinding::NewL(*iConnection, aor, contact, refresh);
CleanupStack::Pop(3);
Software Ontwikkeling I
Handheld devices – Symbian OS
Code Examples• Video service - CVideoPlayerUtility provides a simple interface to
open, play and obtain information from sampled video data. The video data can be supplied either in a file, a descriptor or a URL
- streaming supported ( MVideoLoadingObserver)
class CRMMVideoRenderer : public CBase, public MVideoPlayerUtilityObserver, public MVideoLoadingObserver {private: CVideoPlayerUtility* iVideoPlayerUtility; …}
…iVideoPlayerUtility = CVideoPlayerUtility::NewL( *this, iPriority, iPref, iWindowSession, *iScreenDevice, iDisplayWindowhandle, iDisplayWindowRect, iClipWindowRect )
…// turn on the status reporting for connecting, buffering, and re-bufferingiVideoPlayerUtility->RegisterForVideoLoadingNotification(*this);
…// load a videostreamTRAPD( err, iVideoPlayerUtility->OpenUrlL( iUrl, iIapId, iMimeType, iControllerUid ) ); if ( err != KErrNone ) {
iObserver->ErrorMsg(err);}