Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 2005

TCPView and TCPVCon

Get past Netstat’s limitations
RSS
Subscribe to Windows IT Pro | See More Products / Software Articles Here | Reprints
Or get the Monthly Online Pass—only $5.95 a month!

As a Windows administrator, you often need to monitor active TCP/IP ports to determine which network application server ports are active, ensure that ports aren't open unexpectedly, and find out which remote systems a computer is accessing. You can use Windows' built-in Netstat tool to obtain such information, but Netstat has several limitations. The version that comes with Windows 2000 and earlier doesn't report the process associated with an endpoint; the version that comes with Windows Server 2003 and Windows XP shows the owning process's process identifier (PID) but not the process's image name. These limitations make it difficult to determine which process owns an open network port. Furthermore, Netstat doesn't provide a convenient way to see changes in TCP/IP port use.

Sysinternals' TCPView—a free GUI application that runs on Windows NT 4.0 and later—displays a superset of the information that Netstat shows and gives you an easy way to monitor changes to port use over time. You can download TCPView and its command-line equivalent, TCPVCon, at http://www.sysinternals.com.

Endpoint Basics
When you run Netstat without any command-line arguments, it prints a list of TCP endpoints that are in a connected state, along with each connection's locally bound IP address and the IP address of the connection's remote side. (Because TCP is a connection-oriented protocol, TCP communication requires both sides of a data exchange to establish a connection for the duration of the exchange.)

Netstat's -a option lists all active TCP and UDP endpoints, including TCP endpoints in other states such as LISTENING (waiting for a connection) and TIME_WAIT (closed). UDP is a connectionless protocol, so UDP messages can be sent from a UDP endpoint to any remote IP address. Therefore, UDP endpoints have no state and no concept of a statically bound remote IP address.

The version of Netstat that ships with Windows 2003 and XP offers the -o option, which prints the PID of the process that opened each endpoint. However, when you use the -o option, you must use another tool, such as Task Manager, to map the PID to an image name.

XP Service Pack 2 (SP2) introduced another new Netstat switch—the -b switch—which will also be supported in Windows 2003 SP1. This switch displays the owning image name below an endpoint's output line. For endpoints opened by a svchost.exe or rundll.exe process, this switch also display the names of the DLLs that were on the stack of the thread that opened the endpoint. (Note that Netstat Help text refers to DLLs as components.) Because Svchost is a host process that loads Windows services that are implemented in DLLs, and Rundll32 is the Control Panel host process for Control Panel DLL plug-ins, DLL information can help you identify which service or Control Panel applet opened an endpoint. Unfortunately, a flaw in the way that Netstat examines stack data slows down its output so much that the -b switch is all but unusable.

TCPView
TCPView, which Figure 1 shows, displays all the basic endpoint information that Netstat does. But take a look at the Process column, which displays the icon, name, and PID of the process that owns each endpoint.

For cases in which an image name is ambiguous, TCPView offers more information about the process. To view this information, double-click an endpoint owned by the process, or select the endpoint and choose Process Properties from the Process menu to access the process's Properties dialog box, which Figure 2 shows. This dialog box displays the full path to the process image file, the command that was used to launch the process, and several pieces of information that TCPView pulls from the image's version data (if available): the image's description, vendor name, and version number.

To translate a DNS name (e.g., www.winntmag.com:http) to its underlying IP address and port number, simply press Ctrl+R, click the tool's address-translation toolbar button, or select Resolve Addresses from the Options menu. TCPView will switch to a numeric view for all addresses; you can use the same methods to toggle back to name resolution.

If you leave TCPView running, you might notice endpoint rows temporarily highlighted in red, green, or yellow. The tool uses these colors to call your attention to changes that occur. Newly opened endpoints will be highlighted in green, endpoints that have been closed will be highlighted in red, and TCP endpoints that have changed state will be highlighted in yellow. These colors remain in place for three refreshes of the display. TCPView's default refresh interval is 1 second, but you can change that interval or pause the refresh altogether by using the View, Update Speed option.

You can also use the tool to close an application's established TCP connection. To do so, select the connection's row and select File, Close Connections; alternately, you can right-click an entry and choose Close Connections from the context menu.

TCPVCon
TCPVCon is the command-line version of TCPView. Like Netstat, TCPVCon simply displays connected TCP endpoints when you run it without specifying any command-line arguments, or it displays all endpoints when you include the -a option. But unlike Netstat, TCPVCon formats its output in a standard 80-column command-prompt window, as Figure 3 shows, for easy reading. Another difference between Netstat and TCPVCon is that TCPVCon always prints the full path and PID of each endpoint's process, rather than just the image name. If you're interested in the TCP/IP endpoints of a particular process, you can specify the process name or PID on the TCPVCon command-line and the tool will dump the endpoints for that process only. You can use the tool's -c switch to produce output in comma-separated value (CSV) format. This capability lets you use TCPVCon as a simple auditing tool to generate data for storage in a database that you can query later.

Inside the Tools
When you use TCPView and TCPVCon on Windows 2003 or XP, the tools use undocumented functions (introduced in XP) to obtain TCP/IP endpoint information, including the PID of the process that opened each endpoint. The tools also use documented process-enumeration functions to obtain a list of processes so that they can convert PIDs to process names. To obtain detailed information about a process, you must run the tools from an account that has the Debug programs privilege.

In Win2K and NT, the tools rely on undocumented interfaces to query endpoint information. Because these earlier interfaces don't supply PID information, the tools use an embedded device driver that they install upon startup to map endpoints to processes. Therefore, to use the tools on Win2K or NT, the account must have both the Debug programs and Load drivers privileges.

A Clearer View
If you're tired of Netstat's limitations, TCPView and TCPVCon can be useful additions to your systems-administration toolkit. The tools' ability to show process image names and information, close connections, and highlight changes will save you time and give you a clearer view of your system's network use.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

How can I uninstall the Microsoft Java Virtual Machine (JVM) from Windows XP?

...

What service packs and fixes are available?

...


Windows OSs Whitepapers Replay for Exchange: Enterprise Protection and an Affordable Price

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Disaster Recovery and Backup

A Guide to Windows Certification and Public Keys

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing