<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Mykola,<br>
take in mind that weights are just a probabilitythat one peer will
be selected or not.<br>
Higher weight has higher probability.<br>
<br>
With the following script:<br>
<br>
<br>
lcr_weight_test.php<br>
<br>
#!/usr/bin/php<br>
<?php<br>
<br>
// This script can be used to find out actual probabilities<br>
// that correspond to a list of LCR gateway weights.<br>
<br>
if ($argc < 2) {<br>
echo "Usage: lcr_weight_test.php <list of weights (integers
1-254)>\n";<br>
exit;<br>
}<br>
<br>
$iters = 10000;<br>
<br>
$rands = array();<br>
for ($i = 1; $i <= $iters; $i++) {<br>
$elem = array();<br>
for ($j = 1; $j < $argc; $j++) {<br>
$elem["$j"] = $argv[$j] * (rand() >> 8);<br>
}<br>
$rands[] = $elem;<br>
}<br>
<br>
$sorted = array();<br>
foreach ($rands as $rand) {<br>
asort($rand);<br>
$sorted[] = $rand;<br>
}<br>
<br>
$counts = array();<br>
for ($j = 1; $j < $argc; $j++) {<br>
$counts["$j"] = 0;<br>
}<br>
<br>
foreach ($sorted as $rand) {<br>
end($rand);<br>
$counts[key($rand)]++;<br>
}<br>
<br>
for ($j = 1; $j < $argc; $j++) {<br>
echo "weight " . $argv[$j] . " probability " .
$counts["$j"]/$iters . "\n";<br>
}<br>
<br>
?><br>
<br>
<br>
<br>
you can check the probability that a peer with weight 1 and one
with weight 2 are selected, with:<br>
<br>
./lcr_weight_test.php 1 2<br>
<br>
output:<br>
weight 1 probability 0.2522<br>
weight 2 probability 0.7478<br>
<br>
<br>
as you can see, peer with weight 2 has 74% of probability to be
selected, peer with weight 1 25%.<br>
<br>
<br>
Daniel<br>
<br>
<br>
<br>
On 01/21/2015 02:10 PM, Mykola Zaika wrote:<br>
</div>
<blockquote
cite="mid:CABT8L5ze7UNQ5jAfXCZ48JinuCW7k59uX5LZ2z5ywz7psufxaQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>Hi,<br>
</div>
I have a problem with my routing.<br>
<br>
</div>
example:<br>
</div>
I created one group "Test". <br>
This group include two peers:<br>
</div>
peer1 (IP x.x.x.x) port 5060 wight 1<br>
peer2 (IP y.y.y.y) port 5060 wight 2<br>
<div>
<div>
<div>
<div>
<div>Also there are created peering rules<br>
<br>
</div>
<div>I try to change value "wight", but it does not
work. Calls are always going randomly via peers. One
time via peer1, next time via peer2. I do not
understand why.<br>
</div>
<div><br>
<br>
From manual:<br>
<br>
The selection of peering servers for outbound calls is
done in the following order: 1. length of the matching
peering<br>
rules for a call. 2. priority of the peering group.<b>
3. weight of the peering servers in the selected
peering group</b>. After one<br>
or more peering group(s) is matched for an outbound
call, all servers in this group are tried, according
to their weight<br>
(lower weight has more precedence). If a peering
server replies with SIP codes 408 , 500 or 503 , or if
a peering<br>
server doesn’t respond at all, the next peering server
in the current peering group is used as a fallback,
one after the<br>
other until the call succeeds. If no more servers are
left in the current peering group, the next group
which matches the<br>
peering rules is going to be used.<br>
</div>
<div><br>
<br>
A bit from log:<br>
Jan 21 13:46:47 spce /usr/sbin/kamailio[16077]: INFO:
<script>: Load gws matching calling part '<a
moz-do-not-send="true"
href="mailto:sip%3A032255@10.110.10.55">sip:032255@10.110.10.55</a>'
and called user 'peerB_032255' and called part '<a
moz-do-not-send="true"
href="mailto:sip%3ApeerB_032255@10.110.10.55">sip:peerB_032255@10.110.10.55</a>'
- R=sip:peerB_03225<br>
<a moz-do-not-send="true" href="mailto:5@10.110.10.55">5@10.110.10.55</a>
ID=<a moz-do-not-send="true"
href="mailto:5fc804c63f7f89564addaac057f3d894@10.110.10.55">5fc804c63f7f89564addaac057f3d894@10.110.10.55</a><br>
Jan 21 13:46:47 spce /usr/sbin/kamailio[16077]: INFO:
<script>: Dialog set mark type to outgoing - R=<a
moz-do-not-send="true"
href="mailto:sip%3ApeerB_032255@10.110.10.55">sip:peerB_032255@10.110.10.55</a>
ID=<a moz-do-not-send="true"
href="mailto:5fc804c63f7f89564addaac057f3d894@10.110.10.55">5fc804c63f7f89564addaac057f3d894@10.110.10.55</a><br>
Jan 21 13:46:47 spce /usr/sbin/kamailio[16077]: INFO:
<script>: Load peer preferences for peer host
'11' -
<a class="moz-txt-link-abbreviated" href="mailto:R=sip:peerB_032255@10.110.10.12:5060;transport=udp">R=sip:peerB_032255@10.110.10.12:5060;transport=udp</a> ID=<a
moz-do-not-send="true"
href="mailto:5fc804c63f7f89564addaac057f3d894@10.110.10.55">5fc804c63f7f89564addaac057f3d894@10.110.10.55</a><br>
Jan 21 13:46:47 spce /usr/sbin/kamailio[16077]: INFO:
<script>: Load dialplan IDs for peer host '11' -
<a class="moz-txt-link-abbreviated" href="mailto:R=sip:peerB_032255@10.110.10.12:5060;transport=udp">R=sip:peerB_032255@10.110.10.12:5060;transport=udp</a> ID=<a
moz-do-not-send="true"
href="mailto:5fc804c63f7f89564addaac057f3d894@10.110.10.55">5fc804c63f7f89564addaac057f3d894@10.110.10.55</a><br>
<br clear="all">
<div>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr"><span><font color="#888888">--
<br>
<div>
<div dir="ltr">
<div>З повагою,</div>
<div>Микола Заїка<br>
</div>
<div>Компанія VoIPTime,</div>
<div>Тел: <span
style="color:rgb(0,0,255)"><a
moz-do-not-send="true"
href="tel:%2B380%2032%202328022"
value="+380322328022"
target="_blank">+380 32
2328022</a></span></div>
<div><span
style="color:rgb(0,0,255)"><a
moz-do-not-send="true"
href="mailto:ydidukh@voiptime.net"
target="_blank">mzaika@voiptime.net</a></span></div>
<div><span
style="color:rgb(0,0,255)"><a
moz-do-not-send="true"
href="http://www.voiptime.net"
target="_blank">www.voiptime.net</a></span></div>
</div>
</div>
</font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Spce-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Spce-user@lists.sipwise.com">Spce-user@lists.sipwise.com</a>
<a class="moz-txt-link-freetext" href="https://lists.sipwise.com/listinfo/spce-user">https://lists.sipwise.com/listinfo/spce-user</a>
</pre>
</blockquote>
<br>
</body>
</html>