<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML - vooraf opgemaakt Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTML-voorafopgemaaktChar
{mso-style-name:"HTML - vooraf opgemaakt Char";
mso-style-priority:99;
mso-style-link:"HTML - vooraf opgemaakt";
font-family:"Consolas",serif;
mso-fareast-language:EN-US;}
span.h4
{mso-style-name:h4;}
span.E-mailStijl25
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL-BE" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">We see that the other party is indeed establishing a connection to port 5060, but for some reason after 1 second Kamailio is sending SYN,ACK Retransmission.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Any clues?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I also tried using TOPOS module to update contact header properly, but this does not even seem to add transport=tcp to the contact header, while the INVITE is being sent out over TCP.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Regards</span><span style="mso-fareast-language:NL-BE"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="NL" style="mso-fareast-language:NL-BE">Van:</span></b><span lang="NL" style="mso-fareast-language:NL-BE"> Henning Westerholt <hw@gilawa.com>
<br>
<b>Verzonden:</b> woensdag 3 augustus 2022 19:36<br>
<b>Aan:</b> Maarten Ureel <maarten@youreal.eu>; Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Onderwerp:</b> RE: set source port of TCP socket in Contact header<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="DE">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">the tcp_reuse port setting is mainly using if Kamailio is acting as UAC, and needs an existing connection to be able to re-use something.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">The RFC specify how its normally should done from a client :<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<pre><span class="h4"><span lang="DE"><a href="https://datatracker.ietf.org/doc/html/rfc3261#section-18.1.1"><span lang="EN-GB">18.1.1</span></a></span></span><span class="h4"><span lang="EN-GB"> Sending Requests</span><o:p></o:p></span></pre>
<pre><o:p> </o:p></pre>
<pre><span lang="EN-GB"> [..]<o:p></o:p></span></pre>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> For reliable transports, the response is normally sent on the<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> connection on which the request was received. Therefore, the client<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> transport MUST be prepared to receive the response on the same<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> connection used to send the request. Under error conditions, the<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> server may attempt to open a new connection to send the response. To<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> handle this case, the transport layer MUST also be prepared to<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> receive an incoming connection on the source IP address from which<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:DE"> the request was sent and port number in the "sent-by" field.[..]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Not sure what the other side is, but maybe you can discuss that with them.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB">-- <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning Westerholt – </span><span lang="DE"><a href="https://skalatan.de/blog/"><span lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kamailio services – </span><span lang="DE"><a href="https://gilawa.com/"><span lang="EN-GB">https://gilawa.com</span></a></span><span lang="EN-GB"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b><span lang="DE" style="mso-fareast-language:DE">From:</span></b><span lang="DE" style="mso-fareast-language:DE"> Maarten Ureel <<a href="mailto:maarten@youreal.eu">maarten@youreal.eu</a>>
<br>
<b>Sent:</b> Wednesday, August 3, 2022 2:09 PM<br>
<b>To:</b> Henning Westerholt <<a href="mailto:hw@gilawa.com">hw@gilawa.com</a>>; Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>><br>
<b>Subject:</b> RE: set source port of TCP socket in Contact header<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="DE"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">I tried the tcp_reuse_port but it doesn’t seem to change the source port. It’s always random indeed as you say.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">See also screenshot from sngrep:
<a href="https://i.imgur.com/gp7WQ1C.png">https://i.imgur.com/gp7WQ1C.png</a><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">The problem is that, further down the call, the other party sends the BYE to the port that is specified in the Contact header, so e.g. in the screenshot I would like to put 48952 in the Contact
header – or have it always be 5060 indeed.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b><span lang="NL" style="mso-fareast-language:NL-BE">Van:</span></b><span lang="NL" style="mso-fareast-language:NL-BE"> Henning Westerholt <<a href="mailto:hw@gilawa.com">hw@gilawa.com</a>>
<br>
<b>Verzonden:</b> woensdag 3 augustus 2022 13:28<br>
<b>Aan:</b> Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>><br>
<b>CC:</b> Maarten Ureel <<a href="mailto:maarten@youreal.eu">maarten@youreal.eu</a>><br>
<b>Onderwerp:</b> RE: set source port of TCP socket in Contact header<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Hello,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Not sure if I completely understand the issue.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Kamailio will either use a random source port, or the port 5060 if you specify the tcp_reuse_port core configuration.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Henning</span><span lang="DE"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="DE"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">-- <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Henning Westerholt –
</span><span lang="DE"><a href="https://skalatan.de/blog/"><span lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Kamailio services –
</span><span lang="DE"><a href="https://gilawa.com/"><span lang="EN-GB">https://gilawa.com</span></a></span><span lang="EN-GB"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:70.8pt"><b><span lang="EN-GB" style="mso-fareast-language:DE">From:</span></b><span lang="EN-GB" style="mso-fareast-language:DE"> sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org">sr-users-bounces@lists.kamailio.org</a>>
<b>On Behalf Of </b>Maarten Ureel<br>
<b>Sent:</b> Tuesday, August 2, 2022 4:53 PM<br>
<b>To:</b> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<b>Subject:</b> [SR-Users] set source port of TCP socket in Contact header<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="NL">Hello<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="NL"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US">I want to set the correct source port in an outgoing message over TCP. Is it possible? I can’t find a pseudo-variable for this.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US">Currently we have no port number in the contact header, and the other party is sending their BYE to port 5060 instead of to the source port from which the outgoing TCP connection was made.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US" style="mso-fareast-language:NL-BE">Regards<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:70.8pt"><span lang="EN-US" style="mso-fareast-language:NL-BE">Maarten</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
</body>
</html>