@@ -1393,6 +1393,7 @@ void reliable_endpoint_update( struct reliable_endpoint_t * endpoint, double tim
1393
1393
if ( endpoint -> rtt_history_buffer [i ] >= 0.0f )
1394
1394
{
1395
1395
sum += endpoint -> rtt_history_buffer [i ];
1396
+ count ++ ;
1396
1397
}
1397
1398
}
1398
1399
if ( count > 0 )
@@ -1409,26 +1410,37 @@ void reliable_endpoint_update( struct reliable_endpoint_t * endpoint, double tim
1409
1410
{
1410
1411
uint32_t base_sequence = ( endpoint -> sent_packets -> sequence - endpoint -> config .sent_packets_buffer_size + 1 ) + 0xFFFF ;
1411
1412
int i ;
1413
+ int num_sent = 0 ;
1412
1414
int num_dropped = 0 ;
1413
1415
int num_samples = endpoint -> config .sent_packets_buffer_size / 2 ;
1414
1416
for ( i = 0 ; i < num_samples ; ++ i )
1415
1417
{
1416
1418
uint16_t sequence = (uint16_t ) ( base_sequence + i );
1417
- struct reliable_sent_packet_data_t * sent_packet_data = (struct reliable_sent_packet_data_t * )
1418
- reliable_sequence_buffer_find ( endpoint -> sent_packets , sequence );
1419
- if ( sent_packet_data && !sent_packet_data -> acked )
1419
+ struct reliable_sent_packet_data_t * sent_packet_data = (struct reliable_sent_packet_data_t * ) reliable_sequence_buffer_find ( endpoint -> sent_packets , sequence );
1420
+ if ( sent_packet_data )
1420
1421
{
1421
- num_dropped ++ ;
1422
+ num_sent ++ ;
1423
+ if ( !sent_packet_data -> acked )
1424
+ {
1425
+ num_dropped ++ ;
1426
+ }
1422
1427
}
1423
1428
}
1424
- float packet_loss = ( (float ) num_dropped ) / ( (float ) num_samples ) * 100.0f ;
1425
- if ( fabs ( endpoint -> packet_loss - packet_loss ) > 0.00001 )
1429
+ if ( num_sent > 0 )
1426
1430
{
1427
- endpoint -> packet_loss += ( packet_loss - endpoint -> packet_loss ) * endpoint -> config .packet_loss_smoothing_factor ;
1431
+ float packet_loss = ( (float ) num_dropped ) / ( (float ) num_sent ) * 100.0f ;
1432
+ if ( fabs ( endpoint -> packet_loss - packet_loss ) > 0.00001 )
1433
+ {
1434
+ endpoint -> packet_loss += ( packet_loss - endpoint -> packet_loss ) * endpoint -> config .packet_loss_smoothing_factor ;
1435
+ }
1436
+ else
1437
+ {
1438
+ endpoint -> packet_loss = packet_loss ;
1439
+ }
1428
1440
}
1429
1441
else
1430
1442
{
1431
- endpoint -> packet_loss = packet_loss ;
1443
+ endpoint -> packet_loss = 0.0f ;
1432
1444
}
1433
1445
}
1434
1446
0 commit comments