Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 16,998
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Network traffic

data monitor seems to track the usage separated by wifi and cellular, and when i try to specify an interface for netstat i get a kvm error.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Network traffic

If you hear anything from devs of this app please share. I don't think they used 'netstat' approach, it's too generic... there must be some API.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Network traffic

I'm also looking into this

a customer wants to integrate such a function to control the data traffic

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Network traffic

[ Edited ]

Well, its showing data usage that happened when the app was closed, and it resets after a reboot, so its likely either using program/lib included with the OS or its reading some log directly. It refreshes pretty quickly, so I don't think its parsing a log (most are not accessible anyway).

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Network traffic

Have you tried to run the commands through the app rather than ssh? Maybe you'll have different permissions?

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Network traffic

I tried - the same.

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Network traffic

[ Edited ]

Try this: ifconfig -v

 

It will show:

input: 233 packets, 98698 bytes
output: 492 packets, 197713 bytes

 

And they are separated by network type. You'll just have to figure out which is carrier vs wifi.

 

tiw_sta0 is WiFi

ecm0 is USB

bptp0 is carrier? (Probably not, I don't have a data plan, so I'm not sure)

 

You can match them up with the addresses that show under Settings -> About -> Network. There is a native API that will give you the list of interfaces, so maybe you can use that rather than hardcoding anything.

 

$ ifconfig -v    
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
	input: 2582 packets, 515750 bytes
	output: 2582 packets, 515750 bytes
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
..
tiw_sta0: flags=8c43<UP,BROADCAST,RUNNING,OACTIVE,SIMPLEX,MULTICAST> mtu 1500
	address: 40:6f:2a:68:33:55
	input: 37576 packets, 7452193 bytes
	output: 3402 packets, 715738 bytes, 385 multicasts
	inet 10.2.250.11 netmask 0xfffff800 broadcast 10.2.255.255
	inet6 fe80::426f:2aff:fe68:3355%tiw_sta0 prefixlen 64 scopeid 0x12
...
bptp0: flags=8043<UP,BROADCAST,RUNNING,MULTICAST> mtu 1357
	input: 233 packets, 98698 bytes
	output: 492 packets, 197713 bytes
	inet6 fe80::426f:2aff:fe68:3355%bptp0 prefixlen 64 scopeid 0x2e
	inet6 fd20:c356:6e81:8b81:733b:42c:e51f:5f1b prefixlen 8
ecm0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
	address: 42:6f:2a:68:33:55
	input: 3460 packets, 377825 bytes, 367 multicasts
	output: 2279 packets, 398960 bytes, 165 multicasts
	inet 169.254.0.1 netmask 0xfffffffc broadcast 169.254.0.3
	inet6 fe80::406f:2aff:fe68:3355%ecm0 prefixlen 64 scopeid 0x18

 

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Network traffic

thx for your info about ifconfig -v

 

as I understand it right this gives you the trafffic since last boot

 

...but I would have no idea howto get these values from Cascades ;-)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 16,998
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Network traffic

That seems to do the trick, good find Martin!

Ekke, it should be easy to do from Cascades, just read the values from a c++ utility class using Q_PROPERTY.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Network traffic


simon_hain wrote:
That seems to do the trick, good find Martin!

Ekke, it should be easy to do from Cascades, just read the values from a c++ utility class using Q_PROPERTY.

its more the question howto get the values from the command into c++

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner