Ozeki VoIP SDK - Product Guide
Developers Guide
How to build a PBX
This guide provides step by step instructions on how you can build a simple PBX using the superb background support of Ozeki VoIP SIP SDK. After reading through this page you will be fully familiar with all the essential terms concerning the basics of PBX building and what you will need for creating your own solution using Ozeki VoIP SIP SDK.
Introduction
The Private Branch Exchange (PBX) system is a hardware or software solution for establishing the connection between VoIP clients. It basically operates with SIP messages that are sent to and from the clients.
Please be informed that PBX development support is available in Ozeki VoIP SIP SDK from version 10.0. If you use an older version, please update your Ozeki VoIP SIP SDK. You can download the latest version from the download page
The PBX has to be a fully reliable and stable system that can implement the support not only for the basic session initiation protocol but for a lot of related tools and methods. These tools are defined in several RFC (Request for Comments) documents that contain the standard for these.
Figure 1 - A simple PBX system model
The basic RFC document for SIP is RFC3261 that is implemented in Ozeki VoIP SIP SDK. This support is needed in any VoIP communication application. There are some other necessary RFCs to be implemented in a PBX system, like RFC5947, which defines the SIP registration process.
What is a PBX and what can it be used for?
A Private Branch Exchange is a tool for connecting together communication end points in between companies and connecting the company communication systems to the outside world.
The PBX is mainly used for connection establishment between end points. This is done in the PBX system through the Session Initiation Protocol that uses a SIP account for the connection establishment.
A SIP connection line is established between two communication end points in the following way. Both end points need to register to the PBX with a valid SIP account. This registration is done by sending a REGISTER SIP message to the PBX that sends back authentication data to the end point. The registration is done by sending another REGISTER message that contains the authentication information gotten from the PBX.
When the communication end points are registered to the PBX, they can start communication with each other by dialing the extension ID (phone number) of the other end point. When a phone call is started, the call request goes through the PBX that sends it it the remote party. The phone line establishment is done when both communication parties acknowledged the call. When the line is established, the PBX exits the call and the communication between the end points becomes peer to peer.
Basic PBX functionalities
A PBX system can be used for a lot of communication purposes. The following list shows the basic features that should be implements in a PBX.
- Ext1 calls Ext2 - a communication line is established between two extensions of the PBX system. These are usually two company VoIP phones (softphone or physical) that are in the same network.
- Ext1 rings Ext2 and Ext3, and the first one to answer gets the call - a simple example for dial planning, when more than one extensions are ringed at the same time from a third PBX extension. When one of the called extensions answers the call, the other stops ringing and the phone line is established between the caller and the answerer extensions.
- Ext1 calls Phone1 (PSTN) - a VoIP PBX extension starts a cal towards a traditional telephone through the PBX-PSTN connection
- PSTN1 calls Line1 that rings at Ext1 - incoming call handling that arrives from a PSTN end point on Line1 and rings at the Ext1 extension
- PSTN1 calls Line1 that rings at Ext1 and Ext2, and the first one to answer gets the call
The PBX has some advanced functionalities that are for establishing extended communication networks. The PBX can define so called dial plans that are sets of rules for the calling procedures. In a default case when a communication party calls a number, the extension with that number will ring and in case of no answer the call will stop at some point.
A more sophisticated dial plan can define more advanced calling protocols. For example you can specify that when somebody calls the "100" extension, not only that end point, but others should ring and whichever end points answers the call, the others stop ringing and the line establishes between the caller and the answerer.
You can define even more complicated dial plans when the call can be forwarded to other end points after a certain number of rings in case of no answer. This dial planning can be defined in more layers and can even contain a rule for forwarding a call to an answering machine.
Connection to the outside world
A PBX system is the connection point between the PSTN (wired or mobile telephone network) and the VoIP world. In order to connect these two networks, you need to connect your PBX to a service provider that will ensure the actual connection between the networks.
When connected to the PSTN, the traditional telephones can be reached from the VoIP end points and vice versa. This means that you can call a wired telephone from your VoIP phone set or even from a software phone, and you can start communication from a wired telephone toward VoIP communication hardware and software.
The PSTN connection is done by registering PBX extensions for the SIP service provider that will be used for the wired or mobile devices. It means that the PSTN will be seen as one or more VoIP extensions from the VoIP side and the VoIP network will be seen as one or more standard telephone lines from the PSTN side.
The dial planning works in this case too. This means that you can define dialing and ringing rules in the case of outside calls too. As these calls are handled the same way in the PBX as the pure VoIP calls, the dial plans can be used the same way too as in the case of simple VoIP to VoIP communication.
In the next session, you will learn how easy you can implement a VoIP SIP PBX using Ozeki VoIP SIP SDK PBX support. The example program that is introduced in this article is a basic one that implements the core functionalities of a PBX. You will see how easy is to create a simple solution and you will learn how many possibilities you have for defining an advanced PBX solution.
How to implement a simple PBX with Ozeki VoIP SIP SDK
A simple PBX functionality can be implemented with Ozeki VoIP SIP SDK in a really simple way. The default behavior of a PBX is provided by the SDK, but you can redefine any functionality to meet your company purposes.
The following program code uses the background support of Ozeki VoIP SIP SDK, therefore you will need to download and install the SDK on your computer before starting to use the program code. You will also need to have Visual Studio 2010 or compatible IDE and .NET Framework installed on your system, as the program code below is written in C# language.
Step 1 - creating a Visual Studio project
A PBX system can be created as a simple C# console application in Visual Studio. Basically the PBX can run in the background as a service too, but in this example it is a console app.
In order to use the great support of Ozeki VoIP SIP SDK, you need to set the SDK .dll file as a reference in your Visual studio project.
Step 2 - having the Ozeki PBX support
You will need to extend the recompilation directives with some new using lines that specify the Ozeki VoIP SIP SDK packages that contain the PBX support (Code 1).
using Ozeki.VoIP.PBX; using Ozeki.VoIP.PBX.Services;
Code 1 - new using lines for the PBX support
Step 3 - defining the main PBX class
When creating a PBX, your class needs to be derived from the PBXBase class Ozeki VoIP SIP SDK provides. The definition line of the class can be seen in Code 2.
class MyPBX : PBXBase
Code 2 - PBX class definition
Step 4 - setting up the listening port
In the case of a basic PBX, you can automatically register with any SIP accounts. You only need to specify the listening port for the PBX. This is done by overriding the OnStart method of the PBXBase class (Code 3).
protected override void OnStart()
{
SetListenPort(Ozeki.Network.TransportType.Udp, 5060);
base.OnStart();
}
Code 3 - The OnStart method in the PBX class
At this point you have a fully functional PBX system that is capable for registering any SIP extensions and can establish phone lines in between them. In this simple case when two SIP end points are registered to the PBX, the one can call the other with the SIP account information and the called party will ring, and the communication line can be established between them. This is the default behavior of a simple SIP PBX.
Step 5 - extending the PBX functionality with authentication
When you want to specify which extensions you will register and which you will not, you can done it with Ozeki VoIP SIP SDK really simply by overriding the OnRegisterReceived method. In the default case this methods allows any SIP account registrations to the PBX.
In this example code only the SIP account with the "100" username can register to the PBX. This is, of course, not realistic as the SIP communication needs more than one registered account, but the example shows the concept.
protected override void OnRegisterReceived(Ozeki.VoIP.PBX.Extensions.ISIPExtension extension)
{
Console.WriteLine("Register received from: " + extension.Account.DisplayName);
if (extension.Account.UserName == "100")
{
extension.RegisterAccept();
}
else
{
extension.RegisterNotFound();
}
}
Code 4 - Redefining the registration rules
You can also set authentication information for the extensions. In this case, you need to set a password for the extension and call the extension.Authenticate() method. In this case the registration will be succeeded in the case when the extension tried to register with the right authentication data.
Step 6 - setting up dial plans
When you want to define more advanced dialing rules, you will need a new class in your PBX project that is derived from the IDialplanProvider class of Ozeki SDK. You will need to override the GetRoutingRule method for the dialing rules to be set (Code 5).
If you have any questions or need assistance, please contact us at info@voip-sip-sdk.com
You can select a suitable Ozeki VoIP SIP SDK license for building your PBX on Pricing and licensing information page
Related Pages
- Further solutions for PBX development PBX development solutions
- Setup Ozeki SIP SDK quickly with the help of the Quick start guide
- Download Ozeki VoIP SIP SDK form the Ozeki VoIP SIP SDK download page
- You can find licensing information of Ozeki VoIP SIP SDK on Pricing and licensing information page
INTERMEDIATE
VoIP technology walkthrough
Softphone development
Webphone development
Mobile development
Voice recording
GETTING AROUND
Sitemap
Search the manual
API documentation
FAQ
Appendix

