Netstat (Compact 7)

3/12/2014

The netstat command-line tool displays active TCP/IP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IPv4, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols).

Syntax

netstat [-?] [-e] [-n] [-p proto] [-s] [-r] [-d] [interval]

Options

The following table shows the options for this command-line tool. These options are not case-sensitive.

Option Option Description

-?

Displays information about available netstat options.

-e

Displays Ethernet statistics, such as the number of bytes and packets sent and received over the Ethernet connection.

-n

Displays IP addresses and port numbers in numerical form.

-p

proto

Shows connections for the protocol specified by proto; proto may be any one of: TCP, UDP, TCPv6, or UDPv6. If you use -p with the -s option to display per-protocol statistics, you have more protocol options. In this case, proto may be any of: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6. When you specify IP, netstat displays IPv4 statistics.

-s

Displays per-protocol statistics. By default, statistics are shown for IPv4, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6.

-r

Displays the contents of the IP routing table.

-d

Prints output to the debug output port. If your device is connected to Platform Builder, netstat prints to the Output window in Visual Studio.

interval

Redisplays selected statistics, pausing for the number of seconds specified by interval between each display. Press CTRL+C to stop redisplaying statistics. If interval is omitted, netstat will print the current configuration information once.

Remarks

When you use the netstat command-line tool, you can prefix command options with a hyphen (-) or a slash (/).

The following table shows the items for which netstat provides statistics.

Item Description

Proto

The name of the protocol (IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6).

Local Address

The IP address of the local computer and the port number being used. The name of the local computer that corresponds to the IP address and the name of the port is shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*).

Foreign Address

The IP address and port number of the remote computer to which the socket is connected. The names that correspond to the IP address and the port are shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*).

(state)

Indicates the state of a TCP connection. The possible states are shown in the following table.

State Explanation
CLOSEDThe connection is closed.
LISTENWaiting for a connection request from any remote client and port.
SYN_RCVDWaiting for a confirming connection request acknowledgement after having both received and sent a connection request.
SYN_SENTWaiting for a matching connection request after having sent a connection request.
ESTABAn open connection is established. Data can be transferred over the connection.
FIN_WAIT1Waiting for a connection termination request from the remote side of the connection, or an acknowledgement of a connection request previously sent.
CLOSE_WAITWaiting for a connection termination request from the local application.
LAST_ACKWaiting for an acknowledgement of a connection termination request previously sent to the remote side of the connection.
TIME_WAITWaiting for enough time to pass to be certain that the remote side of a closing connection received acknowledgement of the connection termination request.

For more information about the states of a TCP connection, see RFC 793.

Example

The following example shows how to display the statistics for only the TCP protocol.

netstat -s -p tcp

The following example shows typical output when displaying only TCP protocol statistics.

TCP Statistics:
--------------
Active Opens            = 0
Passive Opens           = 0
Connect Attempt Fails   = 0
Reset Connections       = 0
Current Connections     = 0
Segments Received       = 0
Segments Sent           = 0
Segments Retransmitted  = 0
Errors Received         = 0
Sgmnts sent w/Reset Flag= 0
Cumulative Connections  = 0
Time-Out Algorithm      = 3
Time-Out Minimim        = 10
Time-Out Maximum        = 4294967295
Maximum Connections     = Dynamic (-1)

The following example shows how to display both the Ethernet statistics and the statistics for all protocols.

netstat -e -s

The following example shows the extensive output that results when you display Ethernet statistics and the statistics for all protocols.

     Interface Statistics   Received       Sent
                    Bytes   14424777      60974
          Unicast Packets        144        128
       NonUnicast Packets      51538         51
                 Discards          0          0
                   Errors          0          0
        Unknown Protocols          0 
 Name                  ={76946ED2-F4A7-D370-0742-06FEABB6FF7A}
 Index                 =2 
 Physical Addrress     =0003FFA7CA8E 
 Description           =VMINI1
 Type                  =6
 Mtu                   =1500
 Speed - bps           =1000000 
 Administrative Status =1 
 Oprerational Status   =5
 Output Queue Length   =0 

     Interface Statistics   Received       Sent
                    Bytes          0          0
          Unicast Packets          0          0
       NonUnicast Packets          0          0
                 Discards          0          0
                   Errors          0          0
        Unknown Protocols          0 
 Name                  ={7C4BDF55-A009-944A-7AC5-87693C30AA3A}
 Index                 =3 
 Physical Addrress     =204153594EFF 
 Description           =ASYNCMAC1
 Type                  =23
 Mtu                   =1502
 Speed - bps           =1073741824 
 Administrative Status =1 
 Oprerational Status   =5
 Output Queue Length   =0 

     Interface Statistics   Received       Sent
                    Bytes          0          0
          Unicast Packets          0          0
       NonUnicast Packets          0          0
                 Discards          0          0
                   Errors          0          0
        Unknown Protocols          0 
 Name                  ={5620A97A-F797-995A-4E4A-F8FE7908BADE}
 Index                 =4 
 Physical Addrress     =505054503030 
 Description           =PPTP1
 Type                  =23
 Mtu                   =0
 Speed - bps           =1073741824 
 Administrative Status =1 
 Oprerational Status   =5
 Output Queue Length   =0 

TCP6 Statistics:
--------------
Active Opens            = 0
Passive Opens           = 0
Connect Attempt Fails   = 0
Reset Connections       = 0
Current Connections     = 0
Segments Received       = 0
Segments Sent           = 0
Segments Retransmitted  = 0
Errors Received         = 0
Sgmnts sent w/Reset Flag= 0
Cumulative Connections  = 0
Time-Out Algorithm      = 3
Time-Out Minimim        = 10
Time-Out Maximum        = 4294967295
Maximum Connections     = Dynamic (-1)

TCP Statistics:
--------------
Active Opens            = 0
Passive Opens           = 0
Connect Attempt Fails   = 0
Reset Connections       = 0
Current Connections     = 0
Segments Received       = 0
Segments Sent           = 0
Segments Retransmitted  = 0
Errors Received         = 0
Sgmnts sent w/Reset Flag= 0
Cumulative Connections  = 0
Time-Out Algorithm      = 3
Time-Out Minimim        = 10
Time-Out Maximum        = 4294967295
Maximum Connections     = Dynamic (-1)

UDP6 Statistics:
--------------
Datagrams Received  = 0
No Ports            = 0
Receive Errors      = 0
Datagrams Sent      = 24
Number UDP entries  = 1

UDP Statistics:
--------------
Datagrams Received  = 4701
No Ports            = 17092
Receive Errors      = 0
Datagrams Sent      = 2
Number UDP entries  = 2

IP6 Statistics:
--------------
Packets Received            = 39
Received Header Errors      = 0
Received Address Errors     = 0
Datagrams Forwarded         = 0
Unknown Protocols Received  = 0
Received Packets Discarded  = 0
Received Packets Delivered  = 39
Output Requests             = 30
Routing Discards            = 0
Discarded Output Packets    = 0
Output Packet No Route      = 0
Reassembly Required         = 0
Reassembly Successful       = 0
Reassembly Failures         = 0
Datagrams Fragmented OK     = 0
Datagrams Fragmented Fail   = 0
Fragments Created           = 0
DefaultTTL                  = 128
Datagrams All Frgs Not Rcvd = 60
Number of Interfaces        = 2
Number of Addresses         = 6
Number of Routes in Table   = 4
Forwarding Enabled          = 2

IP Statistics:
--------------
Packets Received            = 38694
Received Header Errors      = 0
Received Address Errors     = 16871
Datagrams Forwarded         = 0
Unknown Protocols Received  = 0
Received Packets Discarded  = 17092
Received Packets Delivered  = 4843
Output Requests             = 130
Routing Discards            = 0
Discarded Output Packets    = 0
Output Packet No Route      = 0
Reassembly Required         = 0
Reassembly Successful       = 0
Reassembly Failures         = 0
Datagrams Fragmented OK     = 0
Datagrams Fragmented Fail   = 0
Fragments Created           = 0
DefaultTTL                  = 128
Datagrams All Frgs Not Rcvd = 60
Number of Interfaces        = 2
Number of Addresses         = 8
Number of Routes in Table   = 9
Forwarding Enabled          = 2

         ICMP6 Statistics   Received       Sent
          ---------------     ------     ------
                 Messages         39          4
                   Errors          0          0
  Destination Unreachable          0          0
           Packet Too Big          0          0
            Time Exceeded          0          0
            Param Problem          0          0
             Echo Request          0          0
               Echo Reply          0          0
         Membership Query          0          0
        Membership report          0          0
     Membership reduction          0          0
      Router Solicitation          0          3
      Router Advertisment         36          0
    Neighbor Solicitation          0          1
    Neighbor Advertisment          3          0
                 Redirect          0          0

          ICMP Statistics   Received       Sent
          ---------------     ------     ------
                 Messages          0        128
                   Errors          0          0
  Destination Unreachable          0        128
            Time Exceeded          0          0
        Parmeter Problems          0          0
          Source Quenches          0          0
                Redirects          0          0
                    Echos          0          0
             Echo Replies          0          0
               Timestamps          0          0
        Timestamp Replies          0          0
            Address Masks          0          0
     Address Mask Replies          0          0

See Also

Reference

Network Command-Line Tools Reference