This project is read-only.

How to Monitor bytesReceived and bytesTransmitted

Aug 13, 2009 at 10:07 AM


I've developed an application that interfaces with a mobile operator via a USB GSM/3G modem, to check usage information. As an added feature the application shows connection statistics to the user. This being Time Connected, Bytes Received and Bytes Transmitted(which is updated every 100 milliseconds).

So, what i am trying to do next is to basically monitor the bytesReceived and bytesSent, and showing a picture for each one respectively(think of the 2 computers that pop-up in the taskbar when connect to the internet, which lights up when theres activity and goes back to normal when theres none).

So far i've managed to determine wether there are Bytes being Received and Bytes being Sent, but...

How do i determine wether the Bytes being Received have stopped and the Bytes being Sent have stopped?

Aug 13, 2009 at 2:43 PM

I would think if the number hasn't changed from the last time you polled that would be a good indication that the data being sent/received has stopped.

The GetConnectionStatistics method will return information regarding the connection. If you need information about a specific link in a multi-link connection, use GetLinkStatistics.

Aug 14, 2009 at 8:00 AM

Thanks Jeff

It does the trick.

For anyone else trying to/wanting to do the same, this is what i did:

    Public Sub CheckForActivity(ByVal [bytesIncoming] As Integer, ByVal [bytesOutgoing] As Integer)
        If [bytesIncoming] > biggerBytesI And [bytesOutgoing] > biggerBytesO Then
            biggerBytesI = [bytesIncoming]
            biggerBytesO = [bytesOutgoing]
            '<Icon for Incoming and Outgoing Bytes>
        ElseIf [bytesIncoming] > biggerBytesI And [bytesOutgoing] = biggerBytesO Then
            biggerBytesI = [bytesIncoming]
            '<Icon here for Incoming Bytes>
        ElseIf [bytesIncoming] = biggerBytesI And [bytesOutgoing] > biggerBytesO Then
            biggerBytesO = [bytesOutgoing]
            '<Icon here for Outgoing Bytes>
        ElseIf [bytesIncoming] = biggerBytesI And [bytesOutgoing] = biggerBytesO Then
            '<Icon here for No Activity>
        End If
    End Sub

Then in another Sub(say called 'CheckConnectionStatus') you call CheckForActivity and pass statistics.bytesReceived and statistics.bytesTransmitted to it.

Then to end things off, put the CheckConnectionStatus Sub in a timer.tick event with an interval of say 500 milliseconds.

Dec 1, 2010 at 3:06 AM

If you are using usb 3G modem, it has the built in features of monitoring the network statistics.
Just read about this

^DSFLOWRPT: N1, N2, N3, N4, N5, N6, N7

Its an event from usb modem. that was trigger if modem is connected to net.
Dec 1, 2010 at 3:06 AM
Edited Dec 2, 2010 at 5:39 AM

Out of topic.. :(

Dec 1, 2010 at 8:27 AM

Why would you want to make your application device specific if you don't have to? The built-in features provided by the RAS SDK mean it will work no matter what kind of device you're using. I'd appreciate it if you keep the posts limited to things dealing with DotRas, all you're going to do is confuse people rather than using the functionality included with the product. Your code will require a USB 3G modem, using DotRas to retrieve the information from Windows will not.

Dec 2, 2010 at 5:35 AM
Edited Dec 2, 2010 at 5:36 AM

Hi jeff, sorry for my last post.. that's really so very product specific idea. My apologize to you jeff..You can delete my post sir. Its really confusing..
@Gaanty. my post is just another idea where you can find net statistics of your product using,
Anyway... I'm in the middle now of reading with jeff DotRAS, and I'm so amaze...really great help.. We all know that RAS is available only in C++ in MSDN site.
This project is really a big help to other dev. And also to a beginner to .net like me :)




Dec 2, 2010 at 5:43 AM

I'm glad the project is helping, makes the 2 years I've spent working on it worthwhile.

Happy coding!