4

'netstat' is deprecated for Linux os. So I am looking for the right alternative of the 'netstat', So what will be right alternative for netstat?

I found out one 'SS' command but it is not sufficient enough to achieve our requirements. We are looking for the following fields:

In IP:

   packets dropped

In TCP:

   segments retransmitted
   detected reordering
   segments received
   segments send out

In UDP:

   packets to unknown port received
   packet receive errors
   packets received
   packets sent

Is there any command available by which we can get the above-mentioned field? If I can collect all the above-mentioned fields by multiple commands then also it will be fine for me.

Dhruv Patel2
  • 41
  • 1
  • 3
  • `ss` is the command that more closely replaces `netstat`. It may not implement everything that `netstat` does and it certainly has additional features. If you show how you obtain those fields, it may be feasible to work out an alternative way to find them. If you look into /proc/sys/net the information you need will probably be there in some form. – Pedro May 28 '20 at 16:48
  • 1
    related: https://unix.stackexchange.com/questions/435579/is-there-documentation-for-proc-net-netstat-and-proc-net-snmp (that's what `netstat -s` is using) – A.B May 28 '20 at 22:16

2 Answers2

3

you can achieve with nstat -asz

  • -a Dump absolute values of counters. The default is to calculate increments since the previous use.
  • -s Do not update history, so that the next time you will see counters including values accumulated to the moment of this measurement too.
  • -z Dump zero counters too. By default they are not shown.

In IP:

netstat -s
   outgoing packets dropped  # nstat -asz | grep IpOutDiscards
   dropped because of missing route  # nstat -asz | grep IpOutNoRoutes
   fragments dropped after timeout  # nstat -asz | grep IpReasmTimeout

In TCP:

netstat -s       
    segments retransmitted  # nstat -asz | grep TcpRetransSegs
    detected reordering (FACK)  # nstat -asz | grep TcpExtTCPFACKReorder
    detected reordering (SACK)  # nstat -asz | grep TcpExtTCPSACKReorder
    detected reordering (reno fast retransmit)  # nstat -asz | grep TcpExtTCPRenoReorder
    detected reordering (time stamp)  # nstat -asz | grep TcpExtTCPTSReorder
    segments received  # nstat -asz | grep TcpInSegs
    segments sent out  # nstat -asz | grep TcpOutSegs

In UDP:

netstat -s       
     packets to unknown port received  # nstat -asz | grep UdpNoPorts
     packet receive errors  # nstat -asz | grep UdpInErrors
     packets received  # nstat -asz | grep UdpInDatagrams
     packets sent  # nstat -asz | grep UdpOutDatagrams

Found useful network statistics reference

binarysta
  • 2,912
  • 10
  • 14
2

ss is the command that more closely replaces netstat. Sadly one of the features it does not have is the equivalent of netstat -s.

"alternative to "netstat -s"" reports that the tool nstat has most of the information produced by netstat -s.

Also you can find and parse some (if not all) of this information under /proc/net/ including:

  • /proc/net/netstat
  • /proc/net/sockstat
  • /proc/net/dev
  • /proc/net/dev_snmp6
Pedro
  • 1,821
  • 12
  • 23