Skip to content

cpu/esp32: Fixes the maximum packet size of 255 bytes in the esp_eth netdev driver of ESP32 mcu.#10604

Merged
gschorcht merged 3 commits intoRIOT-OS:masterfrom
gschorcht:esp32_esp_eth_fix
Jan 4, 2019
Merged

cpu/esp32: Fixes the maximum packet size of 255 bytes in the esp_eth netdev driver of ESP32 mcu.#10604
gschorcht merged 3 commits intoRIOT-OS:masterfrom
gschorcht:esp32_esp_eth_fix

Conversation

@gschorcht
Copy link
Copy Markdown
Contributor

Contribution description

This PR fixes the following problems:

  • Mainly it fixes the problem described in issue cpu/esp32: esp_eth is not working correctly for packet size > 255 octets #10594 that packets with a size > 255 bytes cannot be received.
  • In addition, it replaces LOG_ERROR by DEBUG when receive buffer is to small in _recv to avoid error messages for an usual case
  • In addition, the _recv function is restructured to return -ENOBUFS if the receive buffer is too small, and in all other cases, the size of the packet or the bytes read.

Testing procedure

Compile and flash example/gnrc_networking for an ESP32 board with an Ethernet interface and activate the esp_eth module, e.g.,

USEMODULE=esp_eth make flash -C examples/gnrc_networking BOARD=esp32-olimex-evb

After flashing, just ping any link local address from RIOT shell with an ICMP data size greater than 255 byte, e.g.

ping6 fe80::345b:6598:1369:5bf4 1232

Issues/PRs references

Fixes #10594

@gschorcht gschorcht added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Dec 12, 2018
@gschorcht
Copy link
Copy Markdown
Contributor Author

@TimoRoth It would be interesting whether your ESP Gateway is working with these bug fixes as expected.

@TimoRoth
Copy link
Copy Markdown
Contributor

With this applied I can now ping the gateway itself with a ping size of up to 1434 bytes(which is a packet size of exactly 1500).
And I can ping a client behind the gateway with a ping size of up to 200 bytes, which translates to an ESP-NOW package of exactly 250 bytes.
If I try to ping with 201 bytes I can see one single 246 byte sized ESP-NOW package coming in on the client, but never the second fragment. Same behaviour when pinging from the RIOT shell. Which is weird, because that already worked when I tested it yesterday.
Not an issue with this PR though, the lack of fragmentation support is a different issue entirely.

@gschorcht
Copy link
Copy Markdown
Contributor Author

gschorcht commented Dec 13, 2018

With this applied I can now ping the gateway itself with a ping size of up to 1434 bytes(which is a packet size of exactly 1500).

Not really clear why 1434. ICMPv6 Echo request header has 8 byte and IPv6 header without extensions has 40 bytes. Therefore, I would expect 1452 byte as maximum or missed I something?

Since your output interface has a MTU of 1280, your ICMPv6 Echo requests should be forwarded only for a data size of 1232 byte if fragmentation is not supported or not allowed.

If I try to ping with 201 bytes I can see one single 246 byte sized ESP-NOW package coming in on the client, but never the second fragment. Same behaviour when pinging from the RIOT shell. Which is weird, because that already worked when I tested it yesterday.

I checked out your last commit, it works for me as expected. I can ping using ESP-NOW with a data size of up to 1232 byte.

@jnohlgard
Copy link
Copy Markdown
Member

Not really clear why 1434

Is there a link layer header as well in there?

@gschorcht
Copy link
Copy Markdown
Contributor Author

Is there a link layer header as well in there?

I don't know, @TimoRoth?.

If Ethernet II frame formatting is used, IPv6 should be directly the payload and should be able to use the whole MTU. If he uses a Linux PC to ping, I would guess this should be the case.

@TimoRoth
Copy link
Copy Markdown
Contributor

I'm using Windows ping, I'm not exactly sure what it does, but when I do "ping -6 -l 1434" the package reaching the esp-eth interface has a size of exactly 1500 bytes. Didn't investigate any further why it's exactly that size.

@gschorcht
Copy link
Copy Markdown
Contributor Author

@TimoRoth I see, you are using windows. Hm, does it work to make and flash ESP32 with Windows or are you using Linux/macOS for that?

Anyway, It would be quite interesting how the packets looks like. May I ask you to snap such one ICMPv6 Echo packet with data size of 1434 bytes by wireshark?

@TimoRoth
Copy link
Copy Markdown
Contributor

I'm using a VM with Linux. But it does not have access to the Wifi where the router is on, so I need to do that from the Windows host.

Looks like this on Wireshark. Not sure there the extra 4 Byte on the esp-eth end come from.

image

@gschorcht
Copy link
Copy Markdown
Contributor Author

gschorcht commented Dec 13, 2018

@TimoRoth Thanks. This is what I supposed, Ethernet II formatted MAC frame with 40 bytes IPv6 header and 8 bytes ICMPv6 echo reply header as payload. The frame size of 1496 on wire includes the 14 bytes Ethernet II header. But, Ethernet II MTU size is always the limit for the payload of the Ethernet frame. That is, usually it should be possible to have 1514 bytes on wire.

If you ping any IPv4 host, you will see these 1514 bytes on wire with ping <IPv4 address> -s 1472.

@gschorcht
Copy link
Copy Markdown
Contributor Author

@miri64 May I ask you to review this fix for esp_eth netdev driver? It would be great to get it merged as soon as possible.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Dec 29, 2018

I don't have the hardware to test, but I will give it a code review.

@gschorcht
Copy link
Copy Markdown
Contributor Author

Maybe @TimoRoth could it retest even though he already tried the changes #10604 (comment).

@tcschmidt
Copy link
Copy Markdown
Member

@PeterKietzmann should also have access to the hardware - and is experienced with the netdev interface.

@TimoRoth
Copy link
Copy Markdown
Contributor

Just tested it again on top of current master.
Pinging the board works great up until the packet size exceeds the MTU, which is to be expected.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Dec 29, 2018

Then, once my change request is addressed I think we can merge.

@gschorcht
Copy link
Copy Markdown
Contributor Author

@miri64 Changed

@gschorcht
Copy link
Copy Markdown
Contributor Author

@miri64 Could you give your ACK for the requested change?

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested ACK. Please squash.

@gschorcht
Copy link
Copy Markdown
Contributor Author

Untested ACK.

Thanks. Was tested again by @TimoRoth #10604 (comment)

Fixes the maximum packet size of 255 bytes in the esp_eth netdev driver of ESP32 mcu.

fixup! cpu/esp32: fixes esp_net maximum packet size
@gschorcht gschorcht added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 4, 2019
@gschorcht gschorcht merged commit f7e524d into RIOT-OS:master Jan 4, 2019
@gschorcht gschorcht deleted the esp32_esp_eth_fix branch January 4, 2019 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cpu/esp32: esp_eth is not working correctly for packet size > 255 octets

6 participants