resiprocate-intro (tmc voip)

33
Building Applications using reSIProcate Jason Fischl [email protected]

Upload: zephyr-dai

Post on 29-Nov-2014

196 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: ReSIProcate-Intro (TMC VoIP)

Building Applications using reSIProcateJason Fischl

[email protected]

Page 2: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm2 8/1/2004

reSIProcate Background

• VOCAL / Vovida.org

• http://www.resiprocate.org

• Founded Summer 2002

• Part of SIPfoundry http://sipfoundry.org

• Informal organization

• Attended SiPit 12, 13 and 14

• Attending SiPit 15 in Taipei

Page 3: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm3 8/1/2004

reSIProcate Agenda

• Part I

– What is reSIProcate?

– Who should use it?

• Part II

– Programming with reSIProcate

– Examples

– Introduction to DialogUsageManager (DUM)

Page 4: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm4 8/1/2004

reSIProcate Goals

• Standards Compliant

• Easy to use

• Efficient: > 1000 tps

• Small footprint ( < 1 MB)

• Highly portable

• Microsoft Windows support

• Implement SIP Security

Page 5: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm5 8/1/2004

reSIProcate Applications

• Phones (e.g. embedded)

• Softphones (any platform)

• Gateways

• Proxies

• B2BUAs

• IM / Presence Servers or Clients

Page 6: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm6 8/1/2004

reSIProcate Current Features

• UDP, TCP, TLS

• Object-oriented interface

• Lazy Parser

• 3261 compliant

• Asynchronous DNS

• Single or multi-threaded

• DNS support (NAPTR/SRV)

• IPv6

• Multi-homed hosts

• Platforms: Windows, Linux,

BSD, Solaris, QNX, OS/X

• MIME & S/MIME

• Extendable contents

• User Agent Library (DUM)

Page 7: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm7 8/1/2004

reSIProcate Supported RFCs

• Supported RFCs:

– 2327: SDP

– 2617: HTTP Digest

– 2782: DNS SRV

– 2915: DNS NAPTR

– 2976: sip INFO

– 3261: sip

– 3263: Locating sip servers

– 3265: subscribe/notify

– 3420: sipfrag

– 3325: network asserted id

– 3428: sip MESSAGE

– 3326: reason header

– 3515: sip REFER

– 3581: symmetric response

• In Development

– 3323: Privacy mechanism

– 3262: Reliable provisional

– 3264: Offer/Answer

– 3266: IPv6 in SDP

– 3311: UPDATE

– draft-simple-winfo

– draft-sip-session-timer

– draft-sip-caller-prefs

• Drafts: (partial list)

– draft-impp-srv, draft-simple-presence

– draft-sip-replaces, draft-sip-referredby

– Draft-sip-connect-reuse

– draft-sip-join, sip-gruu

– sip-publish, sipping-mwi

Page 8: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm8 8/1/2004

reSIProcate Ongoing Projects

• User Agent Library

• GAIM plug-in

• Documentation

• Presence Server

• SCTP

• Support for large numbers of TCP connections

• Performance improvements

• Footprint reduction

• Dialog Usage Manager (DUM)

Page 9: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm9 8/1/2004

reSIProcate Platforms

• Windows

• Linux

• MAC

• QNX

• Others

Page 10: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm10 8/1/2004

reSIProcate Licensing

• The Vovida Software License, Version 1.0

• BSD-like

• Free

• Can use it in commercial products

• Re-contribution not required

Page 11: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm11 8/1/2004

reSIProcate Deployments

• PurpleComm (http://www.purplecomm.com)

– Proxy, Registrar, Voicemail, Presence Server

– Windows Softphone (http://teltel.com)

• Jasomi Networks (http://www.jasomi.com)

– PeerPoint – Session Border Controller

• Xten Networks (http://www.xten.com)

– eyeBeam

• CSP – Italy (http://www.csp.it)

– IM/Audio/Video UA for Windows

– Conference Server and h.323 gateway in development

• Computer Talk Technology (http://www.computer-talk.com)

– Evaluating use of resiprocate for Contact Center product

Page 12: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm12 8/1/2004

reSIProcate Architecture

TimerQueue

UDP

Transport

FIFO

TLS

Transport

FIFO

TCP

Transport

FIFO

TransportSelector

tx event

add

DNS

request

response

SipStackFIFO

TransactionFIFO

add

app event

events

Application / DUM

MsgScanner

Parsers

Message

Page 13: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm13 8/1/2004

reSIProcate Making a SipStack

• Adding Transports

– TCP, UDP, TLS

– Custom Transports

– IPv6

– Bind to specific interfaces (e.g. eth2)

Page 14: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm14 8/1/2004

reSIProcate “hello world”

• Use Helper class to help construct messages#include “resiprocate/SipStack.hxx”

#include “resiprocate/Helper.hxx”

#include “resiprocate/SipMessage.hxx”

#include “resiprocate/NameAddr.hxx”

using namespace resip;

SipStack stack;

stack.addTransport(TCP, 5060);

NameAddr from(“<sip:[email protected]>”);

auto_ptr<SipMessage> reg(Helper::makeRegister(from, from);

stack.send(*reg);

Page 15: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm15 8/1/2004

reSIProcate SIP Messages

• Let the stack manage its own thread and select call

SipStack stack;

StackThread stackThread(stack);

stackThread.run();

While(usleep(10)) {

SipMessage* msg = stack.receive();

if (msg) {

// process the incoming sip message

delete msg;

}

}

}

Page 16: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm16 8/1/2004

reSIProcate Threading Model

• Single Threaded Mode

– One thread for the entire application

– Manage file descriptors at the app level

• Multi-Threaded Mode

– Optional thread per transport

– Optional StackThread

– DUM + DUM client must be one thread or provide sync

Page 17: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm17 8/1/2004

reSIProcate SIP Headers

• http://www.sipfoundry.org/reSIProcate/using.txt

SipMessage msg;

NameAddr to;

to.uri().user() = “jason”;

to.uri().host() = “teltel.com”;

msg.header(h_To) = to;

msg.header(h_To).displayName() = “Jason Fischl”;

assert(msg.exists(h_To));

msg.header(h_CSeq).sequence()++;

NameAddrs routes = msg.header(h_Routes);

NameAddrs reversed = routes.reverse();

for (NameAddrs::iterator i=routes.begin();

i != routes.end(); ++i)

{

std::cerr << *i << endl;

}

NameAddr firstRoute = routes.back();

routes.pop_back();

Page 18: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm18 8/1/2004

reSIProcate Header Types

RFC name Access Token resip Type

Accept h_Accepts Mimes

Accept-Encoding h_AcceptEncodings Tokens

Accept-Language h_AcceptLanguages Tokens

Alert-Info h_AlertInfos GenericUris

Allow h_Allows Tokens

Authentication-Info h_AuthenticationInfos Auths

Authorization h_Authorizations Auths

Call-ID h_CallID CallID

Call-Info h_CallInfos GenericUris

Contact h_Contacts NameAddrs

Content-Disposition h_ContentDisposition Token

Content-Encoding h_ContentEncoding Token

Content-Language h_ContentLanguages Tokens

Content-Length h_ContentLength IntegerCategory

Content-Type h_ContentType Mime

Content-Transfer-Encoding h_ContentTransferEncoding StringCategory

CSeq h_CSeq CSeqCategory

Date h_Date DateCategory

Error-Info h_ErrorInfos GenericUris

Expires h_Expires IntegerCategory

From h_From NameAddr

In-ReplyTo h_InReplyTo CallID

Page 19: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm19 8/1/2004

reSIProcate SIP Parameters

SipMessage request;

assert(request.header(h_To).exists(p_tag)); // exists

request.header(h_To).param(p_tag) = “jason”; // assign

request.header(h_To).remove(p_tag); // remove

request.header(h_To).uri().param(p_q) = 1.0; // FloatParam

request.header(h_Vias).front().param(p_branch).getTransactionId();

Auth auth;

auth.scheme() = “Digest”;

auth.param(p_nonce) = “blah”; // QuotedDataParam

auth.param(p_algorithm) = “MD5”;

UnknownParameterType p_myparam(“myparam”);

request.header(h_RequestLine).param(p_myparam) = “myvalue”;

Page 20: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm20 8/1/2004

reSIProcate Contents

• Flexible, extensible Content management

• Multi-part MIME

SipMessage invite;

const SdpContents* offer =

dynamic_cast<const SdpContents*>(invite.getContents);

if (offer) {

SipMessage ok; // make from invite request

SdpContents answer; // make from the offer

ok.setContents(&answer);

delete offer;

}

Page 21: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm21 8/1/2004

reSIProcate Examples

• 400 lines of C++

• Look in sip/stateless-proxy for source code

• Good example of header/parameter manipulation

• Uses the transaction layer only

• Runs as a thread

• Also look at sip/presSvr for presence server (SIMPLE)

• Soon to be contributed: load generator using DUM

Page 22: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm22 8/1/2004

reSIProcate Practicalities

• Compilers

– g++, VS.NET, VC++ 6

– Intel compiler

• Build environment

– Windows

– Linux/Unix

– QNX

– MAC OS X

– Solaris

• Namespaces

– All code in resip namespace

• Exceptions

– BaseException

– Must catch

• Assertions

– Can be compiled out

Page 23: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm23 8/1/2004

reSIProcate Logging

#include “resiprocate/Logger.hxx”

#define RESIPROCATE_SUBSYSTEM resip::Subsystem::TEST

using namespace resip;

// can use Log::SYSLOG, Log::COUT or Log::FILE

Log::initialize(Log::COUT, Log::toLevel(“INFO”), argv[0]);

SipMessage msg;

InfoLog (<< “The message is “ << msg.brief());

DebugLog (<< “detail: “ << msg);

Log::setLevel(Log::Debug);

Page 24: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm24 8/1/2004

reSIProcate Contact / Via

• By default, Contact and Via IP address, port and

transport will be filled in by the TransportSelector

• Application can specify it and avoid stack population

• E.g.

SipMessage request;

request.header(h_Contacts).clear();

NameAddr contact; // default nothing filled in

request.header(h_Contacts).push_back(contact);

stack.send(request);

Page 25: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm25 8/1/2004

reSIProcate Outbound Proxy

• Example code

SipMessage request;

Uri outboundProxy;

outboundProxy.host() = “10.1.1.1”;

outboundProxy.port() = 9999;

Request.sendTo(request, outboundProxy);

Page 26: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm26 8/1/2004

reSIProcate Advanced Topics

• TLS

• S/MIME

• Specifying transport interfaces

• TCP connection reuse

Page 27: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm27 8/1/2004

reSIProcate DUM

• Introduction

– DUM makes writing user agents easy

– Hides the complex sip specific stuff

• Usages

– ClientRegistration, InviteSession, ClientPublication,etc.

• Handlers

– InviteSessionHandler, ClientRegistrationHandler

• What can you do with DUM?

– Softphone

– B2BUA

– Load generator

Page 28: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm28 8/1/2004

reSIProcate DUM Benefits

• Manage refreshes for you

– Just set up registration binding and keep it active

– Set up a subscription and keep it active. DUM will let you know when

new updates come in via NOTIFY requests

– Keep an INVITE session active

– Handles forking for you

– Merged requests

– GRUU

• Implements Offer/Answer (rfc 3264)

• Implements PRACK (rfc 3262)

• Manage Profile information such as authorization

• Implements UAC and UAS

Page 29: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm29 8/1/2004

reSIProcate Usages

Page 30: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm30 8/1/2004

reSIProcate Contributors

• Companies:

• Organizations

– Vovida.org

– SIPfoundry

• Contributors:– Adam Roach, [email protected]

– Alan Hawrylyshen, [email protected]

– Bob Bramwell [email protected]

– Bryan Ogawa [email protected]

– Cullen Jennings, [email protected]

– David Bryan, [email protected]

– David Butcher, [email protected]

– Derek MacDonald, [email protected]

– Jacob Butcher, [email protected]

– Jason Fischl, [email protected]

– Ken Kittlitz <[email protected]>

– Kevin Chmilar, [email protected]

– Robert Sparks, [email protected]

– Rohan Mahy, [email protected]

– Ryan Kereliuk, [email protected]

– Scott Godin, [email protected]

Page 31: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm31 8/1/2004

reSIProcate How to Contribute

• Subscribe to mailing list

• Get subversion access

• http://www.resiprocate.org

Page 32: ReSIProcate-Intro (TMC VoIP)

Jason Fischl, PurpleComm32 8/1/2004

reSIProcate Contact

• Jason Fischl

[email protected]

– http://www.sipfoundry.org

– http://www.resiprocate.org

Page 33: ReSIProcate-Intro (TMC VoIP)

Building Applications using reSIProcateJason Fischl

[email protected]