[asterisk-dev] What's an AOR?

Mark Michelson mmichelson at digium.com
Thu May 23 09:48:47 CDT 2013


On 05/22/2013 01:42 PM, Olle E. Johansson wrote:
> 22 maj 2013 kl. 20:18 skrev Mark Michelson <mmichelson at digium.com>:
>
>> This is not correct. The replacement for peer/user is the type "endpoint". The term "endpoint" is generic enough that it can refer to any sort of logical SIP device with which Asterisk will be communicating.
>>
>> An endpoint may be configured to have any number of aors associated with it. In turn, each aor may have multiple contacts bound to it. This allows a hierarchical structure that decouples endpoints from locations.
> Mark,
> Since I obviously have misunderstood this architecture - can you please describe how this is configured and use cases for this structure. Also, how it is handled by the core pbx - since you now can have multiple devices for one dialstring entry?
>
> Thanks,
> /O

Sure thing. Let's consider a business where you and I work together as 
support technicians. We each have a desk phone (an "endpoint" by 
Asterisk definition), so we initially set up a very simple configuration 
like so:

res_sip.conf:

[mark]
type = endpoint
callerid = Mark <1234>
disallow = all
allow = ulaw
aor = mark-aor
context = default

[mark-aor]
type=aor
max_contacts=1

[olle]
type=endpoint
callerid = oej <5678>
disallow = all
allow = alaw
aor = oej-aor
context = default

[olle-aor]
type=aor
max_contacts=1

extensions.conf:

exten => 1000,1,Dial(PJSIP/mark)
exten => 2000,1,Dial(PJSIP/oej)

So as you can see, the endpoint sections of res_sip.conf describe the 
actual devices with which communication will occur. We set things like 
callerid, codecs, that sort of thing. In addition, device state is 
something that pertains to an endpoint. The aor section right now is 
minimal, because all we're doing is stating the maximum number of 
contacts that can be dynamically bound to the AoR. We could also place 
permanent contact URIs in this section if we wanted. extensions.conf 
just has two entries that attempt to dial you or me.

As is, you and I cannot be dialed because the AoRs for our endpoints 
have no bound contacts. However, our phones will send each send a 
REGISTER to bind contacts to specific AoRs. So for instance, my phone 
sends a REGISTER with a To: header of sip:mark-aor at domain_of_asterisk. 
Asterisk will bind whatever contact is in that REGISTER to the 
"mark-aor" AoR. Then when someone dials extension 1000, the result will 
be that the endpoint "mark" is looked up. Then all of mark's AoRs, will 
be looked up to try to find a contact to send the INVITE to. In this 
case, the 'mark-aor' is the one found, and there is a contact bound to 
that AoR, so that contact is the destination for the call.

A quick aside: for clarity in this example, I named the AoRs "mark-aor" 
and "olle-aor" so that it would be clear when I was referring to 
endpoints and when I was referring to AoRs. It is perfectly valid (and 
very likely) for AoRs and endpoints to share the same name. So endpoint 
"mark" and AoR "mark" can coexist. Similarly, if you wanted to have the 
AoRs be the same as what is in extensions.conf, you could instead have 
named the AoRs "1000" and "2000". Essentially, you have the flexibility 
to do what you need to in order to make things work.

So as a further detour, what happens if "mark-aor" had a higher number 
of max_contacts and my phone had bound multiple contacts to "mark-aor"? 
What would happen when we Dial(PJSIP/mark)? Unfortunately, app_dial is 
not equipped to understand that a single dialled destination can result 
in multiple contacts being called. So if you were to try 
Dial(PJSIP/mark), the result would be that only one contact would be 
dialled. In the case of phones, this will work out most of the time 
since most phones only register a single contact anyway. You can specify 
a URI to send to when dialling an endpoint by placing the URI after the 
endpoint name: Dial(PJSIP/mark/sip:uri at domain). If you want to be able 
to dial multiple bound contacts for an endpoint, then you can use the 
PJSIP_DIAL_CONTACTS() dialplan function to return a dialstring that can 
be passed to app_dial. So if I had bound both sip:mark1 at domain and 
sips:mark2 at domain to mark-aor at domain, then PJSIP_DIAL_CONTACTS(mark) 
would return PJSIP/mark/sip:mark1 at domain&PJSIP/mark/sips:mark2 at domain. 
This can then be passed to app_dial and both contacts will be dialed 
properly. If desired, the dialstring returned by PJSIP_DIAL_CONTACTS() 
can also be manipulated in the dialplan if desired (e.g. to remove one 
of the contacts from the string). PJSIP_DIAL_CONTACTS() can, in addition 
to the endpoint, be given an AoR to restrict the returned string to only 
having contacts bound to the specific AoR.

So now I've talked about binding multiple contacts to a single AoR, but 
I haven't talked about associating multiple AoRs for a single endpoint. 
The use cases for this are less common, but we didn't want the 
architecture to restrict an endpoint from having multiple AoRs 
associated with it. Some possible examples where this might be used are

* A phone has multiple lines that each correspond to different AoRs.
* An ITSP provides multiple accounts that each correspond to different AoRs.

Hopefully, this has shed some light on how this works. Obviously, 
documentation is lacking for now, but proper tutorials, use cases, etc. 
will make it to the wiki before the release of 12.

Mark Michelson



More information about the asterisk-dev mailing list