Re: Monitoring packet loss

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Thu, 08 Aug 2024 01:21:43 UTC
On 8/7/24 7:06 AM, Alan Somers wrote:
> I'd like to track the rate of packet loss for outbound packets from
> some production servers.  Obviously, that's impossible.  But I think
> that the rate of TCP retransmissions should be a close proxy for
> packet loss.  Currently I can only observe TCP retransmissions by
> using wireshark, a slow and laborious process.  But it seems to me
> that the network stack should already have that information

The kernel already maintains a VNET-virtualized tcpstat structure for 
aggregate TCP stats.  netstat and systat grab these using the 
net.inet.tcp.stats sysctl.  This might work for you if you're okay with 
global and not per-interface information.

VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat);	/* tcp statistics */

$ netstat -sp tcp | grep -iE 'retr|rexm'
$ systat -tcp

Regards,
Navdeep

 > Would it
> be possible to add a sysctl to expose the total number of
> retransmissions since boot?  This information would be very useful.
> It could reveal for example problems with a model of NIC, or
> congestion on one network segment but not another, or a regression in
> the OS.
> 
> -Alan
>