<h3>Description</h3>
<p>We have 3 registrar servers storing location information in memory only. The registrations are replicated between each other using DMQ/DMQ USRLOC. When one of these registrars processes a registration it is saved and then replicated to the remaining two nodes.</p>
<p>When nat pinging is enabled then all three of these registrars attempt to send options pings to the endpoints. Ideally, only the registrar that serviced the registration should be sending the ping out.</p>
<p>I see that there is a core parameter to set the server_id for each server, and I also see that nathelper has a "filter_server_id" parameter as well, however, this appears to only work in database mode, it does not work with in memory mode. Would it be possible to extend this to work for in-memory mode too?</p>
<h3>Troubleshooting</h3>
<p>Module definitions</p>
<p>registrar</p>
<pre><code>modparam("registrar", "method_filtering",  1)
modparam("registrar", "case_sensitive",    1)
modparam("registrar", "append_branches",   0)
modparam("registrar", "use_path",          1)
modparam("registrar", "path_mode",         0)
modparam("registrar", "path_use_received", 1)
modparam("registrar", "path_check_local",  1)
modparam("registrar", "max_contacts",      1)
</code></pre>
<p>usrloc</p>
<pre><code>modparam("usrloc", "db_mode",              0)
modparam("usrloc", "use_domain",           1)
modparam("usrloc", "timer_interval",       60)
modparam("usrloc", "timer_procs",          4)
modparam("usrloc", "nat_bflag",            6)
</code></pre>
<p>nathelper<br>
NOTE: force_socket is set to match each registrar server</p>
<pre><code>modparam("nathelper", "natping_interval",   20)
modparam("nathelper", "natping_processes",  4)
modparam("nathelper", "ping_nated_only",    0)
modparam("nathelper", "sipping_from",       "sip:keepalive@example.com")
modparam("nathelper", "sipping_method",     "OPTIONS")
modparam("nathelper", "sipping_bflag",      6)
modparam("nathelper", "force_socket",       "10.7.0.189:5060")
modparam("nathelper", "udpping_from_path",   1)
</code></pre>
<p>Kamailio listen directives:<br>
NOTE: These are set to match the interfaces on each registrar</p>
<pre><code>listen=udp:10.6.0.189:5060
listen=udp:10.7.0.189:5060
listen=tcp:10.6.0.189:80
</code></pre>
<p>dmq</p>
<pre><code>modparam("dmq", "server_address", DMQ_ADDRESS)
modparam("dmq", "notification_address", DMQ_NOTIFY_ADDRESS)
modparam("dmq", "multi_notify", 1)
modparam("dmq", "num_workers", 4)
</code></pre>
<p>dmq_usrloc</p>
<pre><code>modparam("dmq_usrloc", "enable", 1)
</code></pre>
<h4>Reproduction</h4>
<p>Using the settings above, when the location information is replicated to a server, the servers that are replicated to should not send options messages for that AOR, only the registrar that serviced the registration should send nat keepalives out.</p>
<h4>Log Messages</h4>
<h4>SIP Traffic</h4>
<p>Here is the traffic from the registrar that serviced the registration, this is expected and working:</p>
<pre><code>U 2017/11/02 07:50:54.191717 10.7.0.190:5060 -> 10.7.0.186:5062

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP SIP/2.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;branch=z9hG4bK5526436.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
To: sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP.
Call-ID: d9993f61-a1fd4752-73cdc76@10.7.0.190.
CSeq: 1 OPTIONS.
Content-Length: 0.
.


U 2017/11/02 07:50:54.192896 194.213.29.33:5062 -> 212.2.172.228:39808

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP SIP/2.0.
Max-Forwards: 10.
Record-Route: <sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route: <sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Via: SIP/2.0/UDP 194.213.29.33:5062;branch=z9hG4bK13ab.9ccb0733fcecc331893d95f2e09485ee.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
To: sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP.
Call-ID: d9993f61-a1fd4752-73cdc76@10.7.0.190.
CSeq: 1 OPTIONS.
Content-Length: 0.
.


U 2017/11/02 07:50:54.248234 212.2.172.228:39808 -> 194.213.29.33:5062

SIP/2.0 200 OK.
Via: SIP/2.0/UDP 194.213.29.33:5062;branch=z9hG4bK13ab.9ccb0733fcecc331893d95f2e09485ee.0.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
Record-Route: <sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route: <sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Contact: <sip:192.168.1.64:39808>.
To: <sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP>;tag=726ffa30.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
Call-ID: d9993f61-a1fd4752-73cdc76@10.7.0.190.
CSeq: 1 OPTIONS.
Accept: application/sdp, application/sdp.
Accept-Language: en.
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE.
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri.
User-Agent: Z 3.15.40006 rv2.8.20.
Allow-Events: presence, kpml, talk.
Content-Length: 0.
.


U 2017/11/02 07:50:54.248922 10.7.0.186:5062 -> 10.7.0.190:5060

SIP/2.0 200 OK.
Via: SIP/2.0/UDP 10.7.0.190:5060;rport=5060;branch=z9hG4bK5526436.
Record-Route: <sip:194.213.29.33:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Record-Route: <sip:10.7.0.186:5062;r2=on;lr;ftag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781>.
Contact: <sip:192.168.1.64:39808>.
To: <sip:example_user@212.2.172.228:39808;rinstance=d74acdb581467154;transport=UDP>;tag=726ffa30.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-711-3-9968b2da-c2c36781.
Call-ID: d9993f61-a1fd4752-73cdc76@10.7.0.190.
CSeq: 1 OPTIONS.
Accept: application/sdp, application/sdp.
Accept-Language: en.
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE.
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri.
User-Agent: Z 3.15.40006 rv2.8.20.
Allow-Events: presence, kpml, talk.
Content-Length: 0.
.
</code></pre>
<p>Here is a ping attempt from a server replicated to (we should not be pinging from this registrar)</p>
<pre><code>U 2017/11/02 08:37:59.426608 10.6.0.189:5060 -> 10.7.0.186:5062

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP SIP/2.0.
Via: SIP/2.0/UDP 10.6.0.189:5060;branch=z9hG4bK8416926.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-714-17-9968b2da-13812ff4.
To: sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP.
Call-ID: c0cec5f7-555ac383-68bb313@10.6.0.189.
CSeq: 1 OPTIONS.
Content-Length: 0.
.


U 2017/11/02 08:38:19.431937 10.6.0.189:5060 -> 10.7.0.186:5062

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP SIP/2.0.
Via: SIP/2.0/UDP 10.6.0.189:5060;branch=z9hG4bK8345318.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-714-17-9968b2da-23812ff4.
To: sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP.
Call-ID: c0cec5f7-655ac383-a9bb313@10.6.0.189.
CSeq: 1 OPTIONS.
Content-Length: 0.
.
</code></pre>
<p>Here is a ping attempt from the last server replicated to (we should not be pinging from this registrar)</p>
<pre><code>U 2017/11/02 08:53:06.927374 10.6.0.191:5060 -> 10.7.0.186:5062

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP SIP/2.0.
Via: SIP/2.0/UDP 10.6.0.191:5060;branch=z9hG4bK8539212.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-714-17-9968b2da-a25dfc84.
To: sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP.
Call-ID: 89dde755-495a3694-04ae655@10.6.0.191.
CSeq: 1 OPTIONS.
Content-Length: 0.
.


U 2017/11/02 08:53:26.931991 10.6.0.191:5060 -> 10.7.0.186:5062

OPTIONS sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP SIP/2.0.
Via: SIP/2.0/UDP 10.6.0.191:5060;branch=z9hG4bK7581592.
Route: <sip:10.7.0.186:5062;lr;received=sip:212.2.172.228:39808>.
From: sip:keepalive@example.com;tag=uloc-2-59fa1f9d-714-17-9968b2da-b25dfc84.
To: sip:example_user@212.2.172.228:39808;rinstance=ed8aa63e90f53e97;transport=UDP.
Call-ID: 89dde755-595a3694-45ae655@10.6.0.191.
CSeq: 1 OPTIONS.
Content-Length: 0.
.
</code></pre>
<h3>Possible Solutions</h3>
<p>Unknown</p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.0.4 (x86_64/linux) 
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled on 10:57:22 Oct 26 2017 with gcc 4.8.5
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>
<pre><code>CentOS Linux release 7.4.1708 (Core) 
Linux localhost 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1299">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZZ18vjmFgl5jYOfeEHrKcIPwQ1Jrks5syaEJgaJpZM4QPgdU">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZeFCwKsCEiHSHH2abLpDtnN_E3EKks5syaEJgaJpZM4QPgdU.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/1299"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"v5.0.4: nathelper: dont ping replicated aor's (#1299)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1299"}}}</script>