KB103 - How Trunk State Management Works


Why do we care about Trunk State

Clearfly employs a trunk state management mechanism which allows our VOIP switch to be aware of the current status of a customer’s SIP trunks. By knowing if a customer’s phone system or SIP endpoint is responding to SIP messages we can provide a better experience to the customer during times of outage and prevent calls from unnecessarily continuing during an outage.

For example if Clearfly had a call to deliver to the customer’s phone system and the customer was experiencing an outage with their internet the caller would experience 10-15 seconds of silence while our switch made repeated attempts to initiate the call. By knowing that the endpoint is unresponsive we can immediately forward the call via an Unavailable Forward or play an appropriate error message to the caller.

How it works

Once Clearfly’s switch has acquired the "Contact Address" of the customer’s SIP endpoint the switch will start a keepalive timer at zero and increment it by one every second until it receives a SIP message from the contact address. This contact address is found either via a successful registration or is statically configured based on the type of trunk configuration. This message can be one of the following:

  1. INVITE message for a new or existing call from the SIP endpoint.

  2. Response to a SIP OPTIONS request.

The most common SIP message coming from the customer’s system would be an INVITE for a call.

If the keepalive timer reaches 55 the switch will try and force an incoming SIP message by sending a SIP OPTIONS request to the the contact address. If the endpoint responds with a SIP message of any kind the timer will be reset to zero and the process will start all over again. However, if the endpoint fails to respond to repeated OPTIONS messages then:

  • The SIP trunks will be taken to an "out of order" state and calls destined for the customer’s endpoint will not be attempted and will follow out of order treatment.

  • Any established calls will be disconnected. This is a safeguard to ensure that calls are not left connected after connectivity is lost.

  • Any establishing calls will be canceled.

SIP OPTIONS requests will continue every 55 seconds until any SIP message is received from the specified contact.

What is an OPTIONS request?

An OPTIONS request is commonly called an OPTIONS PING but should not be confused with the well known networking "ping" or ICMP messages. A SIP OPTIONS request is commonly used to verify that the specified contact address is alive and healthy.

Must my device reply to an OPTIONS request?

Yes. Per RFC3261 the endpoint must respond to an OPTIONS request with a SIP message. This can be a "200 OK" or even a error message. The mere fact that it responded to a SIP message with any valid SIP message is enough to validate that the endpoint is responsive and reset the timer.

Common Issues

  • I’m not receiving any OPTIONS messages from Clearfly. This is likely because you have a firewall/NAT device in front of your SIP endpoint which is blocking the messages. A packet capture before your firewall/Nat device would confirm this.

  • I’m able to place outbound calls, but no inbound calls are reaching my phone system. The "out of order" status only affects inbound calls your phone system. As long as the outbound call comes from the established contact address the switch will accept the call.