diff --git a/src/extension/network/NUClearNetwork.cpp b/src/extension/network/NUClearNetwork.cpp index 79c993ff..778adaa1 100644 --- a/src/extension/network/NUClearNetwork.cpp +++ b/src/extension/network/NUClearNetwork.cpp @@ -851,6 +851,15 @@ namespace extension { // We have completed this packet, discard the data assemblers.erase(assemblers.find(packet.packet_id)); } + + // Check for and delete any timed out packets + for (auto it = assemblers.begin(); it != assemblers.end();) { + const auto now = std::chrono::steady_clock::now(); + const auto timeout = remote->round_trip_time * 10.0; + const auto& last_chunk_time = it->second.first; + + it = now > last_chunk_time + timeout ? assemblers.erase(it) : std::next(it); + } } } } break;