{
  "id": "networking/udp-socket-buffer-overflow",
  "signature": "UDP: socket receive buffer overflow on port 12345, 5000 packets dropped",
  "signature_zh": "UDP: 端口 12345 上的套接字接收缓冲区溢出，丢弃了 5000 个数据包",
  "regex": "UDP: socket receive buffer overflow on port \\d+, \\d+ packets dropped",
  "domain": "networking",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "UDP socket buffer overflow occurs when the application does not read data fast enough from the receive buffer, causing the kernel to drop incoming packets to prevent memory exhaustion.",
  "root_cause_type": "generic",
  "root_cause_zh": "UDP 套接字缓冲区溢出发生在应用程序未能足够快地从接收缓冲区读取数据时，导致内核丢弃传入数据包以防止内存耗尽。",
  "versions": [
    {
      "version": "Linux kernel 5.15+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Linux kernel 6.5+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "FreeBSD 13.1+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "任意增加套接字接收缓冲区大小（例如 net.core.rmem_max = 10000000）可能延迟溢出，但无法解决应用程序处理速度慢的问题。",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "重启应用程序或服务器会暂时清空缓冲区，但如果应用程序的读取速率与传入流量速率不匹配，溢出会再次发生。",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "禁用 UDP 校验和卸载可能减少 CPU 负载，但无法解决由应用程序级背压引起的缓冲区溢出。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the UDP receive buffer size system-wide: sysctl -w net.core.rmem_max=26214400 && sysctl -w net.core.rmem_default=26214400, then restart the application.",
      "success_rate": 0.8,
      "how": "Increase the UDP receive buffer size system-wide: sysctl -w net.core.rmem_max=26214400 && sysctl -w net.core.rmem_default=26214400, then restart the application.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Optimize the application to read UDP packets in larger batches or use non-blocking I/O: In Python, use socket.setblocking(0) and a loop to drain the buffer.",
      "success_rate": 0.85,
      "how": "Optimize the application to read UDP packets in larger batches or use non-blocking I/O: In Python, use socket.setblocking(0) and a loop to drain the buffer.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the SO_RCVBUF socket option to set a larger buffer per socket: In C, setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));",
      "success_rate": 0.8,
      "how": "Use the SO_RCVBUF socket option to set a larger buffer per socket: In C, setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the UDP receive buffer size system-wide: sysctl -w net.core.rmem_max=26214400 && sysctl -w net.core.rmem_default=26214400, then restart the application.",
    "Optimize the application to read UDP packets in larger batches or use non-blocking I/O: In Python, use socket.setblocking(0) and a loop to drain the buffer.",
    "Use the SO_RCVBUF socket option to set a larger buffer per socket: In C, setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.kernel.org/doc/html/latest/networking/udp.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-08-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}