1

I am testing an app that connects through an asynchronous TCP socket to an C# server and sends 1 byte every 30 sec (implementing a heartbeat). After about an hour later the app had sent 132 packets (of one byte) to the server, the packets have been received ok. The iPhone app connected once to the server and after that sent the packets through the open connection (the server sends nothing). I did that to measure the bandwidth used. So I went to I Phone >Settings>General>Usage and it measured 366KB up and 344KB down (I had reset the statistics before the test). There is no other app connecting to the net installed on the phone and I've tried this about 5 times with similar results.

Is this natural? I only sent 132 bytes but the bandwidth used was about 710 Kilobytes (like 7.000 more). Is there that much bandwidth overhead from the TCP/IP protocol? I guess I'll have worst results with an Http polling implementation, cause of the http headers.

4

4 回答 4

1

不,其他东西正在使用带宽,例如 Safari 或 Mail 检查更新或其他东西。每个数据包上下不能占用 3K。

于 2010-06-04T13:59:19.920 回答
0

如果您使用 wifi 连接,则可以通过在另一台计算机上使用Wireshark来捕获进出 iPhone 的所有流量。通过这种方式,您可能会知道正在使用额外带宽的内容/位置。

于 2010-06-04T14:17:50.747 回答
0

我还测试了通过 http(一个以纯文本/文本 =1 响应的 asp.net httphandler)从服务器获取 1 个字节(大约)。由于 http 标头,我希望此方法会使用更多带宽。但是在测试 Iphone 设备后报告说,来自服务器的每个 1 字节请求(带有所有 http 标头)花费了大约 3.5kb。与使用直接 tcp 套接字时每个数据包的平均成本 (5kb - 7kb) 相比仍然更少。

于 2010-06-04T15:23:50.537 回答
0

发送或接收的每个数据包都有开销,以及设置或拆除连接的额外开销。发送许多小数据包会产生大量的 TCP 开销,并且仅测量在 socked 的另一端接收到的字节不会包括开销。如果您想要更少,请切换到 UDP 并自己处理维护连接的复杂性。

此外,可能还有其他操作系统进程在后台使用带宽。禁用所有邮件/日历/推送通知以获得最佳效果。

于 2010-06-04T19:04:22.957 回答