From 3cc33b3e78a1de0ef5b2d3a3588ca4bef44c1bce Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Tue, 26 Sep 2023 10:10:38 +0200
Subject: [PATCH] L2SS-1538: Explain how to increase UDP buffer size

---
 .../tangostationcontrol/clients/udp_receiver.py             | 6 +++++-
 .../tangostationcontrol/devices/sdp/statistics.py           | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tangostationcontrol/tangostationcontrol/clients/udp_receiver.py b/tangostationcontrol/tangostationcontrol/clients/udp_receiver.py
index c8d364c7b..52170d543 100644
--- a/tangostationcontrol/tangostationcontrol/clients/udp_receiver.py
+++ b/tangostationcontrol/tangostationcontrol/clients/udp_receiver.py
@@ -83,11 +83,15 @@ class UDPReceiver(Thread, StatisticsClientThread):
         )
 
         if self.parameters["recv_buffer_size"] < self.options["recv_buffer_size"]:
+            # Typically this is the host OS not allowing us to allocate buffers
+            # of this size. Try increasing it using (as root):
+            #     sysctl -w net.core.rmem_max=$((16*1024*1024))
             logger.error(
                 f"OS does not allow requested buffer size. "
                 f"This could result in UDP packet loss. "
                 f'Requested {self.options["recv_buffer_size"]} bytes, '
-                f'got {self.parameters["recv_buffer_size"]}.'
+                f'got {self.parameters["recv_buffer_size"]}. Verify '
+                f'if "sysctl net.core.rmem_max" is sufficiently large.'
             )
 
         # specify what host and port to listen on
diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py
index 1c8f0de55..fe1f10932 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py
@@ -58,6 +58,7 @@ class Statistics(OPCUADevice):
     )
     # size of UDP receive buffer
     udp_recv_buffer_size_R = AttributeWrapper(
+        doc="Buffer size for receiving UDP packets.",
         comms_id=StatisticsClient,
         comms_annotation={"type": "udp", "parameter": "recv_buffer_size"},
         datatype=numpy.uint64,
-- 
GitLab