Author Topic: UDP socket buffer size  (Read 1995 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
UDP socket buffer size
« on: November 10, 2023, 02:56:45 PM »
Hi Mark
  Hope you are keeping well...

Where do I find max buffer size of a received UDP packet?  My application can transmit 1k of data and want to make sure the buffer is large enough to hold this

Best Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UDP socket buffer size
« Reply #1 on: November 10, 2023, 11:19:52 PM »
Hi Neil

As long as the Ethernet Rx buffer can hold the UDP reception it will be adequate - your receive the UDP packet directly in that buffer:

#define LAN_BUFFER_SIZE        1518

is adequate for the largest Ethernet frame (excluding jumbo frames) and so UDP payload (over IPv4) is limited to 1492 bytes (I believe) - this assumes no fragmentation, which will be the case in modern local networks.

Regards

Mark