Author Topic: send keepalives only during SIP calls  (Read 11650 times)

slurp

  • Newbie
  • *
  • Posts: 5
    • View Profile
send keepalives only during SIP calls
« on: November 30, 2018, 05:25:44 AM »
Hello Yate developers, thank you for developing such powerful and flexible software.

I'm using mobile broadband which unfortunately is NATed and have accounts with multiple providers. Since I'm cheap and mobile data cost$ I want Yate to use as little data as possible, so first question:

How can I configure or modify Yate to only send keepalives while I have a call? For the providers I use for outbound calls only, I would prefer to eliminate unnecessary keepalives. Since my providers won't send (re-)INVITEs outside of a call there is no need to maintain a NAT binding outside of a call. For those of us stuck behind many if not most types of NAT this is the desirable default behaviour for any provider that doesn't need registration.

I appreciate each keep alive uses little data but it will add up with multiple providers and a system running 24x7.

Thanks!

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: send keepalives only during SIP calls
« Reply #1 on: December 04, 2018, 04:18:24 AM »
There is no keep alive for calls using UDP transport.
For UDP keep alive is only used by registered lines.

If you want to implement a feature to send keep alive for active calls you may
1. Add variable to hold keep alive time
2. Re-implement  'virtual void checkTimers(Message& msg, const Time& tmr)' in YateSIPConnection
    Send keep alive: see YateSIPLine::keepalive() for sending keep alive packet
    Don't forget to call Channel::checkTimers() !!!


slurp

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: send keepalives only during SIP calls
« Reply #2 on: December 09, 2018, 02:54:26 AM »
Hi Marian,

Thanks for the reply. We have our wires crossed I think. I have my outbound only providers set up as lines in accfile.conf rather than what I think you are referring to, (dynamic) SIP targets set by a routing module.

I don't know whether I would go so far to call my outbound only providers "registered lines" as I have omitted the registrar parameter from these lines to prevent registration.

In Yate 6.0 these also send keep-alives regardless of whether there is a call active or not which is pointless in perhaps the majority of NAT configurations so I would like to prevent that.

Looking at message traces, I think a workaround might be to duplicate accfile's behaviour in sending user.login messages but only in response to a call.route message for that line, and send a user.logoff when there no more calls using that line. If globals can't be modified from regexroute than I assume I would need to write an extmodule. I think it would be more sensible to modify ysipchan if the current software can't be configured to behave the way I desire.

BTW, I would have thought that most of the static parameters for a SIP line entry would be able to be supplied as parameters to a call.route message with a SIP destination as a target and vice versa but it seems this is not the case.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: send keepalives only during SIP calls
« Reply #3 on: December 10, 2018, 01:15:58 AM »
You may set the 'keepalive' parameter if want to change the interval (value in seconds).
See:
https://docs.yate.ro/wiki/Accfile

In an external or javascript module you may track call.cdr messages with operation=initialize/finalize.
Track channels belonging to your line. You don't need to logout the line. Just send same parameters as login with changed keepalive
The line parameter can be added to CDR.
See:
https://docs.yate.ro/wiki/CDR_Build_Module
https://docs.yate.ro/wiki/How_to_add_custom_parameters_in_CDR_from_routing

If your last phrase means you want to have some parameters set in outbound/inbound calls using a line you may set them.
All line parameters starting with 'out:' prefix will be set for outbound call legs using them (prefix stripped).
Same for 'inb:' parameters for inbound calls.

slurp

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: send keepalives only during SIP calls
« Reply #4 on: December 10, 2018, 02:38:51 AM »
Thanks Marian, it will take me some time this digest that fully. Do I understand correctly that the advantage of using the cdrbuild module is that any custom parameter I set in routing will be available in cdr.call/finalize? Do I need to keep track of the number of calls using a line myself or is there some trick I can use?

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: send keepalives only during SIP calls
« Reply #5 on: December 10, 2018, 02:54:28 AM »
Custom parameters configured in cdrbuild.conf and set via copyparams in call.execute will be available in all call.cdr messages related a given call leg.

You must track the number of calls related to a given parameter (line ?)
call.cdr with operation=initialize. Increase counter. Start keep alive if counter=1
call.cdr with operation=finalize. Decrease counter. Stop keep alive if counter=0

slurp

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: send keepalives only during SIP calls
« Reply #6 on: December 16, 2018, 04:09:24 AM »
You don't need to logout the line. Just send same parameters as login with changed keepalive
What's the advantage in not logging out? I could see the benefit in this case if only the changed parameter could be sent