Click here to Skip to main content
15,894,017 members
Articles / Programming Languages / C#
Article

SIP Stack with SIP Proxy - (VOIP)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (45 votes)
11 Jun 2007CPOL2 min read 1.6M   28.1K   162   354
C# implementation of SIP
Screenshot - proxy.jpg

SIP Overview

SIP is an application-layer control protocol that can establish, modify, and terminate multimedia sessions (conferences) such as Internet telephony calls. SIP can also invite participants to already existing sessions, such as multicast conferences. Normally SIP uses UDP and TCP port 5060 and TCP 5061 for SSL communication. SIP protocol is very similar to HTTP, so if you have some knowledge about HTTP, then it is easy to learn SIP. SIP doesn't transfer session data like audio, video. RTP(real time protocol) is used for that, SIP just helps to open RTP streams.

SIP Message Example

INVITE sip:john@domain.com SIP/2.0
From: <sip:doe@domain.com>;tag=2084442460
To: <sip:john@1domain.com>
Via: SIP/2.0/UDP domain.com:5060;branch=z9hG4bK2df7b9194cd51e25
Call-ID: john@domain.com-4524j
CSeq: 1 INVITE
Contact: <sip:doe@domain.com:5060>
Content-Length: 226
Content-Type: application/sdp

<session description data, like RTP description>

SIP Server Types

statelessSIP server doesn't store any transaction info.
statefullSIP server creates and holds SIP commands transaction state.
registrar/location Allows users to register their locations and later to use that info to forward calls to registered contact.
B2BUASIP server is like statefull + holds active calls state.(This is needed if call billing or full control of call is needed)
presence Provides user availability services, like if user is online,offline, ... .
...There are some more, but not so important ones.

Basic SIP Commands

  • INVITE - Initiates a session. This method includes information about the calling and called users and the type of media that is to be exchanged.
  • ACK - Sent by the client who sends the INVITE. ACK is sent to confirm that the session is established. Media can then be exchanged.
  • BYE - Terminates a session. This method can be sent by either user.
  • CANCEL - Terminates a pending request, such as an outstanding INVITE. After a session is established, a BYE method needs to be used to terminate the session.
  • OPTIONS - Queries the capabilities of the server or other devices. It can be used to check media capabilities before issuing an INVITE.
  • REGISTER - Used by a client to login and register its address with a SIP registrar server.

Ok, some ABC done, there are many documents on the internet, so it is not a good idea to rewrite these there.

If want more advanced information, then see:

SIP Proxy Demo Overview

This SIP proxy example just implements fully functional simple stateless, statefull, b2bua proxy. You can use hardware SIP phones or soft phones to play with this proxy.This is an advanced example, code is well commented, so beginners don't hate me because no more text here. Just read RFC 3216, see information links I noted earlier. After you go through those, if you then look at the code, it is all nicer then.

Some free available softphones are:

Version:
    11.06.2007
        *) Added B2BUA support.
    07.04.2007 
        *) Many bug fixes. 
        *) SIP -> PSTN and PSTN -> SIP gateway support. 
        *) Non-SIP URI gateway support. 

Contact Details

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: need help for SIP to PSTN call Pin
Ivar Lumi4-May-10 20:24
Ivar Lumi4-May-10 20:24 
GeneralRe: need help for SIP to PSTN call Pin
ASGuru4-May-10 20:28
ASGuru4-May-10 20:28 
GeneralRe: need help for SIP to PSTN call Pin
ASGuru7-May-10 23:51
ASGuru7-May-10 23:51 
GeneralRe: need help for SIP to PSTN call Pin
Ivar Lumi8-May-10 0:10
Ivar Lumi8-May-10 0:10 
GeneralRe: need help for SIP to PSTN call Pin
ASGuru8-May-10 0:16
ASGuru8-May-10 0:16 
GeneralRe: need help for SIP to PSTN call Pin
ASGuru10-May-10 20:35
ASGuru10-May-10 20:35 
Questionhow much client we can connect? Pin
ASGuru23-Apr-10 21:12
ASGuru23-Apr-10 21:12 
GeneralConfused about the basic settings Pin
filipcz19-Apr-10 6:16
filipcz19-Apr-10 6:16 
Hello,thank you for a very nice project!
Would you be so kind and adviced me on the basic setting of this proxy please? I have a Asterisk PBX (lets say 10.0.0.108) and an zoiper softphone (10.0.0.21). If I setup the zoiper to register its extension directly to the Asterisk, the softphone registers, I can make calls, etc:
Zoiper(10.0.0.21)--->Asterisk(10.0.0.108)
However if I try to setup your SIP_Proxy_demo between the two (lets say on an IP 10.0.0.101):
Zoiper(10.0.0.21)---> SIP_Proxy_demo(10.0.0.101) --->Asterisk(10.0.0.108)
the zoiper softphone wont register (I changed the "domain" for the account from 10.0.0.108 to 10.0.0.101) - I get the message "SIP/2.0 407 Proxy Authentication Required". In the SIP_proxy_demo setting I leave the "hostname" empty, in the users I add the same credentials that worked allright in the softphone without proxy (eg 3000,password,3000@10.0.0.108) + press the "Play" button.
Please could you point me to what am I doing wrong? Should I fill the "hostname" settings in the SIP_proxy_demo with the IP of the asterisk? Or add the asterisk IP to the "gateways" tab?
Thank you for any information!
Generalthe size of source code Pin
sntslm22-Mar-10 17:08
sntslm22-Mar-10 17:08 
GeneralSample is not working properly.,. Pin
sajithkalady19-Mar-10 0:40
sajithkalady19-Mar-10 0:40 
Generalthanks from PH Pin
mdingalla18-Oct-09 20:09
mdingalla18-Oct-09 20:09 
GeneralGeneral comment Pin
mapick3-Oct-09 6:36
mapick3-Oct-09 6:36 
GeneralSIP Client Pin
Binni shah2-Oct-09 2:53
Binni shah2-Oct-09 2:53 
GeneralRe: SIP Client Pin
Ivar Lumi2-Oct-09 3:00
Ivar Lumi2-Oct-09 3:00 
GeneralRe: SIP Client Pin
Binni shah2-Oct-09 3:04
Binni shah2-Oct-09 3:04 
QuestionUDP to TCP UA Pin
rudacunhasilva24-Aug-09 6:34
rudacunhasilva24-Aug-09 6:34 
QuestionSIP TCP Pin
rudacunhasilva20-Aug-09 14:48
rudacunhasilva20-Aug-09 14:48 
QuestionSIP_Gateway Pin
rudacunhasilva18-Aug-09 10:15
rudacunhasilva18-Aug-09 10:15 
AnswerRe: SIP_Gateway Pin
Ivar Lumi18-Aug-09 19:36
Ivar Lumi18-Aug-09 19:36 
QuestionHow to run both SIP Proxy and a client in the same computer? Pin
kaiwnyt10-Jul-09 15:36
kaiwnyt10-Jul-09 15:36 
AnswerRe: How to run both SIP Proxy and a client in the same computer? Pin
Ivar Lumi12-Jul-09 20:25
Ivar Lumi12-Jul-09 20:25 
GeneralRe: How to run both SIP Proxy and a client in the same computer? Pin
kaiwnyt14-Jul-09 17:32
kaiwnyt14-Jul-09 17:32 
QuestionSystem.IndexOutOfRangeException: Pin
gokhanuslu17-Jun-09 4:18
gokhanuslu17-Jun-09 4:18 
Generalis there is client Pin
el3ashe211-Jun-09 2:54
el3ashe211-Jun-09 2:54 
GeneralRe: is there is client Pin
Ivar Lumi11-Jun-09 6:32
Ivar Lumi11-Jun-09 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.