summaryrefslogtreecommitdiff
path: root/Kernel/Net/TCPSocket.h
diff options
context:
space:
mode:
authorConrad Pankoff <deoxxa@fknsrs.biz>2019-09-08 17:38:08 +1000
committerAndreas Kling <awesomekling@gmail.com>2019-09-08 12:34:20 +0200
commit117d8db2a2167d97ace675d9a5821a91a6955899 (patch)
treef0ccf7decc19018c28a3be294d51380626fef756 /Kernel/Net/TCPSocket.h
parentb8e3c7ef015b0a888742e1d6973756aebfdf8bc2 (diff)
downloadserenity-117d8db2a2167d97ace675d9a5821a91a6955899.zip
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.
Diffstat (limited to 'Kernel/Net/TCPSocket.h')
-rw-r--r--Kernel/Net/TCPSocket.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index adef5d9802..1a1c1cbced 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -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;
};