Skip to content

Commit 82e5d51

Browse files
committed
Add more CandidatePair stats
1 parent 334ba47 commit 82e5d51

File tree

6 files changed

+172
-44
lines changed

6 files changed

+172
-44
lines changed

lib/ex_ice/candidate_pair.ex

+14-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ defmodule ExICE.CandidatePair do
1515
valid?: boolean(),
1616
last_seen: integer(),
1717
# stats
18+
packets_sent: non_neg_integer(),
19+
packets_received: non_neg_integer(),
20+
bytes_sent: non_neg_integer(),
21+
bytes_received: non_neg_integer(),
1822
requests_received: non_neg_integer(),
1923
requests_sent: non_neg_integer(),
2024
responses_received: non_neg_integer(),
2125
non_symmetric_responses_received: non_neg_integer(),
22-
responses_sent: non_neg_integer()
26+
responses_sent: non_neg_integer(),
27+
packets_discarded_on_send: non_neg_integer(),
28+
bytes_discarded_on_send: non_neg_integer()
2329
}
2430

2531
@enforce_keys [:id, :local_cand_id, :remote_cand_id, :priority]
@@ -29,10 +35,16 @@ defmodule ExICE.CandidatePair do
2935
state: :frozen,
3036
valid?: false,
3137
last_seen: nil,
38+
packets_sent: 0,
39+
packets_received: 0,
40+
bytes_sent: 0,
41+
bytes_received: 0,
3242
requests_received: 0,
3343
requests_sent: 0,
3444
responses_received: 0,
3545
non_symmetric_responses_received: 0,
36-
responses_sent: 0
46+
responses_sent: 0,
47+
packets_discarded_on_send: 0,
48+
bytes_discarded_on_send: 0
3749
]
3850
end

lib/ex_ice/priv/candidate_pair.ex

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ defmodule ExICE.Priv.CandidatePair do
2222
discovered_pair_id: integer() | nil,
2323
keepalive_timer: reference() | nil,
2424
last_seen: integer(),
25+
packets_sent: non_neg_integer(),
26+
packets_received: non_neg_integer(),
27+
bytes_sent: non_neg_integer(),
28+
bytes_received: non_neg_integer(),
2529
requests_received: non_neg_integer(),
2630
requests_sent: non_neg_integer(),
2731
responses_received: non_neg_integer(),
2832
non_symmetric_responses_received: non_neg_integer(),
29-
responses_sent: non_neg_integer()
33+
responses_sent: non_neg_integer(),
34+
packets_discarded_on_send: non_neg_integer(),
35+
bytes_discarded_on_send: non_neg_integer()
3036
}
3137

3238
@enforce_keys [:id, :local_cand_id, :remote_cand_id, :priority]
@@ -42,11 +48,17 @@ defmodule ExICE.Priv.CandidatePair do
4248
# Time when this pair has received some data
4349
# or sent conn check.
4450
last_seen: nil,
51+
packets_sent: 0,
52+
packets_received: 0,
53+
bytes_sent: 0,
54+
bytes_received: 0,
4555
requests_received: 0,
4656
requests_sent: 0,
4757
responses_received: 0,
4858
non_symmetric_responses_received: 0,
49-
responses_sent: 0
59+
responses_sent: 0,
60+
packets_discarded_on_send: 0,
61+
bytes_discarded_on_send: 0
5062
]
5163

5264
@doc false

lib/ex_ice/priv/conn_check_handler/controlled.ex

+11-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
190190
cond do
191191
ice_agent.selected_pair_id == nil ->
192192
Logger.debug("Selecting pair: #{pair_id}")
193-
%ICEAgent{ice_agent | selected_pair_id: pair.id}
193+
194+
%ICEAgent{
195+
ice_agent
196+
| selected_pair_id: pair.id,
197+
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
198+
}
194199

195200
ice_agent.selected_pair_id != nil and pair.id != ice_agent.selected_pair_id ->
196201
selected_pair = Map.fetch!(ice_agent.checklist, ice_agent.selected_pair_id)
@@ -201,7 +206,11 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
201206
New pair: #{pair_id}, old pair: #{ice_agent.selected_pair_id}.\
202207
""")
203208

204-
%ICEAgent{ice_agent | selected_pair_id: pair.id}
209+
%ICEAgent{
210+
ice_agent
211+
| selected_pair_id: pair.id,
212+
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
213+
}
205214
else
206215
Logger.debug("Not selecting a new pair as it has lower priority.")
207216
ice_agent

lib/ex_ice/priv/conn_check_handler/controlling.ex

+11-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
113113
cond do
114114
ice_agent.selected_pair_id == nil ->
115115
Logger.debug("Selecting pair: #{pair_id}")
116-
%ICEAgent{ice_agent | selected_pair_id: pair.id}
116+
117+
%ICEAgent{
118+
ice_agent
119+
| selected_pair_id: pair.id,
120+
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
121+
}
117122

118123
ice_agent.selected_pair_id != nil and pair.id != ice_agent.selected_pair_id ->
119124
selected_pair = Map.fetch!(ice_agent.checklist, ice_agent.selected_pair_id)
@@ -124,7 +129,11 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
124129
New pair: #{pair_id}, old pair: #{ice_agent.selected_pair_id}.\
125130
""")
126131

127-
%ICEAgent{ice_agent | selected_pair_id: pair.id}
132+
%ICEAgent{
133+
ice_agent
134+
| selected_pair_id: pair.id,
135+
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
136+
}
128137
else
129138
Logger.debug("Not selecting a new pair as it has lower priority.")
130139
ice_agent

0 commit comments

Comments
 (0)