rtci-ice
Sans-I/O ICE agent (RFC 8445) with trickle ICE, ICE-TCP and consent freshness, for WebRTC. 25 public modules, 107 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
An ICE agent for WebRTC: candidates, their priorities and pairing, connectivity checks over STUN, nomination, consent freshness and ICE restarts, with trickle ICE and ICE over TCP.
Specifications
- RFC 8445, Interactive Connectivity Establishment
- RFC 8838, Trickle ICE
- RFC 6544, TCP candidates with ICE
- RFC 7675, STUN usage for consent freshness
- RFC 8421, multihomed and dual-stack ICE
- RFC 8489, STUN, as ICE uses it
- draft-ietf-mmusic-mdns-ice-candidates, mDNS names for host candidates
- RFC 8839, the ICE candidate attribute grammar
Clause-by-clause status, with the test that proves each clause: rfc8445, rfc8838, rfc6544, rfc7675, rfc8421, draft-ietf-mmusic-mdns-ice-candidates.
Use
The root crate (rtci) runs an Agent per transport. Used on its own, agent::Agent takes local and remote candidates (candidate), inbound STUN datagrams and time, and gives the checks to send, the state changes and the selected pair.
Sans-I/O
The agent never gathers by itself: the application binds the sockets and tells it which local candidates exist (the root crate's stream interface gathers TCP candidates for it). The crate does no I/O and reads no clock: every call that depends on time takes an Instant from the caller.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_ice
ICE for the Sans-I/O WebRTC stack.
- mod
agentThe Sans-I/O ICE agent. - mod
attributesThe ICE-specific STUN attributes carried in connectivity checks. - mod
candidateCandidate types, priorities, and SDPa=candidateparsing. - mod
mdnsmDNS candidate handling, which hides private addresses behind.localnames. - mod
network_typeUDP/TCP over IPv4/IPv6, as a candidate's transport. - mod
randRandom ICE credentials and identifiers. - mod
stateConnection and gathering states. - mod
statsPer-candidate and per-pair counters, surfaced throughgetStats. - mod
tcp_typeActive, passive and simultaneous-open, for ICE-TCP candidates. - mod
urlParsingstun:/turn:server URLs. - use
AddressDirectionfromagent::remote_policy::AddressDirectionWhich way an address is used, as anIceAddressPolicyis asked about it. - use
AddressPurposefromagent::remote_policy::AddressPurposeWhy anIceAddressPolicyis asked about an address: the point where the address enters the ICE agent or the peer connection. Each purpose has one direction (AddressPurpose::direction). - use
Agentfromagent::AgentRepresents the ICE agent. - use
AgentConfigfromagent::agent_config::AgentConfigCollects the arguments toice::Agentconstruction into a single structure, for future-proofness of the interface. - use
CandidatePairStatsfromagent::agent_stats::CandidatePairStatsContains ICE candidate pair statistics. - use
CandidateStatsfromagent::agent_stats::CandidateStatsContains ICE candidate statistics related to theICETransportobjects. - use
ConsentResponseWaitfromagent::agent_config::ConsentResponseWaitHow long a consent request (RFC 7675) waits for its response: how long its transaction is in progress, so that a matching, authenticated success response still renews consent (RFC 8489 Section 6.3: a response is processed when "the transaction ID matches a transaction that is still in progress"). A consent request is sent once; a response to an earlier one than the latest counts as well (RFC … - use
Credentialsfromagent::CredentialsThe ICE credentials for one side of a session, exchanged in SDP. - use
crypto - use
DataPathfromagent::DataPathThe pair data arrived on. SeeAgent::data_path. - use
Eventfromagent::EventWhat the agent reports to its caller. - use
FailedNominationfromagent::agent_config::FailedNominationWhat an agent does when a nomination fails (RFC 8445 Section 7.2.5.2): the controlling agent's check with USE-CANDIDATE on a valid pair, or the controlled agent's check that a received USE-CANDIDATE triggered (Section 7.3.1.5). The check fails when its transaction times out (Rcrequests, the last givenRmtimes the RTO, Section 14.3 and RFC 8489 Section 6.2.1: 39.5 seconds at an RTO of 500 … - use
IceAddressPolicyfromagent::remote_policy::IceAddressPolicyAn embedder's address policy for ICE: one predicate asked at every point where an address enters the ICE agent or the peer connection's stream, TURN and server-reflexive code, whichever way traffic would go. - use
NominationAcceptancefromagent::agent_config::NominationAcceptanceWhich nomination a controlled agent uses when the controlling agent makes more than one. - use
PacingGroupfromagent::agent_config::PacingGroupA pacing budget several agents share (RFC 8445 Section 14.2: "all agents together send no more than one transaction per 5 ms" — the "global" Ta of an implementation that runs several agents). Give the sameArcto every agent (throughAgentConfig::pacing_groupor the peer connection'sSettingEngineBuilder::with_ice_pacing_group): each starts a connectivity check only when none of them has … - use
TransportErrorfromagent::agent_selector::TransportErrorWhat a transport reports about the path of a connectivity check. SeeAgent::handle_transport_error. - use
UnauthenticatedRequestsfromagent::agent_config::UnauthenticatedRequestsWhat the agent does with a Binding request that fails the short-term credential check.
rtci_ice::agent
The Sans-I/O ICE agent.
- mod
agent_configConfiguration for a newAgent: servers, timeouts and role. - mod
agent_selectorPair selection and nomination — which candidate pair becomes the selected one. - mod
agent_statsSnapshot statistics for an agent's candidates and pairs. - mod
remote_policyWhere connectivity checks may be sent: the remote-address policy. - struct
AgentRepresents the ICE agent. - struct
CredentialsThe ICE credentials for one side of a session, exchanged in SDP. - struct
MediaPathThe addresses and transport data is sent on and accepted from. SeeAgent::media_path. - struct
TaggedEventAnEventtogether with the instant its condition was observed at. - enum
DataPathThe pair data arrived on. SeeAgent::data_path. - enum
EventWhat the agent reports to its caller. - const
DEFAULT_SOFTWAREThe SOFTWARE attribute the agent sends unless configured otherwise (AgentConfig::software).
rtci_ice::agent::agent_config
Configuration for a new Agent: servers, timeouts and role.
- struct
AgentConfigCollects the arguments toice::Agentconstruction into a single structure, for future-proofness of the interface. - struct
PacingGroupA pacing budget several agents share (RFC 8445 Section 14.2: "all agents together send no more than one transaction per 5 ms" — the "global" Ta of an implementation that runs several agents). Give the sameArcto every agent (throughAgentConfig::pacing_groupor the peer connection'sSettingEngineBuilder::with_ice_pacing_group): each starts a connectivity check only when none of them has … - enum
ConsentResponseWaitHow long a consent request (RFC 7675) waits for its response: how long its transaction is in progress, so that a matching, authenticated success response still renews consent (RFC 8489 Section 6.3: a response is processed when "the transaction ID matches a transaction that is still in progress"). A consent request is sent once; a response to an earlier one than the latest counts as well (RFC … - enum
FailedNominationWhat an agent does when a nomination fails (RFC 8445 Section 7.2.5.2): the controlling agent's check with USE-CANDIDATE on a valid pair, or the controlled agent's check that a received USE-CANDIDATE triggered (Section 7.3.1.5). The check fails when its transaction times out (Rcrequests, the last givenRmtimes the RTO, Section 14.3 and RFC 8489 Section 6.2.1: 39.5 seconds at an RTO of 500 … - enum
NominationAcceptanceWhich nomination a controlled agent uses when the controlling agent makes more than one. - enum
UnauthenticatedRequestsWhat the agent does with a Binding request that fails the short-term credential check. - const
MAX_UNAUTHENTICATED_RESPONSE_BURSTThe error responses to unauthenticated requests the agent may send in a burst. - const
UNAUTHENTICATED_RESPONSE_INTERVALHow often the agent may send one more error response to an unauthenticated request.
rtci_ice::agent::agent_selector
Pair selection and nomination — which candidate pair becomes the selected one.
- enum
ChecklistStateThe state of the checklist (RFC 8445 Section 6.1.2.1). With one checklist it is also the state of the ICE session (Section 6.1.3). - enum
TransportErrorWhat a transport reports about the path of a connectivity check. SeeAgent::handle_transport_error.
rtci_ice::agent::agent_stats
Snapshot statistics for an agent's candidates and pairs.
- struct
CandidatePairStatsContains ICE candidate pair statistics. - struct
CandidateStatsContains ICE candidate statistics related to theICETransportobjects.
rtci_ice::agent::remote_policy
Where connectivity checks may be sent: the remote-address policy.
- struct
IceAddressPolicyAn embedder's address policy for ICE: one predicate asked at every point where an address enters the ICE agent or the peer connection's stream, TURN and server-reflexive code, whichever way traffic would go. - enum
AddressDirectionWhich way an address is used, as anIceAddressPolicyis asked about it. - enum
AddressPurposeWhy anIceAddressPolicyis asked about an address: the point where the address enters the ICE agent or the peer connection. Each purpose has one direction (AddressPurpose::direction). - type
AddressPolicyFnThe predicate of anIceAddressPolicy:truelets the address be used. - type
RemoteAddressFilterDecides whether connectivity checks may be sent to a remote candidate's address.
rtci_ice::attributes
The ICE-specific STUN attributes carried in connectivity checks.
- mod
controlICE-CONTROLLINGandICE-CONTROLLED, which resolve role conflicts. - mod
nominationlibwebrtc'sNOMINATIONattribute, by which a controlling agent renominates. - mod
priorityThePRIORITYattribute carried in connectivity checks. - mod
use_candidateTheUSE-CANDIDATEflag, by which the controlling agent nominates a pair.
rtci_ice::attributes::control
ICE-CONTROLLING and ICE-CONTROLLED, which resolve role conflicts.
- struct
AttrControlHelper that wraps ICE-{CONTROLLED,CONTROLLING}. - struct
AttrControlledRepresents ICE-CONTROLLED attribute. - struct
AttrControllingRepresents ICE-CONTROLLING attribute. - struct
TieBreakerCommon helper for ICE-{CONTROLLED,CONTROLLING} and represents the so-called Tiebreaker number. - enum
RoleRepresents ICE agent role, which can be controlling or controlled. Possible ICE agent roles.
rtci_ice::attributes::nomination
libwebrtc's NOMINATION attribute, by which a controlling agent renominates.
- struct
NominationAttrTheNOMINATIONattribute: the renomination value of a connectivity check. - fn
nomination_ofThe nomination a Binding request carries: theNOMINATIONvalue when there is one, else 1 forUSE-CANDIDATE, else 0 (no nomination). - const
ATTR_NOMINATIONTheNOMINATIONattribute type, from libwebrtc's comprehension-optional range.
rtci_ice::attributes::priority
The PRIORITY attribute carried in connectivity checks.
- struct
PriorityAttrRepresents PRIORITY attribute.
rtci_ice::attributes::use_candidate
The USE-CANDIDATE flag, by which the controlling agent nominates a pair.
- struct
UseCandidateAttrRepresents USE-CANDIDATE attribute.
rtci_ice::candidate
Candidate types, priorities, and SDP a=candidate parsing.
- mod
candidate_hostHost candidates: an address on a local interface. - mod
candidate_pairA local/remote candidate pair and its check state. - mod
candidate_peer_reflexivePeer-reflexive candidates, learned from an inbound check's source address. - mod
candidate_relayRelay candidates, allocated on a TURN server. - mod
candidate_server_reflexiveServer-reflexive candidates, learned from a STUN Binding response. - struct
CandidateOne ICE candidate: a transport address this agent can be reached at, or can reach a peer at, together with its type, priority and liveness bookkeeping. - struct
CandidateConfigThe fields common to every candidate type, used when constructing one. - struct
CandidateRelatedAddressConvey transport addresses related to the candidate, useful for diagnostics and other purposes. - enum
CandidateTypeRepresents the type of candidateCandidateTypeenum. - fn
is_teredoWhetheripis a Teredo address, 2001::/32 (RFC 4380 Section 2.6): an address of a UDP tunnel (RFC 6544 Section 5.4). - fn
rank_local_candidatesRanks a set of local candidates gathered together, as RFC 8421 Section 4 recommends for a dual-stack host: within each type, the IPv6 candidates get a head start ofHi = (N_4 + N_6) / N_4places ("If a host has two IPv4 addresses and six IPv6 addresses, it will insert an IPv4 address after four IPv6 addresses"), then the two families alternate, so that both get checks early. Candidates that … - fn
unmarshal_candidateCreates a Candidate from its string representation. - const
UDP_TUNNELLED_TYPE_PREFERENCEThe type preference of a UDP-tunnelled TCP candidate (RFC 6544 Section 4.2: "the RECOMMENDED type preferences for the new candidate types defined in this document ... are 105 for NAT-assisted candidates and 75 for UDP-tunneled candidates").
rtci_ice::candidate::candidate_host
Host candidates: an address on a local interface.
- struct
CandidateHostConfigThe config required to create a newCandidateHost.
rtci_ice::candidate::candidate_pair
A local/remote candidate pair and its check state.
- struct
CandidatePairRepresents a combination of a local and remote candidate. - enum
CandidatePairStateRepresent the ICE candidate pair state.
rtci_ice::candidate::candidate_peer_reflexive
Peer-reflexive candidates, learned from an inbound check's source address.
- struct
CandidatePeerReflexiveConfigThe config required to create a newCandidatePeerReflexive.
rtci_ice::candidate::candidate_relay
Relay candidates, allocated on a TURN server.
- struct
CandidateRelayConfigThe config required to create a newCandidateRelay.
rtci_ice::candidate::candidate_server_reflexive
Server-reflexive candidates, learned from a STUN Binding response.
- struct
CandidateServerReflexiveConfigThe config required to create a newCandidateServerReflexive.
rtci_ice::mdns
mDNS candidate handling, which hides private addresses behind .local names.
- mod
exposureThe two cases in whichQueryAndGathermay leave a host address unwrapped, each its own opt-in setting, off by default (draft-ietf-mmusic-mdns-ice-candidates-03). - struct
MulticastDnsPublishingWhether the application can send the agent's mDNS messages, per address family: an mDNS socket of that family is open (the agent writes its announcements and answers from port 5353 to 224.0.0.251 or ff02::fb). Both by default. An application that has none for a family tells the agent (Agent::set_multicast_dns_publishing) before it adds the host candidates of that family: a name of such an … - enum
MulticastDnsModeRepresents the different Multicast modes that ICE can run. - use
is_global_unicastfromexposure::is_global_unicastWhetheripis a globally reachable unicast address: the only kind of address the two exposure settings may ever leave unwrapped. A hard check of the engine, applied whatever a STUN server answered or the application marked. - use
MdnsRateLimitfrommdns::MdnsRateLimit
rtci_ice::mdns::exposure
The two cases in which QueryAndGather may leave a host address unwrapped, each its own opt-in setting, off by default (draft-ietf-mmusic-mdns-ice-candidates-03).
- fn
is_global_unicastWhetheripis a globally reachable unicast address: the only kind of address the two exposure settings may ever leave unwrapped. A hard check of the engine, applied whatever a STUN server answered or the application marked.
rtci_ice::network_type
UDP/TCP over IPv4/IPv6, as a candidate's transport.
- enum
NetworkTypeRepresents the type of network. - fn
supported_network_typesEvery network type this crate can gather candidates for.
rtci_ice::rand
Random ICE credentials and identifiers.
- fn
generate_cand_id<https://tools.ietf.org/html/rfc5245#section-15.1> candidate-id = "candidate" ":" foundation foundation = 1*32ice-char ice-char = ALPHA / DIGIT / "+" / "/" - fn
generate_pwdGenerates an ICE password withrand's thread-local CSPRNG. - fn
generate_ufragGenerates an ICE username fragment withrand's thread-local CSPRNG.
rtci_ice::state
Connection and gathering states.
- enum
ConnectionStateAn enum showing the state of a ICE Connection List of supported States. - enum
GatheringStateDescribes the state of the candidate gathering process.
rtci_ice::stats
Per-candidate and per-pair counters, surfaced through getStats.
- struct
CandidatePairStatsCandidatePairStats contains ICE candidate pair statistics. - struct
CandidateStatsCandidateStats contains ICE candidate statistics related to the ICETransport objects.
rtci_ice::tcp_type
Active, passive and simultaneous-open, for ICE-TCP candidates.
- enum
TcpTypeThe role of an ICE-TCP candidate, per [RFC 6544] §4.5.
rtci_ice::url
Parsing stun:/turn: server URLs.
- struct
UrlRepresents a STUN (rfc7064) or TURN (rfc7065) URL. - enum
ProtoTypeThe transport protocol type that is used in theice::url::Urlstructure. - enum
SchemeTypeThe type of server used in the ice.URL structure.
Generated from the sources of rtci-ice 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.