Skip to content

UDP socket settings#362

Merged
corrodis merged 5 commits intodevelopfrom
sc/UDP
Mar 6, 2026
Merged

UDP socket settings#362
corrodis merged 5 commits intodevelopfrom
sc/UDP

Conversation

@corrodis
Copy link
Contributor

@corrodis corrodis commented Mar 5, 2026

changed to UDP settings to allow a 'large' amount of data to be sent to the top level

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves UDP socket settings to support sending large amounts of data (e.g., configuration dumps) between remote gateways. It parameterizes previously hardcoded values in acknowledge() and sendAndReceive(), and updates the remote gateway socket to use a 4MB receive buffer.

Changes:

  • acknowledge() in TransceiverSocket now accepts a configurable maxChunkSize parameter (defaulting to 1500) instead of a hardcoded constant, allowing larger UDP datagrams (up to 65500 bytes) when sending large payloads.
  • sendAndReceive() in TransceiverSocket now accepts a configurable interPacketTimeoutUSeconds parameter (defaulting to 10000 µs) instead of a hardcoded 10ms, enabling longer wait between packets for large multi-packet responses.
  • GatewaySupervisor is updated to initialize the remote gateway socket with a 4MB receive buffer, use 200ms inter-packet timeout for command responses, and emit more informative diagnostic messages on timeout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
otsdaq/NetworkUtilities/TransceiverSocket.h Adds maxChunkSize and interPacketTimeoutUSeconds parameters to acknowledge() and sendAndReceive()
otsdaq/NetworkUtilities/TransceiverSocket.cc Implements the new parameters, replacing hardcoded 1500 and 10000 constants
otsdaq/GatewaySupervisor/GatewaySupervisor.cc Increases receive buffer to 4MB, uses 200ms inter-packet timeout for commands, and improves timeout error diagnostics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2843 to +2863
if(commandResponseString.empty())
{
ss << "No data was received at all.";
}
else
{
const size_t maxPrint = 500;
ss << "Received " << commandResponseString.size() << " bytes so far. ";
if(commandResponseString.size() <= maxPrint)
{
ss << "Full received text: [" << commandResponseString << "]";
}
else
{
ss << "First " << maxPrint << " chars: ["
<< commandResponseString.substr(0, maxPrint) << "] ... Last "
<< maxPrint << " chars: ["
<< commandResponseString.substr(commandResponseString.size() -
maxPrint)
<< "]";
}
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check if(commandResponseString.empty()) at line 2843 can never be true. The code only reaches this block when commandResponseString.size() > strlen("Done") + 1 (i.e., the string is non-empty with more than 5 characters). The additional receive calls in the loop can only append data to commandResponseString, never empty it. The "No data was received at all." branch is therefore dead code.

Consider removing the dead commandResponseString.empty() branch, or restructuring the logic to check the initial empty state before this block.

Suggested change
if(commandResponseString.empty())
{
ss << "No data was received at all.";
}
else
{
const size_t maxPrint = 500;
ss << "Received " << commandResponseString.size() << " bytes so far. ";
if(commandResponseString.size() <= maxPrint)
{
ss << "Full received text: [" << commandResponseString << "]";
}
else
{
ss << "First " << maxPrint << " chars: ["
<< commandResponseString.substr(0, maxPrint) << "] ... Last "
<< maxPrint << " chars: ["
<< commandResponseString.substr(commandResponseString.size() -
maxPrint)
<< "]";
}
const size_t maxPrint = 500;
ss << "Received " << commandResponseString.size() << " bytes so far. ";
if(commandResponseString.size() <= maxPrint)
{
ss << "Full received text: [" << commandResponseString << "]";
}
else
{
ss << "First " << maxPrint << " chars: ["
<< commandResponseString.substr(0, maxPrint) << "] ... Last "
<< maxPrint << " chars: ["
<< commandResponseString.substr(commandResponseString.size() -
maxPrint)
<< "]";

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point but I think it doesn't really hurt to keep this in

<< std::endl;

constexpr size_t MAX_SEND_SIZE = 1500;
const size_t MAX_SEND_SIZE = maxChunkSize;
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local variable MAX_SEND_SIZE is a redundant alias for maxChunkSize — it is initialized from maxChunkSize and never modified. Consider using maxChunkSize directly throughout the function body to reduce indirection and make the code clearer.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@rrivera747 rrivera747 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks!

@corrodis corrodis merged commit 3f7e1ed into develop Mar 6, 2026
11 checks passed
@corrodis corrodis deleted the sc/UDP branch March 6, 2026 23:18
@github-project-automation github-project-automation bot moved this from 📋 Triage to 🎉 Done in art-daq Work Tracker Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants