简体   繁体   English

在iPhone上以编程方式测量网络流量

[英]Measure network traffic programmatically on iPhone

I'm interested in measuring the network traffic for my application. 我对测量应用程序的网络流量感兴趣。 Ideally I would need to separate wireless from 3G network traffic. 理想情况下,我需要将无线与3G网络流量分开。 I can't seem to find any API that gets this information; 我似乎无法找到任何获取此信息的API; 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). 然而,我发现AppStore中至少有一个应用程序可以完成某些操作(它们实际上总结了整个手机的流量)。

Any ideas? 有任何想法吗?

I've found one approximate solution: getifaddrs can be used to get statistics on network usage. 我找到了一个近似解决方案: getifaddrs可用于获取网络使用情况的统计数据。

One advantage is that it can get separate statistics for Wi-Fi and WWAN interfaces. 一个优点是它可以获得Wi-Fi和WWAN接口的单独统计信息。

A disadvantage is that on multi-tasking devices those interfaces may be used by multiple applications and the statistics are cumulated. 缺点是在多任务设备上,这些接口可以由多个应用程序使用并且累积统计数据。

I also was looking for solution and found it here: iPhone Data Usage Tracking/Monitoring 我也在寻找解决方案并在此处找到: iPhone数据使用跟踪/监控

Please take a look this post, it provides all info that you need. 请看一下这篇文章,它提供了您需要的所有信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM