Skip to content

Ephemeral source port not random #31

@mcspr

Description

@mcspr

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions