The $Rp is intended to give the attribute of the listen socket
associated with the SIP traffic. It is not taken from the IP layer,
maybe another variable can be done if people need it.

I didn't get the chance to look at the logs and the code, but I guess
that not being an exact match of port with one of listen sockets, then
the first is selected.

As I understood in this discussion, a VIP (or advertised/firewall IP) is
involved, not sure if this has any impact in matching.

For SIP traffic, there might be ways to improve the matching once
parsing some headers (e.g., using top Via for replies).

I am not sure it can be seen as a bug, due to how tcp works and what $Rp
is intended to do, but can be an enhancement to introduce additional
matching modes or variables for IP layer for local receiving port.

Cheers,
Daniel

On 24.06.21 19:12, Giacomo Vacca wrote:
> No worries Shahid,
> mine wasn't really a suggestion for a fix, but I wanted to verify a
> suspicion I had, since I saw a similar behaviour with a certain number
> of listen directives for TCP sockets.
>
> I did notice that, when Kamilio establishes a TCP connection, from a
> port selected from the OS, e.g. 39235 in your example, responses or
> requests received on that same connection, instead of showing 39235
> for $Rp were showing the port of the first listening TCP directive
> (e.g. 8080 in your case, or 5060 once you swapped the listening
> directives).
>
> I take this opportunity to ask the community whether this behaviour is
> expected or a symptom of something that needs changing in the
> configuration files or a bug.
>
> Thanks,
> Giacomo
>
>
>
> On Thu, 24 Jun 2021 at 18:05, Shahid Hussain <shn...@gmail.com
> <mailto:shn...@gmail.com>> wrote:
>
>     Hi Giacomo,
>
>     All of my required test cases are working fine with the
>     combination you suggested along with configuring the NON VIP
>     address in ds_default_socket parameter of dispatcher. I will test
>     the regression suite on this and update if there is any issue.
>
>     Thank you for your suggestion. Thanks  Daniel  as well for looking
>     into this issue.
>
>     However I would still be curious to know what was the root cause,
>     how the previous combination was taking us into strange issues
>     where Kamailio was assuming 8080 as Received port. Is it not based
>     on where the OPTION response arrived ?
>
>     Thanks & Regards,
>     Shahid
>
>     On Thu, Jun 24, 2021 at 7:39 PM Giacomo Vacca
>     <giacomo.va...@gmail.com <mailto:giacomo.va...@gmail.com>> wrote:
>
>         Hi Shahid,
>
>         > This system also listens on port 8080 which is meant for
>         websocket communication [...]
>         > [...] but Kamailio considering the response is on websocket
>         port 8080 ,$Rp value is 8080
>
>         Do you see the same behaviour if you set the listen directive
>         for SIP before the one for WS, in kamailio.cfg?
>         i.e.
>
>         listen=tcp:172.27.45.219:5060 <http://172.27.45.219:5060>
>         advertise 172.27.45.198:5060 <http://172.27.45.198:5060>
>
>         before
>
>         listen=tcp:172.27.45.219:MY_WS_PORT
>
>         ?
>
>         Thanks,
>         Giacomo
>
>
>
>
>
>
>
>
>         On Thu, 24 Jun 2021 at 15:28, Shahid Hussain <shn...@gmail.com
>         <mailto:shn...@gmail.com>> wrote:
>
>             Hi Daniel,
>             Sure, please check as per your availability.
>             I had tried the above option before adding ds_default
>             socket in kamailio .cfg but the result was same.  Now also
>             I have tried, but still kamailio is declaring 8080 as
>             received port .
>             Following is the dispatcher configuration I have tried now.
>             root@localhost ~]# kamcmd dispatcher.list
>             {
>                     NRSETS: 1
>                     RECORDS: {
>                             SET: {
>                                     ID: 1
>                                     TARGETS: {
>                                             DEST: {
>                                                     URI:
>             sip:172.27.44.125:5060;transport=tcp
>                                                     FLAGS: AP
>                                                     PRIORITY: 0
>                                                     ATTRS: {
>                                                             BODY:
>             duid=sample-cas;maxload=1000;socket=tcp:172.27.45.219:5060
>             <http://172.27.45.219:5060>
>                                                             DUID:
>             sample-cas
>                                                             MAXLOAD: 1000
>                                                             WEIGHT: 0
>                                                             RWEIGHT: 0
>                                                             SOCKET:
>             tcp:172.27.45.219:5060 <http://172.27.45.219:5060>
>                                                     }
>                                                     LATENCY: {
>                                                             AVG: 3.750000
>                                                             STD: 1.500000
>                                                             EST: 3.750000
>                                                             MAX: 6
>                                                             TIMEOUT: 0
>                                                     }
>                                                     RUNTIME: {
>                                                             DLGLOAD: 0
>                                                     }
>                                             }
>                                     }
>                             }
>                     }
>             }
>
>             Jun 24 21:29:57 localhost /usr/sbin/kamailio[5169]:
>             WARNING: {2 10 OPTIONS 0f80e2d95e09aca5-5158@172.27.45.198
>             <mailto:0f80e2d95e09aca5-5158@172.27.45.198>} <script>:
>             SIP response received on 8080 protocol:tcp
>              RIP:172.27.45.219 SIP:172.27.44.125 method:OPTIONS
>             cid:0f80e2d95e09aca5-5158@172.27.45.198
>             <mailto:cid%3A0f80e2d95e09aca5-5158@172.27.45.198>
>             replystatus:200 len:416
>
>             On Thu, Jun 24, 2021 at 6:25 PM Daniel-Constantin Mierla
>             <mico...@gmail.com <mailto:mico...@gmail.com>> wrote:
>
>                 Hello,
>
>                 I will check the logs once I finish a few other tasks.
>
>                 Meanwhile, maybe you can try to set the socket per
>                 destination to see if it makes any difference, like
>
>                 1 sip:172.27.44.125:5060;transport=tcp 0 0
>                 duid=sample-cas;maxload=1000;*socket=tcp:172.27.45.219:5060
>                 <http://172.27.45.219:5060>*
>
>                 Cheers,
>                 Daniel
>
>
>                 On 24.06.21 12:48, Shahid Hussain wrote:
>>                 Hi Daniel,
>>                 Please find the debug logs attached. You can refer
>>                 OPTION message of timestamp 18:43:35 though there are
>>                 multiple request.
>>
>>                 There is a line in log says tcp worker on 8080 though
>>                 I have not specified in kamailio.cfg.
>>                 Jun 24 18:43:35 localhost kamailio: 44(11820) DEBUG:
>>                 <core> [core/tcp_main.c:4517]: handle_tcpconn_ev():
>>                 sending to child, events 1
>>                 Jun 24 18:43:35 localhost kamailio: 44(11820) DEBUG:
>>                 <core> [core/tcp_main.c:4190]: send2child(): selected
>>                 tcp worker idx:6 proc:42 pid:11818 for activity on
>>                 [tcp:172.27.45.219:8080 <http://172.27.45.219:8080>],
>>                 0x7fca749c2d60
>>
>>                 Attached kamailio.cfg also.
>>
>>                 On Thu, Jun 24, 2021 at 3:31 PM Daniel-Constantin
>>                 Mierla <mico...@gmail.com <mailto:mico...@gmail.com>>
>>                 wrote:
>>
>>                     Hello,
>>
>>                     can you set debug=3 in kamailio.cfg and then
>>                     reproduce the case and send here all the syslog
>>                     message printed by kamailio?
>>
>>                     Cheers,
>>                     Daniel
>>
>>                     On 24.06.21 11:37, Shahid Hussain wrote:
>>>                     Hi  Daniel,
>>>                     Attaching the filtered  pcap with response for
>>>                     an OPTION message. 
>>>                     I am also attaching the all pcap with no filter
>>>                     having all SIP messages being communicated,
>>>                     there is no data coming on port 8080. 
>>>
>>>                     Regards,
>>>                     Shahid
>>>
>>>                     On Thu, Jun 24, 2021 at 1:21 PM
>>>                     Daniel-Constantin Mierla <mico...@gmail.com
>>>                     <mailto:mico...@gmail.com>> wrote:
>>>
>>>                         Hello,
>>>
>>>                         the pcap shows only the OPTIONS requests,
>>>                         not the replies. Maybe you have to capture
>>>                         the traffic also on 8080 to catch it. It
>>>                         would important to see the reply and where
>>>                         it is sent back to kamailio.
>>>
>>>                         Cheers,
>>>                         Daniel
>>>
>>>                         On 24.06.21 09:24, Shahid Hussain wrote:
>>>>                         Hi,
>>>>                         I have configured the dispatcher default
>>>>                         socket as below IP , the expectation here
>>>>                         is that kamailio should send all traffic
>>>>                         from this IP (port will be ephemeral) over TCP.
>>>>                         modparam("dispatcher", "ds_default_socket",
>>>>                         "tcp:172.27.45.219:5060
>>>>                         <http://172.27.45.219:5060>")
>>>>
>>>>                         This system also listens on port 8080 which
>>>>                         is meant for websocket communication
>>>>                         (dispatcher communication is over non
>>>>                         websocket).
>>>>
>>>>                         Kamailio is sending an OPTION message to
>>>>                         dispatcher IP over TCP on 5060 and getting
>>>>                         200 OK response but Kamailio considering
>>>>                         the response is on websocket port 8080 ,$Rp
>>>>                         value is 8080.
>>>>
>>>>                         onreply_route {
>>>>                              if (($Rp == 8080 ) && !(proto == WS))
>>>>                                 {
>>>>                                         xlog("L_WARN", "SIP
>>>>                         response received on $Rp protocol:proto
>>>>                         RIP:$Ri SIP:$si method:$rm cid:$ci
>>>>                         replystatus:$rs len:$ml\n");
>>>>                                         xlog("L_WARN", "SIP message
>>>>                         received: $mb\n");
>>>>                                         drop;
>>>>                                 }
>>>>
>>>>                         .....
>>>>                         ....
>>>>                         }
>>>>
>>>>                         Following is the output of above logs:
>>>>                         Jun 24 15:10:08 localhost
>>>>                         /usr/sbin/kamailio[6223]: WARNING: {2 10
>>>>                         OPTIONS 1ab6573a4640823b-6209@172.27.45.198
>>>>                         <mailto:1ab6573a4640823b-6209@172.27.45.198>}
>>>>                         <script>: SIP response received on 8080
>>>>                         protocol:tcp  RIP:172.27.45.219
>>>>                         SIP:172.27.44.125 method:OPTIONS
>>>>                         cid:1ab6573a4640823b-6209@172.27.45.198
>>>>                         <mailto:cid%3A1ab6573a4640823b-6209@172.27.45.198>
>>>>                         replystatus:200 len:416
>>>>
>>>>                         Jun 24 15:10:08 localhost
>>>>                         /usr/sbin/kamailio[6223]: WARNING: {2 10
>>>>                         OPTIONS 1ab6573a4640823b-6209@172.27.45.198
>>>>                         <mailto:1ab6573a4640823b-6209@172.27.45.198>}
>>>>                         <script>: SIP message received: SIP/2.0 200
>>>>                         OK#015#012Via: SIP/2.0/TCP
>>>>                         
>>>> 172.27.45.198:5060;branch=z9hG4bK4526.92b79f34000000000000000000000000.0;received=172.27.45.219#015#012From:
>>>>                         
>>>> <sip:dispatcher@localhost>;tag=1ae6c95d92f9ea9ce927f715de5c48c8-eb141029#015#012To:
>>>>                         
>>>> <sip:172.27.44.125:5060;transport=tcp>;tag=a9d542e0#015#012Call-ID:
>>>>                         1ab6573a4640823b-6209@172.27.45.198#015#012CSeq
>>>>                         
>>>> <http://1ab6573a4640823b-6209@172.27.45.198#015%23012CSeq>:
>>>>                         10 OPTIONS#015#012Allow: INVITE, ACK, BYE,
>>>>                         OPTIONS, CANCEL, INFO, UPDATE,
>>>>                         NOTIFY#015#012Content-Length: 0
>>>>
>>>>
>>>>                         Also I have attached a pcap.
>>>>
>>>>                         Dispatcher.list configuration:
>>>>                         1 sip:172.27.44.125:5060;transport=tcp 0 0
>>>>                         duid=sample-cas;maxload=1000
>>>>
>>>>                         Thanks,
>>>>                         Shahid
>>>>
>>>>                         
>>>> __________________________________________________________
>>>>                         Kamailio - Users Mailing List - Non Commercial 
>>>> Discussions
>>>>                           * sr-users@lists.kamailio.org 
>>>> <mailto:sr-users@lists.kamailio.org>
>>>>                         Important: keep the mailing list in the 
>>>> recipients, do not reply only to the sender!
>>>>                         Edit mailing list options or unsubscribe:
>>>>                           * 
>>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users 
>>>> <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
>>>
>>>                         -- 
>>>                         Daniel-Constantin Mierla -- www.asipto.com 
>>> <http://www.asipto.com>
>>>                         www.twitter.com/miconda 
>>> <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda 
>>> <http://www.linkedin.com/in/miconda>
>>>
>>                     -- 
>>                     Daniel-Constantin Mierla -- www.asipto.com 
>> <http://www.asipto.com>
>>                     www.twitter.com/miconda <http://www.twitter.com/miconda> 
>> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>>
>                 -- 
>                 Daniel-Constantin Mierla -- www.asipto.com 
> <http://www.asipto.com>
>                 www.twitter.com/miconda <http://www.twitter.com/miconda> -- 
> www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>
>             __________________________________________________________
>             Kamailio - Users Mailing List - Non Commercial Discussions
>               * sr-users@lists.kamailio.org
>             <mailto:sr-users@lists.kamailio.org>
>             Important: keep the mailing list in the recipients, do not
>             reply only to the sender!
>             Edit mailing list options or unsubscribe:
>               *
>             https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>             <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
>
>         __________________________________________________________
>         Kamailio - Users Mailing List - Non Commercial Discussions
>           * sr-users@lists.kamailio.org
>         <mailto:sr-users@lists.kamailio.org>
>         Important: keep the mailing list in the recipients, do not
>         reply only to the sender!
>         Edit mailing list options or unsubscribe:
>           *
>         https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>         <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
>
>     __________________________________________________________
>     Kamailio - Users Mailing List - Non Commercial Discussions
>       * sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
>     Important: keep the mailing list in the recipients, do not reply
>     only to the sender!
>     Edit mailing list options or unsubscribe:
>       * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>     <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
>
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users@lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the 
> sender!
> Edit mailing list options or unsubscribe:
>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to