Why is there a 1 second delay when sending or receiving from a socket?

I am creating a VoIP application. The VoIP application needs to send and receive RTP packets at 20 ms intervals.

The application calls sendto() of the Socket API at 20 ms intervals, but the iPhone buffers the send data inside iOS and then sends RTP packets in batches at 1 second intervals. (I captured the sned packets of iPhone with rvctl and confirmed this. please reffer "Sending at 1 second intervals.png" for detail)

Similarly, other devices send RTP packets to the iPhone at 20 millisecond intervals, but the iPhone only receives them at 1 second intervals. (please reffer "Receiving at 1 second intervals.png" for detail)

Why is this?

If the cause of the delay is in the Wi-Fi protocol and the cause can be found from sysdiagnose, please tell me the search key for sysdiagnose that shows the cause of the delay and the meaning of the corresponding log.

I uploaded sysdiagnose and result of lan capture to below.

[sysdiagnose and lan capture]

https://drive.google.com/file/d/149OPmePAF4hnZj6NeSnKc5NizfitPQDS/view?usp=sharing

And, the start and end times, packet number in the lan capture of the call shown in the png example are below

Start time; 13:57:22.349608/packet number; 948

End time; 13:57:37.482874/packet number; 2583

Just to be clear, are you running RTP over UDP?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, my app is running RTP over UDP.

NOTE I forgot to attach "Sending at 1 second intervals.png" "Receiving at 1 second intervals.png", so I'll attach it to this comment.

Thanks for confirming.

In Investigating Network Latency Problems you’ll find my general process for investigating problems like this. Please read it through and get back to me with the results.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I confirmed point A(My App log) and PointD(RVI interface) of "Investigating Network Latency Problems". My App is sending packet with 20ms interval (To be precise, 15ms - 25ms, with an average period of 20ms).

But RVI interface is recording packet with 1s interval. (Please refer png files in my comment before for detail)

My App is using only BSD Sockets, and UDP for RTP packet. In addition I tested with Bluetooth OFF.

[QUESTION]

Does the RVI interface provide real-time packet capture? I don't think that packet capture of RVI is done only at 1 second intervals, is this correct?

[QUESTION]

Does the RVI interface provide real-time packet capture? I don't think that packet capture of RVI is done only at 1 second intervals, is this correct?

PS.

My customer says that when he does a packet trace on the RVI interface, there is a 1 second delay between the Mac and the iPhone (i.e. the Lightning cable), but I don't think that's possible. Am I right?

Does the RVI interface provide real-time packet capture?

The packet trace infrastructure records the time at which the packet arrived [1] and tcpdump shows those times. So, while it might take some time for traffic to make it to you via the RVI link, the timestamps shown shouldn’t be affected by that.

That suggests that these delays are ‘real’.

As to what’s causing the delays, it’s hard to be 100% sure given the info you have. My experience is that delays like this are often caused by Wi-Fi level activity. For example, if the device is using peer-to-peer Wi-Fi then it might switch to a different channel for the purpose, which then causes significant delays on the infrastructure Wi-Fi. However, those delays aren’t usually that long.

I’ve also see Wi-Fi AP do really weird stuff.

If you’ve only tested this with one specific AP, it’s definitely worth testing with a different one, preferably one from a different manufacturer.

Beyond that, the next step is to look at a Wi-Fi level packet trace to see what’s actually happening.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] By default. People cleverer than me tell me that this isn’t the case if you set the data link type to raw.

Why is there a 1 second delay when sending or receiving from a socket?
 
 
Q