Hi Folks,

Just found another simple use case of the dispatcher latency stats.

Just shraing this idea of a feature I want to contribute.

When using dispatcher algorithm 8:

   “8” - select destination sorted by priority attribute value (serial forking ordered by priority).

If the gateway as the attribute, the priority becomes the estimated latency.

   cc-priority

- The dispatcher would automatically prioritize the closest one.
- If a gateway is becoming unresponsive it will automatically become de prioritize.

Consider this real life scenario where you have gateways in East and West Coast
Example

URI: sip:28.71.19.140                                                                                                                                                                                      
FLAGS: AP
PRIORITY: 10
ATTRS: {
        BODY: cc_priority=1
}
LATENCY: {
        AVG: 84.001000
        STD: 0.062000
        EST: 84.001000 (high == low priority)
        MAX: 93
        TIMEOUT: 0
URI: sip:28.71.16.140
FLAGS: AP
PRIORITY: 10
ATTRS: {
        BODY: cc_priority=1
}
LATENCY: {
        AVG: 29.110000
        STD: 2.383000
        EST: 31.999000 (low == high priority)
        MAX: 1499
        TIMEOUT: 1


Another major improvement to all of this would be to gather stats on INVITE <> 100 to have a very accurate latency estimation even if the gateway does not support SIP OPTIONS pings