@@ -1410,6 +1410,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
1410
1410
(m_max_data_packets_per_iteration/numpeers));
1411
1411
1412
1412
channel->UpdatePacketLossCounter (timed_outs.size ());
1413
+ g_profiler->graphAdd (" packets_lost" , timed_outs.size ());
1413
1414
1414
1415
m_iteration_packets_avaialble -= timed_outs.size ();
1415
1416
@@ -1421,6 +1422,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
1421
1422
u16 seqnum = readU16 (&(k->data [BASE_HEADER_SIZE+1 ]));
1422
1423
1423
1424
channel->UpdateBytesLost (k->data .getSize ());
1425
+ k->resend_count ++;
1424
1426
1425
1427
LOG (derr_con<<m_connection->getDesc ()
1426
1428
<<" RE-SENDING timed-out RELIABLE to "
@@ -2349,24 +2351,30 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
2349
2351
try {
2350
2352
BufferedPacket p =
2351
2353
channel->outgoing_reliables_sent .popSeqnum (seqnum);
2352
- // Get round trip time
2353
- unsigned int current_time = porting::getTimeMs ();
2354
2354
2355
- if (current_time > p.absolute_send_time )
2356
- {
2357
- float rtt = (current_time - p.absolute_send_time ) / 1000.0 ;
2355
+ // only calculate rtt from straight sent packets
2356
+ if (p.resend_count == 0 ) {
2357
+ // Get round trip time
2358
+ unsigned int current_time = porting::getTimeMs ();
2358
2359
2359
- // Let peer calculate stuff according to it
2360
- // (avg_rtt and resend_timeout)
2361
- dynamic_cast <UDPPeer*>(&peer)->reportRTT (rtt);
2362
- }
2363
- else if (p.totaltime > 0 )
2364
- {
2365
- float rtt = p.totaltime ;
2360
+ // a overflow is quite unlikely but as it'd result in major
2361
+ // rtt miscalculation we handle it here
2362
+ if (current_time > p.absolute_send_time )
2363
+ {
2364
+ float rtt = (current_time - p.absolute_send_time ) / 1000.0 ;
2366
2365
2367
- // Let peer calculate stuff according to it
2368
- // (avg_rtt and resend_timeout)
2369
- dynamic_cast <UDPPeer*>(&peer)->reportRTT (rtt);
2366
+ // Let peer calculate stuff according to it
2367
+ // (avg_rtt and resend_timeout)
2368
+ dynamic_cast <UDPPeer*>(&peer)->reportRTT (rtt);
2369
+ }
2370
+ else if (p.totaltime > 0 )
2371
+ {
2372
+ float rtt = p.totaltime ;
2373
+
2374
+ // Let peer calculate stuff according to it
2375
+ // (avg_rtt and resend_timeout)
2376
+ dynamic_cast <UDPPeer*>(&peer)->reportRTT (rtt);
2377
+ }
2370
2378
}
2371
2379
// put bytes for max bandwidth calculation
2372
2380
channel->UpdateBytesSent (p.data .getSize (),1 );
@@ -2542,7 +2550,8 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
2542
2550
2543
2551
// we already have this packet so this one was on wire at least
2544
2552
// the current timeout
2545
- dynamic_cast <UDPPeer*>(&peer)->reportRTT (dynamic_cast <UDPPeer*>(&peer)->getResendTimeout ());
2553
+ // we don't know how long this packet was on wire don't do silly guessing
2554
+ // dynamic_cast<UDPPeer*>(&peer)->reportRTT(dynamic_cast<UDPPeer*>(&peer)->getResendTimeout());
2546
2555
2547
2556
throw ProcessedSilentlyException (" Retransmitting ack for old packet" );
2548
2557
}
0 commit comments