How Do I Display Summary Statistics For Each Protocol On Linux ?

by lifeLinux on January 31, 2012

Q. How do I display summary statistics for each protocol on Linux ?
A. Using netstat command to display summary statistics for each protocol.

netstat command

netstat (network statistics) is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics. It is available on Unix, Unix-like, and Windows NT-based operating systems.

Display summary statistics using netstat

Simply use netstat -s

# netstat -s

Ouput

Ip:
    927340778 total packets received
    7 with invalid headers
    1959 with invalid addresses
    0 forwarded
    0 incoming packets discarded
    922379597 incoming packets delivered
    1280879573 requests sent out
    27 outgoing packets dropped
    4 fragments dropped after timeout
    757 reassemblies required
    354 packets reassembled ok
    4 packet reassembles failed
    20 fragments failed
Icmp:
    36541 ICMP messages received
    124 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 26890
        timeout in transit: 348
        source quenches: 11
        echo requests: 9274
        echo replies: 1
    18720 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 9446
        echo replies: 9274
IcmpMsg:
        InType0: 1
        InType3: 26890
        InType4: 11
        InType8: 9274
        InType11: 348
        OutType0: 9274
        OutType3: 9446
Tcp:
    5916623 active connections openings
    36244722 passive connection openings
    102606 failed connection attempts
    3493764 connection resets received
    53 connections established
    918246879 segments received
    1254505238 segments send out
    22244556 segments retransmited
    0 bad segments received.
    5748855 resets sent
Udp:
    4086750 packets received
    9427 packets to unknown port received.
    0 packet receive errors
    4125646 packets sent
...

To display the statistics for only the TCP or UDP protocols, type one of the following commands

# netstat -st
# netstat -su

Ouput

IcmpMsg:
    InType0: 1
    InType3: 26890
    InType4: 11
    InType8: 9274
    InType11: 348
    OutType0: 9274
    OutType3: 9446
Tcp:
    5917335 active connections openings
    36247817 passive connection openings
    102606 failed connection attempts
    3493814 connection resets received
    29 connections established
    918349626 segments received
    1254667978 segments send out
    22246760 segments retransmited
    0 bad segments received.
    5749332 resets sent
...

To display the quick interfaces statistics, type the following command

# netstat -i

Ouput

Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0 767575580      0      0      0 1120000223      0      0      0 BMRU
lo        16436   0 161102011      0      0      0 161102011      0      0      0 LRU

To display the extended interfaces statistics, type the following command

# netstat -ie

Ouput

Kernel Interface table
eth0      Link encap:Ethernet  HWaddr 00:25:90:0B:A3:E4
          inet addr:221.132.34.8  Bcast:221.132.34.95  Mask:255.255.255.224
          inet6 addr: fe80::225:90ff:fe0b:a3e4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:767588970 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1120021944 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4030025515 (3.7 GiB)  TX bytes:2208549264 (2.0 GiB)
          Interrupt:169 Memory:fb5e0000-fb600000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:161106440 errors:0 dropped:0 overruns:0 frame:0
          TX packets:161106440 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3387569934 (3.1 GiB)  TX bytes:3387569934 (3.1 GiB)

Related Posts:

Leave a Comment

Previous post:

Next post: