@@ -482,17 +482,35 @@ defmodule ExICE.Priv.ICEAgent do
482
482
remote_cand = Map . fetch! ( ice_agent . remote_cands , pair . remote_cand_id )
483
483
484
484
dst = { remote_cand . address , remote_cand . port }
485
+ data_size = byte_size ( data )
485
486
486
487
case do_send ( ice_agent , local_cand , dst , data ) do
487
488
{ :ok , ice_agent } ->
488
- % {
489
- ice_agent
490
- | bytes_sent: ice_agent . bytes_sent + byte_size ( data ) ,
491
- packets_sent: ice_agent . packets_sent + 1
489
+ pair = % CandidatePair {
490
+ pair
491
+ | packets_sent: pair . packets_sent + 1 ,
492
+ bytes_sent: pair . bytes_sent + data_size
492
493
}
493
494
495
+ ice_agent =
496
+ % {
497
+ ice_agent
498
+ | bytes_sent: ice_agent . bytes_sent + data_size ,
499
+ packets_sent: ice_agent . packets_sent + 1
500
+ }
501
+
502
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
503
+
494
504
{ :error , ice_agent } ->
495
- ice_agent
505
+ pair = Map . fetch! ( ice_agent . checklist , pair . id )
506
+
507
+ pair = % CandidatePair {
508
+ pair
509
+ | packets_discarded_on_send: pair . packets_discarded_on_send + 1 ,
510
+ bytes_discarded_on_send: pair . bytes_discarded_on_send + data_size
511
+ }
512
+
513
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
496
514
end
497
515
end
498
516
@@ -639,7 +657,15 @@ defmodule ExICE.Priv.ICEAgent do
639
657
ice_agent
640
658
641
659
{ :error , ice_agent } ->
642
- ice_agent
660
+ data_size = byte_size ( conn_check . raw_req )
661
+
662
+ pair = % CandidatePair {
663
+ pair
664
+ | packets_discarded_on_send: pair . packets_discarded_on_send + 1 ,
665
+ bytes_discarded_on_send: pair . bytes_discarded_on_send + data_size
666
+ }
667
+
668
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
643
669
end
644
670
end
645
671
@@ -1284,14 +1310,22 @@ defmodule ExICE.Priv.ICEAgent do
1284
1310
end
1285
1311
1286
1312
defp do_handle_data_message ( ice_agent , pair , packet ) do
1287
- pair = % CandidatePair { pair | last_seen: now ( ) }
1313
+ data_size = byte_size ( packet )
1314
+
1315
+ pair = % CandidatePair {
1316
+ pair
1317
+ | last_seen: now ( ) ,
1318
+ packets_received: pair . packets_received + 1 ,
1319
+ bytes_received: pair . bytes_received + data_size
1320
+ }
1321
+
1288
1322
ice_agent = put_in ( ice_agent . checklist [ pair . id ] , pair )
1289
1323
1290
1324
notify ( ice_agent . on_data , { :data , packet } )
1291
1325
1292
1326
% {
1293
1327
ice_agent
1294
- | bytes_received: ice_agent . bytes_received + byte_size ( packet ) ,
1328
+ | bytes_received: ice_agent . bytes_received + data_size ,
1295
1329
packets_received: ice_agent . packets_received + 1
1296
1330
}
1297
1331
end
@@ -2013,7 +2047,13 @@ defmodule ExICE.Priv.ICEAgent do
2013
2047
put_in ( ice_agent . checklist [ pair . id ] , pair )
2014
2048
2015
2049
{ :error , ice_agent } ->
2016
- ice_agent
2050
+ pair = % CandidatePair {
2051
+ pair
2052
+ | packets_discarded_on_send: pair . packets_discarded_on_send + 1 ,
2053
+ bytes_discarded_on_send: pair . bytes_discarded_on_send + byte_size ( resp )
2054
+ }
2055
+
2056
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
2017
2057
end
2018
2058
end
2019
2059
@@ -2781,18 +2821,25 @@ defmodule ExICE.Priv.ICEAgent do
2781
2821
remote_cand = Map . fetch! ( ice_agent . remote_cands , pair . remote_cand_id )
2782
2822
2783
2823
req = binding_request ( ice_agent , local_cand , false )
2824
+ raw_req = Message . encode ( req )
2784
2825
2785
2826
dst = { remote_cand . address , remote_cand . port }
2786
2827
2787
- case do_send ( ice_agent , local_cand , dst , Message . encode ( req ) ) do
2828
+ case do_send ( ice_agent , local_cand , dst , raw_req ) do
2788
2829
{ :ok , ice_agent } ->
2789
2830
pair = % CandidatePair { pair | requests_sent: pair . requests_sent + 1 }
2790
2831
ice_agent = put_in ( ice_agent . checklist [ pair . id ] , pair )
2791
2832
keepalives = Map . put ( ice_agent . keepalives , req . transaction_id , pair . id )
2792
2833
% __MODULE__ { ice_agent | keepalives: keepalives }
2793
2834
2794
2835
{ :error , ice_agent } ->
2795
- ice_agent
2836
+ pair = % CandidatePair {
2837
+ pair
2838
+ | packets_discarded_on_send: pair . packets_discarded_on_send + 1 ,
2839
+ bytes_discarded_on_send: pair . bytes_discarded_on_send + byte_size ( raw_req )
2840
+ }
2841
+
2842
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
2796
2843
end
2797
2844
end
2798
2845
@@ -2833,7 +2880,13 @@ defmodule ExICE.Priv.ICEAgent do
2833
2880
% __MODULE__ { ice_agent | conn_checks: conn_checks , checklist: checklist }
2834
2881
2835
2882
{ :error , ice_agent } ->
2836
- ice_agent
2883
+ pair = % CandidatePair {
2884
+ pair
2885
+ | packets_discarded_on_send: pair . packets_discarded_on_send + 1 ,
2886
+ bytes_discarded_on_send: pair . bytes_discarded_on_send + byte_size ( raw_req )
2887
+ }
2888
+
2889
+ put_in ( ice_agent . checklist [ pair . id ] , pair )
2837
2890
end
2838
2891
end
2839
2892
0 commit comments