@@ -511,7 +511,9 @@ struct reliable_endpoint_t
511
511
float rtt_min ;
512
512
float rtt_max ;
513
513
float rtt_avg ;
514
- float jitter ;
514
+ float jitter_avg_vs_min_rtt ;
515
+ float jitter_max_vs_min_rtt ;
516
+ float jitter_stddev_vs_avg_rtt ;
515
517
float packet_loss ;
516
518
float sent_bandwidth_kbps ;
517
519
float received_bandwidth_kbps ;
@@ -1384,7 +1386,7 @@ void reliable_endpoint_update( struct reliable_endpoint_t * endpoint, double tim
1384
1386
}
1385
1387
}
1386
1388
1387
- // calculate jitter
1389
+ // calculate average jitter vs. min rtt
1388
1390
{
1389
1391
float sum = 0.0f ;
1390
1392
int count = 0 ;
@@ -1398,11 +1400,51 @@ void reliable_endpoint_update( struct reliable_endpoint_t * endpoint, double tim
1398
1400
}
1399
1401
if ( count > 0 )
1400
1402
{
1401
- endpoint -> jitter = sum / (float )count ;
1403
+ endpoint -> jitter_avg_vs_min_rtt = sum / (float )count ;
1402
1404
}
1403
1405
else
1404
1406
{
1405
- endpoint -> jitter = 0.0f ;
1407
+ endpoint -> jitter_avg_vs_min_rtt = 0.0f ;
1408
+ }
1409
+ }
1410
+
1411
+ // calculate max jitter vs. min rtt
1412
+ {
1413
+ float max = 0.0f ;
1414
+ for ( int i = 0 ; i < endpoint -> config .rtt_history_size ; i ++ )
1415
+ {
1416
+ if ( endpoint -> rtt_history_buffer [i ] >= 0.0f )
1417
+ {
1418
+ float difference = ( endpoint -> rtt_history_buffer [i ] - endpoint -> rtt_min );
1419
+ if ( difference > max )
1420
+ {
1421
+ max = difference ;
1422
+ }
1423
+ }
1424
+ }
1425
+ endpoint -> jitter_max_vs_min_rtt = max ;
1426
+ }
1427
+
1428
+ // calculate stddev jitter vs. avg rtt
1429
+ {
1430
+ float sum = 0.0f ;
1431
+ int count = 0 ;
1432
+ for ( int i = 0 ; i < endpoint -> config .rtt_history_size ; i ++ )
1433
+ {
1434
+ if ( endpoint -> rtt_history_buffer [i ] >= 0.0f )
1435
+ {
1436
+ float deviation = ( endpoint -> rtt_history_buffer [i ] - endpoint -> rtt_min );
1437
+ sum += deviation * deviation ;
1438
+ count ++ ;
1439
+ }
1440
+ }
1441
+ if ( count > 0 )
1442
+ {
1443
+ endpoint -> jitter_stddev_vs_avg_rtt = pow ( sum / (float )count , 0.5f );
1444
+ }
1445
+ else
1446
+ {
1447
+ endpoint -> jitter_stddev_vs_avg_rtt = 0.0f ;
1406
1448
}
1407
1449
}
1408
1450
@@ -1592,10 +1634,23 @@ float reliable_endpoint_rtt_avg( struct reliable_endpoint_t * endpoint )
1592
1634
return endpoint -> rtt_avg ;
1593
1635
}
1594
1636
1595
- float reliable_endpoint_jitter ( struct reliable_endpoint_t * endpoint )
1637
+ float reliable_endpoint_jitter_avg_vs_min_rtt ( struct reliable_endpoint_t * endpoint )
1638
+ {
1639
+ reliable_assert ( endpoint );
1640
+ return endpoint -> jitter_avg_vs_min_rtt ;
1641
+ }
1642
+
1643
+ float reliable_endpoint_jitter_max_vs_min_rtt ( struct reliable_endpoint_t * endpoint )
1644
+ {
1645
+ reliable_assert ( endpoint );
1646
+ return endpoint -> jitter_max_vs_min_rtt ;
1647
+ }
1648
+
1649
+
1650
+ float reliable_endpoint_jitter_stddev_vs_avg_rtt ( struct reliable_endpoint_t * endpoint )
1596
1651
{
1597
1652
reliable_assert ( endpoint );
1598
- return endpoint -> jitter ;
1653
+ return endpoint -> jitter_stddev_vs_avg_rtt ;
1599
1654
}
1600
1655
1601
1656
float reliable_endpoint_packet_loss ( struct reliable_endpoint_t * endpoint )
0 commit comments