# Voice over IP/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Voice_over_IP

# Introduction
## Introduction

Voice over IP (or VoIP) is an emerging technology allowing encapsulation of voice telephony services within IP (Internet Protocol) for transmission over IP networks, such as the Internet.
VoIP technology provides cheap and flexible voice telephony by utilizing packet-switched networks for voice data, providing a much cheaper solution than traditional circuit-switched telecommunications services, while also allowing termination of IP calls closer to the intended destination, avoiding long-distance tolls.
With the global prevalence of broadband technology at home, interest in telecommunication technology and a move away from traditional copper line telephony, there is a lot of industry interest in VoIP technology.

## Purpose

This book is intended for those who possess moderate to high computing skills. The initial sections of the book, dealing with VoIP history and simple VoIP deployment for home and small business users, is specifically written to allow those interested in VoIP technology to get an opportunity to try it out without getting too technical. For those more technically inclined, subjects such as VoIP protocol analysis and advanced PBX functions are discussed toward the end of the book.

# Moving Away from Traditional Telephony

There are many compelling reasons for individuals and businesses to invest in Voice over IP. For smaller businesses or home users who frequently make long distance or timed phone calls, to larger commercial ventures looking to reduce costs on site-to-site telephony.
The range of VoIP plans available also allow more flexibility and cost control. Because VoIP termination does not involve any physical rental or consume resources when idle, plans are available on a per-use or prepaid basis, on a monthly subscription basis, or in any number of other configurations.
A successful VoIP deployment requires good planning and a good understanding of the strengths and weaknesses of IP Telephony. Using the right hardware, the right VoIP provider(s), and a customized dialplan can save significant amounts of money.
Both the positive and negative aspects of VoIP technology are detailed in the following sections.

### Benefits of VoIP

Cheaper long-distance - Because VoIP calls can be terminated anywhere in the world, long-distance calls can be made for much cheaper rates. For example, if you are a European VoIP user who frequently calls US numbers, you can purchase VoIP termination credit from a US VoIP provider, which will generally offer near local call prices from anywhere in the world.
Incoming Calls - For the same reason as above, VoIP provides the ability to obtain incoming telephone numbers from anywhere around the world, routed to you over the Internet. It's possible to obtain US 1-800 numbers, for example, no matter what your location.
No copper rental - Without the need for a circuit from your residence or business to your telephone company's exchange, your monthly costs can reduce significantly. Yet, there must be some means of connectivity from the "End User A" who initiates a call onto the Internet. Ostensibly, this connection is either a broadband connection (Cable or Telco DSL), or a "dial-up" connection. In both cases, and in this sense, obviously a copper rental is required.
Dial-Plan freedom - Using a dial plan, you have the ability to direct your softphone, hardware phone or VoIP gateway to send calls to different VoIP gateways or via land-line, depending on the number dialed. You also have the ability to set priority numbers, directing the gateway to drop an existing call in favor of the priority call where no lines are available.
Free IP-to-IP Calls - Where both the caller and recipient are using VoIP to place/receive calls, and where the correct configuration exists (see the section on ENUM at the end of this book), calls can be placed entirely over the Internet without any charge.

### VoIP Issues

As with any new technology, Voice over IP has its share of issues which must be considered carefully before implementation.
Emergency and Information services - There is no guarantee that calls terminated over IP for numbers such as 911 and 411 (in the United States) will be correctly routed. Due to the lack of location-specific termination of Voice over IP calls, it is not possible for such services to determine your location, and it is possible that the gateway your calls are terminating on does not have access to such numbers at all.
This limitation, and suggestions for workarounds, are discussed later in this book.
Bandwidth Issues - VoIP protocols can be very sensitive to both bandwidth limitations and network latency. Generally, VoIP calls must be placed via a broadband connection. Where there is heavy bandwidth utilization, high network latency, or the gateway is a significant distance from the user, call quality can be heavily degraded with the possibility that there will be no VoIP service at all.
See the chapter entitled traffic shaping and bandwidth control later in this book for suggestions on how this can be controlled.
NAT/PAT Issues - NAT (Network Address Translation) and PAT (Port Address Translation) are used to provide connectivity to machines in many situations such as private networks which require Internet connectivity.
With NAT, a gateway/router system will translate an IP address from the source address provided by the machine into another IP address entirely. NAT is often confused with PAT; however NAT provides a 1:1 relationship, eg. 192.168.10.10 will be translated to 203.10.10.10.
PAT is a slightly different translation. With PAT, one or more public IP addresses exist for any number of private/translated addresses. In the most common setup, a home user may have a residential DSL connection and a single public IP address, however they may have several computers on a private network behind their gateway/router which require Internet connectivity.
With PAT, the router/gateway will translate all private IP addresses into the public address provided, and will keep track of which ports established via this address belong to which private IP addresses, allowing the machines to share the public IP address.
VoIP protocols often have inherent issues with NAT and PAT. Due to the prevalence of these gateway devices for cable, wireless and DSL users, even users with single machines may find that PAT is performed by default via their router.
Please see the section immediately below entitled VoIP Protocols for more information on which protocols in particular are affected by NAT and PAT and how to avoid problems.

# Standard Architectures for Next Generation Networks
### IMS(IP Multimedia Subsystem)

IMS is currently in development and testing phases, and was originally developed by 3GPP as an architecture for Mobile Networks.
IMS describes a full architecture that uses IP technologies to transport all traffic (both Voice and Data). It tries to re-use existing protocols defined by IETF and other standards bodies instead of re-inventing the wheel. Some of the protocols it reuses are SIP, MEGACO/H.248, SIGTRAN and DIAMETER.

### TISPAN

TISPAN reuses as much as possible from the IMS architecture and complements it with the required elements to serve fixed/wireless networks.
The work developed by TISPAN is then fed back into IMS.

# VoIP Protocols, Hardware, and Software

The term VoIP is often used to describe general IP telephony technology. Behind this term lies a range of different protocols, languages used to communicate between a range of different devices and vendors.
These protocols are one of the most important factors in choosing a VoIP solution. It is generally impossible to get different devices to communicate, unless they support the same protocol.

### VoIP Protocols

The following protocols are associated with VoIP voice call termination and inter-gateway communication.
H.323 - H.323 is used by many commercial vendors for IP telephony, It is a suite of protocols which includes H.245, Q.931, etc. This suite takes care of session establishment between phone and switch and is heavily based on the Integrated Services Digital Network (ISDN) signalling protocols. Signalling part is also taken care by this protocol. This suite uses RTP, RTCP, RSVP for actual data transfer and QOS between phones.
SIP (Session Initiation Protocol) - SIP is a standard developed by the IETF (Internet Engineering Task Force) for use in establishing multimedia sessions such as voice, instant messaging and video, amongst other applications.
SIP is also responsible for the implementation of other voice session related functions such as holding voice calls, transferring calls, or hosting several voice conversations simultaneously (call conferencing).
SIP utilizes the Session Description Protocol (SDP) to negotiate data types available at either end. Voice and video data carrying is typically performed with the RTP and RTCP protocols.
MGCP (Media Gateway Control Protocol) - MGCP is a protocol typically used internally to systems to represent the whole system as a single entity. MGCP systems are made up of Call Agents and Gateways. The Call Agents keep stateful information and offload the majority of the control work from the Gateway(s). Voice and video carrying is performed by RTP and RTCP.
MEGACO/H.248 - MEGACO is very similar to MGCP and is the standard used for Call Agent architectures.
IAX (Inter Asterisk eXchange) - The IAX protocol was developed by a team of open-source developers working on the Asterisk project, a very popular and successful open-source PBX described later in this document.
There is not much industry support for IAX, however support has been slowly increasing. There has been a lack of good documentation for the IAX protocol, and many commercial vendors are hesitant to give their support to a protocol not ratified by a standards body such as the IETF or ITU.
LTP (Lightweight Telephony Protocol) - the LTP is a binary lightweight protocol that is NAT friendly and based entirely on free codecs. It is easily understood and in use since 1999.

### VoIP Phone Hardware/Software

VoIP hardware and software implementations allow phone calls to be placed over IP. Software which uses a computer's soundcard device to provide voice input and output is known as a Softphone.
Several hardware devices exist to provide VoIP telephony. ATA devices provide standard phone ports, allowing standard phone handsets and other devices such as fax machines to utilize VoIP services. Specialized VoIP handsets are also available, often providing advanced features supported by VoIP gateways.
Hardware phones generally provide a better quality VoIP experience than Softphones; however the convenience of not requiring extra hardware, and the smaller expense involved in Softphone products make softphones a popular choice.

#### Softphones

A softphone is a soundcard device to provide voice input (via microphone) and sound output (via headphones/speakers) without the need for extra hardware. Handsets and headsets are available which plug into the soundcard and resemble normal phone headsets/handsets, making softphone use more comfortable.
A popular open source softphone that runs on both Windows and Linux platforms is ekiga which supports both H.323 and SIP protocols. Xten X-Lite is another popular free Softphone which provides all necessary features to initiate and receive phone calls via SIP. A list of some of the softphones available can be found on voip-info.org here, and on Wikipedia here.

#### ATA Adaptors

`ATA (Analog Telephone Adaptor) Devices provide the ability to connect standard telephone handsets to a hardware unit which provides VoIP capability.
An advantage of ATA devices is the ability to connect other telephony devices, such as TTY devices, FAX machines, Pay TV units and even modems.

# VoIP Gateways and PABX Integration
## Voice over IP Technology
### VoIP Gateway Systems

This chapter deals with the complex world of VoIP gateway systems. These systems are responsible for providing some amount of call control and routing from VoIP phone devices.
Each of these systems is responsible for receiving calls from a VoIP handset, ATA or softphone device via a supported VoIP protocol, consulting a dial-plan or other call routing table, and correctly routing the call. Other features made available by some or all of these gateways include:
Authentication - Ensuring that clients have permission to use VoIP resources.
Call Accounting - Providing tracking of calls via the gateway, including reports and cost controls.
Complex Dialplans - Most dialplans configured on simple devices such as ATAs and softphones only allow for a very straightforward dialplan configuration. Using a VoIP gateway such as Asterisk, factors such as time of day, or even values obtained from external sources can be used to determine which path a call should take.
Hardware Integration - Most gateways provide the ability to interface with physical hardware such as FXS (internal line) and FXO (PSTN line) cards to create a PBX system. They additionally provide the dialplan configuration to determine which calls should route via IP, and which should utilize a card. It is important when selecting gateway software to evaluate which devices they support, and ensure yours is listed. Some devices (for example, Cisco line cards) may require the vendor's specific implementation of VoIP gateway for any support at all.
Internal Numbering - Some gateways offer the ability to provide internal extension numbering for clients, allowing one VoIP device to dial another device registered on your local gateway using a short internal extension number.

#### When would you use a VoIP gateway?

In which situations would you use a VoIP gateway product?
Generally, if you require an advanced configuration such as advanced call accounting for billing, cost controls, complex dialplans, or the ability to call between extensions, you should implement a gateway solution.
If you are interested in integrating extra hardware such as FXO cards (interfaces to the PSTN) you MUST use a gateway product.
If you are designing VoIP solutions for mid-large size business, or will be requiring IVR (Interactive Voice Response) functionality, you should implement a VoIP gateway.
* Open-Source Gateways
* Asterisk
* Bayonne
* OpenSER
* SIP Express Router
* Yate
* YXA

#### Asterisk: The open-source PBX

Asterisk is an extremely popular open-source PBX system which runs on BSD, Linux, Mac OS X, and Windows. The project is sponsored by Digium, a PBX hardware manufacturer.
Asterisk has support for ENUM, e911, Caller ID, all call controls such as Forwarding, Conferencing, Hold, Transfer and Call Waiting. Additional features such as Call Monitoring, Call Recording and Privacy Controls also exist.
In addition to the above, Asterisk is able to provide IVR functions, allowing interactive voice prompts, call queuing, and many many advanced call routing features.
In all, Asterisk is a remarkably full featured commercial-grade PBX system available free of charge.

#### OpenSER

Web page: http://openser.org
OpenSER is a robust and powerful SIP server. Released under GPL, OpenSER is the first free server with integrated TLS, offering secure VoIP communications. It has an architecture designed for scalability and flexibility and high performances.
Main characteristics:
* SIP proxy/registrar/redirect server (RFC3261)
* transaction stateful
* UDP/TCP/TLS support
* modular architecture
* scripting configuration file with pseudo-variables
* authentication, authorization and accounting via database, radius or text files
* enum support
* NAT traversal system
* formatted logging
* least cost routing
* Call Processing Language (CPL)
* MySQL/Postgres/Flat files database backend
* sever monitoring

#### SIP Express Router

Web page: http://www.iptel.org/ser
SIP Express Router (SERi) is a high-performance, configurable, free SIP server licensed under the open-source GNU license . It can act as SIP (RFC 3261) registrar, proxy or redirect server. SER can be configured to serve specialized purposes such as load balancing or SIP front-end to application servers, SEMS for example.
SER features:
* complete support of RFC 3261 functionality,
* a variety of database backends (mysql, oracle, postgres, radius, text-db),
* management features (remote management via XML-RPC, load-balancing),
* NATi traversal, telephony features (LCR, speeddial),
* multidomain hosting, ENUM, presence, and even more.
SER is additionally enhanced by a variety of additional SIP tools, which provide functionality for management, media processing, CDRi processing, etc.
SER is today default part of numerous operating systems and their distributions: Debian, FreeBSD, Gentoo, NetBSD, OpenBSD, OpenSUSE, Solaris.
SER history spans back to the previous century. SER has been used since 2002 for various different purposes, frequently in the industry by major ISPs/ASPs and by universities to enable VoIPi services. SER's particular strength is its performance (SER runs well even under heavy load caused by large subscriber populations or abnormal operational conditions), flexibility (SER's genuine configuration language and module interface allow high degree of customization) and interoperability (tested and operated against tens of SIP products over the years, including but not limited to (Microsoft, Cisco, Mitel, snom, Pingtel, Siemens, xten, and many others).

#### Yate - Yet Another Telephony Engine

Yate is a next-generation telephony engine; while currently focused on Voice over Internet Protocol (VoIP), its power lies in its ability to be easily extended. Voice, video, data and instant messaging can all be unified under Yate's flexible routing engine, maximizing communications efficiency and minimizing infrastructure costs for businesses.
Yate can be used as a:
* VoIP server ****
* VoIP client
* VoIP to PSTN gateway
* PC2Phone and Phone2PC gateway
* H.323 gatekeeper
* H.323 multiple endpoint server
* SIP session border controller
* SIP router
* SIP registration server
* IAX server and client
* IP Telephony server and client
* Call center server
* IVR engine
* Prepaid and post-paid cards system

#### YXA

YXA is a SIP server written in the programming language Erlang at Kungliga Tekniska Högskolan and Stockholms universitet. Erlang was developed by Ericsson to program ordinary telephone switches, with the goal of making a programming system fault-tolerant and robust.
This helps YXA to be a robust SIP server/stack capable of serving tens of thousands of users.
The project's goal is to make YXA compliant to all RFC standards relevant to SIP.
* It is RFC3261 compliant SIP-server, capable of everything a generic domain needs:
** Registrar that keeps track of your users
** Handles incoming SIP requests to your domain
** Handles routing of requests from your users to remote domains
** TCP, UDP and TLS (including SIPS) support
** Automatically maps e-mail addresses of your users to their SIP addresses, if you have the e-mail addresses in LDAP
** Handles multiple domains using a single server instance
* ENUM support for PSTN-bypass whenever possible
* IPv6 support
* Forking, both parallel and sequential
* CPL (RFC3880) support for advanced user-control of events (currently incoming calls only)
* Modular user database, currently with LDAP, Mnesia, MySQL and text-file backends
* PSTN destination access control (per user or for anonymous users)

### VoIP PABX Integration
# Advanced VoIP Configuration
### Correctly terminating emergency calls

Particular attention should be given to ensuring that emergency calls on VoIP lines are handled correctly. In some cases, it may not be possible to provide useful or reliable emergency service via VoIP services. In this case, it may be possible to offload emergency calls to a landline service.
If reliable emergency service is not available, the handset or VoIP device should clearly be marked with a warning.
Some VoIP providers allow emergency calls to be routed via their service; however this is only of use if you are within an area covered by the receiving emergency call centre. Additionally, a lack of bandwidth or Internet service or a power loss can lead to loss of emergency service via telephone.

#### Suggestions for dealing with emergency calls

If a functioning landline handset is nearby, it is advisable to attach a notice to the VoIP device directing emergency calls to the landline. It is much easier for emergency services to assist if they have information on your location which is generally not available via VoIP calls.
Where calls are handled by a gateway administered by yourself or your organisation, and the ability to route certain calls via landline exists, the dialplan for your VoIP gateway should immediately route emergency calls via the landline, and where possible, any active conversations should be dropped if there are not sufficient lines to handle the call.
It is important to find out whether your VoIP provider(s) offer emergency numbers, what areas they are able to cover and whether they are able to provide enhanced emergency services such as e911 initiatives which allow providers to transmit information on subscribers to 911 call centres.
Ensure that emergency calls are routed via the most appropriate gateways in your dial plan.

### IVR (Interactive Voice Response) application

IVR applications are automated response units which receive input from the user (traditionally in the form of DTMF) and allow the user to progress along a pre-set interactive path. For example, a menuing system where the IVR may announce Press 1 for Sales, 2 for Marketting and then await user input. Once the user input arrives the IVR unit may patch through the call to another line and/or may provide a pre-recorded message.

# ENUM and E146 Technology

The following section is quite technical, as it deals with complicated infrastructure and the integration of VoIP into core internet technologies.
The ENUM protocol (described in RFC document RFC 3761) translates standard telephone number routing (known as E.164, as the ITU defines the standard by which telephone numbers are assigned in the E.164 standard) into an addressing scheme able to route to VoIP (eg. SIP/H323) gateways using DNS technology.
ENUM technology allows VoIP servers to use the DNS infrastructure to query routing paths for terminating voice calls given a phone number.
When a call is initiated to a given phone number, a VoIP gateway capable of ENUM service will query the provided number in DNS to determine whether there is a path other than the PSTN line available to the destination service.
This allows providers to advertise paths via VoIP to services otherwise only available via a VoIP to PSTN gateway.
ENUM records may contain other information in addition to a VoIP gateway address, such as a web URL or e-mail address.

### Private vs Public ENUM databases

The public ENUM database is a collection of ENUM records, known as NAPTR RRs in DNS speak, which map telephone numbers to VoIP service gateways. These records are stored in a hierarchical tree beneath the e164.arpa domain.
Records within the e164.arpa domain are delegated to their responsible owner via the E.164 addressing convention. Much like the in-addr.arpa domain, which is used to provide mapping of IP addresses to names, these records are delegated in blocks to the agency responsible for this number assignment.
The agency is then responsible for further smaller delegations where necessary. As a result, it is unlikely that individuals or small businesses will have access to provide ENUM records for their telephone numbers.
It also stands to reason that telephone companies would be hesitant to allow telephone calls destined to their customers to instead terminate over the Internet, as much of a phone company's revenue would be derived from call termination fees, charged to carriers for calls terminating on a company's network.
This is unfortunate for end users. Via the ENUM database, you would have the opportunity to direct VoIP-based calls to terminate over the Internet via your VoIP gateway, rather than via a phone line.
For this reason, several free ENUM databases have been created to allow users to share alternate IP-based paths to their phone numbers. Most ENUM aware gateways will allow additional 'search domains' to be configured, providing access to these unofficial databases.
Whilst configuring a gateway to query these extra domains can dramatically reduce costs by terminating calls over IP, therefore freeing copper lines/voice channels for both the caller and recipient, there is an important factor to consider. If a malicious or unauthenticated entry is added, an attacker can direct calls for a phone number to an arbitrary VoIP gateway.
Consider the example of rival businesses. If Business A were tech-savvy and entered their competitor's number into a public directory, directing calls to their own VoIP gateway, any calls placed via a VoIP gateway configured to query that directory would be directed to Business A's phone, rather than the intended recipient, Business B.
Some of these directories require voice verification of ownership when you register phone numbers. Others do not require verification or have dispute resolution policies which deal with disputes on a case-by-case basis.
Another less serious but still important consideration is the possibility that your information will be harvested from the database, or sold by the database owner. ENUM information may be valuable to advertisers or phone spammers, as it would provide them with a list of valid phone numbers, and allow them to call for free via IP.

### Public ENUM registries
#### VoIP Providers Worldwide

VoIP technology has completely changed how companies interact with their customers. VoIP has scaled so much that now it is being used for residential as well as business purposes. VoIP providers are mainly of two types, Retail VoIP provider and wholesale VoIP provider. There are bunch of VoIP providers online but these are some of the best VoIP providers online.
* Traverse Telecom
* Ringcentral
* Grasshopper

#### ENUM Trial Registries

Many ENUM trial registries are becoming available. Most of these registries are regional, and often are limited by telephony provider, limited number of trial participants, or a trial fee.
Australian ENUM Trial - Fee applies for registration
Austrian ENUM Trial - Open to Austrian residents, a fee applies for registration.
German ENUM Trial
Japanese ENUM Trial - Open to ETJP contributors since 2003. Currently has 46 members.
Taiwan ENUM Trial
UK ENUM Trial

# Reference
## Appendices
### Appendix A: Glossary of Terms

| ATA | Analog Telephone Adaptor |
| Broadband | Using multiple transmissions simultaneously over a single medium. |
| Baseband | Using a single transmission over a single medium. | CAS | Channel Associated Signaling |
| CCS | Common Channel Signaling |
| DTMF | Dual-Tone Multi-Frequency |
| DS0 | 64K Channel |
| DSL | Digital Subscriber Line |
| E1 | 32 DS0 Channels |
| FXO | Foreign eXchange Office |
| FXS | Foreign eXchange Subscriber |
| IP | Internet Protocol - IP is the common protocol, or language, used by all devices on the Internet to communicate regardless of vendor. |
| MGCP | Media Gateway Control Protocol |
| NAT | Network Address Translation - The translation of a Network (IP) Address to another address by a gateway or router device |
| PAT | Port Address Translation - The translation of multiple inside IP addresses to a single IP address on the outside, used in typical home applications. |
| PBX | Private Branch Exchange |
| PoE | Power over Ethernet |
| POTS | Plain Old Telephone System. See PSTN below. |
| PSTN | Public Switched Telephone Network |
| Q.931 | Layer 3 ISDN Signaling |
| Q.921 | Layer 2 ISDN Signaling |
| RFC | Request For Comments |
| RTCP | Real-Time Control Protocol |
| RTP | Real-Time Transport Protocol |
| SIP | Session Initiation Protocol |
| T1 | 24 DS0 Channels |
* ↑ Wholesale VoIP Provider