Typical UDP latency on iPhone over 3G - are my numbers right?(iPhone 在 3G 上的典型 UDP 延迟 - 我的数字对吗?)
问题描述
为了在 iPhone 上评估 TCP 与 UDP,我在我的计算机上编写了一个小型回显服务器,并在 iPhone 上使用了 AsyncUdpSocket 库,但是延迟出乎意料地大,我想知道我的实现是否有问题不知何故.
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.
我的设置有一个 wifi 路由器(Apple Airport),它有一个外部静态 IP.回显服务器使用的端口被转发到我的开发计算机.
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:
- iPhone -> Wifi -> Wifi 路由器 -> Wifi -> 电脑
- iPhone -> 3G -> Wifi 路由器 -> Wifi -> 电脑
数据包大小约为 10 个字节.
Packet size was around 10 bytes.
在第一种情况下,往返时间从 9 毫秒到 600 毫秒不等.大多数情况下,我会看到大约 300 毫秒的中位数,但有些运行只有 30 毫秒.
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.
第二种情况...最好的情况是 2000 毫秒,移动到 5000 毫秒.
Second case... Best case 2000 ms, moving up to 5000 ms.
实现会发送一个 UDP 数据包,等待它返回,然后发送下一个.
Implementation would send an UDP packet, wait until it gets back, then send the next.
我最初认为实现有问题,但从模拟器运行它得到的一致延迟只有 7 毫秒.
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?
推荐答案
我看到了这个关于 iphone Wifi 延迟的链接 我决定尝试更快地抽取 UDP 数据包.
I saw this link on iphone Wifi latency and I decided to try pumping UDP packets faster.
我开始降低接收 ping 和发送新 ping 之间的延迟,直到达到 50 毫秒.
I started lowering my delay between receiving a ping and sending a new ping until I reached 50 ms.
在 50 毫秒时,使用 3G 的 UDP ping(往返)下降到大约 80 毫秒(请记住,这最初是大约 2000 毫秒)!
At 50 ms, the UDP ping (roundtrip) was down to around 80 ms using 3G (remember, this was originally around 2000 ms)!
TCP 也有所改进,但不如 UDP.我会得到 100-200 毫秒,再次使用 3G.
TCP also improved, but not as much as UDP. I would get 100-200 ms, again on 3G.
我的结论是 iPhone 会关闭天线,这会严重影响 UDP.TCP 更好,因为手机知道打开的连接并且开机速度更快.
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.
顺便在丢包期间,TCP 会达到 1000-2000 毫秒的 ping.这与自己的观察结果相吻合,即 TCP 连接偶尔会在 iPhone 上遭受较大的延迟.
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.
这篇关于iPhone 在 3G 上的典型 UDP 延迟 - 我的数字对吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone 在 3G 上的典型 UDP 延迟 - 我的数字对吗?
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01