espressif / esp-protocols

Collection of ESP-IDF components related to networking protocols
181 stars 126 forks source link

[BUG] mDNS stops working with heavy UDP load (IDFGH-12307) #524

Closed MrozMarcin closed 6 months ago

MrozMarcin commented 6 months ago

Answers checklist.

General issue report

What component are you using? If you choose Other, provide details in More Information.

mdns

Component version

1.2.5

IDF version.

SDK V5.3

More Information.

I'm using mDNS with just one service. The mDNS component works stable when there is no parallel UDP load or when UDP packets are not fragmented (so with payload under 1460 bytes in my case) but fails when there is heavy parallel load (in my case 83k bytes per second) with UDP fragmented packets. Failure manifests itself through allocating internal memory in the mdns task till no heap is left and ESP32 stops responding to mdns queries. In my case, LWIP uses PSRAM, so I can still keep sending UDP packets and receive mdns queries after failure has happened.

I keep tracking the heap in my tasks via esp_dump_per_task_heap_info(); I kept checking heap integrity via heap_caps_check_integrity(MALLOC_CAP_INTERNAL, true) and everything seemed fine.

Before failure, the mdns task has allocated 140 bytes and during failure mdns alocates more than 23k bytes

MrozMarcin commented 6 months ago

After some debugging I spotted that esp_timer stops triggering _mdns_timer_cb() and that causes those TX packet allocations - bug it's not connected directly to this component so I'm closing this issue.

MrozMarcin commented 6 months ago

I think that using esp_timer is overkill (quite wastefull) and software timer implemened in FreeRTOS is good enough since we are using several FreeRTOS components anyway