Hi all,
while tracing UDP telegrams via Wireshark I see checksums. The telegrams are send to a ESP32 acting as an AP. My questions are:
1. Does the ESP32 automatically dismiss corrupted UDP telegrams?
2. Can I be sure, that when I read out data via recvfrom() that the checksum for this UDP telegram was at least correct ?
Thanks and regards
Checksums in UDP telegrams
Re: Checksums in UDP telegrams
Enabled by default here:
https://github.com/espressif/esp-lwip/b ... pt.h#L2364
Packet checked and discarded if invalid here:
https://github.com/espressif/esp-lwip/b ... udp.c#L331
https://github.com/espressif/esp-lwip/b ... pt.h#L2364
Packet checked and discarded if invalid here:
https://github.com/espressif/esp-lwip/b ... udp.c#L331
Re: Checksums in UDP telegrams
Hi boarchuz,
ok if I get your answer correctly, you mean it should discard corrupt telegrams by default ?
Meanwhile I checked it by sending UDP telegrams with a corrupt checksums (using packETH), but it still receives it. Wireshark also marks this telegrams corrupt. Not sure, maybe I use the wrong functions? I just create and bind a socket with the functions socket(), bind() and then read from it with recvfrom(). I've got this from: https://github.com/espressif/esp-idf/bl ... p_server.c
any idea what I'm doing wrong ?
Thanks and regards
ok if I get your answer correctly, you mean it should discard corrupt telegrams by default ?
Meanwhile I checked it by sending UDP telegrams with a corrupt checksums (using packETH), but it still receives it. Wireshark also marks this telegrams corrupt. Not sure, maybe I use the wrong functions? I just create and bind a socket with the functions socket(), bind() and then read from it with recvfrom(). I've got this from: https://github.com/espressif/esp-idf/bl ... p_server.c
any idea what I'm doing wrong ?
Thanks and regards
-
- Posts: 9043
- Joined: Thu Nov 26, 2015 4:08 am
Re: Checksums in UDP telegrams
Note that some network/wifi devices have the ability to calculate CRCs for packets they send themselves; unless you disable that somehow (depends on the driver) they may not even be able to send corrupted packets, even if Wireshark (running on the same pc as you send the packets) indicates they're corrupt when leaving the software layer.
Re: Checksums in UDP telegrams
yes I use Wireshark on the same machine as I send out the UDP telegrams to the ESP32. I use dumpcap -I on a linux machine for the dump and then analyse it with Wireshark. The UDP packets are generated with PackETH, which allows to generate a checksum automatically or by hand. In the raw data the corresponding checksums show up before the payload data. In the good and bad checksum case the ESP32 accepts this package.
For me it looks like the checksum check is not enabled by default:
From: https://github.com/espressif/esp-lwip/b ... pt.h#L2364
but this means if the name CHECKSUM_CHECK_UDP is not defined, then define it and use a 1 as value. On the top of opt.h the file lwipopts.h is included and there it is defined:
From: https://github.com/espressif/esp-idf/bl ... pts.h#L964
Thus it is disabled by default. If I change it to 1 then the ESP32 discards the corrupt telegram.
But for me chaning it in lwipopts.h is not a good way, as this is part of the framework and I want to define it in my code as this is specific to my project.
Does anyone know how I can handle this ?
Thanks and regards
For me it looks like the checksum check is not enabled by default:
From: https://github.com/espressif/esp-lwip/b ... pt.h#L2364
Code: Select all
#if !defined CHECKSUM_CHECK_UDP || defined __DOXYGEN__
#define CHECKSUM_CHECK_UDP 1
#endif
From: https://github.com/espressif/esp-idf/bl ... pts.h#L964
Code: Select all
#define CHECKSUM_CHECK_UDP 0
But for me chaning it in lwipopts.h is not a good way, as this is part of the framework and I want to define it in my code as this is specific to my project.
Does anyone know how I can handle this ?
Thanks and regards
Re: Checksums in UDP telegrams
Sorry, I missed that one earlier.
You could copy and modify lwip in your project's local components folder if you want to change it without messing with your IDF directory (https://docs.espressif.com/projects/esp ... -same-name).
This looks like a useful option to expose via menuconfig.
You could copy and modify lwip in your project's local components folder if you want to change it without messing with your IDF directory (https://docs.espressif.com/projects/esp ... -same-name).
This looks like a useful option to expose via menuconfig.
Re: Checksums in UDP telegrams
thanks boarchuz, your suggestion is what I was looking for
Who is online
Users browsing this forum: MicroController and 118 guests