在iPhone上以编程方式测量网络流量 [英] Measure network traffic programmatically on iPhone

查看:119
本文介绍了在iPhone上以编程方式测量网络流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对测量应用程序的网络流量感兴趣。理想情况下,我需要将无线与3G网络流量分开。我似乎无法找到任何获取此信息的API;然而,我发现AppStore中至少有一个应用程序可以完成某些操作(它们实际上总结了整个手机的流量)。

I'm interested in measuring the network traffic for my application. Ideally I would need to separate wireless from 3G network traffic. I can't seem to find any API that gets this information; however I see that there is at least one app in the AppStore that does something close (they actually sum up the traffic for the entire phone).

任何想法?

推荐答案

我找到了一个近似解决方案: getifaddrs 可以用来获取网络使用情况统计。

I've found one approximate solution: getifaddrs can be used to get statistics on network usage.

一个优点是它可以获得Wi-Fi和WWAN接口的单独统计数据。

One advantage is that it can get separate statistics for Wi-Fi and WWAN interfaces.

缺点是在多任务设备上,多个应用程序可以使用这些接口,并累积统计数据。

A disadvantage is that on multi-tasking devices those interfaces may be used by multiple applications and the statistics are cumulated.

这篇关于在iPhone上以编程方式测量网络流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆