1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

Kernel: Implement outgoing TCP retransmission and better ACK handling

This approach is a bit naiive - whenever we send a packet out, we
check to see if there are any other packets we should try to send.
This works well enough for a busy connection but not very well for a
quiet one. Ideally we would check for not-acked packets on some kind
of timer, and use the length of this not-acked list as feedback to
throttle the writes coming from userspace.
This commit is contained in:
Conrad Pankoff 2019-09-08 17:38:08 +10:00 committed by Andreas Kling
parent b8e3c7ef01
commit 117d8db2a2
3 changed files with 90 additions and 28 deletions

View file

@ -1,6 +1,8 @@
#pragma once
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/SinglyLinkedList.h>
#include <AK/WeakPtr.h>
#include <Kernel/Net/IPv4Socket.h>
@ -119,7 +121,8 @@ public:
u32 bytes_out() const { return m_bytes_out; }
void send_tcp_packet(u16 flags, const void* = nullptr, int = 0);
void record_incoming_data(int);
void send_outgoing_packets();
void receive_tcp_packet(const TCPPacket&, u16 size);
static Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& sockets_by_tuple();
static RefPtr<TCPSocket> from_tuple(const IPv4SocketTuple& tuple);
@ -159,4 +162,13 @@ private:
u32 m_bytes_in { 0 };
u32 m_packets_out { 0 };
u32 m_bytes_out { 0 };
struct OutgoingPacket {
u32 ack_number;
ByteBuffer buffer;
int tx_counter { 0 };
timeval tx_time;
};
SinglyLinkedList<OutgoingPacket> m_not_acked;
};