Hello,
I am using Sofia-SIP 1.12.10 and it works great. Thank you
for your open source contribution.
I use an ITSP where, until recently, a DNS lookup by Sofia-SIP
would obtain a single SRV record. Outbound SIP calls work as
expected every time.
The ITSP now wants to distribute the SIP traffic across three
destinations (three cities), so the same DNS lookup by Sofia-SIP
obtains three SRV records.
The DNS server is provisioned to rotate the SRV records
round-robin, so the first choice will alternate among the three
destinations. I can see in a packet trace that the SRV record
sequence is in fact alternating across DNS lookups. (These are
the external DNS lookups after the Sofia-SIP DNS cache expires).
The problem is that even though the DNS response presents the
SRV records in varying order, Sofia-SIP always selects the same
particular SRV record, so outbound calls always go to a single
destination and are not distributed.
I reviewed the Sofia-SIP source, and think I see what is
happening.
Sofia-SIP sorts the SRV records on priority, weight, srv_target,
and srv_port:
sofia-resolv/sres_record.h
/** Service location record (@RFC2782). */
typedef struct sres_srv_record
{
sres_common_t srv_record[1]; /**< Common part of DNS records. */
uint16_t srv_priority; /**< Priority */
uint16_t srv_weight; /**< Weight */
uint16_t srv_port; /**< Service port on the target host. */
uint16_t srv_pad;
char *srv_target; /**< Domain name of the target host. */
} sres_srv_record_t;
sres.c
sres_record_compare(sres_record_t const *aa, sres_record_t const *bb)
{
<snip>
case sres_type_srv:
{
sres_srv_record_t const *A = aa->sr_srv, *B = bb->sr_srv;
D = A->srv_priority - B->srv_priority; if (D) return D;
/* Record with larger weight first */
D = B->srv_weight - A->srv_weight; if (D) return D;
D = strcmp(A->srv_target, B->srv_target); if (D) return D;
return A->srv_port - B->srv_port;
}
<snip>
}
If the priority and weight are identical for all three SRV records,
as they are with my ITSP, then the alpha sort of the srv_target name
determines the SRV record sort sequence.
The result is that Sofia-SIP loses the SRV record sequence intended
by the round-robin ordering by the DNS server, and the SRV record
selected by Sofia-SIP is always the record that just happens to have
the target name with the lowest alpha sort key.
It seems to me that the correct sort would be by priority and weight
only, and where those are identical for adjacent records, the original
SRV record sequence would be preserved so the first choice intended
by the DNS server round-robin ordering would be used by Sofia-SIP
to determine where to send the SIP for the outbound call.
Thanks.
Jim
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel