VoIP Explained — Beginner's Guide to Voice over IP Technology
In this tutorial, you'll learn about VoIP Explained. We cover key concepts, practical examples, and best practices.
VoIP (Voice over IP) is a technology that converts analog voice signals into digital data packets for transmission over IP networks, replacing traditional circuit-switched telephone systems with packet-switched communication.
What You'll Learn
You will learn how VoIP systems encode voice, establish sessions with SIP, transport media with RTP, and manage bandwidth to deliver clear voice calls over standard internet connections.
Why It Matters
VoIP has replaced traditional phone systems in most businesses and consumer applications because it reduces costs by 40-80%, enables features impossible on analog lines (video calling, presence, unified communications), and runs on existing data infrastructure without separate copper wiring.
Real-World Use
A company with offices in Mumbai, London, and New York replaces three separate PBX systems and expensive ISDN PRI lines with a single cloud-hosted VoIP PBX. Employees call each other by extension, calls between offices cost nothing, and adding a new user takes five minutes instead of weeks waiting for a telephone line installation.
Main Content
How VoIP Works
The VoIP process involves four stages:
- Digitization — the analog voice signal is sampled 8,000 times per second and converted into a digital bitstream using an Analog-to-Digital Converter (ADC)
- Encoding and Compression — the digital stream is passed through a codec (coder/decoder) that compresses the data by removing silence and redundant information
- Packetization — the compressed audio is divided into packets (typically 10-30ms of audio per packet), each wrapped with RTP, UDP, and IP headers
- Transmission — packets are sent over the IP network, received at the far end, reordered, decompressed, and converted back to analog sound
flowchart LR
A[Analog Voice] --> B[ADC Conversion]
B --> C[Codec Encoding]
C --> D[Packetization RTP/UDP/IP]
D --> E[IP Network]
E --> F[Dejitter Buffer]
F --> G[Codec Decoding]
G --> H[DAC Conversion]
H --> I[Analog Voice Out]
Expected behavior: The end-to-end delay from analog input to analog output should be under 150 milliseconds for good quality. Delays above 300ms cause noticeable lag that makes conversation difficult.
VoIP Codecs Compared
| Codec | Bitrate | Sampling Rate | MOS Score | Bandwidth per Call |
|---|---|---|---|---|
| G.711 u-law/A-law | 64 kbps | 8 kHz | 4.1-4.4 | 87.2 kbps (with headers) |
| G.729 | 8 kbps | 8 kHz | 3.9-4.1 | 31.2 kbps |
| G.722 (HD Voice) | 64 kbps | 16 kHz | 4.3-4.5 | 87.2 kbps |
| G.726 | 32 kbps | 8 kHz | 3.8-4.0 | 55.2 kbps |
| Opus | 6-510 kbps | 8-48 kHz | 4.0-4.5 | Variable |
| iLBC | 13.33 kbps | 8 kHz | 3.8-4.0 | 40.5 kbps |
MOS (Mean Opinion Score) ranges from 1 (worst) to 5 (best). A score above 4.0 is considered toll-quality.
Bandwidth Calculation
To calculate total bandwidth for a VoIP call, you must account for:
- Codec bitrate (payload)
- IP header: 20 bytes
- UDP header: 8 bytes
- RTP header: 12 bytes
- Ethernet header: 18 bytes
- Packet rate depends on the packetization interval
Example for G.711 with 20ms packetization:
G.711 bitrate: 64,000 bps
Packet duration: 20ms = 50 packets per second
Payload per packet: 160 bytes (20ms x 8 bytes/ms)
Total headers: 20 (IP) + 8 (UDP) + 12 (RTP) + 18 (Ethernet) = 58 bytes
Total packet size: 160 + 58 = 218 bytes
Total bandwidth: 218 bytes x 50 pps x 8 bits/byte = 87,200 bps
Expected output: A single G.711 call requires approximately 87 kbps of bandwidth. A G.729 call with the same 20ms packetization yields approximately 31 kbps total bandwidth. The difference explains why G.729 is preferred for low-bandwidth links.
SIP Registration and Call Flow
SIP Phone A SIP Proxy/Registrar SIP Phone B
| | |
|----REGISTER----------------->| |
|<---200 OK-------------------| |
| | |
|----INVITE (call to B)------->| |
| |----INVITE--------------->|
|<---100 Trying----------------|<---180 Ringing----------|
| |<---200 OK----------------|
|<---180 Ringing--------------| |
|<---200 OK-------------------| |
|----ACK--------------------->| |
|----ACK--------------------------------> (direct or via proxy)
| | |
|===================== RTP Media Stream =================>|
| | |
|----BYE--------------------->| |
| |----BYE------------------>|
|<---200 OK-------------------|<---200 OK----------------|
Expected behavior: Both phones must first register with the SIP proxy. The proxy routes the INVITE to the called party. After the 200 OK/ACK handshake, media flows directly between endpoints if possible (or through a media relay if NAT is involved).
Quality of Service (QoS) for VoIP
Voice packets are delay-sensitive but can tolerate some loss. Data packets are loss-sensitive but tolerate delay. QoS prioritizes voice traffic at every network hop:
| QoS Mechanism | Purpose | Configuration |
|---|---|---|
| DSCP EF (46) | Mark voice RTP packets | ip dscp 46 on Cisco interfaces |
| DSCP AF41 (34) | Mark SIP signaling | ip dscp 34 on Cisco interfaces |
| LLQ (Low Latency Queuing) | Priority queue for voice | priority percent 10 in policy-map |
| Traffic Shaping | Limit data bursts | shape average 1000000 |
| WRED | Drop lower-priority packets first | random-detect dscp-based |
VoIP Security Considerations
VoIP systems face unique security threats that traditional phone systems do not:
- Toll Fraud — attackers register fake extensions or brute-force SIP credentials to make international calls charged to the victim. Mitigation: strong passwords, IP access control lists, and call rate limiting.
- Eavesdropping — unencrypted RTP streams can be captured and replayed with tools like Wireshark and sipdump. Mitigation: SRTP (Secure RTP) with AES encryption.
- DoS Attacks — flooding a SIP proxy with INVITE requests can saturate call capacity. Mitigation: rate limiting, SIP-aware firewalls, and anomaly detection.
- Caller ID Spoofing — SIP headers can be forged to display any calling number. Mitigation: SIP Identity headers (STIR/SHAKEN) verify caller ID authenticity.
Common Errors
1. No QoS Configuration
Deploying VoIP on a network without QoS guarantees that a large file download will starve voice packets of bandwidth, causing choppy audio and dropped calls. Voice traffic must be prioritized at every switch and router hop.
2. Jitter Buffer Misconfiguration
Jitter buffers smooth out packet arrival time variations but add delay. A buffer set too large (200ms+) makes conversation feel slow. A buffer set too small (10ms) causes breakup on variable-latency links like LTE.
3. Codec Mismatch During Negotiation
When two endpoints cannot agree on a common codec, calls fail silently or fall back to an incompatible mode. Always offer multiple codecs in SDP and verify codec support on both sides during testing.
4. NAT Traversal Not Configured
SIP carries IP addresses in its payload (SDP). NAT rewrites IP headers but not payloads, so the far end receives private RFC 1918 addresses. Calls connect but there is no audio. STUN or TURN relays are required.
5. Confusing Extension and Trunk Configuration
Extensions connect internal users. Trunks connect to the PSTN or upstream carriers. Misconfiguring a trunk as an extension causes one-way audio or complete call failure on outbound calls.
6. Echo Without Proper Echo Cancellation
Acoustic echo occurs when the speaker audio leaks back into the microphone. VoIP phones and gateways include echo cancellers, but they must be tuned. Poor echo cancellation makes calls unusable for the far-end party.
7. Insufficient Bandwidth for Peak Call Volume
Calculating bandwidth per call and multiplying by the expected number of concurrent calls is necessary but often overlooked. A codec like G.711 at 87 kbps per call means 100 concurrent calls need 8.7 Mbps of dedicated voice bandwidth.
Practice Questions
Question 1
What are the four stages of VoIP voice transmission?
Answer: Digitization (ADC), encoding/compression (codec), packetization (RTP/UDP/IP), and transmission over the IP network, followed by reverse operations at the receiver.
Question 2
How much total bandwidth does a single G.711 VoIP call consume with 20ms packetization?
Answer: Approximately 87 kbps. This includes the 64 kbps codec bitrate plus IP, UDP, RTP, and Ethernet header overhead across 50 packets per second.
Question 3
Why does SIP require NAT traversal solutions like STUN or TURN?
Answer: SIP embeds IP addresses and ports in the SDP body. NAT translates IP headers but does not modify SDP payloads. The remote endpoint receives private addresses and cannot send audio to the correct destination.
Question 4
What is the difference between a SIP extension and a SIP trunk?
Answer: A SIP extension is an internal user registered to a PBX (e.g., extension 1001). A SIP trunk is a connection from the PBX to an external carrier for routing calls to and from the PSTN.
Challenge Question
Design a VoIP deployment for a company with 200 employees across two sites connected by a 50 Mbps MPLS link. Calculate the bandwidth needed if 40% of employees are on calls simultaneously using G.729 codec. Account for signaling and overhead. Determine if the 50 Mbps link is sufficient and what QoS policies you would implement.
Mini Project
Configure a VoIP Call Between Two Softphones
Set up a point-to-point VoIP call without a PBX to understand the direct SIP communication flow.
Requirements:
- Two instances of a SIP softphone (Linphone or Zoiper) on the same LAN
- Wireshark for packet capture
- A SIP server (optional, for registration mode)
Steps:
- Install the softphone on two machines (VM or physical)
- On Phone A, configure: SIP URI
sip:userA@192.168.1.10(use Phone A's actual IP) - On Phone B, configure: SIP URI
sip:userB@192.168.1.20(use Phone B's actual IP) - Disable registration — configure the softphone to accept incoming calls directly
- From Phone A, place a call to
sip:userB@192.168.1.20 - Capture the SIP signaling and RTP stream with Wireshark
- Examine the SDP in the INVITE and 200 OK — note the codecs offered and chosen
- Hang up and capture the BYE
Expected output: Wireshark shows the full call flow. The SDP section in the INVITE lists codecs offered (e.g., PCMU, PCMA, Speex). The 200 OK SDP shows the chosen codec. The RTP stream carries the encoded audio payload. The BYE message terminates the session correctly.
This direct SIP call is the same mechanism used by every VoIP system and SIP PBX deployment, whether on-premises or cloud-hosted.
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro