Ticket #13634: 0006-tcp-rfc-5681-implemented-ideal-timer.patch

File 0006-tcp-rfc-5681-implemented-ideal-timer.patch, 2.4 KB (added by a-star, 7 years ago)
  • src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp

    From 4b6a45fab09efbc71ed9b1e8d53f4b38fe80c3fe Mon Sep 17 00:00:00 2001
    From: A-star-ayush <myselfthebest@yahoo.com>
    Date: Sat, 29 Jul 2017 22:25:11 +0530
    Subject: [PATCH 6/6] tcp: rfc 5681: implemented ideal timer
    
    ---
     .../kernel/network/protocols/tcp/TCPEndpoint.cpp   | 29 +++++++++++++++++++---
     1 file changed, 26 insertions(+), 3 deletions(-)
    
    diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
    index 3aaaae7..16f6bd6 100644
    a b TCPEndpoint::_AddData(tcp_segment_header& segment, net_buffer* buffer)  
    13791379    if ((segment.flags & TCP_FLAG_PUSH) != 0)
    13801380        fReceiveQueue.SetPushPointer();
    13811381
     1382    if (fSendUnacknowledged == fSendMax) {
     1383        TRACE("data received, resetting ideal timer to: %"
     1384                B_PRIdBIGTIME, fRetransmitTimeout);
     1385        gStackModule->set_timer(&fRetransmitTimer, fRetransmitTimeout);
     1386        T(TimerSet(this, "ideal", fRetransmitTimeout));
     1387    }
     1388
    13821389    return fReceiveQueue.Available() > 0;
    13831390}
    13841391
    TCPEndpoint::_Acknowledged(tcp_segment_header& segment)  
    22952302        }
    22962303
    22972304        if (fSendUnacknowledged == fSendMax) {
    2298             TRACE("all acknowledged, cancelling retransmission timer");
    2299             gStackModule->cancel_timer(&fRetransmitTimer);
    2300             T(TimerSet(this, "retransmit", -1));
     2305            TRACE("all acknowledged, cancelling retransmission timer. Using it as ideal timer for: %"
     2306                B_PRIdBIGTIME, fRetransmitTimeout);
     2307            gStackModule->set_timer(&fRetransmitTimer, fRetransmitTimeout);
     2308            T(TimerSet(this, "ideal", fRetransmitTimeout));
    23012309
    23022310            fSendTime = 0;
    23032311
    TCPEndpoint::_Retransmit()  
    23272335    if (fState < ESTABLISHED) {
    23282336        fRetransmitTimeout = TCP_SYN_RETRANSMIT_TIMEOUT;
    23292337        fCongestionWindow = fSendMaxSegmentSize;
     2338    } else if (fSendUnacknowledged == fSendMax) {
     2339        TRACE("Ideal timeout");
     2340        // idle period time out - did not receive any segment for a time equal
     2341        // to the retransmission timeout
     2342
     2343        uint32 initialWindow;
     2344        if (fSendMaxSegmentSize > 2190)
     2345            initialWindow = 2 * fSendMaxSegmentSize;
     2346        else if (fSendMaxSegmentSize > 1095)
     2347            initialWindow = 3 * fSendMaxSegmentSize;
     2348        else
     2349            initialWindow = 4 * fSendMaxSegmentSize;
     2350
     2351        fCongestionWindow = min_c(initialWindow, fCongestionWindow);
     2352        return;
    23302353    } else {
    23312354        _ResetSlowStart();
    23322355        fDuplicateAcknowledgeCount = 0;