[SR-Users] How to correctly answer a PnP-SUBSCRIBE message

Jan-Hendrik Dörner sr-users at doerner.net
Mon Mar 30 18:41:56 CEST 2020


Hello Daniel,

thank you for your reply.

I changed the line mentioned to
t_uac_send("NOTIFY", "$(ct{s.substr,1,0}{s.striptail,1})", "$su", "192.168.1.156","Call-ID: $hdr(Call-ID)\r\nSubscription-State: terminated;reason=timeout\r\nEvent: $hdr(Event)\r\nContent-Type: application/url\r\nFrom: $fU\r\nTo: $hdr(From)", "http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>"); 

the result is:
3) Call-ID is fine now ; Problem solved :-)

1) The Via IP is now changed to the IP and port of the server, but not to the IP of the phone. 

2) The sending interface  / IP is not correct: It now sends _only_ from the wrong IP !!
As a result, it repeats sending the NOTIFY-message over and over again since the message does not get to the phone ...
Please see the starting of the SIP-traffic below

U 192.168.1.152:57283 -> 224.0.1.75:5060 #53
SUBSCRIBE sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.152:57283;rport.
From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=176419003.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>.
Call-ID: 277773303 at 192.168.1.152 <mailto:277773303 at 192.168.1.152>.
CSeq: 1 SUBSCRIBE.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Expires: 0.
Accept: application/url.
Contact: <sip:192.168.1.152:57283 <sip:192.168.1.152:57283>>.
User-Agent: snom760/8.9.3.80.
Content-Length: 0.
.

#
U 192.168.1.156:5060 -> 192.168.1.152:57283 #54
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.1.152:57283;rport=57283;received=192.168.1.152.
From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=176419003.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=fb721cde02dffb6bb099728401306798.1182.
Call-ID: 277773303 at 192.168.1.152 <mailto:277773303 at 192.168.1.152>.
CSeq: 1 SUBSCRIBE.
Server: kamailio (5.2.5 (x86_64/linux)).
Content-Length: 0.
.

#
U 172.23.56.1:5060 -> 192.168.1.152:57283 #55
NOTIFY sip:192.168.1.152:57283 <sip:192.168.1.152:57283> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.156:5060;branch=z9hG4bKee8f.0ea476a1000000000000000000000000.0.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=176419003.
From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-9700.
CSeq: 10 NOTIFY.
Call-ID: 277773303 at 192.168.1.152 <mailto:277773303 at 192.168.1.152>.
Max-Forwards: 70.
Content-Length: 33.
User-Agent: kamailio (5.2.5 (x86_64/linux)).
Subscription-State: terminated;reason=timeout.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Content-Type: application/url.
.
http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
#
U 172.23.56.1:5060 -> 192.168.1.152:57283 #56
NOTIFY sip:192.168.1.152:57283 <sip:192.168.1.152:57283> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.156:5060;branch=z9hG4bKee8f.0ea476a1000000000000000000000000.0.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=176419003.
From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-9700.
CSeq: 10 NOTIFY.
Call-ID: 277773303 at 192.168.1.152 <mailto:277773303 at 192.168.1.152>.
Max-Forwards: 70.
Content-Length: 33.
User-Agent: kamailio (5.2.5 (x86_64/linux)).
Subscription-State: terminated;reason=timeout.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Content-Type: application/url.
.
http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
#
U 172.23.56.1:5060 -> 192.168.1.152:57283 #57
NOTIFY sip:192.168.1.152:57283 <sip:192.168.1.152:57283> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.156:5060;branch=z9hG4bKee8f.0ea476a1000000000000000000000000.0.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=176419003.
From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-9700.
CSeq: 10 NOTIFY.
Call-ID: 277773303 at 192.168.1.152 <mailto:277773303 at 192.168.1.152>.
Max-Forwards: 70.
Content-Length: 33.
User-Agent: kamailio (5.2.5 (x86_64/linux)).
Subscription-State: terminated;reason=timeout.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Content-Type: application/url.
.
http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
#
U 192.168.1.152:57283 -> 224.0.1.75:5060 #58
SUBSCRIBE sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.152:57283;rport.
From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1472545741.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>.
Call-ID: 1886698335 at 192.168.1.152 <mailto:1886698335 at 192.168.1.152>.
CSeq: 1 SUBSCRIBE.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Expires: 0.
Accept: application/url.
Contact: <sip:192.168.1.152:57283 <sip:192.168.1.152:57283>>.
User-Agent: snom760/8.9.3.80.
Content-Length: 0.
.

#
U 192.168.1.156:5060 -> 192.168.1.152:57283 #59
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.1.152:57283;rport=57283;received=192.168.1.152.
From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1472545741.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=fb721cde02dffb6bb099728401306798.1182.
Call-ID: 1886698335 at 192.168.1.152 <mailto:1886698335 at 192.168.1.152>.
CSeq: 1 SUBSCRIBE.
Server: kamailio (5.2.5 (x86_64/linux)).
Content-Length: 0.
.

#
U 172.23.56.1:5060 -> 192.168.1.152:57283 #60
NOTIFY sip:192.168.1.152:57283 <sip:192.168.1.152:57283> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.156:5060;branch=z9hG4bKa0df.967a0433000000000000000000000000.0.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1472545741.
From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-d106.
CSeq: 10 NOTIFY.
Call-ID: 1886698335 at 192.168.1.152 <mailto:1886698335 at 192.168.1.152>.
Max-Forwards: 70.
Content-Length: 33.
User-Agent: kamailio (5.2.5 (x86_64/linux)).
Subscription-State: terminated;reason=timeout.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Content-Type: application/url.
.
http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
#
U 172.23.56.1:5060 -> 192.168.1.152:57283 #61
NOTIFY sip:192.168.1.152:57283 <sip:192.168.1.152:57283> SIP/2.0.
Via: SIP/2.0/UDP 192.168.1.156:5060;branch=z9hG4bKa0df.967a0433000000000000000000000000.0.
To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1472545741.
From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-d106.
CSeq: 10 NOTIFY.
Call-ID: 1886698335 at 192.168.1.152 <mailto:1886698335 at 192.168.1.152>.
Max-Forwards: 70.
Content-Length: 33.
User-Agent: kamailio (5.2.5 (x86_64/linux)).
Subscription-State: terminated;reason=timeout.
Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
Content-Type: application/url.
.
http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
#

(If I change the IP-parameter to "172.23.56.1" the resulting sending IP is unchanged!)



> Am 30.03.2020 um 16:17 schrieb Daniel-Constantin Mierla <miconda at gmail.com <mailto:miconda at gmail.com>>:
> 
> Hello,
> 
> On 30.03.20 12:07, Jan-Hendrik Dörner wrote:
>> Hallo,
>> 
>> several telephones send a SIP-multicast SUBSCRIBE message to address 224.0.1.75 if they have no settings-URL configured and receive none over DHCP.
>> 
>> So I configure my kamailio server, to respond to that multicast-request.
>> But: Although mine is working, I do feel it could be improved, since the NOTIFY packet send out is  not quite as it should be …
>> 
>> Here is what I did (the 172.23.56.1 is my voip-vlan-address)
>> 
>> listen=udp:172.23.56.1:5060 advertise 192.168.1.156:5060
>> listen=udp:192.168.1.156:5060 advertise 192.168.1.156:5060
>> listen=tcp:127.0.0.1:5060          
>> 
>> mcast="eth0"
>> listen=udp:224.0.1.75:5060
>> 
>> ….
>> 
>>   if ($Ri == "224.0.1.75"){
>>        if(is_method("SUBSCRIBE")){
>>           xlog("L_INFO", "Received pnp-event from IP $si from User-Agent $hdr(User-Agent) und User $fU\r\n" );                                           
>>           sl_send_reply("200", "OK");                                                                                                                    
>>           t_uac_send("NOTIFY", "$(ct{s.substr,1,0}{s.striptail,1})", "", "","Subscription-State: terminated;reason=timeout\r\nEvent: $hdr(Event)\r\nContent-Type: application/url\r\nFrom: $fU\r\nTo: $hdr(From)", "http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>");
>>        }else  {                                                                                                                                                                                                                         
>>          xlog("L_INFO", "Drop message $rm from pnp-Interface \r\n" );
>>       }                                          
>>       exit;
>>    }                    
>> 
>> 
>> And here are the SIP-packets  I see on my server (192.168.1.156) coming from my snom-phone (192.168.1.152).
>> My problems with the NOTIFY -packets are: 
>> 1) How do I set the Via parameters to be the same as in the OK-reply?
> 
> Try to set the next hop address to "$su" and combined with 2) maybe it
> results in what you want to get.
> 
> 
>> 2) How do I send out the NOTIFY only via the 192.168.1.156 network interface? 
> 
> Set the local socket parameter from where to send the NOTIFY.
> 
> 
>> 3) May I send out the NOTIFY with the Call-ID from the SUBSCRIBE message? How?
> 
> 
> Provide the Call-Id haeder as part of the headers parameter:
> 
>   -
> https://www.kamailio.org/docs/modules/stable/modules/tm.html#tm.f.t_uac_send <https://www.kamailio.org/docs/modules/stable/modules/tm.html#tm.f.t_uac_send>
> 
> Cheers,
> Daniel
> 
> 
>> 
>> Any help is highly appreciated
>> Jan-Hendrik
>> 
>> #
>> U 192.168.1.152:58714 -> 224.0.1.75:5060 #258
>> SUBSCRIBE sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan> SIP/2.0.
>> Via: SIP/2.0/UDP 192.168.1.152:58714;rport.
>> From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1750588964.
>> To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>.
>> Call-ID: 1395386659 at 192.168.1.152 <mailto:1395386659 at 192.168.1.152>.
>> CSeq: 1 SUBSCRIBE.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Expires: 0.
>> Accept: application/url.
>> Contact: <sip:192.168.1.152:58714 <sip:192.168.1.152:58714>>.
>> User-Agent: snom760/8.9.3.80.
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.156:5060 -> 192.168.1.152:58714 #259
>> SIP/2.0 200 OK.
>> Via: SIP/2.0/UDP 192.168.1.152:58714;rport=58714;received=192.168.1.152.
>> From: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1750588964.
>> To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=fb721cde02dffb6bb099728401306798.2f00.
>> Call-ID: 1395386659 at 192.168.1.152 <mailto:1395386659 at 192.168.1.152>.
>> CSeq: 1 SUBSCRIBE.
>> Server: kamailio (5.2.5 (x86_64/linux)).
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.156:5060 -> 192.168.1.152:58714 #260
>> NOTIFY sip:192.168.1.152:58714 <sip:192.168.1.152:58714> SIP/2.0.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bKf21c.917eaf36000000000000000000000000.0.
>> To: <sip:MAC%3a0004137120D8 at lan <sip:MAC%3a0004137120D8 at lan>>;tag=1750588964.
>> From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-8cfb.
>> CSeq: 10 NOTIFY.
>> Call-ID: 24eaa8de01be1768-70960 at 172.23.56.1 <mailto:24eaa8de01be1768-70960 at 172.23.56.1>.
>> Max-Forwards: 70.
>> Content-Length: 33.
>> User-Agent: kamailio (5.2.5 (x86_64/linux)).
>> Subscription-State: terminated;reason=timeout.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Content-Type: application/url.
>> .
>> http://server.conf/settings-{mac} <http://server.conf/settings-%7Bmac%7D>
>> #
>> U 172.23.56.1:5060 -> 192.168.1.152:58714 #261
>> NOTIFY sip:192.168.1.152:58714 SIP/2.0.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bKf21c.917eaf36000000000000000000000000.0.
>> To: <sip:MAC%3a0004137120D8 at lan>;tag=1750588964.
>> From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-8cfb.
>> CSeq: 10 NOTIFY.
>> Call-ID: 24eaa8de01be1768-70960 at 172.23.56.1.
>> Max-Forwards: 70.
>> Content-Length: 33.
>> User-Agent: kamailio (5.2.5 (x86_64/linux)).
>> Subscription-State: terminated;reason=timeout.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Content-Type: application/url.
>> .
>> http://server.conf/settings-{mac}
>> #
>> U 172.23.56.1:5060 -> 192.168.1.152:58714 #262
>> NOTIFY sip:192.168.1.152:58714 SIP/2.0.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bKf21c.917eaf36000000000000000000000000.0.
>> To: <sip:MAC%3a0004137120D8 at lan>;tag=1750588964.
>> From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-8cfb.
>> CSeq: 10 NOTIFY.
>> Call-ID: 24eaa8de01be1768-70960 at 172.23.56.1.
>> Max-Forwards: 70.
>> Content-Length: 33.
>> User-Agent: kamailio (5.2.5 (x86_64/linux)).
>> Subscription-State: terminated;reason=timeout.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Content-Type: application/url.
>> .
>> http://server.conf/settings-{mac}
>> #
>> U 192.168.1.152:58714 -> 224.0.1.75:5060 #263
>> SUBSCRIBE sip:MAC%3a0004137120D8 at lan SIP/2.0.
>> Via: SIP/2.0/UDP 192.168.1.152:58714;rport.
>> From: <sip:MAC%3a0004137120D8 at lan>;tag=1971605806.
>> To: <sip:MAC%3a0004137120D8 at lan>.
>> Call-ID: 1846532696 at 192.168.1.152.
>> CSeq: 1 SUBSCRIBE.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Expires: 0.
>> Accept: application/url.
>> Contact: <sip:192.168.1.152:58714>.
>> User-Agent: snom760/8.9.3.80.
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.156:5060 -> 192.168.1.152:58714 #264
>> SIP/2.0 200 OK.
>> Via: SIP/2.0/UDP 192.168.1.152:58714;rport=58714;received=192.168.1.152.
>> From: <sip:MAC%3a0004137120D8 at lan>;tag=1971605806.
>> To: <sip:MAC%3a0004137120D8 at lan>;tag=fb721cde02dffb6bb099728401306798.2f00.
>> Call-ID: 1846532696 at 192.168.1.152.
>> CSeq: 1 SUBSCRIBE.
>> Server: kamailio (5.2.5 (x86_64/linux)).
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.156:5060 -> 192.168.1.152:58714 #265
>> NOTIFY sip:192.168.1.152:58714 SIP/2.0.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bK201a.063839a4000000000000000000000000.0.
>> To: <sip:MAC%3a0004137120D8 at lan>;tag=1971605806.
>> From: <MAC%3a0004137120D8>;tag=da567df9df3ac234e43969a051db4641-f31b.
>> CSeq: 10 NOTIFY.
>> Call-ID: 24eaa8de01be1768-70963 at 172.23.56.1.
>> Max-Forwards: 70.
>> Content-Length: 33.
>> User-Agent: kamailio (5.2.5 (x86_64/linux)).
>> Subscription-State: terminated;reason=timeout.
>> Event: ua-profile;profile-type="device";vendor="snom";model="snom760";version="8.9.3.80".
>> Content-Type: application/url.
>> .
>> http://server.conf/settings-{mac}
>> #
>> U 192.168.1.152:58714 -> 192.168.1.156:5060 #266
>> SIP/2.0 200 Ok.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bKf21c.917eaf36000000000000000000000000.0;received=192.168.1.156.
>> From: <MAC:0004137120D8>;tag=da567df9df3ac234e43969a051db4641-8cfb.
>> To: <sip:MAC%3A0004137120D8 at lan>;tag=1750588964.
>> Call-ID: 24eaa8de01be1768-70960 at 172.23.56.1.
>> CSeq: 10 NOTIFY.
>> User-Agent: snom760/8.9.3.80.
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.152:58714 -> 192.168.1.156:5060 #267
>> SIP/2.0 200 Ok.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bKf21c.917eaf36000000000000000000000000.0;received=192.168.1.156.
>> From: <MAC:0004137120D8>;tag=da567df9df3ac234e43969a051db4641-8cfb.
>> To: <sip:MAC%3A0004137120D8 at lan>;tag=1750588964.
>> Call-ID: 24eaa8de01be1768-70960 at 172.23.56.1.
>> CSeq: 10 NOTIFY.
>> User-Agent: snom760/8.9.3.80.
>> Content-Length: 0.
>> .
>> 
>> #
>> U 192.168.1.152:58714 -> 192.168.1.156:5060 #268
>> SIP/2.0 200 Ok.
>> Via: SIP/2.0/UDP 224.0.1.75;branch=z9hG4bK201a.063839a4000000000000000000000000.0;received=192.168.1.156.
>> From: <MAC:0004137120D8>;tag=da567df9df3ac234e43969a051db4641-f31b.
>> To: <sip:MAC%3A0004137120D8 at lan>;tag=1971605806.
>> Call-ID: 24eaa8de01be1768-70963 at 172.23.56.1.
>> CSeq: 10 NOTIFY.
>> User-Agent: snom760/8.9.3.80.
>> Content-Length: 0.
>> .
>> 
>> 
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>> 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>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200330/12ae8ec8/attachment.html>


More information about the sr-users mailing list