Typical UDP latency on iPhone over 3G - are my numbers right?

百般思念 提交于 2019-12-01 12:32:51

问题


In order to evaluate TCP versus UDP on the iPhone, I wrote a small echo server on my computer and used the AsyncUdpSocket library on the iPhone, but latencies are coming out surprisingly large and I wonder if there is something wrong with my implementation somehow.

My setup has a wifi-router (Apple Airport) which has an external static IP. The port used by the echo server is forwarded to my development computer.

I used two different setups:

  1. iPhone -> Wifi -> Wifi Router -> Wifi -> Computer
  2. iPhone -> 3G -> Wifi Router -> Wifi -> Computer

Packet size was around 10 bytes.

In the first case, roundtrip varied from 9 ms to 600 ms. Mostly I would see a median of around 300 ms, but some runs would have only 30 ms.

Second case... Best case 2000 ms, moving up to 5000 ms.

Implementation would send an UDP packet, wait until it gets back, then send the next.

I initially believed something was wrong with the implementation, but running it from the simulator give a consistent latency of only 7 ms.

Are my numbers right or is something weird going on?


回答1:


I saw this link on iphone Wifi latency and I decided to try pumping UDP packets faster.

I started lowering my delay between receiving a ping and sending a new ping until I reached 50 ms.

At 50 ms, the UDP ping (roundtrip) was down to around 80 ms using 3G (remember, this was originally around 2000 ms)!

TCP also improved, but not as much as UDP. I would get 100-200 ms, again on 3G.

My conclusion is that iPhone powers down the antennae, which severely affects UDP. TCP is better, because the phone knows of the open connection and is faster to power up.

Incidentally during packet loss, TCP would reach pings of 1000-2000 ms. This coincides with own observations that TCP connections would occasionally suffer large delays on the iPhone.




回答2:


I send a udp packet of 1 byte every 30th of second and the latency desapeared. This way the antenna never sleep.



来源:https://stackoverflow.com/questions/17859732/typical-udp-latency-on-iphone-over-3g-are-my-numbers-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!