5,276,406 members and growing! (17,219 online)
Email Password   helpLost your password?
Web Development » Internet / Network » General     Intermediate License: The Code Project Open License (CPOL)

Applications Traffic Watcher

By Warlib

Applications Traffic Watcher is a small utility to get information about the amount of data transferred to and from the Internet.
Windows, Visual Studio, Dev

Posted: 28 Jun 2006
Updated: 17 Jul 2006
Views: 30,083
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
14 votes for this Article.
Popularity: 5.25 Rating: 4.58 out of 5
0 votes, 0.0%
1
2 votes, 14.3%
2
0 votes, 0.0%
3
4 votes, 28.6%
4
8 votes, 57.1%
5
Sample Image - apptraffwatcher.gif - Click to enlarge image

Introduction

Applications Traffic Watcher (ATW) is a small utility to get information about the amount of data transferred to and from the Internet. It uses the WinPcap library from here.

Network traffic inside a LAN is calculated, but ignored when calculating costs. So, you can see which applications are consuming traffic. ATW is very useful in understanding how much traffic is consumed by Skype, Gizmo etc.

Main Idea

The idea of the application is quite simple:

  1. Application Traffic Watcher constantly gets packets from WinPCap.
  2. It tries to associate packets with process ID using packet's information about local address and port and also information about all active connections, using the functions GetExtendedTcpTable or GetExtendedUdpTable.
  3. If the application cannot associate the packet with its corresponding process ID, add this packet to a "virtual" application named "Unknown_" and local port number. Unfortunately, sometimes it cannot associate a packet with a process (see "Problems" section of the article).
  4. ATW determines that either the packet belongs to a local network or to the Internet using lib IPNumber (Read this article).

Installation

There is no installation required if WinPcap is already installed. Just run the *.exe file. Otherwise you must download WinPCap from here and install it. After installation, you should maybe restart your computer to properly initialize the WinPcap drivers - otherwise the program may crash.

Problems

As you can see in the screen shot, there are a lot of processes specified as "Unknown_". Unfortunately, I couldn't find any way to determine which application sends/receives packets. Packets couldn't be identified when Internet Explorer/Firefox etc. download some Web pages. They create a lot of connections on different local ports with unknown PIDs (I couldn't associate the connection which I get from GetExtendedTcpTable and packet which I get from WinPCap). So, if you can help to resolve this problem, you are welcome to do so.

Another big problem - sometimes ATW consumes a lot of CPU resources and I couldn't minimize it for now.

References

  1. SharpPcap - A Packet Capture Framework for .NET
  2. IP list, Check an IP Number against a List in C#
  3. Getting Active TCP/UDP Connections on a Box
  4. Getting Active TCP/UDP Connections using GetExtendedTcpTable Function
  5. TrafficWatcher

Tools

To understand how Microsoft does some things and for code optimization, I used the following tools:

  1. Reflector for .NET
  2. Interactive Disassembler (IDA)
  3. ANTS
  4. Sysinternals tools
  5. Microsoft Netstat

License

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

About the Author

Warlib


I am a CIO in Nizhny Novgorod, Russia.
Occupation: Web Developer
Location: Russian Federation Russian Federation

Other popular Internet / Network articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 17 of 17 (Total in Forum: 17) (Refresh)FirstPrevNext
Subject  Author Date 
QuestionatwmemberJan Stetka13:04 11 Apr '08  
GeneralFull ProjectmemberM.A.B.3:48 30 Jul '07  
GeneralCannot stop monitoring and cannot close the applicationmemberNonthanut22:53 24 Apr '07  
GeneralDoes not run on x64 windowsmembermanfbraun13:32 8 Apr '07  
GeneralRe: Does not run on x64 windowsmemberWarlib21:02 8 Apr '07  
GeneralRe: Does not run on x64 windowsmembermanfbraun23:39 8 Apr '07  
GeneralWrong IPNumbers VersionmemberKevinI596:37 30 Jul '06  
GeneralRe: Wrong IPNumbers VersionmemberWarlib9:04 30 Jul '06  
Generalmissing projects in zip filesmemberDavid Every17:30 10 Jul '06  
GeneralRe: missing projects in zip files [modified]memberWarlib20:18 10 Jul '06  
GeneralRe: missing projects in zip filesmemberchakkaradeepcc19:38 27 Sep '06  
GeneralRe: missing projects in zip filesmemberWarlib20:03 27 Sep '06  
GeneralRe: missing projects in zip filesmemberchakkaradeepcc21:50 27 Sep '06  
GeneralRe: missing projects in zip filesmemberWarlib21:58 27 Sep '06  
GeneralRe: missing projects in zip filesmemberchakkaradeepcc22:36 27 Sep '06  
GeneralRe: missing projects in zip filesmemberWarlib22:51 27 Sep '06  
GeneralRe: missing projects in zip filesmemberTefo4:13 25 Jul '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Jul 2006
Editor: Deeksha Shenoy
Copyright 2006 by Warlib
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project