Re: Starting a 3G traffic monitoring application for N900: some questions

Re: Starting a 3G traffic monitoring application for N900: some questions

2010-11-29 14:14 UTC
Hi,

On 11/29/2010 04:04 PM, a.grandi@gmail.com wrote:
> Hi all,
>
> I'd like to write an application that allows me to monitor the 3G data
> traffic on my N900.
> I've an option called "SuperInternet" with Tre Italy that gives you
> 100Mb/day Internet traffic.
>
> It's not easy to keep track of transfered data, so I'd like to write a
> desktop applet that monitor traffic and keep the amount updated.
> I'm going to write this in Qt/C++.
>
> I've some question before starting:
>
> 1) How can I detect, from a Qt/C++ application, if a 3G connection is
> estabilished and when it disconnects?
>
> 2) Is it ok if I monitor the trasmitted/received data using ifconfig?
> If yes, how can I execute ifconfig from an application running as
> user? (Usually you can only execute ifconfig if you "sudo gainroot"
> before).
>
> Thanks for your help!
>

You can use DBus to monitor 3G connection states, run dbus-monitor
--system in a shell to see the paths send, then you can just use QtDbus
to connect a signal to a function in your app.

I'm not sure if ifconfig is the right way (you might also be able to use
DBus, I see something about DataCounters in dbus-monitor too), but if
you find it good enough, you can run /sbin/ifconfig and use QProcess and
read standard output, the reason you can't run it as user is that /sbin
isn't in user's $PATH (at least not by default ;))

Regards,
Mohammad Abu-Garbeyyeh
  •  Reply

Re: Starting a 3G traffic monitoring application for N900: some questions

Harald Schmitt
Karma: 785
2010-11-29 15:02 UTC
Am 29.11.2010 15:14, schrieb Mohammad Abu-Garbeyyeh:
> Hi,
>
> On 11/29/2010 04:04 PM, a.grandi@gmail.com wrote:
>> Hi all,
>>
>> I'd like to write an application that allows me to monitor the 3G data
>> traffic on my N900.
>> I've an option called "SuperInternet" with Tre Italy that gives you
>> 100Mb/day Internet traffic.
>>
>> It's not easy to keep track of transfered data, so I'd like to write a
>> desktop applet that monitor traffic and keep the amount updated.
>> I'm going to write this in Qt/C++.
>>
>> I've some question before starting:
>>
>> 1) How can I detect, from a Qt/C++ application, if a 3G connection is
>> estabilished and when it disconnects?
>>
>> 2) Is it ok if I monitor the trasmitted/received data using ifconfig?
>> If yes, how can I execute ifconfig from an application running as
>> user? (Usually you can only execute ifconfig if you "sudo gainroot"
>> before).
>>
>> Thanks for your help!
>>
>
> You can use DBus to monitor 3G connection states, run dbus-monitor
> --system in a shell to see the paths send, then you can just use QtDbus
> to connect a signal to a function in your app.
>
> I'm not sure if ifconfig is the right way (you might also be able to use
> DBus, I see something about DataCounters in dbus-monitor too), but if
> you find it good enough, you can run /sbin/ifconfig and use QProcess and
> read standard output, the reason you can't run it as user is that /sbin
> isn't in user's $PATH (at least not by default ;))
>
> Regards,
> Mohammad Abu-Garbeyyeh

You can have a look at "Personal Dataplan Monitor"
http://maemo.org/packages/view/personal-gprs-mon/
and "Netstory".
http://maemo.org/packages/view/netstory/
Maybe they do what you want and you can combine the best of both.

Best regards,
Harald

  •  Reply

Re: Starting a 3G traffic monitoring application for N900: some questions

Andrea Grandi
Karma: 662
2010-12-02 15:43 UTC
Hi,

On 29 November 2010 15:14, Mohammad Abu-Garbeyyeh
<mohammad7410@gmail.com> wrote:
> You can use DBus to monitor 3G connection states, run dbus-monitor --system
> in a shell to see the paths send, then you can just use QtDbus to connect a
> signal to a function in your app.

I've tried your idea and I've saved a text file with dbus log. I think
this is the best way to monitor both connection, disconnection and
traffic.

I won't report the whole log, just a brief extract, but anyway I think
that the interesting part should be this one:

1) How to detect connection: this message appears once, when you have
estabilished a connection.

signal sender=:1.18 -> dest=(null destination) serial=15255
path=/com/nokia/csd/gprs/0; interface=com.nokia.csd.GPRS.Context;
member=Connected
string "tre.it"
string "IP"
string "gprs0"
string "1.87.169.88"
string "62.13.173.92"
string "62.13.173.93"

2) How to monitor traffic: this message appears every time there is a
traffic. The two uint64 are sent and received bytes.

signal sender=:1.18 -> dest=(null destination) serial=15266
path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS; member=Status
array [
dict entry(
object path "/com/nokia/csd/gprs/0"
struct {
string "tre.it"
string "IP"
string "gprs0"
string "1.87.169.88"
boolean true
uint64 10528
uint64 38281
}
)
]

3) How to detect disconnection:

signal sender=:1.18 -> dest=(null destination) serial=15319
path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS;
member=Suspended
uint32 3
string "Detached"


I've two more question now. Since I've never worked with dbus before,
is there any good example about a dbus "client" in Qt/C++?
Is there a way to "simulate" those messages, so I will be able to test
my application directly on my desktop, without having to build the
executable for N900 and test it on the device?

p.s: very last question... let me guess..... QtDbus is not available
on Qt for Symbian, right :) ?

--
Andrea Grandi - Nokia Qt Ambassador
Maemo Community Council member
website: http://www.andreagrandi.it
  •  Reply

Re: Starting a 3G traffic monitoring application for N900: some questions

Naresh Mehta
Karma: 68
2010-12-03 09:41 UTC
Check out the source for my conference manager at
https://garage.maemo.org/projects/confmgr/. It is written in QT. I
also have a class which abstracts the dbus implementation and allows
for methods to send and receive as well subscribe and unsubscribe to
dbus events.

BR; Naresh

On Thu, Dec 2, 2010 at 4:43 PM, a.grandi@gmail.com <a.grandi@gmail.com> wrote:
> Hi,
>
> On 29 November 2010 15:14, Mohammad Abu-Garbeyyeh
> <mohammad7410@gmail.com> wrote:
>> You can use DBus to monitor 3G connection states, run dbus-monitor --system
>> in a shell to see the paths send, then you can just use QtDbus to connect a
>> signal to a function in your app.
>
> I've tried your idea and I've saved a text file with dbus log. I think
> this is the best way to monitor both connection, disconnection and
> traffic.
>
> I won't report the whole log, just a brief extract, but anyway I think
> that the interesting part should be this one:
>
> 1) How to detect connection: this message appears once, when you have
> estabilished a connection.
>
> signal sender=:1.18 -> dest=(null destination) serial=15255
> path=/com/nokia/csd/gprs/0; interface=com.nokia.csd.GPRS.Context;
> member=Connected
>   string "tre.it"
>   string "IP"
>   string "gprs0"
>   string "1.87.169.88"
>   string "62.13.173.92"
>   string "62.13.173.93"
>
> 2) How to monitor traffic: this message appears every time there is a
> traffic. The two uint64 are sent and received bytes.
>
> signal sender=:1.18 -> dest=(null destination) serial=15266
> path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS; member=Status
>   array [
>      dict entry(
>         object path "/com/nokia/csd/gprs/0"
>         struct {
>            string "tre.it"
>            string "IP"
>            string "gprs0"
>            string "1.87.169.88"
>            boolean true
>            uint64 10528
>            uint64 38281
>         }
>      )
>   ]
>
> 3) How to detect disconnection:
>
> signal sender=:1.18 -> dest=(null destination) serial=15319
> path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS;
> member=Suspended
>   uint32 3
>   string "Detached"
>
>
> I've two more question now. Since I've never worked with dbus before,
> is there any good example about a dbus "client" in Qt/C++?
> Is there a way to "simulate" those messages, so I will be able to test
> my application directly on my desktop, without having to build the
> executable for N900 and test it on the device?
>
> p.s: very last question... let me guess..... QtDbus is not available
> on Qt for Symbian, right :) ?
>
> --
> Andrea Grandi - Nokia Qt Ambassador
> Maemo Community Council member
> website: http://www.andreagrandi.it
>



--

BR; Naresh

visit me at:
http://www.naresh.se/
  •  Reply

Re: Starting a 3G traffic monitoring application for N900: some questions

2010-12-03 15:07 UTC
Hey,

On Thu, Dec 2, 2010 at 5:43 PM, a.grandi@gmail.com <a.grandi@gmail.com>wrote:

> Hi,
>
> On 29 November 2010 15:14, Mohammad Abu-Garbeyyeh
> <mohammad7410@gmail.com> wrote:
> > You can use DBus to monitor 3G connection states, run dbus-monitor
> --system
> > in a shell to see the paths send, then you can just use QtDbus to connect
> a
> > signal to a function in your app.
>
> I've tried your idea and I've saved a text file with dbus log. I think
> this is the best way to monitor both connection, disconnection and
> traffic.
>
> I won't report the whole log, just a brief extract, but anyway I think
> that the interesting part should be this one:
>
> 1) How to detect connection: this message appears once, when you have
> estabilished a connection.
>
> signal sender=:1.18 -> dest=(null destination) serial=15255
> path=/com/nokia/csd/gprs/0; interface=com.nokia.csd.GPRS.Context;
> member=Connected
> string "tre.it"
> string "IP"
> string "gprs0"
> string "1.87.169.88"
> string "62.13.173.92"
> string "62.13.173.93"
>
> 2) How to monitor traffic: this message appears every time there is a
> traffic. The two uint64 are sent and received bytes.
>
> signal sender=:1.18 -> dest=(null destination) serial=15266
> path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS; member=Status
> array [
> dict entry(
> object path "/com/nokia/csd/gprs/0"
> struct {
> string "tre.it"
> string "IP"
> string "gprs0"
> string "1.87.169.88"
> boolean true
> uint64 10528
> uint64 38281
> }
> )
> ]
>
> 3) How to detect disconnection:
>
> signal sender=:1.18 -> dest=(null destination) serial=15319
> path=/com/nokia/csd/gprs; interface=com.nokia.csd.GPRS;
> member=Suspended
> uint32 3
> string "Detached"
>
>
> I've two more question now. Since I've never worked with dbus before,
> is there any good example about a dbus "client" in Qt/C++?
> Is there a way to "simulate" those messages, so I will be able to test
> my application directly on my desktop, without having to build the
> executable for N900 and test it on the device?
>
> p.s: very last question... let me guess..... QtDbus is not available
> on Qt for Symbian, right :) ?
>
> --
> Andrea Grandi - Nokia Qt Ambassador
> Maemo Community Council member
> website: http://www.andreagrandi.it
>

DBus in Qt is actually very simple to use, have a look at
http://doc.trolltech.com/qq/qq20-dbus.html
It's basically the same as QObject::connect but with DBus :)
Also check keyboard-leds, it uses DBus to detect keyboard slides.

I'm not sure about DBus on Symbian, BUT, I have seen DBus related files
in Symbian^3's Z: drive (Z:\data\dbus iirc), apparently, Symbian adopted
DBus (not sure if it works the same since there isn't any shell on the N8.

Regards,
Mohammad Abu-Garbeyyeh

  •  Reply