diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index b0dc783807..c6cd0c5b3e 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace Kernel { @@ -165,8 +166,9 @@ void TCPSocket::release_for_accept(NonnullRefPtr socket) TCPSocket::TCPSocket(int protocol, NonnullOwnPtr receive_buffer, NonnullOwnPtr scratch_buffer) : IPv4Socket(SOCK_STREAM, protocol, move(receive_buffer), move(scratch_buffer)) + , m_last_ack_sent_time(TimeManagement::the().monotonic_time()) + , m_last_retransmit_time(TimeManagement::the().monotonic_time()) { - m_last_retransmit_time = kgettimeofday(); } TCPSocket::~TCPSocket() @@ -258,7 +260,7 @@ ErrorOr TCPSocket::send_tcp_packet(u16 flags, UserOrKernelBuffer const* pa if (flags & TCPFlags::ACK) { m_last_ack_number_sent = m_ack_number; - m_last_ack_sent_time = kgettimeofday(); + m_last_ack_sent_time = TimeManagement::the().monotonic_time(); tcp_packet.set_ack_number(m_ack_number); } @@ -358,7 +360,7 @@ bool TCPSocket::should_delay_next_ack() const return false; // RFC 1122 says we should not delay ACKs for more than 500 milliseconds. - if (kgettimeofday() >= m_last_ack_sent_time + Duration::from_milliseconds(500)) + if (TimeManagement::the().monotonic_time(TimePrecision::Precise) >= m_last_ack_sent_time + Duration::from_milliseconds(500)) return false; return true; @@ -585,7 +587,7 @@ void TCPSocket::dequeue_for_retransmit() void TCPSocket::retransmit_packets() { - auto now = kgettimeofday(); + auto now = TimeManagement::the().monotonic_time(); // RFC6298 says we should have at least one second between retransmits. According to // RFC1122 we must do exponential backoff - even for SYN packets. diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index d018db3d96..c6a3a90cc7 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -215,11 +216,11 @@ private: u32 m_duplicate_acks { 0 }; u32 m_last_ack_number_sent { 0 }; - UnixDateTime m_last_ack_sent_time; + MonotonicTime m_last_ack_sent_time; // FIXME: Make this configurable (sysctl) static constexpr u32 maximum_retransmits = 5; - UnixDateTime m_last_retransmit_time; + MonotonicTime m_last_retransmit_time; u32 m_retransmit_attempts { 0 }; // Default to maximum window size. receive_tcp_packet() will update from the