레이블이 sip인 게시물을 표시합니다. 모든 게시물 표시
레이블이 sip인 게시물을 표시합니다. 모든 게시물 표시

2012년 5월 1일 화요일

[VoIP SIP 알자/11-2. SIP 서비스 Call Flow]

출처 : http://blog.naver.com/mongu2/140123155328



[고급 전화 서비스]
SIP 기반 전화서비스에 대한 기본적인 기대는, 이 서비스가 인터넷에서 구현될 수 있고, 서비스사간의 경계를 없애며,
나아가 개별 회사의 제품이나 소프트웨어에 구애 받지 않을 것이라는 점이다.
   
* 전화통신의 고급 서비스 기능
PBX 및 센트릭스 기능들
사설 구내 교환 서비스(CLASS:Custom Local Area Signaling Services) 기능들
지능망(Advanced Intelligent Network) 서비스
   
기존 PBX 제품들은 상호 연동을 기대할 수 없다. 하지만 인터넷 기반 PBX 서비스들에 대한 표준화는 그 자체로
기존 PBX 시장에 지각변동을 일으키기에 충분하다.
   
[PBX 및 CLASS(사설 구내 교환 서비스) 기능]
   
ㄱ. 호 전환(Call Transfer)
ㄴ. 통화중 대기(Call waiting)
ㄷ. 호 보류(Call Hold)
ㄹ. 호 교체(Call Park and Pickup)
ㅁ. 착신 전환(Call Forwarding)
ㅂ. 발신자 표시(Calling Line Identification)
ㅅ. 수발신 호 걸러내기(incoming and outgoing call screening)
ㅇ. 자동 콜백(automatic callback and recall)
ㅈ. 단축 다이얼
ㅊ. 컨퍼런스 콜
ㅋ. 음성메일
ㅌ. 음성 자동 안내 시스템(IVR)
ㅍ. 최적 라우팅 서비스
ㅎ. 데이터베이스 관련 서비스
   
   
ㄱ. 호 전환(Call Transfer)
크게 4가지의 형태(Unattended, Attended, Consultation Hold, Instant Messaging)가 있으며 REFER 메소드로 구현된다.
   
a. Unattended (무조건 확인 없이 전환)
: 전화를 돌려주는 측이 REFER 메시지를 보낸 후 바로 BYE 메시지를 보내 호 전환 결과에 무관하게 현재 호를 종료한다.
! 아래는 Alice<->Bob 간 통화 중 Alice 가 Carol 로 호를 전환 해주는 과정의 Flow 이다.
   
   
b. Attended (확인 후 전환)
: 일시적인 3자간 컨퍼런싱과 같다. 돌려주는 측은 호 전환 진행상황을 주시하다가 호 전환이 이루어진 것을 확인 한 후
호에서 빠진다. 즉, 통화 연결음 후 통화 완료 후 전환 후 빠지는 방법
! 아래는 Alice<->Bob 간 통화 중 Bob 가 Carol 에게 호를 전환 해주고 빠지는 과정의 Flow 이다.
   
   
c. Consultation Hold (확인 없는 호 전환)
: 돌려주는 측이 REFER 요청에 대한 응답을 기다리는 동안 발신자도 기다리게 한다. REFER 요청에 대한 결과로 호 전환이
성공하면 BYE 메시지를 보내 기존 호를 종료한다. 즉, 통화 연결음만 듣고 전환 후 빠지는 방법
   
d. Instant Messaging
: 돌려주는 측이 메시지에 URI를 보내어 URI를 선택하면 발신자와 호 연결이 된다.
   
   
tip. 시스코 IOS 장비에서 transfer-system
   
   
ㄴ. 통화중 대기(Call waiting)
: SIP 네트워크는 '회선'이라는 개념이 없기 때문에 이와 정확히 일치하는 서비스는 없다. 하지만 수신측에서 현재
통화중인 상태임에도 불구하고 180Ringing 응답을 보낸 후, 현재 호를 중단하고 새로운 호를 받을 지, 아니면 두 번째
호 발신자를 그냥 무시할 지를 결정할 수 있다.
! 아래는 시스코 의 Call waiting 의 Call Flow 이다.
! SIP A<-> SIP B 통화 중 SIP C가 SIP B로 통화를 하게 되면 SIP B에 display 에 두번째 통화가 표현이 되고
! SIP B는 SIP C를 받게 되면 SIP A는 잠시 Hold 상태가 된다. 이후 SIP B는 SIP C와 통화를 한다.
! 중간에 SIP B가 SIP A에게 미디어를 단방향으로 전달하게 하는 INVITE(a=sendonly)로 보내는 것 알 수 있다.
! 이후 SIP B가 SIP A와 통화를 재게 하기 위해서 INVITE(a=sendrecv)를 다시 보내는 것 을 알 수 있다.
   
   
ㄷ. 호 보류(Call Hold)
PSTN에서 이 기능은 매우 다양한다. 간단하게는 전화기의 '보류' 버튼을 눌러서 수화기의 스피커와 마이크를 차단하는
것에서부터 PBX나 ISDN 시스템의 고급 서비스에까지 걸쳐 있다. SIP 에서는 통화중에 re-INVITE 메시지를 보내
미디어 스트림을 양방향 통신에서 단방향(보내기만 하는) 통신으로 변경함으로써 호 보류 기능을 제공할 수 있다.
초기 버전에서는 SDP의 IP 주소를 0.0.0.0 으로 설정한 re-INVITE 메시지가 이 기능을 담당했다. 호 보류의 해제는
0 이 아닌 IP 주소의 re-INVITE 메시지를 보내 양방향 통신으로 변경함으로써 이루어 진다.
! Alice 와 Bob 이 통화 중 Bob 이 hold 후 hole 해제 후 통화 과정의 Flow 이다.
   
   
ㄹ. 호 교체(Call Park and Pickup)
현재 호를 잠시 보류하고 다른 장소에서 호를 재개하는 기능.
SIP에서는 REFER 를 이용한 방식제3자 호 제어re-INVITE를 통한 방식 등이 있다.
!- Call Park 아래는 Alice<->Bob 통화 중 Bob이 REFER 로 Call Park 후 Carol 이 Alice 와 통화를 재개하는 방식이다.
   
!- Call Pickup, Alice 가 Bob에게 전화를 하지만 Bob이 부재중이라서 Bill 이 대신 Bob에게 걸려온 전화를 pickup 한다.
   
   
ㅁ. 착신 전환(Call Forwarding)
착신 전환은 3가지로 형태로 나누어진다. 즉 '통화중/부재중/무조건 착신전환' 이다.
SIP 착신 전환은 [7. SIP 서비스] 에서 알아보았습니다. Proxy 나 UA에서 기능 제공될 수 있습니다.
   
a. 무조건 착신 전환(Unconditional)
! SIP A가 SIP B에게 전화를 하였지만 무조건 착신 전환에 의해 SIP C에게 전화가 걸리게 됩니다.
   
!- 아래는 Alice 가 Bob에게 전화를 하였지만 Proxy에서 Bob의 착신전화측은 PSTN(Gateway측)으로 INVITE 보냄
   
b. 퉁화중 착신 전환(Busy)
! Alice 가 Bob에게 통화를 시도하였으나 현재 Bob(B1) 은 통화 중이라서 486 메시지 후 Bob(B2)로 INVITE 한다.
   
c. 부재중 착신 전환(No Answer)
일정 기간 동안 전화를 받지 않을 시 다른 쪽으로 호를 전환하는 방법이다.
! Alice 가 Bob(B1)에게 전화를 하였으나 일정 기간 동안(TIMEOUT!) Bob(B1)이 응답하지 않으면 Bob(B2)에게 호 전환.
   
   
ㅂ. 발신자 표시(Calling Line Identification)
위 기능은 모르는 사람으로 부터 오는 전화는 미리 차단할 수 있다. SIP 에서는 From 헤더 정보를 통해 간단히 구현 됨.
문제는 From 헤더가 발신 UA에 의해 작성되는 것이기 때문에 정확하지 않을 수 있다. 대안으로 [9. SIP보안]에서 살펴본
Identity 헤더를 통해 From 헤더의 정확성을 검증 할 수 있다.
   
   
ㅅ. 수발신 호 걸러내기(incoming and outgoing call screening)
이 기능은 Proxy 나 UA에서 구현 가능. 메시지의 Request-URI 나 From 헤더를 미리 저장된 허용 또는 차단 URI 목록과
비교하여 적절한 동작을 수행한다. 예를 들면 차단 URI에 해당되면 403 Forbidden 응답을 보내고 호를 차단한다.
발신 호의 경우 UA가 항샹 Outbound Proxy 를 기본으로 사용하도록 설정되어 있다면 그 Proxy 에서 걸러내기 기능을
수행할 수 있다. 수신 호의 경우에도 UA가 Inbound Proxy 하고만 통신하도록 설정되어 있다면 수신 호 걸러내기 기능은
Inbound Proxy 에서 제공될 수 있다.
   
! incoming call screening (수신호 걸러내기)
Alice 가 Bob 에게 전화를 하였지만 Bob의 차단 List 에 Alice 가 있어서 차단 되고 차단에 대한 간단한 응답 멘트를 들음.
   
! outcoming call screening (발신호 걸러내기)
   
   
ㅇ. 자동 콜백(automatic callback and recall)
PSTN 자동 콜백은 발신자 표시 서비스를 이용하여 받지 못한 전화를 다시 걸어준다. SIP에서는 성공하지 못한 이전
INVITE 메시지들의 From 헤더를 이용한다. PSTN 자동 재시도는 상대방이 통화중으로 인해 실패했던 호에 대해
상대방이 통화를 마치는대로 다시 연결해주는 서비스이다. SIP에서는 상태정보 서비스로 간단히 해결된다.
상대방에게 통화를 끝내는대로 알려줄 것을 요청하는 SUBSCRIBE 메시지를 보내고 NOTIFY 메시지를 통해 자동으로
INVITE 메시지를 다시 보내도록 한다. [6장] 참고
   
! Alice 가 Bob 에게 전화를 하였으나 Bob 이 통화 중이다. Bob은 AutoCallBack 기능에 의해서 Subscirbe/NOTIFY 을
통해 Bob가 이후 전화 가능 상태가 되면 NOTIFT를 보내엇 Alice 가 다시 INVITE 가 보내어지게 한다.
   
!- 아래는 시스코의 CallBack 서비스 실행 후
   
   
ㅈ. 단축 다이얼
작은 갯수의 번호만으로 전화를 걸 수 있는 기능. 단축 다이얼 정보는 전화기 또는 망에 저장된다.
! 시스코의 스피드 다이얼 설정 화면(단축 다이얼)
   
   
ㅊ. 컨퍼런스 콜
[14장]에서 다루기로 한다.
   
   
ㅋ. 음성메일
[12장]에서 다루기로 한다
   
ㅌ. 음성 자동 안내 시스템(IVR)
시스템이 자동으로 전화를 받아 음성 안내나 음성 멘트를 내보낸다. 발신자의 음성이나 DTMF 신호(키 패드 입력)
로부터 정보를 수집하여, 필요 시 담당자에게 호를 연결, 즉 전환한다. 이 뒤 제3자 제어 방식으로 구현 가능.
   
ㅍ. 최적 라우팅 서비스
호 설정 경로를 시간, 발신 위치, 트래픽 상황 등에 따라 최적화하여 제공하는 서비스, Proxy 서버에 의해 제공 된다.
   
ㅎ. 데이터베이스 관련 서비스
PSTN망에서는 망과 DB가 분리되어 있어 DB에 접근하는 일이 매우 민감한 문제이다. 반면 SIP은 SIP 장비나 DB 서버나
모두 같은 인터넷에 있기 때문에 DB에 접근하는 것도 간단하다. 보통 HTTP나 FTP가 사용되고 간단한 질의 서비스는
SIP Redirect Server 를 통해 제공된다.
   
   
* 참고
http://www.flypiggy.org/mtwin/tech-invite/ <- SIP Call Flow(강추!)


* 쏠라구구 생각
위 기능들은 대부분의 PSTN에서 제공하는 기술로 VoIP 에서도 거의 필수적으로 구현되야만 하는 기술이라 생각합니다.
해당 서비스 기술들이 어떠한 Call Flow 를 통해서 제공되는지 명확히 알고 있어야 '기능 구현/장애 처리/고객과대화' 를
유연하게 처리할 수 있을거라 생각합니다. 물론 장비/단말에서도 지원이 되어야 겠지요.


2012년 1월 19일 목요일

port exosip to android

출처 : http://rxwen.wordpress.com/2010/12/20/port-exosip-to-android/


port exosip to android

Port exosip to android platform isn’t a difficult task because exosip doesn’t rely on any special system calls that aren’t available on android. It only requires osip to compile, which can also be easily ported.
As an example, I created two applications to run against exosip lib. One is a native application that can run in android shell, the other is an java application that interact with exosip through jni. The dependency relationship between modules is:
The diagram below depicts the organization of files. They’re organized this way so that they can be compiled through androidndk build system.
exosip_root (NDK_MODULE_PATH environment variable points here)
To comply with ndk build system’s requirements, we create a directory named jni under sip_jni and sip_exe module, and place actual source file there. The Android.mk and Application.mk (optional) are placed in the jni directory as well. Keeping files this way, we can issue ndk-build command right in sip_jni or sip_exe directories to compile applications.
Note that we don’t create jni directory for libosip and libexosip, their Android.mk is placed directly under libosip and libexosip directories. This is because they are dependent on by application modules. We don’t need compile them directly, instead, the build system will build them automatically while building applications. In order to help build system find libosip and libexosip, we must set NDK_MODULE_PATH environment variable to the directory that directly containing  libosip and libexosip. The build system will search for them based on directory name, so their names matter.
To port exosip to android, the essential task is to create theAndroid.mk file, which specifies source files, c flags, ld flags, dependent libraries. We define HAVE_TIME_H and HAVE_SYS_SELECT_H to compile exosip successfully. And we define ENABLE_TRACE and OSIP_MT to enable logging and multi-threading. In the last line, $(call import-module,libosip) tells the build system that exosip depends on osip, and all header files exported by osip (LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_C_INCLUDES))  will be included by exosip automatically. 
import-module is a feature that isn’t available in the build system in android source tree. It enables us organizing our projects in arbitrary manner. For example, we can place libosip and libexosip directories in another directory. The build system can still find them as long as NDK_MODULE_PATH is set to the directory containing them. It’s much more flexible than specifying dependency relationship with relative path.
Sample:
The sample for this post is available at:
http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/android/exosip_sample/
It shows how to:
  1. use ndk build system
  2. use stl in c++ code
  3. create a very basic exosip application
  4. call native code from java
  5. call java code from native code

An basic introduction to SIP

출처 : http://rxwen.blogspot.com/2009/11/basic-introduction-to-sip.html


An basic introduction to SIP

What is SIP
SIP Protocol is one of widely used signaling protocol, with the main purpose of, as its name is abbreviated for, initialization session between several participants. Due to its nature, it's mainly used in VOIP, IM applications.

Basics of SIP
Because SIP is always mentioned together with other multimedia application protocols such as SDPRTP. They are so mixed up that easily confuse beginners, like me. To make things clear, it's necessary to know SIP has nothing to do with those protocols. It can be used independently with SDP and RTP. SIP is just being lucky to be employed to work with them in many situations.
In short, their relationship is:
SDP describes the capabilities and preferences of a participant. Usually, it's included in the payload of SIP message.
SIP is the message flow that enable two or more participants to negotiate, setup, modify and terminate a session.
RTP is the protocol for transferring audio or video data after the session has been established, it usually relies on the information contains in SDP.

SIP is a text based protocol with request/response transaction model, similar to HTTP. Unlike HTTP, whose request and response always comes in pairs, SIP's request and response doesn't hold a one on one relationship. A SIP transaction may have multiple request and multiple response.
The format of SIP message is similar to HTTP's too. A message is composed of a start-line(includes method, request-uri and sip-version), several headers and a message body.
Like SMTP, the recipient of a message doesn't have to be directly accessible to the sender. A message may hop several times before it reaches the destination with the help of Proxy Server.

To better understand SIP protocol, the document SIP Protocol Structure through an Example provides a thorough illustration and it's good material for getting start.

SIP Libraries
PJSIP is a powerful sip library implemented in c. Besides SIP, it also support SDP, and has strong multi-media processing capability. It exposes APIs at different layers so that users can pick either a convenient or flexible API set at their will. It's also a highly portable library can run many operating systems, including windows and linux. The best thing is it has complete document which is rare in open source project.
MJSIP is a java based sip library with SDP, RTP supporting. It's also a convenient and complete solution for building VOIP application. But I'd say the library still have room to improve the quality, for there are some apparent spelling mistakes.
OSIP is part of of gnu project, implemented in c. By following the "do one thing, and do it well" philosophy, it solely focus on SIP and is a light weight, fast library.

References:
http://www.ietf.org/rfc/rfc3261.txt
http://en.wikipedia.org/wiki/Session_Description_Protocol
http://en.wikipedia.org/wiki/Real-time_Transport_Protocol