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)
|
1379 | 1379 | if ((segment.flags & TCP_FLAG_PUSH) != 0) |
1380 | 1380 | fReceiveQueue.SetPushPointer(); |
1381 | 1381 | |
| 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 | |
1382 | 1389 | return fReceiveQueue.Available() > 0; |
1383 | 1390 | } |
1384 | 1391 | |
… |
… |
TCPEndpoint::_Acknowledged(tcp_segment_header& segment)
|
2295 | 2302 | } |
2296 | 2303 | |
2297 | 2304 | 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)); |
2301 | 2309 | |
2302 | 2310 | fSendTime = 0; |
2303 | 2311 | |
… |
… |
TCPEndpoint::_Retransmit()
|
2327 | 2335 | if (fState < ESTABLISHED) { |
2328 | 2336 | fRetransmitTimeout = TCP_SYN_RETRANSMIT_TIMEOUT; |
2329 | 2337 | 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; |
2330 | 2353 | } else { |
2331 | 2354 | _ResetSlowStart(); |
2332 | 2355 | fDuplicateAcknowledgeCount = 0; |