Click here to Skip to main content
Click here to Skip to main content

SIP Stack with SIP Proxy - (VOIP)

By , 11 Jun 2007
 
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

stateless SIP server doesn't store any transaction info.
statefull SIP 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.
B2BUA SIP 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)

About the Author

Ivar Lumi
Estonia Estonia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalvoip sip client with videomemberwaelsys200724 May '11 - 1:33 
Hello,
i would like to ask you if you know any source code for sip client with Video support that works fine ?
 
Thanks
wael
GeneralRe: voip sip client with videomemberIvar Lumi24 May '11 - 2:41 
Hi,
 
Sorry i don't know any.
GeneralA question about RTCPmemberywchen8 Apr '11 - 15:17 
Hi,
 
I have a few questions about RTCP.
Let's assume that a SIP connection between 2 soft-phones, A and B, is established.
1. Subsequently, if A sends a RTCP sender report to B, is B required to send something like ACK back to A?
2. How often is A supposed to send a RTCP sender/receiver report to B?
3. If A sends a RTCP packet with RTP version set to 0 (instead of 2), will B complain and cause some delay?
Thanks.
GeneralRe: A question about RTCPmemberIvar Lumi8 Apr '11 - 20:10 
Hi,
 
>1. Subsequently, if A sends a RTCP sender report to B, is B required to send something like ACK back to A?
No.
 
>2. How often is A supposed to send a RTCP sender/receiver report to B?
It depends how many participants in session. The formula is defined in RTP rfc.
 
>3. If A sends a RTCP packet with RTP version set to 0 (instead of 2), will B complain and cause some delay?
No. Also RTCP is optional.
GeneralRe: A question about RTCPmemberywchen12 Apr '11 - 12:58 
Thanks for your reply.
I am having a problem calling from a landline to a sip client via a sip provider. (Landline-->SIP provider-->Asterisk (NATed)-->SIP client)
The problem is that after a session is established, I always have to wait about 19 seconds before I can hear things from the SIP client.
WireShark shows SIP packets are exchanged properly as soon as a call comes in.
And during the wait, I also see a few "Unknown RTP version 0" packets in WireShark.
 
Some people on the Internet said this may have something to do with incorrect codec, but in my case, I can still hear things from the SIP client.
 
What might be causing this problem? How do I narrow down the problem? Thanks again.
GeneralRe: A question about RTCPmemberIvar Lumi12 Apr '11 - 19:01 
There can be NAT/firewall problems. It't may block data communication on one way.
GeneralSIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52012 Mar '11 - 18:07 
When using the AuthContext.get, the function can get the user name, realm, algorithm...but the password is empty.
What is the problem? In the userInfo of the server can get the password, but when compare witht the e.AuthContext.password, it is empty.
 
In the application: For registration, it need:
Domain : (without port:5060)
User : 100
Password: 123456
Auth ID: 100
Expire Time: 1000
 
In the AuthContext can get username = Auth ID....why not User property?? Is me set the wrong property?
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberIvar Lumi2 Mar '11 - 19:12 
This is because you need to set password: e.AuthContext = password;
Then server authenticates user.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52012 Mar '11 - 19:15 
But in the private void SIP_Authenticate(SIP_AuthenticateEventArgs e)
See the property,it cannot found the value of password.
Where can i set it again?
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberIvar Lumi2 Mar '11 - 19:17 
Server must know user password.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52012 Mar '11 - 19:24 
e.AuthContext = {realm="192.168.1.1",username="100",nonce="613b61d6c7054dcb97b6bc9009fb80a1",nc="1",
cnonce="",response="25a1a0b3f387d627164b93b8f76cdb71",opaque="c9ca6ab13eff454092ec20d02d0fb591",
uri="sip:192.168.1.1"}
 
There is no password in the authContext. And see the property, the value is empty. The other information is correct.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberIvar Lumi2 Mar '11 - 19:26 
As i said already you need to "PROVIDE" password for conecting client there.
If you provide it, server will calculate Digest-MD5 and compares it to client diegst.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52012 Mar '11 - 19:31 
In the client application has provide the password. Using other server, the server can get the password correctly.
But use the same configuration, in the sip proxy server can get the username, realm...only missing password.
So it will show the error 407 proxy authentication.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberIvar Lumi2 Mar '11 - 19:51 
Demo app searches user/word auto matically: If user is created in demo apllication and realm of demo application and connecting client matches.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52012 Mar '11 - 20:05 
When i try the demo version, the log can see the realm is missing.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client application [modified]memberSing52012 Mar '11 - 21:27 
I have try the other client application"X-Lite 4"
 
In Server:
Hostname = 192.168.1.1
Listening Port = 5060
 
create account:
user = 100
pw = 123456
AOR = 100@192.168.1.1
 
In Client:
User ID = 100
Domain = 192.168.1.1
Password = 123456
Display name = 100
Authorization name = 100
 
Domain Proxy
(selected) Register with domain and receive call
Send outbound via: Proxy and IP = 192.168.1.124
 
But use the demo the password is also missing. Do you have idea?
Is setting problem or other problem?
 
Is it possible to change SIP_AuthenticateEventArgs e?

modified on Friday, March 4, 2011 4:11 AM

GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52013 Mar '11 - 14:26 
I have set the breakpoint in the demo. the result is still cannot get the password & realm. In the source,
it can get the realm but lost password.
 
Can you provide the setting of the server account (Hostname, Listening Port, user, password, address of record)
& setting of X-lite (User Id, Domain, password, authorization name, Domain Proxy, Send outbound viaSmile | :) ?
I need to make sure that the setting is correct.
 
I think that the setting of server may be having some problem, coz of the same setting of the client application
can registrar in the other SIP server.
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52013 Mar '11 - 22:27 
If i only have the demo and xlite can i connect them. Is it need to setup another proxy?
I try it every time, but the server is still can get user and realm but no password.
If i see the realm in the log = domain is it ok?
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberIvar Lumi3 Mar '11 - 22:45 
What "demo" ?
GeneralRe: SIP_Authenticate AuthContext cannot get the password of the client applicationmemberSing52014 Mar '11 - 3:00 
the demo project that you provide in the code project.
Generalvoipcorememberabhisoft_abto21 Dec '10 - 0:21 
But voipcore is just an old version of Abto Voip Sip SDK from http://www.voipsipsdk.com/ . Why bother with old versions?
GeneralSIP Stackmembersdfsdfsdfsdfdfgdf30 Sep '10 - 2:55 
I came across this SIP Stack:
 
www.voipcore.com
 
Can anybody share experience using it?
QuestionHow to fix error?memberLý Tầm Hoan30 Jun '10 - 21:26 
System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at LumiSoft.Net.Net_Utils.CreateSocket(IPEndPoint localEP, ProtocolType protocolType) in E:\LumiSoft\Net\Net\Net_Utils.cs:line 380
at LumiSoft.Net.UDP.UDP_Server.Start() in E:\LumiSoft\Net\Net\UDP\UDP_Server.cs:line 171
Generalneed help for SIP to PSTN callmemberASGuru3 May '10 - 1:24 
Hi Ivar,
Im using your SIP Proxy application. I want to know how to enable the SIP to PSTN phone calls and what configuration i have to do .
Please help me on this
GeneralRe: need help for SIP to PSTN callmemberIvar Lumi3 May '10 - 1:35 
Hi,
 
Currently this is only possible for "tel:" URI, and you need to add PSTN gateway in geateway tab.

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 11 Jun 2007
Article Copyright 2007 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid