24.1 SIP trunks: registration-based and IP-based
A SIP trunkSIP trunk. A SIP connection between an organisation's PBX and a carrier, in place of physical phone lines. connects a company’s PBXPBX. The phone system of an organisation. Modern PBXs use SIP. to a carrier, in place of physical phone lines. The carrier gives the company a block of numbers (DIDsDID. A telephone number from the carrier that reaches one user or extension behind a PBX directly.), takes its outgoing calls to the PSTNPSTN. The traditional telephone network, built on circuits between telephone exchanges., and sends it the incoming ones. Every trunk must answer one question: how does the carrier know that a request comes from this customer, and where to send calls for its numbers? There are two common answers.
| Registration-based trunk | IP-based trunk | |
|---|---|---|
| The PBX’s address | Can change; the PBX tells the carrier with REGISTER | Fixed, and written in the carrier’s configuration |
| Authentication | Digest: 401 to REGISTER, often 407 to every INVITE | The source IP address, often with TLS and certificates |
| Is the PBX alive? | The registration expires if the PBX stops refreshing | The carrier sends OPTIONS and stops calls if no answer comes |
| Typical use | Small offices, PBXs behind NAT, cloud PBXs | Larger sites and data centres, with a fixed address |
The PBX in this module, in Atlanta, uses the carrier’s Carrier SBCCarrier SBC. The SBC at the edge of a carrier's network. It ends its customers' SIP trunks, checks who is calling, and passes calls to the carrier's gateways., a B2BUA at the edge of the carrier’s network. Behind it, a Carrier gatewayCarrier gateway. The gateway between SIP and the public telephone network. converts SIP to ISUP, the signaling of the telephone exchanges. Switch Trunk between the two types. Every option in this builder changes the messages, so try each one as you read this module:
Flow builder · a call to the PSTN on a SIP trunk
A call to the PSTN on a registered trunk: Bob answers
- SIP
- RTP media
- TCP / IP
The PBX registers the trunk's main number, like a phone. The carrier then sends calls for the whole number block there.
All steps as text
- PBX → Carrier SBC: REGISTER. The PBX registers the trunk's main number, like a phone. The carrier then sends calls for the whole number block there.
- Carrier SBC → PBX: 401 Unauthorized. The carrier asks for the trunk's username and password.
- PBX → Carrier SBC: REGISTER (credentials). The PBX sends the REGISTER again, with Authorization.
- Carrier SBC → PBX: 200 OK. The carrier stores the binding for an hour. The PBX refreshes it before then.
- PBX → Carrier SBC: INVITE. The PBX sends the number in E.164 format: + and the country code. Any carrier can route it.
- Carrier SBC → PBX: 407 Proxy Authentication Required. The carrier challenges every INVITE on a registered trunk. This stops anyone else from calling on its account.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 407 on the same hop.
- PBX → Carrier SBC: INVITE (credentials). The PBX sends the INVITE again, with Proxy-Authorization and the next CSeq.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC checks that the caller's number belongs to this trunk. It relays the media through its own address.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. It removes +1, because the country code is local to it.
- PSTN → Carrier gateway: ISUP ACM. Bob's mobile rings. The ACM says that the exchange plays the ringback tone in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (ringback tone). Alice hears the ringback tone from the far exchange, through the gateway and the SBC.
- PSTN → Carrier gateway: ISUP ANM. Bob answers. The ANM starts the charge for the call.
- Carrier gateway → Carrier SBC: 200 OK. The gateway maps the ANM to 200 OK.
- Carrier SBC → PBX: 200 OK. The SBC answers the PBX on its own dialog.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 200 OK.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the 200 OK on its own dialog.
- PBX → Carrier gateway: RTP. The call audio flows in both directions, through the SBC.
- PSTN → Carrier gateway: ISUP REL (cause 16). Bob hangs up. The exchange releases the call with cause 16, normal call clearing.
- Carrier gateway → Carrier SBC: BYE. The gateway ends the SIP call. The Reason header carries the Q.850 cause.
- Carrier SBC → Carrier gateway: 200 OK. The SBC confirms the BYE.
- Carrier SBC → PBX: BYE. The SBC ends its dialog with the PBX, and copies the Reason.
- PBX → Carrier SBC: 200 OK. The PBX confirms. Its call record shows cause 16: Bob hung up.
A registration-based trunk registers one number, often the main number of the company, and the carrier routes the whole number block to that binding. RFC 6140 defines a standard REGISTER for a block of numbers, but most carriers use their own conventions. Read your carrier’s trunk guide.
“For purposes of efficiency, many of these deployments do not wish to maintain separate registrations for each of the AORs in the block.”Read the section ↗
24.2 Numbers: E.164, tel URIs, user=phone, normalisation
Users dial numbers in many ways: 9 for an outside line, seven digits for a local call, 011 for an international one. A carrier cannot guess what each PBX means, so trunks almost always carry numbers in E.164E.164. The ITU-T plan for international telephone numbers: a country code and a national number, at most 15 digits. Written with a leading +, as in +14045550199. format: +, the country code, and the national number, with no prefixes.
“Globally unique numbers are identified by the leading "+" character.”Read the section ↗
The PBX therefore does number normalisationnumber normalisation. Changing a number from the format a user dialled, or a network uses, into another format, usually E.164.: it removes the outside-line prefix, replaces an international prefix with +, and adds the country code and area code where they are missing. Try some numbers, in two different countries:
Number normaliser
From what the user dialled to what the trunk carries
Outside line 9 · international prefix 011 · country code +1 · area code 404
Local number
- Remove spaces, dashes, dots, and brackets
95550199 - Remove the outside-line prefix 9
5550199 - Add +1 and the PBX's area code, 404
+14045550199
- E.164
+14045550199- tel URI
tel:+14045550199- Request-URI
sip:+14045550199@sip.carrier.example;user=phone- Unnormalised
tel:5550199;phone-context=+1-404- ISUP, at a gateway in this country
4045550199(national number)
A local number in a URI must say where it is valid, with phone-context. Most carriers accept only E.164, so the PBX adds the country and area code.
A number can travel in two kinds of URI. A tel URItel URI. A URI that holds a telephone number, such as tel:+12025550123., tel:+14045550199, is only a number. A SIP URI with user=phone, sip:+14045550199@sip.carrier.example;user=phone, says that the user part is a telephone number, and also names the host that routes it. Trunks usually use the second form. A local number in either form must say where it is valid:
“If the user string contains a telephone number formatted as a telephone-subscriber, the user parameter value "phone" SHOULD be present.”Read the section ↗
“Local numbers MUST have a 'phone-context' parameter that identifies the scope of their validity.”Read the section ↗
At the gateway, the number goes into the ISUP IAMIAM. The ISUP message that starts a call. It carries the called and calling numbers. A gateway sends it when it receives an INVITE.. If the country code is the gateway’s own, it becomes a national number:
“If the country code is local to the gateway (the gateway has one or more trunks that point to switches which are homed to the country code in question), the gateway SHOULD set the NoA to reflect 'national (significant) number' and strip the country code from the URI before populating the digits field.”Read the section ↗
A number that is not in international format may not work at all. Set Number sent to Local in the builder:
Flow builder · seven digits, with no area code
A call to the PSTN on an IP-based trunk: the number is incomplete
- SIP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. The PBX sends seven digits, as the user dialled them. Without an area code, the number is incomplete.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC cannot know which area code the PBX means. It passes the seven digits on.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → Carrier SBC: 484 Address Incomplete. The number has no + and no area code, so the gateway cannot build an ISUP number from it.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the failure on its hop.
- Carrier SBC → PBX: 484 Address Incomplete. The SBC passes the 484 back, with the Reason. The PBX must send the number in a format that the carrier accepts.
- PBX → Carrier SBC: ACK. The PBX acknowledges it, and shows the user the right message.
“If the URI is not in international format, the gateway MAY attempt to treat the telephone number within the URI as if it were appropriate to its national or network-specific dialing plan; if doing so gives rise to internal gateway errors or the gateway does not support such procedures, then the gateway SHOULD respond with appropriate SIP status codes to express that the URI could not be understood (if the URI in question is the Request-URI, a 484).”Read the section ↗
24.3 Caller ID: From, PAI, and Privacy; withheld numbers
Module 7 introduced the three headers, and Module 14 the trust domain. On a trunk, they decide the number on the called phone:
- From is what the PBX writes. Carriers do not trust it for the caller’s number.
- P-Asserted-Identity (PAI) is the identity that the carrier checks. The carrier SBC accepts it only if the number belongs to this trunk, or if the call shows why it does not (24.4).
- Privacy: id asks the network to keep that identity from the called party. At the gateway, it becomes the ISUP presentation restrictionpresentation restriction. A request that the called phone does not show the caller's number. The network still knows the number. flag.
| The PBX sends | The SBC passes on | The ISUP IAM | Bob’s mobile shows |
|---|---|---|---|
| From and PAI with Alice’s number | PAI | Presentation allowed | +1 404 555 0101 |
| Anonymous From, PAI, Privacy: id | PAI and Privacy: id | Presentation restricted | “Withheld” |
| Anonymous From and PAI, no Privacy | PAI | Presentation allowed | +1 404 555 0101 |
Flow builder · a withheld number
A call to the PSTN on an IP-based trunk: Bob answers
- SIP
- RTP media
- TCP / IP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. Alice withholds her number: an anonymous From, P-Asserted-Identity, and Privacy: id.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC checks that the caller's number belongs to this trunk. It relays the media through its own address.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. Privacy: id becomes "presentation restricted", so the mobile shows no number.
- PSTN → Carrier gateway: ISUP ACM. Bob's mobile rings. The ACM says that the exchange plays the ringback tone in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (ringback tone). Alice hears the ringback tone from the far exchange, through the gateway and the SBC.
- PSTN → Carrier gateway: ISUP ANM. Bob answers. The ANM starts the charge for the call.
- Carrier gateway → Carrier SBC: 200 OK. The gateway maps the ANM to 200 OK.
- Carrier SBC → PBX: 200 OK. The SBC answers the PBX on its own dialog.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 200 OK.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the 200 OK on its own dialog.
- PBX → Carrier gateway: RTP. The call audio flows in both directions, through the SBC.
- PSTN → Carrier gateway: ISUP REL (cause 16). Bob hangs up. The exchange releases the call with cause 16, normal call clearing.
- Carrier gateway → Carrier SBC: BYE. The gateway ends the SIP call. The Reason header carries the Q.850 cause.
- Carrier SBC → Carrier gateway: 200 OK. The SBC confirms the BYE.
- Carrier SBC → PBX: BYE. The SBC ends its dialog with the PBX, and copies the Reason.
- PBX → Carrier SBC: 200 OK. The PBX confirms. Its call record shows cause 16: Bob hung up.
“ISUP has a concept of presentation restriction - a mechanism by which a user can specify that they would not like their telephone number to be displayed to the person they are calling (presumably someone with Caller ID).”Read the section ↗
“The presence of this privacy type in a Privacy header field indicates that the user would like the Network Asserted Identity to be kept private with respect to SIP entities outside the Trust Domain with which the user authenticated.”Read the section ↗
A withheld number is hidden only from the called party. The carrier still has it in the IAM, for emergency services, for complaints about nuisance calls, and for its own records.
24.4 Diversion and History-Info for forwarded calls
Carol calls Alice’s DID from the PSTN, and Alice has forwarded her calls to her mobile. The PBX makes a new call on the trunk, from Carol’s number to the mobile. To the carrier, this looks like a PBX that uses a number it does not own. The forwarding history explains it:
Diversion: <sip:+14045550101@sip.carrier.example;user=phone>;reason=unconditional;counter=1
History-Info: <sip:+14045550101@pbx.atlanta.example;user=phone?Reason=SIP%3Bcause%3D302>;index=1
History-Info: <sip:+14045550199@sip.carrier.example;user=phone>;index=1.1;mp=1
Both say the same thing: the call was for +1 404 555 0101, and that number forwarded it unconditionally. In History-Info, cause=302 is the reason, and mp=1 says that the new target is a different user, “mapped from” entry 1. Set Forwarded call in the builder, and compare With no history:
Flow builder · a forwarded call, with Diversion
A call to the PSTN on an IP-based trunk: Bob answers
- SIP
- RTP media
- TCP / IP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. From and P-Asserted-Identity give Carol's number: Alice forwards the call, so Carol is the caller.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. Carol's number is not one of the trunk's numbers. Diversion shows that Alice's number forwarded the call, so the SBC accepts it.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. Alice's number goes in the original called number.
- PSTN → Carrier gateway: ISUP ACM. Bob's mobile rings. The ACM says that the exchange plays the ringback tone in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (ringback tone). Carol hears the ringback tone from the far exchange, through the gateway and the SBC.
- PSTN → Carrier gateway: ISUP ANM. Bob answers. The ANM starts the charge for the call.
- Carrier gateway → Carrier SBC: 200 OK. The gateway maps the ANM to 200 OK.
- Carrier SBC → PBX: 200 OK. The SBC answers the PBX on its own dialog.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 200 OK.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the 200 OK on its own dialog.
- PBX → Carrier gateway: RTP. The call audio flows in both directions, through the SBC.
- PSTN → Carrier gateway: ISUP REL (cause 16). Bob hangs up. The exchange releases the call with cause 16, normal call clearing.
- Carrier gateway → Carrier SBC: BYE. The gateway ends the SIP call. The Reason header carries the Q.850 cause.
- Carrier SBC → Carrier gateway: 200 OK. The SBC confirms the BYE.
- Carrier SBC → PBX: BYE. The SBC ends its dialog with the PBX, and copies the Reason.
- PBX → Carrier SBC: 200 OK. The PBX confirms. Its call record shows cause 16: Bob hung up.
“Question 1: From whom was the request diverted? Question 2: Why was the request diverted?”Read the section ↗
“This request history information allows the receiving application to obtain information about how and why the SIP request arrived at the application/user.”Read the section ↗
The gateway copies the history into the IAM as the original called number and the redirection information. A voicemail system in the PSTN or behind the PBX uses the same history for the same purpose: to find the right mailbox. Many carriers accept only one of the two headers; the trunk guide says which.
24.5 Q.850 causes and SIP codes; the Reason header
The gateway translates between two signaling protocols, message by message (RFC 3398):
| ISUP message | Meaning | SIP |
|---|---|---|
| IAMIAM. The ISUP message that starts a call. It carries the called and calling numbers. A gateway sends it when it receives an INVITE. | Set up a call to this number | INVITE |
| ACMACM. The ISUP message that says the exchange has the whole number and the phone is ringing. A gateway turns it into 180 or 183. | The number is complete; the phone rings | 180 Ringing, or 183 with SDP for in-band tones |
| ANMANM. The ISUP message that says the called phone answered. Charging starts here. A gateway turns it into 200 OK. | The phone answered; charging starts | 200 OK |
| RELREL. The ISUP message that ends or rejects a call. It carries a Q.850 cause., with a cause | End or reject the call | BYE, CANCEL, or a 4xx–6xx response |
“An REL can be sent to tear down a call that is already in progress (BYE), to cancel a previously sent call setup request that has not yet been completed (CANCEL), or to reject a call setup request (IAM) that has just been received (corresponding to a SIP status code).”Read the section ↗
Every REL carries a Q.850Q.850. The ITU-T list of cause values that telephone networks use to say why a call ended, such as 16 (normal clearing) or 17 (user busy). cause. The gateway maps it to a SIP response, and also copies it into a Reason header, so the SIP side keeps the exact cause:
“Any SIP Response message, with the exception of a 100 (Trying), MAY contain a Reason header field with a Q.850 [Q.850] cause code.”Read the section ↗
SIP/2.0 486 Busy Here
Reason: Q.850;cause=17;text="User busy"
Change The PSTN in the builder to see each cause:
Flow builder · the mobile is busy
A call to the PSTN on an IP-based trunk: Bob is busy
- SIP
- TCP / IP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. The PBX sends the number in E.164 format: + and the country code. Any carrier can route it.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC checks that the caller's number belongs to this trunk. It relays the media through its own address.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. It removes +1, because the country code is local to it.
- PSTN → Carrier gateway: ISUP REL (cause 17). Bob's mobile is on another call. The exchange releases the call with cause 17.
- Carrier gateway → Carrier SBC: 486 Busy Here. The gateway maps cause 17 to 486, and adds the cause in a Reason header.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the failure on its hop.
- Carrier SBC → PBX: 486 Busy Here. The SBC passes the 486 and its Reason to the PBX.
- PBX → Carrier SBC: ACK. The PBX acknowledges it, and shows the user the right message.
| Q.850 cause (REL) | → SIP response | SIP response | → Q.850 cause (REL) |
|---|---|---|---|
| 1 Unallocated number | 404 | 404 Not Found | 1 |
| 17 User busy | 486 | 486 Busy Here | 17 |
| 19 No answer from user | 480 | 480 Temporarily Unavailable | 18 No user responding |
| 28 Invalid number format | 484 | 484 Address Incomplete | 28 |
| 34 No circuit available | 503 | 503 Service Unavailable | 41 Temporary failure |
| 16 Normal call clearing | BYE (not a response) | BYE | 16 |
The mapping is not the same in both directions. A cause that passes through two gateways can therefore change, and many networks change the defaults. When the cause matters, as for billing records or for announcements, read the Reason header, not only the status code. Module 6 has the longer table.
24.6 Early media from the PSTN: ringback and announcements in 183
On a SIP call between two phones, the caller’s phone makes its own ringback tone when a 180 arrives. On a call to the PSTN, the far exchange often plays the tones, or an announcement such as “The number you have called is not in service”. The ACM says so, and the gateway sends 183 Session Progress with SDP, then sends that audio as early mediaearly media. Audio sent before the call is answered, such as a ringback tone or an announcement from the far network.:
“After early media transmission has been initiated, the gateway SHOULD send a 183 Session Progress response code.”Read the section ↗
“For telephony, establishment of media in the backwards direction is desirable so that tones and announcements can be played, especially when interworking with a network that cannot signal call status out of band (such as a legacy MF network).”Read the section ↗
Flow builder · an announcement before the 404
A call to the PSTN on an IP-based trunk: the number is not in service
- SIP
- RTP media
- TCP / IP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. The PBX sends the number in E.164 format: + and the country code. Any carrier can route it.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC checks that the caller's number belongs to this trunk. It relays the media through its own address.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. It removes +1, because the country code is local to it.
- PSTN → Carrier gateway: ISUP ACM. The exchange has an announcement for this number. The ACM says to listen in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (announcement). Alice hears the exchange's announcement: "The number you have called is not in service."
- PSTN → Carrier gateway: ISUP REL (cause 1). After the announcement, the exchange releases the call with cause 1.
- Carrier gateway → Carrier SBC: 404 Not Found. The gateway maps cause 1 to 404, with the cause in a Reason header.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the failure on its hop.
- Carrier SBC → PBX: 404 Not Found. The SBC passes the 404 on. Alice has already heard why the call failed.
- PBX → Carrier SBC: ACK. The PBX acknowledges it, and shows the user the right message.
If the ACM says only that the phone rings, with no in-band information, the gateway sends 180 with no SDP, and the PBX makes the ringback tone itself. Turn off In-band tones to compare.
“If the ACM contains a Backward Call Indicators parameter with a value of 'subscriber free', the gateway SHOULD send a '180 Ringing' response.”Read the section ↗
Early media is free for the caller: the exchanges start charging at the ANM. Some networks limit how long early media can last for this reason, and some phones abuse it to talk before the answer.
“In common ISUP network practice, billing commences when the ANM is received.”Read the section ↗
Three practical points:
- A PBX that plays its own ringback tone on 183 hides the announcement from the caller. Module 21 shows this mistake.
- Many gateways send the 183 reliably, with
Require: 100rel, and expect a PRACK (Module 22). A PBX that does not support 100rel may get no early media at all. - In IMS networks, the P-Early-Media header (RFC 5009) says whether the network allows early media to flow on this call.
Common mistakes
A number in the wrong format for the carrier
A PBX sends numbers on the trunk as its users dial them. National numbers work, because this carrier adds +1. Local seven-digit numbers fail with 484, and an international call fails as soon as the PBX moves to a carrier in another country.
Broken: seven digits, as dialled
A call to the PSTN on an IP-based trunk: the number is incomplete
- SIP
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. The PBX sends seven digits, as the user dialled them. Without an area code, the number is incomplete.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC cannot know which area code the PBX means. It passes the seven digits on.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → Carrier SBC: 484 Address Incomplete. The number has no + and no area code, so the gateway cannot build an ISUP number from it.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the failure on its hop.
- Carrier SBC → PBX: 484 Address Incomplete. The SBC passes the 484 back, with the Reason. The PBX must send the number in a format that the carrier accepts.
- PBX → Carrier SBC: ACK. The PBX acknowledges it, and shows the user the right message.
Remember: normalise every number to E.164 in the PBX, before the trunk. Use the format the carrier’s trunk guide asks for, and test local, national, international, and emergency calls.
The original called number is lost on a forwarded call
Calls to Alice that she does not answer go to a voicemail server. The PBX makes the new INVITE with Carol’s number in From, but adds no Diversion or History-Info. The voicemail server cannot tell whose mailbox to open, plays its main menu, and Carol hangs up.
Problem: no history
Forwarded to voicemail, with no history
- SIP
- RTP media
- ⚠Problem
Carol calls Alice's direct number from the PSTN. The carrier sends the call down the trunk.
All steps as text
- Carrier SBC → PBX: INVITE. Carol calls Alice's direct number from the PSTN. The carrier sends the call down the trunk.
- PBX → Carrier SBC: 100 Trying. The PBX looks up the extension for this DID: Alice.
- PBX → Alice: INVITE. The PBX calls Alice's desk phone on its own dialog.
- Alice → PBX: 180 Ringing. Alice's phone rings, but she is not at her desk.
- PBX → Carrier SBC: 180 Ringing. The PBX passes the ringing on to Carol.
- PBX → Alice: CANCEL. After 20 seconds with no answer, the PBX stops ringing Alice's phone.
- Alice → PBX: 200 OK (CANCEL). Alice's phone accepts the CANCEL.
- Alice → PBX: 487 Request Terminated. Alice's phone ends the INVITE transaction.
- PBX → Alice: ACK. The PBX acknowledges the 487.
- PBX → Voicemail server: INVITE. The PBX forwards the call to voicemail. The INVITE gives only Carol's number, and nothing about Alice. Problem: The voicemail server cannot tell whose mailbox this call is for.
- Voicemail server → PBX: 200 OK. The voicemail server answers. It does not know which mailbox to open.
- PBX → Voicemail server: ACK. The PBX acknowledges the 200 OK.
- PBX → Carrier SBC: 200 OK. The PBX answers Carol's call, with its own SDP.
- Carrier SBC → PBX: ACK. The carrier acknowledges the 200 OK.
- Voicemail server → Carrier SBC: RTP (main menu). Carol hears "Please enter the mailbox number". She does not know it, and hangs up. Problem: Carol leaves no message, and Alice never learns that she called.
Remember: every element that forwards a call adds Diversion or History-Info, and every B2BUA in the path passes them on. Check which header the voicemail server and the carrier read.
Forwarding a call with the caller's number and no history
The same PBX forwards a call from Carol to Alice’s mobile, with Carol’s number in P-Asserted-Identity and no Diversion. The carrier sees a number that does not belong to the trunk and replaces it with the company’s main number, or rejects the call. Alice’s mobile never shows who is calling.
Broken: no history
A call to the PSTN on an IP-based trunk: Bob answers
- SIP
- RTP media
- TCP / IP
- ⚠Problem
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. From and P-Asserted-Identity give Carol's number: Alice forwards the call, so Carol is the caller.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. Carol's number is not one of the trunk's numbers, and nothing shows a forwarded call. The SBC replaces it with the trunk's main number. Problem: The PSTN now gets the company's main number, not Carol's. Bob cannot tell who is calling.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. It removes +1, because the country code is local to it.
- PSTN → Carrier gateway: ISUP ACM. Bob's mobile rings. The ACM says that the exchange plays the ringback tone in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (ringback tone). Carol hears the ringback tone from the far exchange, through the gateway and the SBC.
- PSTN → Carrier gateway: ISUP ANM. Bob answers. The ANM starts the charge for the call.
- Carrier gateway → Carrier SBC: 200 OK. The gateway maps the ANM to 200 OK.
- Carrier SBC → PBX: 200 OK. The SBC answers the PBX on its own dialog.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 200 OK.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the 200 OK on its own dialog.
- PBX → Carrier gateway: RTP. The call audio flows in both directions, through the SBC.
- PSTN → Carrier gateway: ISUP REL (cause 16). Bob hangs up. The exchange releases the call with cause 16, normal call clearing.
- Carrier gateway → Carrier SBC: BYE. The gateway ends the SIP call. The Reason header carries the Q.850 cause.
- Carrier SBC → Carrier gateway: 200 OK. The SBC confirms the BYE.
- Carrier SBC → PBX: BYE. The SBC ends its dialog with the PBX, and copies the Reason.
- PBX → Carrier SBC: 200 OK. The PBX confirms. Its call record shows cause 16: Bob hung up.
Remember: a forwarded call keeps the original caller’s number only if the INVITE shows which of the trunk’s numbers forwarded it.
Withholding the number in From only
A user asks for their number to be withheld. The PBX writes an anonymous From, but still sends P-Asserted-Identity, and no Privacy header. The network treats the asserted identity as public, and the called phone shows the number.
Broken: anonymous From only
A call to the PSTN on an IP-based trunk: Bob answers
- SIP
- RTP media
- TCP / IP
- ⚠Problem
The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
All steps as text
- Carrier SBC → PBX: OPTIONS. The carrier knows the PBX by its fixed address, 192.0.2.20: no REGISTER, no password. It checks the PBX with OPTIONS.
- PBX → Carrier SBC: 200 OK. The PBX is up. The carrier sends calls only to a PBX that answers its OPTIONS.
- PBX → Carrier SBC: INVITE. Alice withholds her number, but the PBX only makes From anonymous. It sends no Privacy header. Problem: Without Privacy: id, the network treats the identity in P-Asserted-Identity as public.
- Carrier SBC → PBX: 100 Trying. The SBC accepts the INVITE and starts its own call to the gateway.
- Carrier SBC → Carrier gateway: INVITE. The SBC checks that the caller's number belongs to this trunk. It relays the media through its own address.
- Carrier gateway → Carrier SBC: 100 Trying. The gateway takes the call.
- Carrier gateway → PSTN: ISUP IAM. The gateway starts the PSTN call. With no Privacy header, the number goes out as "presentation allowed". Problem: Alice wanted her number withheld, but the PSTN now treats it as public.
- PSTN → Carrier gateway: ISUP ACM. Bob's mobile rings. The ACM says that the exchange plays the ringback tone in-band.
- Carrier gateway → Carrier SBC: 183 Session Progress. The gateway sends 183 with an SDP answer, and connects the in-band audio.
- Carrier SBC → PBX: 183 Session Progress. The SBC passes the 183 on, with its own SDP. The PBX must play the media, not a local tone.
- Carrier gateway → PBX: RTP (ringback tone). Alice hears the ringback tone from the far exchange, through the gateway and the SBC.
- PSTN → Carrier gateway: ISUP ANM. Bob answers. The ANM starts the charge for the call.
- Carrier gateway → Carrier SBC: 200 OK. The gateway maps the ANM to 200 OK.
- Carrier SBC → PBX: 200 OK. The SBC answers the PBX on its own dialog.
- PBX → Carrier SBC: ACK. The PBX acknowledges the 200 OK.
- Carrier SBC → Carrier gateway: ACK. The SBC acknowledges the 200 OK on its own dialog.
- PBX → Carrier gateway: RTP. The call audio flows in both directions, through the SBC.
- PSTN → Carrier gateway: ISUP REL (cause 16). Bob hangs up. The exchange releases the call with cause 16, normal call clearing.
- Carrier gateway → Carrier SBC: BYE. The gateway ends the SIP call. The Reason header carries the Q.850 cause.
- Carrier SBC → Carrier gateway: 200 OK. The SBC confirms the BYE.
- Carrier SBC → PBX: BYE. The SBC ends its dialog with the PBX, and copies the Reason.
- PBX → Carrier SBC: 200 OK. The PBX confirms. Its call record shows cause 16: Bob hung up.
Remember: to withhold a number, send Privacy: id with P-Asserted-Identity, and an anonymous From. Test with a mobile phone, not only with another phone on the same PBX.
Summary
- A SIP trunk connects a PBX to a carrier. A registration-based trunk uses REGISTER and digest authentication; an IP-based trunk uses a fixed address, and often OPTIONS to check that the PBX is up.
- Trunks carry numbers in E.164:
+, the country code, and the national number. The PBX normalises what users dial. A local number in a URI needsphone-context. - P-Asserted-Identity carries the caller’s number that the carrier checks; Privacy: id withholds it and becomes ISUP presentation restriction. An anonymous From alone withholds nothing.
- On a forwarded call, Diversion or History-Info shows which number forwarded the call. Carriers need it to accept the caller’s number, and voicemail needs it to find the mailbox.
- The gateway maps IAM, ACM, ANM, and REL to INVITE, 180 or 183, 200 OK, and BYE or an error. Reason: Q.850 keeps the exact cause, because the mapping between causes and status codes loses detail.
- 183 with SDP carries tones and announcements from the PSTN. Play that media; make a local ringback tone only after a 180 without SDP.