[simulation] increase socket receive buffer size to 2MB (#13173)

This commit sets the SO_RCVBUF socket option to 2MB on the
multicast receiving sockets in the simulation platform.

Under heavy simulation load (such as expect tests with 15 nodes
all sending MLE advertisements and discovery packets), the default
OS UDP receive socket buffer can overflow, leading to silent
packet drops. This occasionally caused expect tests like
cli-big-table.exp to fail with "Join failed [NotFound]" because
Node 4's discovery requests or response beacons were dropped.

Increasing the receive buffer size to 2MB prevents packet loss
during dense simulation runs, resolving intermittent CI test
failures.
This commit is contained in:
Jonathan Hui
2026-05-28 16:52:16 -07:00
committed by GitHub
parent fa374236a5
commit e1b34bc5bc
@@ -91,6 +91,7 @@ static void InitRxSocket(utilsSocket *aSocket,
int fd; int fd;
int one = 1; int one = 1;
int rval; int rval;
int rcvBufSize = 2 * 1024 * 1024;
fd = socket(aIp4Address ? AF_INET : AF_INET6, SOCK_DGRAM, IPPROTO_UDP); fd = socket(aIp4Address ? AF_INET : AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
ExpectOrExitWithErrorMsg(fd != -1, "socket(RxFd)"); ExpectOrExitWithErrorMsg(fd != -1, "socket(RxFd)");
@@ -101,6 +102,9 @@ static void InitRxSocket(utilsSocket *aSocket,
rval = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)); rval = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
ExpectOrExitWithErrorMsg(rval != -1, "setsockopt(RxFd, SO_REUSEPORT)"); ExpectOrExitWithErrorMsg(rval != -1, "setsockopt(RxFd, SO_REUSEPORT)");
rval = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvBufSize, sizeof(rcvBufSize));
ExpectOrExitWithErrorMsg(rval != -1, "setsockopt(RxFd, SO_RCVBUF)");
if (aIp4Address) if (aIp4Address)
{ {
struct ip_mreqn mreq; struct ip_mreqn mreq;