Completes basic changes to support per-device/per-link TCP receive window size

This commit is contained in:
Gregory Nutt 2014-11-16 11:15:21 -06:00
parent 29dc5916af
commit 38754a3466
5 changed files with 78 additions and 29 deletions

View file

@ -88,7 +88,7 @@
* There are other device-specific features that at tied to the link layer:
*
* - Maximum Transfer Unit (MTU)
* - TCP Receive Window size
* - TCP Receive Window size (See TCP configuration options below)
*
* A better solution would be to support device-by-device MTU and receive
* window sizes. This minimum support is require to support the optimal
@ -298,15 +298,17 @@
#define TCP_MSS(d) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - IPTCP_HDRLEN)
#ifdef CONFIG_NET_ETHERNET
# define MIN_TCP_MSS (CONFIG_NET_ETH_MTU - ETH_HDRLEN - IPTCP_HDRLEN)
#else /* if defined(CONFIG_NET_SLIP) */
# define MIN_TCP_MSS (CONFIG_NET_SLIP_MTU - IPTCP_HDRLEN)
# define ETH_TCP_MSS (CONFIG_NET_ETH_MTU - ETH_HDRLEN - IPTCP_HDRLEN)
# define MIN_TCP_MSS ETH_TCP_MSS
#elif defined(CONFIG_NET_SLIP)
# define SLIP_TCP_MSS (CONFIG_NET_SLIP_MTU - IPTCP_HDRLEN)
# define MIN_TCP_MSS SLIP_TCP_MSS
#endif
#ifdef CONFIG_NET_SLIP
# define MAX_TCP_MSS (CONFIG_NET_SLIP_MTU - IPTCP_HDRLEN)
#else /* if defined(CONFIG_NET_ETHERNET) */
# define MAX_TCP_MSS (CONFIG_NET_ETH_MTU - ETH_HDRLEN - IPTCP_HDRLEN)
# define MAX_TCP_MSS SLIP_TCP_MSS
#elif defined(CONFIG_NET_ETHERNET)
# define MAX_TCP_MSS ETH_TCP_MSS
#endif
/* The size of the advertised receiver's window.
@ -318,10 +320,37 @@
* See the note above regarding the TCP MSS and CONFIG_NET_MULTILINK.
*/
#ifndef CONFIG_NET_RECEIVE_WINDOW
# define CONFIG_NET_RECEIVE_WINDOW MIN_TCP_MSS
#ifdef CONFIG_NET_SLIP
# ifndef CONFIG_NET_SLIP_TCP_RECVWNDO
# define CONFIG_NET_SLIP_TCP_RECVWNDO SLIP_TCP_MSS
# endif
#endif
#ifdef CONFIG_NET_ETHERNET
# ifndef CONFIG_NET_ETH_TCP_RECVWNDO
# define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS
# endif
#endif
#if defined(CONFIG_NET_MULTILINK)
/* We are supporting multiple network devices using different link layer
* protocols. Get the size of the receive window from the device structure.
*/
# define NET_DEV_RCVWNDO(d) ((d)->d_recvwndo)
#elif defined(CONFIG_NET_SLIP)
/* Only SLIP.. use the configured SLIP receive window size */
# define NET_DEV_RCVWNDO(d) CONFIG_NET_SLIP_TCP_RECVWNDO
#else /* if defined(CONFIG_NET_ETHERNET) */
/* Only Ethernet.. use the configured SLIP receive window size */
# define NET_DEV_RCVWNDO(d) CONFIG_NET_ETH_TCP_RECVWNDO
#endif /* MULTILINK or SLIP or ETHERNET */
/* How long a connection should stay in the TIME_WAIT state.
*
* This configuration option has no real implication, and it should be

View file

@ -102,6 +102,9 @@ struct net_driver_s
uint8_t d_lltype; /* See enum net_datalink_e */
uint8_t d_llhdrlen; /* Link layer header size */
uint16_t d_mtu; /* Maximum packet size */
#ifdef CONFIG_NET_TCP
uint16_t d_recvwndo; /* TCP receive window size */
#endif
#endif
#ifdef CONFIG_NET_ETHERNET

View file

@ -29,6 +29,15 @@ config NET_NOINTS
Otherwise, it assumed that uIP will be called from interrupt level handling
and critical sections will be managed by enabling and disabling interrupts.
config NET_PROMISCUOUS
bool "Promiscuous mode"
default n
---help---
Force the Ethernet driver to operate in promiscuous mode (if supported
by the Ethernet driver).
menu "Driver buffer configuration"
config NET_MULTIBUFFER
bool "Use multiple device-side I/O buffers"
default n
@ -40,13 +49,6 @@ config NET_MULTIBUFFER
Or, as another example, the driver may support queuing of concurrent
input/ouput and output transfers for better performance.
config NET_PROMISCUOUS
bool "Promiscuous mode"
default n
---help---
Force the Ethernet driver to operate in promiscuous mode (if supported
by the Ethernet driver).
config NET_ETH_MTU
int "Ethernet packet buffer size (MTU)"
default 1294 if NET_IPv6
@ -66,6 +68,17 @@ config NET_ETH_MTU
IPv6 hosts are required to be able to handle an MSS of 1220 octets,
resulting in a minimum buffer size of of 1220+20+40+14 = 1294
config NET_ETH_TCP_RECVWNDO
int "Ethernet receive window size"
default 1220 if NET_IPv6
default 536 if !NET_IPv6
depends on NET_ETHERNET && NET_TCP
---help---
The size of the advertised receiver's window. Should be set low
(i.e., to the size of the MSS) if the application is slow to process
incoming data, or high (32768 bytes) if the application processes
data quickly.
config NET_SLIP_MTU
int # "SLIP packet buffer size (MTU)"
default 296
@ -79,11 +92,10 @@ config NET_SLIP_MTU
support at lest 256+20+20 = 296. Values other than 296 are not
recommended.
config NET_RECEIVE_WINDOW
int "Receive window size"
default 1220 if !NET_SLIP && NET_IPv6
default 536 if !NET_SLIP && !NET_IPv6
default 256 if NET_SLIP && !NET_IPv6
config NET_SLIP_TCP_RECVWNDO
int "SLIP receive window size"
default 256
depends on NET_SLIP && NET_TCP
---help---
The size of the advertised receiver's window. Should be set low
(i.e., to the size of the MSS) if the application is slow to process
@ -101,6 +113,8 @@ config NET_GUARDSIZE
packet size will be chopped down to the size indicated in the TCP
header.
end menu # Driver buffer configuration
menu "Data link support"
config NET_MULTILINK

View file

@ -135,6 +135,9 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
case NET_LL_ETHERNET: /* Ethernet */
dev->d_llhdrlen = ETH_HDRLEN;
dev->d_mtu = CONFIG_NET_ETH_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = CONFIG_NET_ETH_RECVWNDO;
#endif
devfmt = NETDEV_ETH_FORMAT;
break;
#endif
@ -143,6 +146,9 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
case NET_LL_SLIP: /* Serial Line Internet Protocol (SLIP) */
dev->d_llhdrlen = 0;
dev->d_mtu = CONFIG_NET_SLIP_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = CONFIG_NET_SLIP_RECVWNDO;
#endif
devfmt = NETDEV_SLIP_FORMAT;
break;
#endif
@ -151,16 +157,13 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
case NET_LL_PPP: /* Point-to-Point Protocol (PPP) */
dev->d_llhdrlen = 0;
dev->d_mtu = CONFIG_NET_PPP_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = CONFIG_NET_PPP_RECVWNDO;
#endif
devfmt = NETDEV_PPP_FORMAT;
break;
#endif
/* REVISIT: Here we must also set the size of the link header
* header the precedes network layer headers.
*/
break;
default:
nlldbg("ERROR: Unrecognized link type: %d\n", lltype);
return -EINVAL;

View file

@ -201,8 +201,8 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
}
else
{
pbuf->wnd[0] = ((CONFIG_NET_RECEIVE_WINDOW) >> 8);
pbuf->wnd[1] = ((CONFIG_NET_RECEIVE_WINDOW) & 0xff);
pbuf->wnd[0] = ((NET_DEV_RCVWNDO(dev)) >> 8);
pbuf->wnd[1] = ((NET_DEV_RCVWNDO(dev)) & 0xff);
}
/* Finish the IP portion of the message, calculate checksums and send