1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 15:34:58 +00:00

Kernel: Trigger TCP fast retransmission when we encounter lost packets

When we receive a TCP packet with a sequence number that is not what
we expected we have lost one or more packets. We can signal this to
the sender by sending a TCP ACK with the previous ack number so that
they can resend the missing TCP fragments.
This commit is contained in:
Gunnar Beutner 2021-05-12 08:13:53 +02:00 committed by Andreas Kling
parent 7272127927
commit ffc6b714b0
2 changed files with 14 additions and 0 deletions

View file

@ -533,9 +533,16 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const Time& packet_timestamp)
if (tcp_packet.sequence_number() != socket->ack_number()) {
dbgln_if(TCP_DEBUG, "Discarding out of order packet: seq {} vs. ack {}", tcp_packet.sequence_number(), socket->ack_number());
if (socket->duplicate_acks() < TCPSocket::maximum_duplicate_acks) {
dbgln_if(TCP_DEBUG, "Sending ACK with same ack number to trigger fast retransmission");
socket->set_duplicate_acks(socket->duplicate_acks() + 1);
unused_rc = socket->send_tcp_packet(TCPFlags::ACK);
}
return;
}
socket->set_duplicate_acks(0);
if (tcp_packet.has_fin()) {
if (payload_size != 0)
socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp);