Skip to content

Add more candidate pair and transport stats #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/ex_ice/candidate_pair.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ defmodule ExICE.CandidatePair do
valid?: boolean(),
last_seen: integer(),
# stats
packets_sent: non_neg_integer(),
packets_received: non_neg_integer(),
bytes_sent: non_neg_integer(),
bytes_received: non_neg_integer(),
requests_received: non_neg_integer(),
requests_sent: non_neg_integer(),
responses_received: non_neg_integer(),
non_symmetric_responses_received: non_neg_integer(),
responses_sent: non_neg_integer()
responses_sent: non_neg_integer(),
packets_discarded_on_send: non_neg_integer(),
bytes_discarded_on_send: non_neg_integer()
}

@enforce_keys [:id, :local_cand_id, :remote_cand_id, :priority]
Expand All @@ -29,10 +35,16 @@ defmodule ExICE.CandidatePair do
state: :frozen,
valid?: false,
last_seen: nil,
packets_sent: 0,
packets_received: 0,
bytes_sent: 0,
bytes_received: 0,
requests_received: 0,
requests_sent: 0,
responses_received: 0,
non_symmetric_responses_received: 0,
responses_sent: 0
responses_sent: 0,
packets_discarded_on_send: 0,
bytes_discarded_on_send: 0
]
end
16 changes: 14 additions & 2 deletions lib/ex_ice/priv/candidate_pair.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ defmodule ExICE.Priv.CandidatePair do
discovered_pair_id: integer() | nil,
keepalive_timer: reference() | nil,
last_seen: integer(),
packets_sent: non_neg_integer(),
packets_received: non_neg_integer(),
bytes_sent: non_neg_integer(),
bytes_received: non_neg_integer(),
requests_received: non_neg_integer(),
requests_sent: non_neg_integer(),
responses_received: non_neg_integer(),
non_symmetric_responses_received: non_neg_integer(),
responses_sent: non_neg_integer()
responses_sent: non_neg_integer(),
packets_discarded_on_send: non_neg_integer(),
bytes_discarded_on_send: non_neg_integer()
}

@enforce_keys [:id, :local_cand_id, :remote_cand_id, :priority]
Expand All @@ -42,11 +48,17 @@ defmodule ExICE.Priv.CandidatePair do
# Time when this pair has received some data
# or sent conn check.
last_seen: nil,
packets_sent: 0,
packets_received: 0,
bytes_sent: 0,
bytes_received: 0,
requests_received: 0,
requests_sent: 0,
responses_received: 0,
non_symmetric_responses_received: 0,
responses_sent: 0
responses_sent: 0,
packets_discarded_on_send: 0,
bytes_discarded_on_send: 0
]

@doc false
Expand Down
13 changes: 11 additions & 2 deletions lib/ex_ice/priv/conn_check_handler/controlled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
cond do
ice_agent.selected_pair_id == nil ->
Logger.debug("Selecting pair: #{pair_id}")
%ICEAgent{ice_agent | selected_pair_id: pair.id}

%ICEAgent{
ice_agent
| selected_pair_id: pair.id,
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
}

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

%ICEAgent{ice_agent | selected_pair_id: pair.id}
%ICEAgent{
ice_agent
| selected_pair_id: pair.id,
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
}
else
Logger.debug("Not selecting a new pair as it has lower priority.")
ice_agent
Expand Down
13 changes: 11 additions & 2 deletions lib/ex_ice/priv/conn_check_handler/controlling.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
cond do
ice_agent.selected_pair_id == nil ->
Logger.debug("Selecting pair: #{pair_id}")
%ICEAgent{ice_agent | selected_pair_id: pair.id}

%ICEAgent{
ice_agent
| selected_pair_id: pair.id,
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
}

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

%ICEAgent{ice_agent | selected_pair_id: pair.id}
%ICEAgent{
ice_agent
| selected_pair_id: pair.id,
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
}
else
Logger.debug("Not selecting a new pair as it has lower priority.")
ice_agent
Expand Down
Loading
Loading