<div dir="ltr">Hi Dave,<div><br></div><div>I appreciate the time you and many in our community spend understanding how freeswitch works when reporting issues.</div><div><br></div><div>For audio, RTP is usually handled by the same thread that is executing dialplan apps.  Dialplan apps must not spend a lot of time on blocking operations otherwise RTP will not be processed in time.  switch_ivr_play_file() is one of many core functions dialplan apps execute and it is responsible for reading and writing audio frames.  Knowing that FS can fall behind, it is a common pattern in FS to flush buffers prior to playing.  In 1-legged calls this should have no bad effect, however you've noticed a side-effect of that in the RTCP reports.</div><div><br></div><div>Chris</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 20, 2020 at 12:57 PM David Horton <<a href="mailto:daveh@drachtio.org">daveh@drachtio.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Could someone on the freeswitch team please respond to this?  I spent a fair bit of time/effort gathering logs and investigating, and would like a quick answer to the question “why does freeswitch discard incoming RTP packets when starting to pay a file?”<br>
<br>
Dave<br>
<br>
On Nov 11, 2020, at 3:44 PM, David Horton <<a href="mailto:daveh@drachtio.org" target="_blank">daveh@drachtio.org</a>> wrote:<br>
<br>
Any response to this?<br>
<br>
On Nov 7, 2020, at 9:26 PM, David Horton <<a href="mailto:daveh@drachtio.org" target="_blank">daveh@drachtio.org</a>> wrote:<br>
<br>
I have investigated this further, and for some reason the issue seems to be related to the fact that I am playing a file on the channel, and when the file starts playing freeswitch for some reason flushes packets, which then occasionally leads to freeswitch reporting lost packets (the very packets it flushed).<br>
<br>
I’m lacking some information to fully understand this — most importantly, I would like to know what the function of doing an AUDIO_SYNC on the channel when a file finishes playing, and why this should cause freeswitch to flush incoming packets?<br>
<br>
Here, step by step, is what I observe:<br>
<br>
1.  I issue a command to play an mp3 file on the channel<br>
2.  When the file starts playing, I see freeswitch issue an AUDIO_SYNC event<br>
3. This causes freeswitch to set the SWITCH_RTP_FLAG_FLUSH flag on the channel<br>
4.  Freeswitch then does a non-blocking read on the UDP socket and discards any packets it receives — this is where incoming packets get dropped on the floor — not all the times, only if the non-blocking read happens just as a packet was received at the network layer<br>
5.  Once the non-blocking read fails, freeswitch turns off the SWITCH_RTP_FLAG_FLUSH flag and continues on.<br>
<br>
Therefore, every time a play file command starts, there appears to be a chance of dropping some packets.<br>
<br>
Below is some logging showing the above sequence of events (I’ve added some additional logging).<br>
<br>
So, for the freeswitch team — can you provide some background info on why we would want to discard *incoming* packets when we start streaming an *outbound* audio file?<br>
<br>
What exactly are we trying to solve for here?<br>
<br>
Am I doing something wrong somehow? <br>
<br>
<br>
********<br>
EXECUTE [depth=1] sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> playback(/tmp/tts-02413eaa-538f-49cc-be9f-54f71e45f389e572411e7d5b2eda396848cd8c4ff467c47513a9.mp3)<br>
2020-11-08 02:14:49.087939 [ALERT] switch_core_session.c:2889 sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> receive message [APPLICATION_EXEC]<br>
2020-11-08 02:14:49.087939 [ALERT] switch_core_session.c:1047 Send signal sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> [BREAK]<br>
2020-11-08 02:14:49.087939 [DEBUG] switch_ivr_play_say.c:1492 Codec Activated L16@8000hz 1 channels 20ms<br>
2020-11-08 02:14:49.087939 [ALERT] switch_ivr_play_say.c:1423 sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> receive message [AUDIO_SYNC]<br>
2020-11-08 02:14:49.087939 [DEBUG] switch_rtp.c:7627 starting to flush packets<br>
2020-11-08 02:14:49.087939 [ERR] switch_rtp.c:5704 *** do_flush: total flushed packets: 2 ***<br>
2020-11-08 02:14:49.087939 [DEBUG] switch_rtp.c:7631 done flushing packets<br>
2020-11-08 02:14:49.087939 [ALERT] switch_core_media.c:15808 sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> receive message [TRANSCODING_NECESSARY]<br>
2020-11-08 02:14:49.107937 [ERR] switch_rtp.c:6123 Missed 2 RTP frames from sequence [11395] to [11396] (flushed by FS). Time since last read [19998]<br>
2020-11-08 02:14:49.307936 [ALERT] switch_rtp.c:1572 sofia/drachtio_mrf/<a href="http://nobody@172.31.32.120:5060" rel="noreferrer" target="_blank">nobody@172.31.32.120:5060</a> audio 2 consecutive flaws, adding 2 flaw penalty<br>
2020-11-08 02:14:49.727937 [ALERT] switch_rtp.c:1846 LOST PACKETS!! expected 53, got 51, highest: 11427, last_rpt_ext_seq 11374, extra 0<br>
2020-11-08 02:14:49.727937 [CRIT] switch_rtp.c:1867 rtcp_generate_sr: stats_ssrc[288672665] received[51] expected[53] cum[3] lost[2|9/256]pkt last_seq[11427] cyc[0] last_rpt_seq[11374] cyc[0] ssrc[288672665]<br>
*********<br>
<br>
On Nov 5, 2020, at 11:12 AM, Dragos Oancea <<a href="mailto:dragos@freeswitch.org" target="_blank">dragos@freeswitch.org</a>> wrote:<br>
<br>
Chris pointed out that the packets need to be there, at the app level, when FS wants them, even if the JB is not used. And how are you sure that those packets are not actually lost for FS ? What network stats ? Also, OS/network interfaces have very large buffers.  <br>
<br>
On Wed, Nov 4, 2020 at 5:29 PM David Horton <<a href="mailto:daveh@drachtio.org" target="_blank">daveh@drachtio.org</a>> wrote:<br>
No, they are audio only.<br>
<br>
On Nov 4, 2020, at 10:22 AM, Dragos Oancea <<a href="mailto:dragos@freeswitch.org" target="_blank">dragos@freeswitch.org</a>> wrote:<br>
<br>
Are these video calls ? JB gets enabled by default for video.<br>
<br>
On Wed, Nov 4, 2020 at 5:12 PM David Horton <<a href="mailto:daveh@drachtio.org" target="_blank">daveh@drachtio.org</a>> wrote:<br>
Good point - but I have not enabled jitter buffer.<br>
<br>
On Nov 4, 2020, at 10:08 AM, Dragos Oancea <<a href="mailto:dragos@freeswitch.org" target="_blank">dragos@freeswitch.org</a>> wrote:<br>
<br>
What's in the RTCP report is what comes after passing through the Jitter Buffer, if there's jitter , some packets are late and they will be dropped by JB.<br>
<br>
On Tue, Nov 3, 2020 at 7:26 PM David Horton <<a href="mailto:daveh@drachtio.org" target="_blank">daveh@drachtio.org</a>> wrote:<br>
I have a freeswitch server v1.10.1 running on AWS EC2 which I have noticed is reporting lost packets in the RTCP reports it is sending out.  This happens even with a single call.  Meanwhile, the network stats on the same instances show no dropped packets and no packet receive errors.  Is there anything which could explain this?  Have others seen errors in the RTCP stats reported by freeswitch?<br>
<br>
dave<br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
<br>
<br>
<br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a></blockquote></div>