Skip to content

Conversation

@WaterBirdWayOrigin
Copy link
Contributor

Set CONFIG_NET_ETH_PKTSIZE to 1514 when performing
$ tools/configure.sh spresense/rndis
configuration

CONFIG_NET_ETH_PKTSIZE defines the size of ethernet packet.
Ethernet packet size is 1514 including the ethernet header.

This commit can send 1514 bytes packet as follow:
e.g) For OpenWrt Router
nsh> ping -c 1 -s 1472 192.168.1.1
PING 192.168.1.1 1472 bytes of data
1472 bytes from 192.168.1.1: icmp_seq=0 time=0 ms
1 packets transmitted, 1 received, 0% packet loss, time 1010 ms
nsh>

https://tools.ietf.org/html/rfc894
said at Frame Format

   The minimum length of the data field of a packet sent over an
   Ethernet is 1500 octets, thus the maximum length of an IP datagram
   sent over an Ethernet is 1500 octets.  Implementations are encouraged
   to support full-length packets.
``

Just for your information,
include/nuttx/net/ethernet.h:78:#define ETH_HDRLEN       14     /* Header size: 2*6 + 2 */

Signed-off-by: Koichi Okamoto <Koichi.Okamoto@sony.com>

Set CONFIG_NET_ETH_PKTSIZE to 1514 when performing
 $ tools/configure.sh spresense/rndis
configuration

CONFIG_NET_ETH_PKTSIZE defines the size of ethernet packet.
Ethernet packet size is 1514 including the ethernet header.

This commit can send 1514 bytes packet as follow:
  e.g) For OpenWrt Router
  nsh> ping -c 1 -s 1472 192.168.1.1
  PING 192.168.1.1 1472 bytes of data
  1472 bytes from 192.168.1.1: icmp_seq=0 time=0 ms
  1 packets transmitted, 1 received, 0% packet loss, time 1010 ms
  nsh>

https://tools.ietf.org/html/rfc894
said at Frame Format
```
   The minimum length of the data field of a packet sent over an
   Ethernet is 1500 octets, thus the maximum length of an IP datagram
   sent over an Ethernet is 1500 octets.  Implementations are encouraged
   to support full-length packets.
``

Just for your information,
include/nuttx/net/ethernet.h:78:#define ETH_HDRLEN       14     /* Header size: 2*6 + 2 */

Signed-off-by: Koichi Okamoto <Koichi.Okamoto@sony.com>
@WaterBirdWayOrigin
Copy link
Contributor Author

#109 (comment)

@WaterBirdWayOrigin
Copy link
Contributor Author

@WaterBirdWayOrigin

https://en.wikipedia.org/wiki/Ethernet_frame#Ethernet_II

The original Ethernet IEEE 802.3 standard defined the minimum Ethernet frame size as 64 bytes and the maximum as 1518 bytes (1500+header/trailer). The maximum was later increased to 1522 bytes to allow for VLAN tagging.

I am not sure but I think the last CRC (4Byte) isn't consider by software tcp/ip stack side.

The cause of 1500 byte maximum issue comes from original comment of uIP source code.
https://github.com/adamdunkels/uip/blob/master/uip/uipopt.h#L369

uIP original defines as follows:
https://github.com/adamdunkels/uip/blob/master/uip/uipopt.h#L299
And TCP maximum segment size
#define UIP_TCP_MSS (UIP_BUFSIZE-UIP_LLH_LEN-UIP_TCPIP_HLEN)

It seems to me that from the definition, UIP_BUFSIZE is considered to be a packet buffer including the header of Link Layer (14 bytes for Ethernet (excluding 4 bytes for FCS(CRC))) in the first place, so that the original comment misread.

https://tools.ietf.org/html/rfc894 said

   The minimum length of the data field of a packet sent over an
   Ethernet is 46 octets. If necessary, the data field should be padded
   (with octets of zero) to meet the Ethernet minimum frame size. This
   padding is not part of the IP packet and is not included in the total
   length field of the IP header.

   The minimum length of the data field of a packet sent over an
   Ethernet is 1500 octets, thus the maximum length of an IP datagram
   sent over an Ethernet is 1500 octets. Implementations are encouraged
   to support full-length packets. Gateway implementations MUST be
   prepared to accept full-length packets and fragment them if
   necessary. If a system cannot receive full-length packets, it should
   take steps to discourage others from sending them, such as using the
   TCP Maximum Segment Size option [4].

The above two paragraph said the data area of ethernet is from 46 byte to 1500 byte.
As the header size of ethernet is 14 byte, from 60 byte to 1514 byte is ethernet packet size.

@WaterBirdWayOrigin
Copy link
Contributor Author

uIP is also used contiki os:
https://github.com/contiki-os/contiki/blob/master/core/net/ip/uipopt.h#L163
/**

  • The size of the uIP packet buffer.
  • The uIP packet buffer should not be smaller than 60 bytes, and does
  • not need to be larger than 1514 bytes. Lower size results in lower
  • TCP throughput, larger size results in higher TCP throughput.
  • \hideinitializer
    /
    #ifndef UIP_CONF_BUFFER_SIZE
    #define UIP_BUFSIZE (UIP_LINK_MTU + UIP_LLH_LEN)
    #else /
    UIP_CONF_BUFFER_SIZE /
    #define UIP_BUFSIZE (UIP_CONF_BUFFER_SIZE)
    #endif /
    UIP_CONF_BUFFER_SIZE */

This side is fixed to 1514, not 1500.

@patacongo
Copy link
Contributor

" am not sure but I think the last CRC (4Byte) isn't consider by software tcp/ip stack side." That is my experience too. The FCS is generated and consumed by hardware.

I've also worked with Ethernet hardware that adds additional information at the end of the packet.

There is a special configuration setting to allow additional space at the end of the packet for this hardware specific stuff. It is CONFIG_NET_GUARDSIZE. The total packet allocation size is the max payload (1500) plus the Ethernet header size (14) plus CONFIG_NET_GUARDSIZE.

@patacongo
Copy link
Contributor

Don't use uIP documentation. The NuttX network does include a few things from uIP, but it is an original network and nothing you know about uIP applies here.

Especially anything related to buffering.

@patacongo
Copy link
Contributor

The confusion here is between packet size, MTU, and additional FCS bytes.

The MTU does not include either the Ethernet header or the FCS bytes. CONFIG_NET_ETH_PKTSIZE is not the MTU and does include the Ethernet header (the FCS is provided by the GUARD size, if needed).

So for an MTU of 1500, the correct value of CONFIG_NET_ETH_PKTSIZE is 1514. So your change is correct.

Too much talking for such a simple change.

@Ouss4 Ouss4 merged commit d360205 into apache:master Jan 16, 2020
@WaterBirdWayOrigin
Copy link
Contributor Author

@patacongo
Thank you for your confirmation !

Don't use uIP documentation.
Too much talking for such a simple change.

I see. Thank your for your advice.

@WaterBirdWayOrigin WaterBirdWayOrigin deleted the fixedethernetpacketsizeforspresenserndis branch January 17, 2020 05:36
@jerpelea
Copy link
Contributor

@patacongo thanks for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants