Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / MFC
Article

TrafficWatcher

Rate me:
Please Sign up or sign in to vote.
3.62/5 (24 votes)
15 Nov 2002CPOL2 min read 485.6K   18.7K   153   160
A tool to measure network traffic by service (FTP, mail, news, web, UDP etc)

Sample Image

Description

TrafficWatch is a small utility to get information about the amount of data transferred to and from the internet. It uses the WinPcap library from http://winpcap.polito.it/docs/default.htm. Network traffic inside a LAN is ignored - only IP packets going through the standard gateway are measured. Traffic is also measured by service: FTP, mail, news, web, UDP and others. So you can see for what you need your internet connection.

Why?

Flat rates are getting more common these days. ISPs often offer them only up to a specified amount of traffic - additional transferred data must be paid extra. So I wanted to know exactly how much traffic I use/need to decide which ISP and which offer I wanted. And of course I'm curious :)

Sample Image

Implementation

To gather only the internet traffic and ignore traffic inside LAN I needed a way to analyse every IP data packet entering or leaving the network interface. The WinPcap library is used to catch all these packets. Then the program analyses the captured packets by source and destination IP and port. With these data the program builds the statistics.

Other tools

There are other tools in this utility: Ping, Traceroute, Connection Information and Whois. The Whois-utility uses a text file to determine which server to ask for specific TLD's. The one offered with this utility is far from complete. If someone wants to complete it, please send me a copy!

Installation

An installer is provided. If you don't have WinPcap already installed, you must either download it from http://winpcap.polito.it/docs/default.htm or let the installer install it for you. After installation you should maybe restart your computer to proper initialize the WinPcap drivers - otherwise the program may crash.

Notes

For this tool I used many classes and tips from this website. Some of them are unchanged, some of them I changed a little or more. This tool is also kind of a try out project for me - whenever I want to try out some API's or functions I add them to this tool. An example of that you can see in the "About" pane. So please don't blame me if some things are not perfectly coded.

Update

16.11.02 fixed several bugs where the prog crashed on startup (I hope :). Also the statistics page now shows a red line in the bars to separate up from downloads.

22.6.02 corrected a bug where the statistics weren't correctly cleaned up. Fixed a bug where the program crashed when more than 10 adapters were found. Also fixed missing files in source.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Switzerland Switzerland
---

Comments and Discussions

 
QuestionComplier Errors? Pin
Kant19-Nov-02 11:29
Kant19-Nov-02 11:29 
AnswerRe: Complier Errors? Pin
gabmurillo19-Nov-02 13:01
gabmurillo19-Nov-02 13:01 
GeneralRe: Complier Errors? Pin
Kant19-Nov-02 15:29
Kant19-Nov-02 15:29 
GeneralRe: Complier Errors? Pin
gabmurillo19-Nov-02 19:09
gabmurillo19-Nov-02 19:09 
AnswerRe: Complier Errors? Pin
Member 7976103-Mar-05 1:59
Member 7976103-Mar-05 1:59 
GeneralDoes this work for anyone Pin
gabmurillo19-Nov-02 10:13
gabmurillo19-Nov-02 10:13 
GeneralRe: Didn't worked for me on my Laptop Pin
Kant19-Nov-02 10:53
Kant19-Nov-02 10:53 
GeneralRe: Does this work for anyone Pin
Peter Sjöström26-Nov-02 3:10
Peter Sjöström26-Nov-02 3:10 
Nope, Windows XP Pro patched to latest stuff, same problem as last time I tried this demo software. Starts in Systray, but on Open it crashes. View opens a window without border in the top left with two numbers slanted down to up.
GeneralRe: Does this work for anyone Pin
SteveKing26-Nov-02 5:14
SteveKing26-Nov-02 5:14 
GeneralRe: Does this work for anyone Pin
Peter Sjöström26-Nov-02 12:47
Peter Sjöström26-Nov-02 12:47 
GeneralRe: Does this work for anyone Pin
SteveKing27-Nov-02 8:32
SteveKing27-Nov-02 8:32 
GeneralRe: Does this work for anyone Pin
Peter Sjöström27-Nov-02 14:12
Peter Sjöström27-Nov-02 14:12 
Generalcan't find file iphlpapi.h Pin
guard200217-Nov-02 17:40
guard200217-Nov-02 17:40 
GeneralRe: can't find file iphlpapi.h Pin
tyounsi18-Nov-02 4:16
tyounsi18-Nov-02 4:16 
GeneralProblem with two adapters Pin
Neville Franks17-Nov-02 10:00
Neville Franks17-Nov-02 10:00 
GeneralRe: Problem with two adapters Pin
SteveKing18-Nov-02 8:34
SteveKing18-Nov-02 8:34 
Generalcould not open Adapter in CPacket::Open() Pin
TaknuMone17-Nov-02 8:25
TaknuMone17-Nov-02 8:25 
GeneralRe: could not open Adapter in CPacket::Open() Pin
Shedon25-Feb-05 0:56
Shedon25-Feb-05 0:56 
GeneralRe: could not open Adapter in CPacket::Open() Pin
Alexandru Matei15-Jan-06 21:27
Alexandru Matei15-Jan-06 21:27 
GeneralAwesome tool Pin
Hans J. Schroeder29-Oct-02 9:24
Hans J. Schroeder29-Oct-02 9:24 
GeneralI think, I found the bug Pin
Hans J. Schroeder29-Oct-02 8:47
Hans J. Schroeder29-Oct-02 8:47 
GeneralStill crashes Pin
Rubio6-Nov-02 3:10
Rubio6-Nov-02 3:10 
GeneralRe: Still crashes Pin
SteveKing13-Nov-02 4:08
SteveKing13-Nov-02 4:08 
GeneralNo *.dsp nor *.dsw !! Pin
Anthony_Yio20-Oct-02 16:41
Anthony_Yio20-Oct-02 16:41 
GeneralRe: No *.dsp nor *.dsw !! Pin
Daniel Ferguson22-Oct-02 5:30
Daniel Ferguson22-Oct-02 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.