From a53635b1acba058f017426ea7de7c3da5771982f Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Thu, 5 Mar 2026 20:26:46 +0100 Subject: [PATCH] TCP: Send FIFO max size (though not exposed at the moment) --- common/JfjochTCP.h | 2 +- docs/IMAGE_STREAM.md | 30 +++++++++++++++--------------- image_puller/TCPImagePuller.cpp | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common/JfjochTCP.h b/common/JfjochTCP.h index 268adc66..e945613b 100644 --- a/common/JfjochTCP.h +++ b/common/JfjochTCP.h @@ -48,5 +48,5 @@ struct alignas(64) TcpFrameHeader { uint16_t ack_code = 0; uint16_t ack_for = 0; uint64_t ack_fifo_occupancy = 0; - uint64_t reserved = 0; + uint64_t ack_fifo_max_occupancy = 0; }; \ No newline at end of file diff --git a/docs/IMAGE_STREAM.md b/docs/IMAGE_STREAM.md index fc2b369f..4ccb9e07 100644 --- a/docs/IMAGE_STREAM.md +++ b/docs/IMAGE_STREAM.md @@ -125,21 +125,21 @@ On Linux, large payload transmission (`DATA` and `CALIBRATION` frames) can use k #### TCP frame header (`TcpFrameHeader`) -| Field | Type | Description | -|------------------------|---|----------------------------------------------------------| -| `magic` | `uint32_t` | Protocol magic (`0x4A464A54`, `"JFJT"`) | -| `version` | `uint16_t` | Protocol version (`2`) | -| `type` | `uint16_t` | Frame type (see table above) | -| `image_number` | `uint64_t` | Image index for `DATA` frames | -| `payload_size` | `uint64_t` | Number of payload bytes after header | -| `socket_number` | `uint32_t` | Connection index in split-stream mode | -| `flags` | `uint32_t` | ACK flags (`OK`, `FATAL`, `HAS_ERROR_TEXT`) | -| `run_number` | `uint64_t` | Run identifier | -| `ack_processed_images` | `uint32_t` | In `ACK`: number of images processed by receiver | -| `ack_code` | `uint16_t` | In `ACK`: error/status code | -| `ack_for` | `uint16_t` | In `ACK`: frame type being acknowledged | -| `ack_fifo_occupancy` | `uint16_t` | In `ACK`: occupancy of input FIFO in the `jfjoch_writer` | -| `reserved` | `uint64_t` | Reserved, set to `0` | +| Field | Type | Description | +|--------------------------|---|----------------------------------------------------------| +| `magic` | `uint32_t` | Protocol magic (`0x4A464A54`, `"JFJT"`) | +| `version` | `uint16_t` | Protocol version (`2`) | +| `type` | `uint16_t` | Frame type (see table above) | +| `image_number` | `uint64_t` | Image index for `DATA` frames | +| `payload_size` | `uint64_t` | Number of payload bytes after header | +| `socket_number` | `uint32_t` | Connection index in split-stream mode | +| `flags` | `uint32_t` | ACK flags (`OK`, `FATAL`, `HAS_ERROR_TEXT`) | +| `run_number` | `uint64_t` | Run identifier | +| `ack_processed_images` | `uint32_t` | In `ACK`: number of images processed by receiver | +| `ack_code` | `uint16_t` | In `ACK`: error/status code | +| `ack_for` | `uint16_t` | In `ACK`: frame type being acknowledged | +| `ack_fifo_occupancy` | `uint16_t` | In `ACK`: occupancy of input FIFO in the `jfjoch_writer` | +| `ack_fifo_max_occupancy` | `uint64_t` | In `ACK`: max occupancy of input FIFO | The header is 64-byte aligned (`alignas(64)`). diff --git a/image_puller/TCPImagePuller.cpp b/image_puller/TCPImagePuller.cpp index 0077b051..f1e83ee2 100644 --- a/image_puller/TCPImagePuller.cpp +++ b/image_puller/TCPImagePuller.cpp @@ -109,6 +109,7 @@ bool TCPImagePuller::SendAck(const PullerAckMessage &ack) { h.ack_code = static_cast(ack.error_code); h.payload_size = ack.error_text.size(); h.ack_fifo_occupancy = cbor_fifo.GetCurrentUtilization(); + h.ack_fifo_max_occupancy = cbor_fifo.Size(); if (!SendAll(&h, sizeof(h))) return false;