mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-27 03:41:14 +03:00
Cleanup and modularize receive path, improve timestamp support [10/x]
Summary: This diff makes the fields in `NetworkData` private so that they can only be manipulated via accessors. - This will be used in a subsequent diff to make it possible to populate a new `ReceivedPacket::Timings` structure in each `ReceivedPacket` held by a `NetworkData` object with the timing information currently held in `NetworkData.` - These accessors are temporary and being used to split up the stack, so relying on existing tests to provide coverage instead of adding new tests here. -- This diff is part of a larger stack focused on the following: - **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance: - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests. - The client currently has three receive paths, and none of them are well tested. - **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers. - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples). - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives. - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer. - **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps. Reviewed By: jbeshay Differential Revision: D48724715 fbshipit-source-id: 0230ea3feea525fa15b908161f444f4f6d9d4b39
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d1f042b967
commit
cb10ddf0ce
@@ -142,9 +142,9 @@ QuicAsyncUDPSocketWrapperImpl::recvMmsg(
|
||||
size_t len = bytesRead;
|
||||
size_t remaining = len;
|
||||
size_t offset = 0;
|
||||
size_t totalNumPackets =
|
||||
networkData.packets.size() + ((len + params.gro - 1) / params.gro);
|
||||
networkData.packets.reserve(totalNumPackets);
|
||||
size_t totalNumPackets = networkData.getPackets().size() +
|
||||
((len + params.gro - 1) / params.gro);
|
||||
networkData.reserve(totalNumPackets);
|
||||
while (remaining) {
|
||||
if (static_cast<int>(remaining) > params.gro) {
|
||||
auto tmp = readBuffer->cloneOne();
|
||||
@@ -157,18 +157,18 @@ QuicAsyncUDPSocketWrapperImpl::recvMmsg(
|
||||
|
||||
offset += params.gro;
|
||||
remaining -= params.gro;
|
||||
networkData.packets.emplace_back(std::move(tmp));
|
||||
networkData.addPacket(ReceivedPacket(std::move(tmp)));
|
||||
} else {
|
||||
// do not clone the last packet
|
||||
// start at offset, use all the remaining data
|
||||
readBuffer->trimStart(offset);
|
||||
DCHECK_EQ(readBuffer->length(), remaining);
|
||||
remaining = 0;
|
||||
networkData.packets.emplace_back(std::move(readBuffer));
|
||||
networkData.addPacket(ReceivedPacket(std::move(readBuffer)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
networkData.packets.emplace_back(std::move(readBuffer));
|
||||
networkData.addPacket(ReceivedPacket(std::move(readBuffer)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user