'The Round Trip Time of iOS MultipeerConnectivity is very unstable
I am doing a project using iOS MultipeerConnectivity network with 2 iPhones. When I was measuring the round trip time (RTT), I found that the RTT is very unstable.
What I did in code was that I send a ping message from device A to device B and record the current system uptime ([[NSProcessInfo processInfo] systemUptime]
) on device A. When device B receives the ping message, it immediately sends a pong message back to device A. When device A receives the pong message, the RTT is calculated by
RTT = (current system uptime - previously recorded system uptime) * 1000
I sent the ping message every 2 seconds from device A to device B and got the following RTT result:
Current Rtt 8.79170834377874
Current Rtt 156.932708341628
Current Rtt 251.297625000007
Current Rtt 3.99058334005531
Current Rtt 6.2492500001099
Current Rtt 5.35900000249967
Current Rtt 96.0188750032103
Current Rtt 190.877625005669
Current Rtt 291.066874997341
Current Rtt 7.09629166522063
Current Rtt 6.8734583328478
Current Rtt 43.4346249967348
Current Rtt 227.179375011474
Current Rtt 235.792583334842
Current Rtt 336.144541666727
Current Rtt 10.1862916635582
Current Rtt 14.6641249884851
Current Rtt 100.17424999387
Current Rtt 194.973624995328
Current Rtt 294.071500000427
Current Rtt 5.01749999239109
Current Rtt 5.53570833289996
Current Rtt 65.7211666693911
Current Rtt 159.985583333764
Current Rtt 253.625583325629
Current Rtt 7.48362501326483
Current Rtt 4.94183332193643
Current Rtt 20.4326250095619
Current Rtt 122.555875001126
Current Rtt 214.03287499561
Current Rtt 296.639208332635
Current Rtt 6.16570832789876
Current Rtt 5.21995832968969
Current Rtt 61.9622916710796
You might have noticed the pattern, it is a loop! At the beginning, the RTT is very low (around 5 ms), which is good. But after a short period of time (about 5 seconds), it gradually increases and finally hits a peak value of around 300 ms. Then it immediately drops to around 5 ms and the loop repeats again. I didn't send any other message between these two devices, only ping pong messages were transmitted.
This is very weird to me, since it is stably unstable... Is that supposed to happen because of the nature of iOS MultipeerConnectivity? Or I did something wrong to cause that?
Is that possible to make iOS MultipeerConnectivity network stable with a low RTT (around 5ms)? Thank you very much!
Solution 1:[1]
I think the main purpose of MultipeerConnectivity is to transfer large files instead of stable low latency communication. As a result, MultipeerConnectivity might not be suitable for a local peer-to-peer game which requires stable and low latency.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | yuchen |