Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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).

Any ideas?

like image 755
Mihai Damian Avatar asked Nov 30 '10 11:11

Mihai Damian


People also ask

How do I measure network traffic?

The best way to check network traffic is with a tool like SolarWinds® Bandwidth Analyzer Pack (BAP). BAP is built to automatically check and compile network traffic insights from devices across your network in a centralized dashboard and alert you to any concerning behavior in your network.


1 Answers

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

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.

like image 171
Mihai Damian Avatar answered Oct 20 '22 20:10

Mihai Damian