Difference in SIP protocol for Trunks vs. Endpoints

I understand the use case differences for trunks vs devices from the FreePBX style. I am looking for a good knowledge base that would explain the technical difference between a SIP trunk and SIP endpoint. I’m not smart enough to read the protocol standards doc, but everything I google is "Why you should buy our SIP trunks!"
Thanks for the recommendations.

Ask the FreePBX people as neither SIP nor Asterisk makes such a distinction.

Are you saying there is no protocol difference, or practical use difference in the protocol format when I register say a Polycom to my Asterisk vs when I register my Asterisk to say Vitelity?

I don’t know what type of service Vitelity provide. A PABX is likely to be able to handle multiple calls which are up and carrying media and a phone is unlikely to look at the user part of the URI to work out which number was dialed.

From a protocol level there is no difference to what is fundamentally going on.

1 Like

If you look in sip.conf you will see that trunks and extensions are both treated the same way. Generally, extensions tend to use type=friend and trunks use type=peer. So it’s all in the configuration in sip.conf or the equivalent freepbx files.

Although the use of friend for “extensions” is actually an example of blindly following the cookbook, and type=peer is almost always better for those as well. Especially with tie trunks, you can end up with calls on the “trunk” matching a local “extension” because it has the same number as a remote one.


If there is no difference from a protocol point of view, in which field of a sip invite are specified the inbound caller id and the outbound called id when I have a trunk?

That depends. It can be in the From header, the Remote-Party-ID header, or the P-Asserted-Identity header. It depends on what is supported by the other side.

@jcolp Oh, I see.
So, if I were to develop a voip gateway to be connected through a trunk with asterisk, which method should I implement? Which is best? E.g., I read somewhere that Remote-Party-ID is a rejected RFC, although many sip devices support it.
Is there a way to configure asterisk to use one of the three methods when setting up a trunk?

Yes, Asterisk supports all three and can be configured to use a combination of them.

The essential difference on an outgoing “trunk” is that there must be a user part to the request URI, whereas it is optional when talking to a phone, if that phone only has one “line”. If the phone has more than one line, it could identify the line by registering form different port numbers, but it could also act as though it was connected by a “trunk” with a mini PBX within the device.

When registering, it can specify the user part to use. Registrations don’t have to be issued to a device which is local to the registering device, so a device that you call and endpoint can register in such a way that the first hop towards it has to be sent down what you call a trunk.

Nowhere in RFC 3261 does the word “trunk” appear, and the only use of extension is in the sense of an addition to the protocol.

A “trunk” doesn’t even need to use the user part. It is not uncommon for people to have a single incoming trunk, corresponding to a single address of record at their upstream provider, and use an IVR, or even a human operator, to determine the downstream routing. One could conceive of cases where an outgoing one used information other than the user part for onward routing.

@jcolp is there a way to see P-Asserted-Identity header value in asterisk ARI events?
I mean, let’s say I place a call to a stasis extension. With the caller id inside a P-Asserted-Identity header. Is there a way to retrieve the value of the caller id from ARI?

The channel driver (either chan_sip or chan_pjsip) if properly configured will parse, interpet, and place that information on the callerid store which is accessible using CALLERID[1]. Otherwise you could manually get the header using something like PJSIP_HEADER[2] and parse it yourself.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_CALLERID
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_PJSIP_HEADER