Skip to content
SIP Mastery

Part 9 · SIP in the real world / Module 25

Proxies, B2BUAs, and SBCs

The elements in the middle of real SIP networks: what a proxy may change and what a B2BUA may change; the usual roles of Kamailio, OpenSIPS, Asterisk, FreeSWITCH, and rtpengine; the functions of an SBC and what each one costs; load balancing and failover with OPTIONS health checks; and high availability with floating IP addresses and shared state.

AdvancedNOC coreDEV core

After this module, you can

  • Say which headers and bodies a proxy may change, and show in a trace that an element is a B2BUA.
  • Name the usual role of each common open-source SIP server, and draw a typical design with them.
  • Explain topology hiding, normalisation, media anchoring, transcoding, security, and call admission control, and what each costs.
  • Follow a load balancer that fails over with health checks, after a timeout, after a 503, and not after a 6xx.
  • Explain what state an HA pair must share so that calls survive a failover.
On this page7 sections
  1. 25.1What a proxy may change, and what a B2BUA may change
  2. 25.2Common open-source roles
  3. 25.3SBC functions
  4. 25.4Load balancing and failover with OPTIONS health checks
  5. 25.5High availability: shared state and floating IPs
  6. Common mistakes
  7. Summary

25.1 What a proxy may change, and what a B2BUA may change

Module 3 introduced the two kinds of element in the middle of a call. A proxyproxy. An element that forwards requests and responses. It does not start or end calls. routes requests that belong to someone else, so RFC 3261 limits what it may touch. A B2BUAB2BUA. An element that ends one call leg as a UAS and starts a new leg as a UAC. ends the call on one side and starts a new call on the other, so it may change anything:

RFC 3261 §16.6 · Request Forwarding
“The proxy MUST NOT reorder field values with a common field name (See Section 7.3.1). The proxy MUST NOT add to, modify, or remove the message body.”
Read the section ↗
RFC 7092 §3.1.2 · Signaling-only B2BUA
“No SIP header field is guaranteed to be copied from the received request on the UAS side to the generated request on the UAC side.”
Read the section ↗
Part of the message Proxy B2BUA
Request-URI Yes: the next target (location service, Route) Its own, for the new call
Via Adds its own on top; removes it from responses A new Via stack: only its own
Max-Forwards Minus one Usually starts again at 70, or copies it minus one
Record-Route, Route Adds Record-Route; removes its own Route entry Its own route set on each side
From, To, tags Never New tags; it may also change the names and URIs
Call-ID, CSeq Never New on each side
Contact Never Its own address
Body (SDP) Never Anything: its own address, other codecs, other media
Other headers May add some (such as P-Asserted-Identity); does not remove others Copies only what it chooses

Pick a message in the diagram, and compare what each element does to it. The + and ~ marks show the headers that the element added or changed; − marks the ones it removed:

Proxy vs B2BUA

The same message, before and after the element

Proxy

2 added · 2 changed · 0 removed

Reaches the proxy, from Alice

INVITE sip:bob@biloxi.example SIP/2.0
Via: SIP/2.0/UDP 192.0.2.10:5060;branch=z9hG4bK74b1d75
Max-Forwards: 70
From: Alice <sip:alice@atlanta.example>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example>
Call-ID: 3848276298220188511@192.0.2.10
CSeq: 314159 INVITE
Contact: <sip:alice@192.0.2.10:5060>
Content-Type: application/sdp
Content-Length: 158
v=0
o=alice 2890844526 2890844526 IN IP4 192.0.2.10
s=-
c=IN IP4 192.0.2.10
t=0 0
m=audio 49170 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

Leaves, to Bob

~INVITE sip:bob@203.0.113.20:5060 SIP/2.0
+Via: SIP/2.0/UDP 198.51.100.10:5060;branch=z9hG4bKpr1801
Via: SIP/2.0/UDP 192.0.2.10:5060;branch=z9hG4bK74b1d75
~Max-Forwards: 69
+Record-Route: <sip:198.51.100.10;lr>
From: Alice <sip:alice@atlanta.example>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example>
Call-ID: 3848276298220188511@192.0.2.10
CSeq: 314159 INVITE
Contact: <sip:alice@192.0.2.10:5060>
Content-Type: application/sdp
Content-Length: 158
v=0
o=alice 2890844526 2890844526 IN IP4 192.0.2.10
s=-
c=IN IP4 192.0.2.10
t=0 0
m=audio 49170 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

The proxy changes only what routing needs: the Request-URI (from the location service), a new Via on top, Max-Forwards minus one, and its Record-Route. Call-ID, tags, CSeq, Contact, and the SDP pass unchanged.

B2BUA

3 added · 7 changed · 3 removed

Reaches the B2BUA, from Alice

INVITE sip:bob@biloxi.example SIP/2.0
Via: SIP/2.0/UDP 192.0.2.10:5060;branch=z9hG4bK74b1d75
Max-Forwards: 70
From: Alice <sip:alice@atlanta.example>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example>
Call-ID: 3848276298220188511@192.0.2.10
CSeq: 314159 INVITE
Contact: <sip:alice@192.0.2.10:5060>
Content-Type: application/sdp
Content-Length: 158
v=0
o=alice 2890844526 2890844526 IN IP4 192.0.2.10
s=-
c=IN IP4 192.0.2.10
t=0 0
m=audio 49170 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

Leaves, to Bob

~INVITE sip:bob@203.0.113.20:5060 SIP/2.0
~Via: SIP/2.0/UDP 198.51.100.10:5060;branch=z9hG4bKbb1801
Max-Forwards: 70
~From: Alice <sip:alice@atlanta.example>;tag=bb51a0
To: Bob <sip:bob@biloxi.example>
~Call-ID: 7c4d2e91f0@198.51.100.10
~CSeq: 1 INVITE
~Contact: <sip:b2bua@198.51.100.10:5060>
Content-Type: application/sdp
~Content-Length: 152
v=0
+o=b2bua 4001 4001 IN IP4 198.51.100.10
s=-
+c=IN IP4 198.51.100.10
t=0 0
+m=audio 30000 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
−o=alice 2890844526 2890844526 IN IP4 192.0.2.10
−c=IN IP4 192.0.2.10
−m=audio 49170 RTP/AVP 0 8

The B2BUA answers Alice's INVITE as a UAS and sends a new one as a UAC. Call-ID, From tag, CSeq, Via, Contact, and the SDP are all its own; only the names in From and To survive.

Two consequences matter in daily work:

  • Behind a proxy there is one dialog. Alice and Bob hold the same Call-ID and tags, and every feature that works end to end works through the proxy: REFER, Replaces, SDP encryption keys, an Identity signature (Module 28).
  • Behind a B2BUA there are two dialogs. To follow one call in a trace, match the two sides by time, numbers, and any correlation header the B2BUA adds. Every end-to-end feature now works only if the B2BUA supports it, on both sides.

25.2 Common open-source roles

Most SIP networks are built from a few well-known open-source servers, each in its usual role. This course does not teach their configuration, but you will meet them in traces and in job descriptions:

Server Role Typical work
Kamailio, OpenSIPS Proxy, registrar, load balancer, edge proxy Routing, authentication, registration, load balancing, rate limits. Tens of thousands of calls per server, because they handle only signaling.
Asterisk, FreeSWITCH B2BUA PBX features, IVR, voicemail, conferences, queues, recording, transcoding. They handle the media, so far fewer calls per server.
rtpengine Media relay, controlled by a proxy Anchors RTP, converts between RTP and SRTP or WebRTC, records.

A common design puts these together: Kamailio at the edge as registrar and load balancer, rtpengine next to it for the media, and a group of Asterisk or FreeSWITCH servers behind it for the features.

25.3 SBC functions

An SBCSBC. Session Border Controller. A B2BUA at the edge of a network that protects and normalises SIP. is a B2BUA at the border of a network:

RFC 5853 §2 · Background on SBCs
“SBCs often modify certain SIP headers and message bodies that proxies are not allowed to modify. Consequently, they are, by definition, B2BUAs (Back-to-Back User Agents).”
Read the section ↗

Each of its functions solves a problem at the border, and each has a cost. Turn them on and off below. The PBX on the left sends the same INVITE each time; watch what reaches the carrier, where the media flows, and what happens to attacks:

SBC function explorer

What each function of an SBC changes

Calls already up
Inside · 10.1.1.0/24InternetPBX10.1.1.20SBC10.1.1.1 | 203.0.113.1Carrier198.51.100.50AttackersSIP · UDPSIP · UDPRTP to 10.1.1.20 ✕ never arrivesscans and fraud reach the PBX

From the PBX, inside

INVITE sip:4045550199@10.1.1.1;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.1.1.20:5060;branch=z9hG4bKpx4a1c
Max-Forwards: 70
From: "Alice" <sip:4045550101@pbx.corp.internal>;tag=px81a2
To: <sip:4045550199@10.1.1.1;user=phone>
Call-ID: 5f0c1e9a@10.1.1.20
CSeq: 1 INVITE
Contact: <sip:4045550101@10.1.1.20:5060>
Remote-Party-ID: "Alice" <sip:4045550101@pbx.corp.internal>;party=calling;screen=yes;privacy=off
User-Agent: CorpPBX 13.4.2
X-Corp-Route: trunk-group-3
Content-Type: application/sdp
Content-Length: 157
v=0
o=pbx 1001 1001 IN IP4 10.1.1.20
s=-
c=IN IP4 10.1.1.20
t=0 0
m=audio 20000 RTP/AVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000

To the carrier, outside

~INVITE sip:4045550199@sip.carrier.example;user=phone SIP/2.0
~Via: SIP/2.0/UDP 203.0.113.1:5060;branch=z9hG4bKsb93c7
~Max-Forwards: 69
~From: "Alice" <sip:4045550101@pbx.corp.internal>;tag=sb20d4
To: <sip:4045550199@10.1.1.1;user=phone>
Call-ID: 5f0c1e9a@10.1.1.20
CSeq: 1 INVITE
~Contact: <sip:4045550101@203.0.113.1:5060>
Remote-Party-ID: "Alice" <sip:4045550101@pbx.corp.internal>;party=calling;screen=yes;privacy=off
User-Agent: CorpPBX 13.4.2
X-Corp-Route: trunk-group-3
Content-Type: application/sdp
Content-Length: 157
v=0
o=pbx 1001 1001 IN IP4 10.1.1.20
s=-
c=IN IP4 10.1.1.20
t=0 0
m=audio 20000 RTP/AVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000

Result: The carrier answers 404 Not Found: it cannot route ten digits with no country code.

  • ⚠ Number format. The carrier expects E.164 and P-Asserted-Identity. It gets ten digits and Remote-Party-ID, a header from an old draft.
  • ⚠ Codec. The PBX offers only G.722. The carrier supports only G.711, so it answers 488 Not Acceptable Here.
  • ⚠ Media address. The SDP gives 10.1.1.20, a private address. The carrier's RTP never arrives: a call with no audio.
  • ⚠ Internal names. The Call-ID, From, To, User-Agent, and X-Corp-Route show inside addresses, host names, the PBX product, and its version.
  • ⚠ Transport. Plain UDP and RTP over the Internet: anyone on the path can read the call and listen to it.
  • ✓ Call limit. Nobody counts the calls. Fine at 12 calls; a problem when the trunk is full, or under attack.
  • REGISTER scan from 192.0.2.66, guessing extensions: passed to the PBX
  • INVITE to an international premium number from 198.51.100.99: passed to the PBX
  • 400 INVITEs per second from 203.0.113.250: passed to the PBX
Function What it does What it costs
topology hidingtopology hiding. An SBC removes or replaces the addresses of the inner network in each message it forwards. New Call-ID, its own Via, Contact, and route set; inside names and addresses removed Traces on each side show different calls
SIP normalisationSIP normalisation. Changes an SBC makes so that each side gets the SIP it expects, such as E.164 numbers, P-Asserted-Identity in place of an old header, or the removal of unknown headers. E.164 numbers, P-Asserted-Identity, removes or rewrites headers that the other side does not accept Rules to write and test for each peer
media anchoringmedia anchoring. An SBC or B2BUA puts its own address in the SDP, so the RTP flows through it. Needed for NAT traversal, transcoding, SRTP on one side, and recording. (NAT) Its own address in the SDP; relays the RTP and latches onto its real source Bandwidth and a little delay; the SBC is now in the media path
transcodingtranscoding. Decoding the media in one codec and encoding it in another, for example G.722 to G.711. It costs CPU or DSP capacity, and some quality. Converts between codecs that the two sides do not share CPU or DSP capacity, delay, and some quality, on every packet
Security TLS and SRTP on the Internet side, access lists, rate limits, protocol repair Certificates to manage; CPU for encryption
call admission controlcall admission control. A limit on the number of calls, or the bandwidth, that an SBC accepts on a trunk or from a site. Calls over the limit get an error at once. Limits calls per trunk or site; rejects the rest at once A limit that must match the trunk contract
RFC 5853 §3.1.1 · Topology Hiding
“The most common form of topology hiding is the application of header privacy (see Section 5.1 of [2]), which involves stripping Via and Record-Route headers, replacing the Contact header, and even changing Call-IDs.”
Read the section ↗
RFC 5853 §3.2.1 · Media Traffic Management
“By modifying the session description, the SBC can force the media to be sent through a media relay which may be co-located with the SBC.”
Read the section ↗
RFC 5853 §3.3.1 · Fixing Capability Mismatches
“For example, an SBC can enable a plain SIP [1] user agent to connect to a 3GPP network, or enable a connection between user agents that support different IP versions, different codecs, or that are in different address realms.”
Read the section ↗
RFC 5853 §3.5.1 · Access Control
“This way, all the SIP traffic entering the inner network needs to be routed though the SBC, which only routes messages from authorized parties or traffic that meets a specific policy that is expressed in the SBC administratively.”
Read the section ↗
RFC 5853 §3.7.1 · Media Encryption
“This is the case when media encryption (e.g., Secure Real-time Transport Protocol (SRTP)) is used only on the access network (outer network) side and the media is carried unencrypted in the inner network.”
Read the section ↗

Everything an SBC does to the SDP breaks end-to-end features. Encryption keys exchanged in the SDP, a signature over the SDP, and any feature that the SBC does not understand stop working:

RFC 5853 §3.2.2 · Media Traffic Management (Architectural Issues)
“Implementing traffic management in this manner requires the SBC to access and modify the session descriptions (i.e., offers and answers) exchanged between the user agents. Consequently, this approach does not work if user agents encrypt or integrity-protect their message bodies end-to-end.”
Read the section ↗

25.4 Load balancing and failover with OPTIONS health checks

A Load balancerLoad balancer. A proxy in front of a group of servers. It sends each new call or registration to one of them, and skips servers that do not answer its health checks. is a proxy in front of a group of servers. It chooses a server for each new call, often in turn (“round robin”) or by weight, and it must skip servers that are down. It learns that a server is down in one of two ways:

  • After a failure. The server answers 503, or nothing comes back at all. With no answer, the load balancer waits for Timer B: 32 seconds over UDP, while the caller hears nothing.
  • Before the call, with a health checkhealth check. A request, often OPTIONS, that a load balancer or SBC sends to a server every few seconds to learn whether it is up.. The load balancer sends OPTIONS to each server every few seconds, and takes a server out of the list when it stops answering.

Flow builder · a load balancer in front of two PBXs

Load balancing, with health checks: PBX A is down

  • SIP
PBX A
What if

Alice192.0.2.10Load balancer198.51.100.20PBX A203.0.113.31PBX B203.0.113.3201✕OPTIONS02OPTIONS03200 OK04INVITE05100 Trying06INVITE07180 Ringing08180 Ringing09200 OK10200 OK11ACK
01/11

PBX A does not answer. After a few probes, the load balancer marks it down and sends it no calls.

All steps as text
  1. Load balancer → PBX A: OPTIONS. PBX A does not answer. After a few probes, the load balancer marks it down and sends it no calls.
  2. Load balancer → PBX B: OPTIONS. The load balancer checks PBX B every few seconds, with OPTIONS.
  3. PBX B → Load balancer: 200 OK. PBX B is up.
  4. Alice → Load balancer: INVITE. Alice calls Bob. The load balancer in front of the PBXs receives the INVITE.
  5. Load balancer → Alice: 100 Trying. The load balancer stops Alice's retransmissions.
  6. Load balancer → PBX B: INVITE. The load balancer knows that PBX A is down, so it sends the INVITE to PBX B at once.
  7. PBX B → Load balancer: 180 Ringing. PBX B rings Bob's phone.
  8. Load balancer → Alice: 180 Ringing. The load balancer removes its Via and forwards the 180.
  9. PBX B → Load balancer: 200 OK. Bob answers. PBX B relays his media.
  10. Load balancer → Alice: 200 OK. The load balancer forwards the 200 OK. It did not Record-Route, so it leaves the dialog now.
  11. Alice → PBX B: ACK. Alice sends the ACK straight to PBX B, the Contact in the 200 OK.
RFC 3263 §4.3 · Details of RFC 2782 Process
“For SIP requests, failure occurs if the transaction layer reports a 503 error response or a transport failure of some sort (generally, due to fatal ICMP errors in UDP or connection failures in TCP). Failure also occurs if the transaction layer times out without ever having received any response, provisional or final (i.e., timer B or timer F in RFC 3261 [1] fires).”
Read the section ↗
RFC 3263 §4.3 · Details of RFC 2782 Process
“If a failure occurs, the client SHOULD create a new request, which is identical to the previous, but has a different value of the Via branch ID than the previous (and therefore constitutes a new SIP transaction). That request is sent to the next element in the list as specified by RFC 2782.”
Read the section ↗

Fail over only on a failure of the server: a timeout, a transport error, or a 503. A 4xx or 6xx is an answer about the call, and the next server would give the same answer, or worse, ring the user a second time:

RFC 3261 §16.7 · Response Processing
“If a 6xx response is received, it is not immediately forwarded, but the stateful proxy SHOULD cancel all client pending transactions as described in Section 10, and it MUST NOT create any new branches in this context.”
Read the section ↗

A 503 with Retry-After tells the load balancer how long to leave that server alone:

RFC 3261 §20.33 · Retry-After
“The Retry-After header field can be used with a 500 (Server Internal Error) or 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client”
Read the section ↗

Three design choices go with every load balancer:

  • What it balances: calls, not requests. In-dialog requests follow the Contact and the route set to the server that has the call. A load balancer that Record-Routes must send them to the same server, not to the next one in turn.
  • Where registrations live. If each PBX keeps its own registrations, a call for Bob must go to the PBX where Bob registered. A shared location database lets any PBX take any call.
  • How fast it detects a failure. OPTIONS every 5 seconds, with a server marked down after 2 or 3 missed answers, finds a failure in about 15 seconds. Shorter intervals find it faster, at the cost of more traffic. DNS SRV (Module 11) spreads the load from the client side instead, with the same failover rules.

25.5 High availability: shared state and floating IPs

An Active SBCActive SBC. In Module 25, the SBC of a high-availability pair that holds the floating IP address and handles the calls. and a Standby SBCStandby SBC. In Module 25, the SBC of a high-availability pair that waits. It takes over the floating IP address when the active SBC fails. share one floating IP addressfloating IP address. An IP address that moves between the servers of a high-availability pair. Clients always use it, so they need not know which server is active.. Phones, carriers, and DNS know only that address. When the active SBC stops sending keepalives, the standby takes the address and announces it with a gratuitous ARPgratuitous ARP. An ARP message that a server sends without being asked, to tell the switches and routers on its LAN that an IP address now belongs to its MAC address.. Packets for the floating address now reach the new active SBC. For this to work, every address that other elements store must be the floating address: Via, Contact, Record-Route, and the SDP.

What survives a failover depends on the state that the two SBCs share:

State If it is not shared If it is shared
Registrations Phones are unreachable until they register again Incoming calls work at once
Dialogs The next request in a call gets 481; one side of the call never ends BYE, re-INVITE, and transfer work as before
Media relay sessions The RTP stops; both sides hear silence The audio continues after a short gap
Transactions A request in progress is lost; retransmissions or the user retry it Rarely shared; the gain is small

Call flow · a failover during a call, with shared dialogs

SBC failover, with replicated dialogs

  • SIP
  • RTP media
  • TCP / IP
Alice192.0.2.10Active SBC198.51.100.41Standby SBC198.51.100.42Bob203.0.113.2001INVITE02100 Trying03INVITE04200 OK05200 OK06ACK07ACK08RTP09✕keepalive10gratuitous ARP11BYE12200 OK13BYE14200 OK
01/14

Alice calls Bob. The SBC pair has one floating IP address, 198.51.100.40; the active SBC holds it.

All steps as text
  1. Alice → Active SBC: INVITE. Alice calls Bob. The SBC pair has one floating IP address, 198.51.100.40; the active SBC holds it.
  2. Active SBC → Alice: 100 Trying. The active SBC takes the call.
  3. Active SBC → Bob: INVITE. The SBC starts its call to Bob, and copies the state of both dialogs to the standby SBC.
  4. Bob → Active SBC: 200 OK. Bob answers.
  5. Active SBC → Alice: 200 OK. The SBC answers Alice. Its Contact and SDP give the floating address, not its own.
  6. Alice → Active SBC: ACK. Alice acknowledges.
  7. Active SBC → Bob: ACK. The SBC acknowledges Bob's 200 OK.
  8. Alice → Bob: RTP. The media flows through the floating address of the SBC pair.
  9. Active SBC → Standby SBC: keepalive. The active SBC crashes. Its keepalives to the standby SBC stop.
  10. Standby SBC → Bob: gratuitous ARP. The standby SBC takes 198.51.100.40 and announces it on its LAN. Packets for that address now reach the standby SBC.
  11. Bob → Standby SBC: BYE. Bob hangs up. His BYE goes to the floating address, so the standby SBC receives it.
  12. Standby SBC → Bob: 200 OK. The standby SBC has a copy of both dialogs, so it accepts the BYE.
  13. Standby SBC → Alice: BYE. It ends Alice's side of the call too, with the tags from the copy.
  14. Alice → Standby SBC: 200 OK. Alice confirms. Both sides of the call end, and the call record is complete.
RFC 3261 §12 · Dialogs
“This state consists of the dialog ID, a local sequence number (used to order requests from the UA to its peer), a remote sequence number (used to order requests from its peer to the UA), a local URI, a remote URI, remote target, a boolean flag called "secure", and a route set, which is an ordered list of URIs.”
Read the section ↗
RFC 3261 §12.2.2 · UAS Behavior
“If the UAS wishes to reject the request because it does not wish to recreate the dialog, it MUST respond to the request with a 481 (Call/Transaction Does Not Exist) status code and pass that to the server transaction.”
Read the section ↗

A proxy that does not keep dialog state needs none of this: any copy of it can forward the next request, because the route set in the request says where to go. That is one reason why large networks keep their proxies stateless or transaction-stateful, and put the state that must survive in a shared database.

Common mistakes

Topology hiding that forgets the SDP

An SBC rewrites Via, Contact, and Call-ID on its way to the carrier, and the headers look clean. The SDP still gives the PBX’s private address. Calls connect, but the carrier’s RTP goes to 10.1.1.20 and never arrives: one-way audio on every outbound call.

Broken

An SBC that hides the headers but copies the SDP

  • SIP
  • RTP media
  • ⚠Problem
PBX10.1.1.20SBC203.0.113.1Carrier gateway198.51.100.5001INVITE02INVITE⚠03200 OK04200 OK05ACK06ACK07RTP08✕RTP⚠
01/08

The PBX sends a call to the SBC on its inside interface. Its SDP gives its private address.

All steps as text
  1. PBX → SBC: INVITE. The PBX sends a call to the SBC on its inside interface. Its SDP gives its private address.
  2. SBC → Carrier gateway: INVITE. The SBC hides the inside addresses in the headers: new Call-ID, its own Via and Contact. It copies the SDP unchanged. Problem: The SDP still gives 10.1.1.20. The carrier cannot send media to a private address.
  3. Carrier gateway → SBC: 200 OK. The carrier answers.
  4. SBC → PBX: 200 OK. The SBC passes the carrier's SDP to the PBX.
  5. PBX → SBC: ACK. The PBX acknowledges.
  6. SBC → Carrier gateway: ACK. The SBC acknowledges the carrier's 200 OK.
  7. PBX → Carrier gateway: RTP. The PBX's RTP reaches the carrier through the company's NAT.
  8. Carrier gateway → PBX: RTP. The carrier sends its RTP to 10.1.1.20, a private address. It never arrives. Problem: One-way audio: Bob hears Alice, but Alice hears nothing.

Remember: an address in the SDP is part of the topology. Anchor the media on the SBC, or make sure that the inside address is reachable from the outside. The course’s checker calls this rule sdp-private-address (Module 20).

A load balancer with no health checks

A load balancer sends calls in turn to two PBXs, and does not probe them. PBX A fails at night. Every second call now waits 32 seconds for Timer B before it goes to PBX B, and most callers hang up first.

Broken: no health checks

Load balancing, no health checks: PBX A is down

  • SIP
  • ⚠Problem
Alice192.0.2.10Load balancer198.51.100.20PBX A203.0.113.31PBX B203.0.113.3201INVITE02100 Trying03✕INVITE04✕INVITE (retransmission)05✕INVITE (retransmission)06INVITE⚠07180 Ringing08180 Ringing09200 OK10200 OK11ACK
01/11

Alice calls Bob. The load balancer in front of the PBXs receives the INVITE.

All steps as text
  1. Alice → Load balancer: INVITE. Alice calls Bob. The load balancer in front of the PBXs receives the INVITE.
  2. Load balancer → Alice: 100 Trying. The load balancer stops Alice's retransmissions.
  3. Load balancer → PBX A: INVITE. PBX A is next in the round robin. The load balancer does not know that PBX A is down.
  4. Load balancer → PBX A: INVITE (retransmission). No 100 Trying comes back. The load balancer sends the INVITE again, and again, with longer gaps.
  5. Load balancer → PBX A: INVITE (retransmission). Still no answer. Alice hears nothing at all.
  6. Load balancer → PBX B: INVITE. Timer B fires after 32 seconds. Only now does the load balancer try PBX B, with a new branch. Problem: Alice waited 32 seconds in silence. Most callers hang up before this.
  7. PBX B → Load balancer: 180 Ringing. PBX B rings Bob's phone.
  8. Load balancer → Alice: 180 Ringing. The load balancer removes its Via and forwards the 180.
  9. PBX B → Load balancer: 200 OK. Bob answers. PBX B relays his media.
  10. Load balancer → Alice: 200 OK. The load balancer forwards the 200 OK. It did not Record-Route, so it leaves the dialog now.
  11. Alice → PBX B: ACK. Alice sends the ACK straight to PBX B, the Contact in the 200 OK.

Remember: probe every server with OPTIONS, and take it out of the list after a few missed answers. Also set a failover timer much shorter than 32 seconds for the INVITE to a server.

Failing over after a final answer from the user

A load balancer tries the next server after any error response. Bob presses Decline, and PBX A answers 603. The load balancer sends the call to PBX B, which rings Bob’s phone again.

Broken: fails over on 603

Load balancing, with health checks: PBX A bob declines (603)

  • SIP
  • ⚠Problem
Alice192.0.2.10Load balancer198.51.100.20PBX A203.0.113.31PBX B203.0.113.3201OPTIONS02200 OK03OPTIONS04200 OK05INVITE06100 Trying07INVITE08180 Ringing09180 Ringing10603 Decline11ACK12INVITE⚠13180 Ringing14603 Decline15ACK16603 Decline17ACK
01/17

The load balancer checks PBX A every few seconds, with OPTIONS.

All steps as text
  1. Load balancer → PBX A: OPTIONS. The load balancer checks PBX A every few seconds, with OPTIONS.
  2. PBX A → Load balancer: 200 OK. PBX A is up.
  3. Load balancer → PBX B: OPTIONS. The load balancer checks PBX B every few seconds, with OPTIONS.
  4. PBX B → Load balancer: 200 OK. PBX B is up.
  5. Alice → Load balancer: INVITE. Alice calls Bob. The load balancer in front of the PBXs receives the INVITE.
  6. Load balancer → Alice: 100 Trying. The load balancer stops Alice's retransmissions.
  7. Load balancer → PBX A: INVITE. PBX A is next in the round robin.
  8. PBX A → Load balancer: 180 Ringing. PBX A rings Bob's phone.
  9. Load balancer → Alice: 180 Ringing. The load balancer forwards the 180.
  10. PBX A → Load balancer: 603 Decline. Bob sees who is calling, and presses Decline.
  11. Load balancer → PBX A: ACK. The load balancer acknowledges the failure on this hop.
  12. Load balancer → PBX B: INVITE. This load balancer tries the next PBX after any failure. PBX B rings Bob's phone again. Problem: Bob declined the call, and his phone rings again. A 6xx means: try nowhere else.
  13. PBX B → Load balancer: 180 Ringing. Bob's phone rings a second time.
  14. PBX B → Load balancer: 603 Decline. Bob declines again.
  15. Load balancer → PBX B: ACK. The load balancer acknowledges the failure on this hop.
  16. Load balancer → Alice: 603 Decline. Only now does Alice learn that Bob declined.
  17. Alice → Load balancer: ACK. Alice acknowledges it.

Remember: fail over on a timeout, a transport error, or a 503. Pass every other final response to the caller, and never try another server after a 6xx.

An HA pair that does not share dialogs

Two SBCs share a floating IP address, and the failover test passes: new calls work within seconds. Nobody tests a call that is up during the failover. In production, every such call has one side that never ends; billing records run for hours, and trunk channels stay in use.

Problem: 481, one side stays up

SBC failover, without replicated dialogs

  • SIP
  • RTP media
  • TCP / IP
  • ⚠Problem
Alice192.0.2.10Active SBC198.51.100.41Standby SBC198.51.100.42Bob203.0.113.2001INVITE02100 Trying03INVITE04200 OK05200 OK06ACK07ACK08RTP09✕keepalive10gratuitous ARP11BYE12481 Call/Transaction Does Not Exist⚠13RTP
01/13

Alice calls Bob. The SBC pair has one floating IP address, 198.51.100.40; the active SBC holds it.

All steps as text
  1. Alice → Active SBC: INVITE. Alice calls Bob. The SBC pair has one floating IP address, 198.51.100.40; the active SBC holds it.
  2. Active SBC → Alice: 100 Trying. The active SBC takes the call.
  3. Active SBC → Bob: INVITE. The SBC starts its call to Bob. It keeps the state of both dialogs in its own memory only.
  4. Bob → Active SBC: 200 OK. Bob answers.
  5. Active SBC → Alice: 200 OK. The SBC answers Alice. Its Contact and SDP give the floating address, not its own.
  6. Alice → Active SBC: ACK. Alice acknowledges.
  7. Active SBC → Bob: ACK. The SBC acknowledges Bob's 200 OK.
  8. Alice → Bob: RTP. The media flows through the floating address of the SBC pair.
  9. Active SBC → Standby SBC: keepalive. The active SBC crashes. Its keepalives to the standby SBC stop.
  10. Standby SBC → Bob: gratuitous ARP. The standby SBC takes 198.51.100.40 and announces it on its LAN. Packets for that address now reach the standby SBC.
  11. Bob → Standby SBC: BYE. Bob hangs up. His BYE goes to the floating address, so the standby SBC receives it.
  12. Standby SBC → Bob: 481 Call/Transaction Does Not Exist. The standby SBC knows nothing about this dialog. Problem: Nobody sends a BYE to Alice. Her call stays up, and billing keeps counting.
  13. Alice → Standby SBC: RTP. Alice's phone still sends RTP. The standby SBC drops it, and Alice hears silence until she hangs up.

Remember: replicate dialog state and media relay sessions between the pair, and use session timers (Module 22) so that a call whose state was lost ends by itself. Test a failover with calls in progress.

Summary

  • A proxy changes only what routing needs: Request-URI, Via, Max-Forwards, Route, and Record-Route. It never changes From, To, Call-ID, CSeq, Contact, or the body. A B2BUA may change everything, and splits the call into two dialogs.
  • Kamailio and OpenSIPS are proxies, registrars, and load balancers; Asterisk and FreeSWITCH are B2BUAs with media features; rtpengine is a media relay that a proxy controls.
  • An SBC is a B2BUA at the border. Its functions: topology hiding, normalisation, media anchoring for NAT, transcoding, security, and call admission control. Each one has a cost, and every change to the SDP breaks end-to-end features.
  • A load balancer probes its servers with OPTIONS and fails over on a timeout, a transport error, or a 503, never on a 4xx or 6xx answer about the call.
  • An HA pair shares a floating IP address. Calls survive a failover only if the pair shares registrations, dialogs, and media sessions, and every stored address is the floating one.