NetStatTool Technology Sample
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
This sample demonstrates NetStatTool, which is a tool that displays statistical information about network traffic. Depending on the arguments supplied at the command line, NetStatTool collects and displays information about network connections, listening ports, and packets sent and received by the local computer. The tool uses classes in the System.Net and System.Net.NetworkInformation namespaces to gather and display information about network protocols and current TCP/IP network connections.
The following describes the command line options of NetStatTool:
NETSTATTOOL [-?] [-a] [-e] [-n] [-s] [-p protocol] [interval]
(default) Displays open connection information.
-? Displays this help message.
-e Displays NIC statistics. May be combined with -s.
-s Displays per-protocol statistics. By default, statistics are shown for TCP. The -p and -a options may be used to specify other protocols to display.
-p protocol Display information for the protocol specified. May be any of: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6TCP. Connections can only be shown for TCP, UDP, TCPv6, or UDPv6.
-a Display information for all protocols.
-n Displays addresses and port numbers in numerical form.
Interval Redisplays selected statistics, pausing interval seconds between each display. Press CTRL+C to stop.
For information about using the samples, see the following topics:
Introduces developers to the NetStatTool network information tool.
To build the sample using the Command Prompt
Navigate to the language subdirectory (CS or VB) of the NetworkInformation\NetStatTool directory, using the command prompt. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.
Type msbuild.exe NetStatTool<lang>.sln at the command line, where <lang> is either CS or VB.
To build the sample using Visual Studio
Open Windows Explorer and navigate to the language subdirectory (CS or VB) of the NetworkInformation\NetStatTool directory.
Double-click the icon for the NetStat<Lang>.sln file to open the file in Visual Studio, where <lang> is either CS or VB.
In the Build menu, click Build Solution. The NetStatTool.exe application is created in the Bin\Debug subdirectory.
To run the sample
In the Command Prompt window, navigate to the directory that contains the built executable file.
Type NetStatTool.exe at the command line, with optional arguments, using the syntax described in the Remarks section.
The NetStatTool sample is a console application. You must launch and run it in a Command Prompt window to view its output.