Skip to content

Commit c70f96d

Browse files
authored
Merge pull request #16 from chenfeixyz/master
rto值计算fix
2 parents c74e526 + cd0a3dc commit c70f96d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

KCP/KCP.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,19 @@ void update_ack(Int32 rtt)
432432
else
433433
{
434434
Int32 delta = (Int32)((UInt32)rtt - rx_srtt);
435+
rx_srtt += (UInt32)(delta >> 3);
435436
if (0 > delta) delta = -delta;
436437

437438
if (rtt < rx_srtt - rx_rttval)
438439
{
439440
// if the new RTT sample is below the bottom of the range of
440441
// what an RTT measurement is expected to be.
441-
// give an 8x reduced weight versus its normal weighting
442-
rx_rttval += ((uint)delta - rx_rttval) >> 5;
442+
// give an 8x reduced weight versus its normal weighting
443+
rx_rttval += (uint)((delta - rx_rttval) >> 5);
443444
}
444445
else
445446
{
446-
rx_rttval += ((uint)delta - rx_rttval) >> 2;
447+
rx_rttval += (uint)((delta - rx_rttval) >> 2);
447448
}
448449
}
449450

0 commit comments

Comments
 (0)