-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I happened to stumble upon another difference between lwip1.4 and lwip2 used by the Arduino Core - source port randomization. After reset, lwip1 always selects a random port when doing outgoing connections, while lwip2 increments port values starting from the same number. Which causes weird issues from time to time.
Some sources:
esp8266/Arduino#632
me-no-dev/ESPAsyncTCP#108
https://blog.voneicken.com/2018/lp-wifi-esp8266-2/
Core's WiFiClient has an option to select source port, but current versions of AsyncTCP does not expose such method. IDK whether this is a issue for async lib or lwip but! current versions of ESP32 and ESP8266_RTOS modify lwip to randomize it by default:
idf: espressif/esp-lwip@4cc89a0
https://github.com/espressif/esp-idf/blob/1aa8e8d38ebe688c391359b5962707c1d135d07e/components/lwip/port/esp32/include/lwipopts.h#L749
esp8266: espressif/ESP8266_RTOS_SDK@a66d130#diff-d4ffea296f65048ca90617f4680cf389