How do extensions “stay registered”

Home » Asterisk Users » How do extensions “stay registered”
Asterisk Users 6 Comments

I know this is probably a very basic question for many on this list. But in troubleshooting an issue, I wanted to take a step back & ask the question. In Asterisk (or maybe all SIP), how do extensions stay registered with the SIP server?

Do the extensions simply register repeatedly as a means of telling asterisk “I’m still here”, or are there actual keepalive packets that are transmitted to actually keep a TCP session alive? My guess is the former.

But am I oversimplifying it? Is there more to the process?

Thanks,

Doug Mortensen
Network Consultant
Impala Networks Inc
CCNA, MCSA, Security+, A+
Linux+, Network+, Server+
.
www.impalanetworks.com
P: (505) 327-7300
F: (505) 327-7545
.

6 thoughts on - How do extensions “stay registered”

  • SIP normally doesn’t use TCP, it uses UDP, and is sessionless in that
    context. The exact mechanics of a registration can get deeply involved, so
    I’m going to give a very cursory overview. The endpoint tells the server
    (Asterisk, or whatever) that it would like to register, with a username and
    password, and what its IP address and port are. The server puts this in a
    list, and when it has a call for that endpoint, sends UDP packets to the
    known IP and port. There it typically encounters a NAT rounter, which had
    opened the port during the original registration and hopefully still has it
    open.

    You can enable a feature called NAT keep-alive on most endpoints to
    overcome bad NAT in some routers.

    On Mon, Nov 14, 2011 at 2:51 PM, Douglas Mortensen
    wrote:

  • “Extensions” do not register – peers do. A peer can register itself or be
    registered by Asterisk. In most cases the “extension” is equivalent to the
    “peer” (301 = 301) but it can be quite different (301 = sipuser1) or (301 =
    doug@impalanetworks.com).

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Douglas
    Mortensen
    Sent: Monday, November 14, 2011 3:52 PM

    I know this is probably a very basic question for many on this list. But in
    troubleshooting an issue, I wanted to take a step back & ask the question.
    In Asterisk (or maybe all SIP), how do extensions stay registered with the
    SIP server?

    Do the extensions simply register repeatedly as a means of telling asterisk
    “I’m still here”, or are there actual keepalive packets that are transmitted
    to actually keep a TCP session alive? My guess is the former.

    But am I oversimplifying it? Is there more to the process?

    Thanks,

    Doug Mortensen

    Network Consultant

    Impala Networks Inc

    CCNA, MCSA, Security+, A+

    Linux+, Network+, Server+

    .

    http://www.impalanetworks.com

    P: (505) 327-7300

    F: (505) 327-7545

    .

  • Continuing eherr here, behind the OPTIONS messages(infact all SIP comm) you
    definitely to look into SIP timers which tell how many time to resend a
    packet if no response is received and for how long to wait before thinking
    that the SIP packet got lost(network disconnected or end-point lost)

    so, qualify=yes a peer means to send-keep alives and have the NAT mechanism
    stay active, as soon as the SIP keep-alive packets reach a no-reply (max
    time)x(max retries) Asterisk marks the peer as UNREACHABLE.

    qualify=no wouldn’t do all of the above.

    Another interesting thing to know is that SIP end-points have registrations
    time-out and refresh Registration timers as well. So if everything is going
    well, SIP end-points refresh their registration after some defined time.

  • Thanks for the answer Danny. Can you give an example of when we would setup peers through Method 1 & 2 as you described?

    If I am using FreePBX & setup generic SIP extensions & then use Polycom phones & configure them to register with the SIP server (asterisk) with the extension/user & password, are these extensions (or maybe more correctly “peers”) I setup via FreePBX actually “self-registration” or “required-registration” peers?

    Thanks,

    Doug Mortensen
    Network Consultant
    Impala Networks
    P: 505.327.7300

    Sent: Monday, November 14, 2011 3:26 PM

    Just trying to offer a little enlightenment – There are basically two methods of sip phone (peer/extension) registration. Method 1 is “self-registration” where Asterisk does not know or care about the phone until it asks to register. Method 2 is “required-registration” where Asterisk expects the phone to be there pretty much 24/7 and will attempt to register the phone and verify that it is still there at whatever frequency is specified. I personally record method 1 phones in users.conf and method 2 phones in sip.conf.

    Sent: Monday, November 14, 2011 4:19 PM

    I think the question is more along the lines of how does asterisk know immediately when a sip phone becomes on line and when you unplug the phone from the network, how does asterisk essentially know immediately that it status is “UNKNOWN”

    If I am not mistaken.

  • OK. Thanks everyone for the responses. If I can summarize, I think here’s what’s been discussed:

    Asterisk becomes aware of SIP extensions/peers, as soon as they register.

    Regarding how asterisk becomes aware of (or determines) that they are unavailable/unreachable, I believe I am hearing two possible scenarios:

    1. “The Interval of Registration”. So asterisk has a timeout value that it is expecting the phone to reregister within. If the phone does not reregister within the timeout period, then asterisk determines that the extension/peer is no longer available. A few questions I have on this are:

    a. Where does this “timeout” interval come from? Is it a configuration parameter that we configure asterisk with, or is it something that is dynamically determined, or is it something that the phone/peer actually dictates to asterisk?

    b. If it is an asterisk configuration parameter, where does it exist (how do I set it & confirm what it is currently set to)? It is a per-extension/peer setting, or is it global?

    c. Is there a command I can issue from the asterisk CLI to query it?

    2. “qualify=yes” can be configured for any given SIP peer in asterisk. This will send a SIP OPTIONS message/packet to the peer every 1 or 2 minutes (depending on the configuration) that probes the peer to confirm it is still online. The keepalives (SIP OPTIONS packets) are actually sent from asterisk to the SIP peer, correct? But then the SIP peer actually has to respond to each one with its own SIP packet, correct? With this scenario, asterisk will still utilize scenario 1 (reregistration) as a means of determining that the peer is available, but additionally will continue to monitor the peer constantly (every 1-2 seconds) via these keepalives? This way asterisk is able to have a much more rapid discovery of peers that become unavailable (because they are literally no longer reachable, as they’re no longer responding to the keepalives), correct? So my next questions are:

    a. Am I wrong with any of the above interpretations of the explanations you guys have given?

    b. Is the “no-reply” timer Sammy mentioned [(max time)x(max retries)] a parameter that can be set within asterisk? If so, what are the corresponding configuration parameters called? If not, what are the “max time” and “max retries” values?

    c. Is the SIP response the peer is supposed to give also an OPTIONS packet or something else?

    Thanks a LOT! I really appreciate all of the input & insight you guys bring!


    Doug Mortensen
    Network Consultant
    Impala Networks
    P: 505.327.7300

    Sent: Monday, November 14, 2011 10:36 PM

    Continuing eherr here, behind the OPTIONS messages(infact all SIP comm) you definitely to look into SIP timers which tell how many time to resend a packet if no response is received and for how long to wait before thinking that the SIP packet got lost(network disconnected or end-point lost)

    so, qualify=yes a peer means to send-keep alives and have the NAT mechanism stay active, as soon as the SIP keep-alive packets reach a no-reply (max time)x(max retries) Asterisk marks the peer as UNREACHABLE.

    qualify=no wouldn’t do all of the above.

    Another interesting thing to know is that SIP end-points have registrations time-out and refresh Registration timers as well. So if everything is going well, SIP end-points refresh their registration after some defined time.

    I think the wrap up answer is the interval of registration compacted, if used, with the SIP OPTION packet.

    I like the SIP OPTION packet because we have scripts to monitor the status and lets us know when a phone is up or down.

  • Hey,

    I haven’t thoroughly read the whole of your reply- just a quick answer to
    your timers question-generally I think you’re right. Those timers are
    property of UAC so you may need to look into the phone configurations.
    I’d CISCO 79X0 phones and we wanted those to refresh their registrations at
    very short intervals of time as well as the INVITES timers was reduced
    too,…umm..I think that was for DNS-SRV based failovers. Though reducing
    the default timers from UAC heavily increased SIP traffic but we achieved
    the target by reducing the SIP timers in all phones.

    So that was an example.

    When you are using Asterisk as UAC to register onto another SIP server you
    can change the registration timeout and retry variables..and yes you can
    change these SIP timers in Asterisk sip.conf but thats not recommended.(see
    sip.conf.sample for details too)

    PS: with a quick look at sip.conf.sample + voip-info.org sip.conf details +
    google you can find lot more information than what you’ve collected so far.