6loWPAN: Fix some MTU-related craziness.

This commit is contained in:
Gregory Nutt 2017-03-30 17:18:18 -06:00
parent 9aabb44118
commit 1a12682f23
4 changed files with 70 additions and 14 deletions

View File

@ -116,6 +116,22 @@
# endif
#endif
#ifndef CONFIG_NET_6LOWPAN_FRAG
# undef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
#endif
#ifndef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
# ifdef CONFIG_NET_6LOWPAN_FRAG
# define CONFIG_NET_6LOWPAN_MTU 1294
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO 1220
# else
# define CONFIG_NET_6LOWPAN_MTU CONFIG_NET_6LOWPAN_FRAMELEN
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO (CONFIG_NET_6LOWPAN_FRAMELEN - 25)
# endif
#endif
#if defined(CONFIG_NET_MULTILINK)
/* We are supporting multiple network devices using different link layer
* protocols. Get the size of the link layer header from the device
@ -142,15 +158,23 @@
# endif
# ifdef CONFIG_NET_SLIP
# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_6LOWPAN_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_6LOWPAN_MTU)
# else
# define _MIN_SLIP_MTU _MIN_LO_MTU
# define _MAX_SLIP_MTU _MAX_LO_MTU
# endif
# define MIN_NET_DEV_MTU _MIN_SLIP_MTU
# define MAX_NET_DEV_MTU _MAX_SLIP_MTU
# ifdef CONFIG_NET_6LOWPAN
# define _MIN_6LOWPAN_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_6LOWPAN_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU)
# else
# define _MIN_6LOWPAN_MTU _MIN_LO_MTU
# define _MAX_6LOWPAN_MTU _MAX_LO_MTU
# endif
# define MIN_NET_DEV_MTU _MIN_6LOWPAN_MTU
# define MAX_NET_DEV_MTU _MAX_6LOWPAN_MTU
/* For the loopback device, we will use the largest MTU */
@ -190,8 +214,20 @@
# define MIN_NET_DEV_MTU NET_LO_MTU
# define MAX_NET_DEV_MTU NET_LO_MTU
#elif defined(CONFIG_NET_6LOWPAN)
/* There is no link layer header with SLIP */
# ifndef CONFIG_NET_IPv6
# error 6loWPAN requires IPv support
# endif
# define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) CONFIG_NET_6LOWPAN_MTU
# define MIN_NET_DEV_MTU CONFIG_NET_6LOWPAN_MTU
# define MAX_NET_DEV_MTU CONFIG_NET_6LOWPAN_MTU
#else
/* Perhaps only Unix domain sockets of the loopback device */
/* Perhaps only Unix domain sockets or the loopback device */
# define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) 0

View File

@ -340,9 +340,12 @@ struct rimeaddr_s
* 5) On network input RX oprations, both buffers must be provided. The size
* of the i_frame buffer is, again, greater than or equal to
* CONFIG_NET_6LOWPAN_FRAMELEN. The larger dev.d_buf must have a size
* of at least <tbd>. The dev.d_buf is used for de-compressing each
* frame and reassembling any fragmented packets to create the full input
* packet that is provided to the applicatino.
* of at least the advertised MTU of the protocol, CONFIG_NET_6LOWPAN_MTU.
* If fragmentation is enabled, then the logical packet size may be
* significantly larger than the size of the frame buffer. The dev.d_buf
* is used for de-compressing each frame and reassembling any fragmented
* packets to create the full input packet that is provided to the
* application.
*
* Frame Organization:
*

View File

@ -229,8 +229,8 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
#ifdef CONFIG_NET_6LOWPAN
case NET_LL_IEEE802154: /* IEEE 802.15.4 MAC */
dev->d_llhdrlen = 0; /* REVISIT */
dev->d_mtu = CONFIG_NET_6LOWPAN_FRAMELEN;
dev->d_llhdrlen = 0;
dev->d_mtu = CONFIG_NET_6LOWPAN_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = CONFIG_NET_6LOWPAN_TCP_RECVWNDO;
#endif

View File

@ -159,15 +159,32 @@ config NET_6LOWPAN_MAXPAYLOAD
of a 802.15.4 frame) - 25 bytes (for the 802.15.4 MAClayer header). This
can be increased for systems with larger packet sizes.
config NET_6LOWPAN_MTU
int "6LoWPAN packet buffer size"
default 1294
range 590 1518
depends on NET_6LOWPAN_FRAG
---help---
Packet buffer size. This size includes the TCP/UDP payload plus the
size of TCP/UDP header, the IP header, and the Ethernet header.
This value is normally referred to as the MTU (Maximum Transmission
Unit); the payload is the MSS (Maximum Segment Size).
NOTE that this option depends on fragmentation support. By
supporting fragmentation, we can handle quite large "logical" packet
sizes. Without fragmentation support, the MTU is equal to the frame
size and that has already been selected.
config NET_6LOWPAN_TCP_RECVWNDO
int "6LoWPAN TCP receive window size"
default 102
default 1220 if NET_6LOWPAN_FRAG
default 102 if !NET_6LOWPAN_FRAG
depends on NET_TCP
---help---
The size of the advertised receiver's window. Should be set low
(i.e., to the size of the IEEE802.15.4 frame payload) if the application
is slow to process incoming data, or high (32768 bytes) if the
application processes data quickly. REVISIT!
(i.e., to the size of the IEEE802.15.4 MTU or frame payload) if
the application is slow to process incoming data, or high (32768
bytes) if the application processes data quickly.
config NET_6LOWPAN_SNIFFER
default n