Você está na página 1de 18

Asterisk Scalable Communications

Framework – Developer APIS

Kevin P. Fleming
Director of Software Technologies
Framework for communications systems

 Introduced at AstriCon in October, 2010


 Designed to address long-standing needs
expressed by the global Asterisk community
 Four focus areas:
– Performance
– Scalability
– Fault-Tolerance/Redundancy
– Extensibility

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


In some ways like Asterisk 1.x

 Multi-protocol
 Intended to be a communications network
element, not transparent
 Flexible and programmable
 Designed to be used by developers; not a
'packaged solution'
 Neither are written in Visual Basic

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


In some ways very different

 Multi-platform (POSIX and Windows)


 Distributed architecture
 Single-function components
 Leverages existing tools and libraries
 Native developer control using existing
programming languages
 No 'internal' or 'external' APIs; all components
use the same APIs
 Framework not limited to 'session' type
communications

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Distributed architecture

 Components implement single 'functional


blocks'
 Connections between components use well-
defined version controlled APIs
 APIs are logical interfaces, not tied to specific
implementations
 Even state replication for failover is performed
using such APIs, so many different replication
mechanisms can be used

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Component communication

 Components communicate using Ice (Internet


Communications Engine) from ZeroC, Inc.
 Ice is a lightweight object middleware and
messaging platform
 APIs defined using Slice, a simple interface
definition language
 Slice APIs supported natively in C++, C#, Java,
Objective-C, Python, Ruby and PHP
 Developers interact with APIs and remote
objects using native methods in their language
of choice

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 SIP components (Session Gateway,


Messaging Gateway, Presence Gateway,
Registration Manager) implement
authentication mechanisms, but not policy
 Authentication policy is 'business logic' and
should be provided by an additional
component
 SIP components provide an authentication
Extension Point, where one (or more)
additional components can attach hook(s) to
determine when authentication should be
requested

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Extension Point provides various pieces of


information to hook when SIP request is being
processed:

enum Transport
{
UDP,
TCP,
TLS
};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Extension Point provides various pieces of information


to hook when SIP request is being processed:

class RequestInfo
{
// The display name in the From header
string fromName;
// The URI in the From header
string fromURI;
// URI parameters in the From header
ParamDict fromParams;
// The display name in the To header
string toName;
// The URI in the To header
string toURI;

};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Hook returns object to Extension Point


indicating whether authentication should be
requested and details required:

enum DigestAlgorithm
{
MD5,
MD5sess,
AKAv1MD5,
AKAv1MD5sess,
AKAv2MD5,
AKAv2MD5sess
};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Hook returns object to Extension Point


indicating whether authentication should be
requested and details required:

class DigestChallenge
{
string username;
string password;
StringSeq domain;
string realm;
StringSeq nonce;
StringSeq opaque;
DigestAlgorithm algorithm;
};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Hook must implement interface that Extension


Point expects:

sequence<DigestChallenge> DigestChallengeSeq;

interface AuthHook
{
HookResult getAuthChallenge(
RequestInfo info,
out DigestChallengeSeq challenge);
};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


API Example: SIP Authentication

 Hook needs to add itself to Extension Point:

enum RequestType
{
DialogEstablishing,
OutOfDialog,
InDialog
}

sequence<RequestType> RequestTypeSeq;

interface SipExtensionPoints
{
HookId addAuthHook(AuthHook *hook,
RequestTypeSeq types);
void removeAuthHook(HookId id);
void clearAuthHooks();
};

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Putting it all together

 Hook can be implemented in any language


supported by Ice, and operate on any platform
the user wishes to use
 SIP component being hooked can be in a
different language, on a different platform, on
a different computer, in a different location, or
any combination
 Simple hook interface allows developer to
focus on the actual logic the hook needs to
implement, not mechanics

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Let's see some examples

 Warning (1): Examples will be displayed using


Emacs. If this offends you, feel free to leave
the room.
 Warning (2): Examples are written in Java and
Python, and the author's Java-fu and Python-
fu are weak. Be gentle with criticism :-)
 And now on to the code...

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


More information

 Asterisk SCF
– https://wiki.asterisk.org/

 Ice (Internet Communications Engine)


– http://www.zeroc.com/

 Example Code
git://git.asterisk.org/team/kpfleming/fosdem2011

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Questions?

Creative Innovation – Customer Satisfaction – Continual Quality Improvement


Thank You!

Creative Innovation – Customer Satisfaction – Continual Quality Improvement

Você também pode gostar