[tcp] Report TCP statistics via the "ipstat" command

Gather some basic statistics on TCP connections to allow out-of-order
packets and duplicate packets to be observed even in non-debug builds.

Report these statistics via the existing "ipstat" command, rather than
introducing a separate "tcpstat" command, on the basis that we do not
need the additional overhead of a separate command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-01-09 16:36:52 +00:00
parent a8c89276cc
commit 2110afb351
3 changed files with 49 additions and 2 deletions
+12 -2
View File
@@ -24,23 +24,25 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdio.h>
#include <ipxe/tcp.h>
#include <ipxe/ipstat.h>
#include <usr/ipstat.h>
/** @file
*
* IP statistics
* TCP/IP statistics
*
*/
/**
* Print IP statistics
* Print TCP/IP statistics
*
*/
void ipstat ( void ) {
struct ip_statistics_family *family;
struct ip_statistics *stats;
/* Print per-family statistics */
for_each_table_entry ( family, IP_STATISTICS_FAMILIES ) {
stats = family->stats;
printf ( "IP version %d:\n", family->version );
@@ -63,4 +65,12 @@ void ipstat ( void ) {
stats->out_mcast_pkts, stats->out_bcast_pkts,
stats->out_octets );
}
/* Print TCP statistics */
printf ( "TCP:\n" );
printf ( " InSegs:%ld InOctets:%ld InOctetsGood:%ld\n",
tcp_stats.in_segs, tcp_stats.in_octets,
tcp_stats.in_octets_good );
printf ( " InDiscards:%ld InOutOfOrder:%ld\n",
tcp_stats.in_discards, tcp_stats.in_out_of_order );
}