Summary:ASTERISK-02854: [patch] RTP keepalive for SIP
Reporter:jshugart (jshugart)Labels:
Date Opened:2004-11-18 16:00:41.000-0600Date Closed:2008-01-15 15:20:24.000-0600
Versions:Frequency of
Environment:Attachments:( 0) chan_sip.c.diff
( 1) chan_sip.c.diff
( 2) sip.conf.sample.diff
Description:I use AudioCodes gateways and they disconnect the call when no RTP is received for a set amount of time (a few seconds).  This is like the rtptimeout feature in the SIP module.  I have altered chan_sip.c to periodically send a RTP packet if configured.  There is a global and peer parameter called rtpkeepalive that is the number of seconds to wait before sending the keepalive packet.  I have only tested this with G711 ULaw.
Comments:By: Mark Spencer (markster) 2004-11-18 16:05:34.000-0600

This patch is only going to send the keepalive RTP if there is received audio, is this what you really want?

By: jshugart (jshugart) 2004-11-18 16:19:54.000-0600

No.  It should send regardless.  I'll upload the new change in a minute.

By: jshugart (jshugart) 2004-11-18 16:27:14.000-0600

I was looking deeper and it should send a keepalive because the last tx time is updated when SDP is sent or received.  This should then send a keepalive X seconds after the SDP message is sent or received if no other RTP is sent.  If no SDP info is sent or received then no keepalive would be sent, but that seems like correct behavior.

By: Mark Spencer (markster) 2004-11-19 00:28:07.000-0600

you'll need to schedule it then in chan_sip

By: Olle Johansson (oej) 2004-11-20 15:04:10.000-0600

Is this code dislaimed?

By: Olle Johansson (oej) 2004-11-20 15:06:43.000-0600

jshugart: Could you please upload the config file diff again? I deleted it by mistake. Really sorry about that.

By: jshugart (jshugart) 2004-11-22 10:49:13.000-0600

I have sent in the disclaimer, and have submitted a few fixes in the past.  I am still not clear on markster's response.  The thread code where the send was added run on all SIP channels.  Is there some other place that is needed to update?  Everything worked fine in my limited environment.

By: Mark Spencer (markster) 2004-11-22 14:24:13.000-0600

Can you try sending just an empty, 0 byte packet (either looking like a real RTP frame or not) and see if that is sufficient?  Trying to make a packet for every codec type will definitely not be pleasant.

I was thinking that the code to check the lastrtptx was in the receiver function, but upon closer inspection I see that it is actually in the main thread, so that's fine, sorry about the confusion.

By: jshugart (jshugart) 2004-11-22 17:10:36.000-0600

I just tested this with the X-Lite phone the ast_rtp_write function appears to handle the translation from ULAW to whatever format is needed.  I picked the frame to be ULAW because it should be able to be translated to almost anything.  I could easily be wrong on this, so I would be happy to dig further if you disagree.

By: Mark Spencer (markster) 2004-11-22 17:25:22.000-0600

Can you please test sending a codec of whatever type was last transmitted that is 0 bytes long and/or just sending an empty UDP packet.  Thanks.

By: jshugart (jshugart) 2004-11-23 00:38:57.000-0600

I just created a packet with a datalen of 10 and a subclass of AST_RTP_CN.  The audiocodes seemed to handle it fine.  If I only sent 1 byte the audiocodes tossed the packet.  Not sure if always sending a ULAW packet is better or worse that AST_RTP_CN.  I tried sending a ULAW packet with a data size of 10, but the audiocodes tossed that.  The difficulty of trying to send the same codec would be to get the right packet size.

One strange thing I noticed, when playing a GSM file it sent a coder type of 3 (AST_FORMAT_GSM).  Shouldn't it send a G711 packet if the RTP session was established that way?

By: Mark Spencer (markster) 2004-12-01 00:13:10.000-0600

Definitely prefer sending CNG to sending empty audio.  Can you update the patch accordingly?

By: Mark Spencer (markster) 2004-12-12 00:07:05.000-0600

Do you have any interest in making it transmit CNG?

By: jshugart (jshugart) 2004-12-13 10:52:57.000-0600

Yes, and sorry for the long gap.  December is our busiest month, so these kinds of projects get put on the back burner.  I'll work on it and get you something before the end of the month.

By: jshugart (jshugart) 2004-12-14 12:11:33.000-0600

The code changes were smaller than I thought.  Here is the updated patch.  It works fine with my AudioCodes gateways, and also the X-Lite phone.  I have not tested it against anything else.

By: nick (nick) 2005-01-02 18:52:09.000-0600

Updates?  Has anybody else tested this? Is it CVS-ready (stable and still applies)?


By: Mark Spencer (markster) 2005-01-07 01:06:45.000-0600

Added to CVS with changes, thanks!

By: Russell Bryant (russell) 2005-01-08 15:46:22.000-0600

not in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:20:24.000-0600

Repository: asterisk
Revision: 4704

U   trunk/channels/chan_sip.c
U   trunk/include/asterisk/rtp.h
U   trunk/rtp.c

r4704 | markster | 2008-01-15 15:20:24 -0600 (Tue, 15 Jan 2008) | 2 lines

Support CNG transmission when on hold (bug ASTERISK-2854)