traffic-measurement

TrafficStats functions always return -1

大城市里の小女人 提交于 2019-12-02 19:43:58
问题 When i try to retrieve traffic data using TrafficStats class, TrafficStats.getTotalRxBytes() and TrafficStats.getTotalTxBytes() functions always return -1 even if i use the browser to load some web pages. I knew from some forums that -1 mean that the device don't support the action. I used WVGA, NEXUS ONE and NEXUS S and the problem persists. Thank you. 回答1: If you are using emulator it might not work. Try on a real device. 来源: https://stackoverflow.com/questions/21330735/trafficstats

TrafficStats functions always return -1

旧城冷巷雨未停 提交于 2019-12-02 07:43:30
When i try to retrieve traffic data using TrafficStats class, TrafficStats.getTotalRxBytes() and TrafficStats.getTotalTxBytes() functions always return -1 even if i use the browser to load some web pages. I knew from some forums that -1 mean that the device don't support the action. I used WVGA, NEXUS ONE and NEXUS S and the problem persists. Thank you. If you are using emulator it might not work. Try on a real device. 来源: https://stackoverflow.com/questions/21330735/trafficstats-functions-always-return-1

Measure Network Data with Python

半城伤御伤魂 提交于 2019-11-30 08:55:50
I'm currently writing a program to shut down a computer when over a period of time (say, half an hour) network traffic is below a certain threshold. Here's the pseudocode that I've worked will give the correct logic: BEGIN SUBPROGRAM loopFlag = True Wait 5 minutes # Allows time for boot and for the machine to settle traffic = 0 WHILE loopFlag = True DO FOR sec = 0 to 3600 traffic += *network.traffic()* wait 1 second ENDFOR IF traffic < trafficThreshold THEN loopFlag = False ENDIF ENDWHILE os.ShutDown() END SUBPROGRAM What I'm looking for is the Python module or library that will allow me to

Measure Network Data with Python

醉酒当歌 提交于 2019-11-29 12:43:53
问题 I'm currently writing a program to shut down a computer when over a period of time (say, half an hour) network traffic is below a certain threshold. Here's the pseudocode that I've worked will give the correct logic: BEGIN SUBPROGRAM loopFlag = True Wait 5 minutes # Allows time for boot and for the machine to settle traffic = 0 WHILE loopFlag = True DO FOR sec = 0 to 3600 traffic += *network.traffic()* wait 1 second ENDFOR IF traffic < trafficThreshold THEN loopFlag = False ENDIF ENDWHILE os

How to get the correct number of bytes sent and received in TrafficStats?

北战南征 提交于 2019-11-28 19:43:02
My app is trying to count the number of bytes send and received over WiFi/LAN and mobile data connections. To do that, I get the values of TrafficStats counters at one point in time and subtract that from its values the next time I check. // get current values of counters long currentMobileTxBytes = TrafficStats.getMobileTxBytes(); long currentMobileRxBytes = TrafficStats.getMobileRxBytes(); long totalTxBytes = TrafficStats.getTotalTxBytes(); long totalRxBytes = TrafficStats.getTotalRxBytes(); // to get mobile data count, subtract old from current long currentMobileSent = currentMobileTxBytes

android statistic 3g traffic for each APP, how?

我只是一个虾纸丫 提交于 2019-11-28 18:24:53
For statistic network traffic per APP, what I'm using now is Android TrafficStats That I can get result like following : Youtube 50.30 MBytes Facebook 21.39 MBytes Google Play 103.38 MBytes (and more...) As I know, the "Android Trafficstats" just a native pointer to a c file. (maybe an .so ?) But it mixed Wifi & 3g traffic, is there any way to only get non-WiFi traffic statistic ? RRTW Evening all, I got some way to do that... First I have to create a class which extends BroadcasrReceiver, like this: Manifest definition: <receiver android:name=".core.CoreReceiver" android:enabled="true"

How to get the correct number of bytes sent and received in TrafficStats?

夙愿已清 提交于 2019-11-27 11:46:09
问题 My app is trying to count the number of bytes send and received over WiFi/LAN and mobile data connections. To do that, I get the values of TrafficStats counters at one point in time and subtract that from its values the next time I check. // get current values of counters long currentMobileTxBytes = TrafficStats.getMobileTxBytes(); long currentMobileRxBytes = TrafficStats.getMobileRxBytes(); long totalTxBytes = TrafficStats.getTotalTxBytes(); long totalRxBytes = TrafficStats.getTotalRxBytes()

android statistic 3g traffic for each APP, how?

被刻印的时光 ゝ 提交于 2019-11-27 11:32:51
问题 For statistic network traffic per APP, what I'm using now is Android TrafficStats That I can get result like following : Youtube 50.30 MBytes Facebook 21.39 MBytes Google Play 103.38 MBytes (and more...) As I know, the "Android Trafficstats" just a native pointer to a c file. (maybe an .so ?) But it mixed Wifi & 3g traffic, is there any way to only get non-WiFi traffic statistic ? 回答1: Evening all, I got some way to do that... First I have to create a class which extends BroadcasrReceiver,