diff --git a/uip/uip-conf.h b/uip/uip-conf.h index 384f7fa..2da25a3 100644 --- a/uip/uip-conf.h +++ b/uip/uip-conf.h @@ -106,9 +106,23 @@ typedef unsigned short uip_stats_t; /** * uIP buffer size. * + * Sized to the largest frame the CPU port accepts on ingress: anything above + * that the NIC drops in hardware, so a larger buffer only costs XDATA. Measured + * with ICMP, which bypasses MSS and so probes the hardware directly: a 1502-byte + * payload is answered and 1503 is not, which puts the frame at 1556 bytes of + * uip_buf. The limit is the NIC's rather than a port's, so how the frame was + * tagged on the wire does not change it. + * * \hideinitializer */ -#define UIP_CONF_BUFFER_SIZE 2200 +#define UIP_CONF_BUFFER_SIZE 1556 + +/** + * Bytes of the buffer kept out of the advertised MSS. + * + * \hideinitializer + */ +#define UIP_CONF_BUFFER_EXTRA 30 /** * CPU byte order. diff --git a/uip/uipopt.h b/uip/uipopt.h index 16046cf..731484c 100644 --- a/uip/uipopt.h +++ b/uip/uipopt.h @@ -298,11 +298,8 @@ /** * The TCP maximum segment size. - * - * This is should not be to set to more than - * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN. */ -#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) +#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN - UIP_BUFFER_EXTRA) /** * The size of the advertised receiver's window. @@ -381,6 +378,17 @@ #define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE #endif /* UIP_CONF_BUFFER_SIZE */ +/** + * Bytes of uip_buf kept out of the advertised MSS. + * + * \hideinitializer + */ +#ifndef UIP_CONF_BUFFER_EXTRA +#define UIP_BUFFER_EXTRA 0 +#else /* UIP_CONF_BUFFER_EXTRA */ +#define UIP_BUFFER_EXTRA UIP_CONF_BUFFER_EXTRA +#endif /* UIP_CONF_BUFFER_EXTRA */ + extern __xdata uint8_t uip_buf[UIP_CONF_BUFFER_SIZE+2]; @@ -447,7 +455,7 @@ void uip_log(char *msg); #ifdef UIP_CONF_LLH_LEN #define UIP_LLH_LEN UIP_CONF_LLH_LEN #else /* UIP_CONF_LLH_LEN */ -#define UIP_LLH_LEN ETHER_HEADER_SIZE + RTL_FRAME_DESC_SIZE +#define UIP_LLH_LEN (ETHER_HEADER_SIZE + RTL_FRAME_DESC_SIZE) #endif /* UIP_CONF_LLH_LEN */ /** @} */