From 28b8f4a2e6f307ef4ba01f18991c289318522384 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 12 Dec 2007 14:41:36 +0000 Subject: [PATCH] ifconfig shows uIP stats git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@450 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 1 + Documentation/NuttX.html | 3 +- TODO | 2 + configs/c5471evm/nshconfig | 2 +- examples/nsh/nsh_netcmds.c | 120 ++++++++++++++++++++++++++++++++++++- include/net/uip/uip-tcp.h | 2 +- 6 files changed, 126 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 611da81bc9..fe40ebcb13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -281,3 +281,4 @@ * Fixed errors in C5471 configuration files for examples/uip * Modified DHCPC (netutils/dhcpc) so that it should work in environments where there are more than one DHCPD server. + * NSH ifconfig command now shows uIP status was well (examples/nsh) diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 979d25e9b7..d795e086e7 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: December 11, 2007

+

Last Updated: December 12, 2007

@@ -975,6 +975,7 @@ Other memory: * Fixed errors in C5471 configuration files for examples/uip * Modified DHCPC (netutils/dhcpc) so that it should work in environments where there are more than one DHCPD server. + * NSH ifconfig command now shows uIP status was well (examples/nsh) diff --git a/TODO b/TODO index 3351d7e46c..9cd59baa38 100644 --- a/TODO +++ b/TODO @@ -47,6 +47,8 @@ o Network for new data, the driver should be throttled. Perhaps the driver should disable RX interrupts when throttled and re-anable on each poll time. recvfrom would, of course, have to un-throttle. +- Need to standardize collection of statistics from network drivers. examples/nsh + ifconfig command should present statistics. o USB - Implement USB device support diff --git a/configs/c5471evm/nshconfig b/configs/c5471evm/nshconfig index 5389284dbf..fc611ac73d 100644 --- a/configs/c5471evm/nshconfig +++ b/configs/c5471evm/nshconfig @@ -286,7 +286,7 @@ CONFIG_NET_UDP_CHECKSUMS=y #CONFIG_NET_UDP_CONNS=10 CONFIG_NET_ICMP=y #CONFIG_NET_PINGADDRCONF=0 -CONFIG_NET_STATISTICS=n +CONFIG_NET_STATISTICS=y #CONFIG_NET_RECEIVE_WINDOW= #CONFIG_NET_ARPTAB_SIZE=8 CONFIG_NET_BROADCAST=n diff --git a/examples/nsh/nsh_netcmds.c b/examples/nsh/nsh_netcmds.c index c58a23f079..3874d3a53e 100644 --- a/examples/nsh/nsh_netcmds.c +++ b/examples/nsh/nsh_netcmds.c @@ -51,6 +51,10 @@ #include #include +#ifdef CONFIG_NET_STATISTICS +#include +#endif + #include "nsh.h" /**************************************************************************** @@ -77,6 +81,119 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: uip_statistics + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static inline void uip_statistics(void *handle) +{ + nsh_output(handle, "uIP IP "); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " TCP"); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " UDP"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ICMP"); +#endif + nsh_output(handle, "\n"); + + /* Received packets */ + + nsh_output(handle, "Received %04x",uip_stat.ip.recv); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.recv); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.recv); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.recv); +#endif + nsh_output(handle, "\n"); + + /* Dropped packets */ + + nsh_output(handle, "Dropped %04x",uip_stat.ip.drop); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.drop); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.drop); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.drop); +#endif + nsh_output(handle, "\n"); + + nsh_output(handle, " IP VHL: %04x HBL: %04x\n", + uip_stat.ip.vhlerr, uip_stat.ip.hblenerr); + nsh_output(handle, " LBL: %04x Frg: %04x\n", + uip_stat.ip.lblenerr, uip_stat.ip.fragerr); + + nsh_output(handle, " Checksum %04x",uip_stat.ip.chkerr); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.chkerr); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.chkerr); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ----"); +#endif + nsh_output(handle, "\n"); + +#ifdef CONFIG_NET_TCP + nsh_output(handle, " TCP ACK: %04x SYN: %04x\n", + uip_stat.tcp.ackerr, uip_stat.tcp.syndrop); + nsh_output(handle, " RST: %04x %04x\n", + uip_stat.tcp.rst, uip_stat.tcp.synrst); +#endif + + nsh_output(handle, " Type %04x",uip_stat.ip.protoerr); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.typeerr); +#endif + nsh_output(handle, "\n"); + + /* Sent packets */ + + nsh_output(handle, "Sent ----",uip_stat.ip.sent); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.sent); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.sent); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.sent); +#endif + nsh_output(handle, "\n"); + +#ifdef CONFIG_NET_TCP + nsh_output(handle, " Rexmit ---- %04x",uip_stat.tcp.rexmit); +#ifdef CONFIG_NET_UDP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ----"); +#endif + nsh_output(handle, "\n"); +#endif + nsh_output(handle, "\n"); +} +#else +# define uip_statistics(handle) +#endif + /**************************************************************************** * Name: ifconfig_callback ****************************************************************************/ @@ -91,7 +208,7 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg) addr.s_addr = dev->d_draddr; nsh_output(arg, "DRaddr:%s ", inet_ntoa(addr)); addr.s_addr = dev->d_netmask; - nsh_output(arg, "Mask:%s\n", inet_ntoa(addr)); + nsh_output(arg, "Mask:%s\n\n", inet_ntoa(addr)); } /**************************************************************************** @@ -105,6 +222,7 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg) void cmd_ifconfig(FAR void *handle, int argc, char **argv) { netdev_foreach(ifconfig_callback, handle); + uip_statistics(handle); } #endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/include/net/uip/uip-tcp.h b/include/net/uip/uip-tcp.h index f6d19b8de5..789a5b4795 100644 --- a/include/net/uip/uip-tcp.h +++ b/include/net/uip/uip-tcp.h @@ -191,7 +191,7 @@ struct uip_tcp_stats_s uip_stats_t sent; /* Number of sent TCP segments */ uip_stats_t chkerr; /* Number of TCP segments with a bad checksum */ uip_stats_t ackerr; /* Number of TCP segments with a bad ACK number */ - uip_stats_t rst; /* Number of recevied TCP RST (reset) segments */ + uip_stats_t rst; /* Number of received TCP RST (reset) segments */ uip_stats_t rexmit; /* Number of retransmitted TCP segments */ uip_stats_t syndrop; /* Number of dropped SYNs due to too few available connections */