G
Giuseppe.Zarbo
Hi,
1 years ago I wrote a service that monitor the gprs traffic on a
smartphone and on pocket pc WM5.
The service first of all check if the connection is Gprs type and
after store the amount of traffic generated.
To check if the device is connected in GPRS mode here is the code:
bool isConnected = false;
RASCONN rgrc[4];
DWORD dwSize = sizeof(rgrc);
DWORD dwConn = 0;
rgrc[0].dwSize = sizeof(RASCONN);
if (!RasEnumConnections(rgrc, &dwSize, &dwConn)) {
RASENTRY rasEntry;
rasEntry.dwSize = sizeof(RASENTRY);
DWORD i;
for (i=0; i<dwConn; i++){
if(!RasGetEntryProperties(NULL, rgrc.szEntryName, &rasEntry,
&rasEntry.dwSize, NULL, NULL)){
if(wcsstr(rasEntry.szLocalPhoneNumber, L"~GPRS!") !
= NULL){
isConnected = true;
break;
}
}
else{
//Debug(_T("Error RasGetEntryProperties"));
}
}
}
else{
//Debug(_T("Error RasEnumConnections"));
}
DeleteObject(rgrc);
return isConnected;
To check the amount of traffic:
IPAddr dwDestAddr = inet_addr("207.46.19.60");
DWORD dwBestIfIndex = -1;
DWORD dwRes = GetBestInterface(dwDestAddr, &dwBestIfIndex);
MIB_IFROW IfRow;
IfRow.dwIndex = dwBestIfIndex;
dwRes = GetIfEntry(&IfRow);
if(dwRes == NO_ERROR){
DWORD dwTotal = IfRow.dwInOctets + IfRow.dwOutOctets;
return dwTotal;
}
else{
return 0;
}
I don't know if there is a better mode, but with GPRS connection this
works fine.
Now I have a problem with EDGE connection.
I try the same software with the Smartphone HTC S620 and the service
store the right traffic, instead with anothere HTC device, Pocket PC
P3600 the service store more traffic, for example 90 Mb in 2 o 3 days.
This is very strange.
Did anyone try to monitor edge traffic?
Thanks a lot
Giuseppe
1 years ago I wrote a service that monitor the gprs traffic on a
smartphone and on pocket pc WM5.
The service first of all check if the connection is Gprs type and
after store the amount of traffic generated.
To check if the device is connected in GPRS mode here is the code:
bool isConnected = false;
RASCONN rgrc[4];
DWORD dwSize = sizeof(rgrc);
DWORD dwConn = 0;
rgrc[0].dwSize = sizeof(RASCONN);
if (!RasEnumConnections(rgrc, &dwSize, &dwConn)) {
RASENTRY rasEntry;
rasEntry.dwSize = sizeof(RASENTRY);
DWORD i;
for (i=0; i<dwConn; i++){
if(!RasGetEntryProperties(NULL, rgrc.szEntryName, &rasEntry,
&rasEntry.dwSize, NULL, NULL)){
if(wcsstr(rasEntry.szLocalPhoneNumber, L"~GPRS!") !
= NULL){
isConnected = true;
break;
}
}
else{
//Debug(_T("Error RasGetEntryProperties"));
}
}
}
else{
//Debug(_T("Error RasEnumConnections"));
}
DeleteObject(rgrc);
return isConnected;
To check the amount of traffic:
IPAddr dwDestAddr = inet_addr("207.46.19.60");
DWORD dwBestIfIndex = -1;
DWORD dwRes = GetBestInterface(dwDestAddr, &dwBestIfIndex);
MIB_IFROW IfRow;
IfRow.dwIndex = dwBestIfIndex;
dwRes = GetIfEntry(&IfRow);
if(dwRes == NO_ERROR){
DWORD dwTotal = IfRow.dwInOctets + IfRow.dwOutOctets;
return dwTotal;
}
else{
return 0;
}
I don't know if there is a better mode, but with GPRS connection this
works fine.
Now I have a problem with EDGE connection.
I try the same software with the Smartphone HTC S620 and the service
store the right traffic, instead with anothere HTC device, Pocket PC
P3600 the service store more traffic, for example 90 Mb in 2 o 3 days.
This is very strange.
Did anyone try to monitor edge traffic?
Thanks a lot
Giuseppe