files/en-us/web/api/rtctransportstats/index.md
{{APIRef("WebRTC")}}
The RTCTransportStats dictionary of the WebRTC API provides information about the transport ({{domxref("RTCDtlsTransport")}} and its underlying {{domxref("RTCIceTransport")}}) used by a particular candidate pair.
The BUNDLE feature is an SDP extension that allows negotiation to use a single transport for sending and receiving media described by multiple SDP media descriptions.
If the remote endpoint is aware of this feature, all {{domxref("MediaStreamTrack")}} and data channels are bundled onto a single transport at the completion of negotiation.
This is true for current browsers, but if connecting to an older endpoint that is not BUNDLE-aware, then separate transports might be used for different media.
The policy to use in the negotiation is configured in the RTCPeerConnection constructor.
These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the type of transport.
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.client, server, unknown (before the DTLS negotiation starts).new, connecting, connected, closed, failed.role of the underlying {{domxref("RTCIceTransport")}}.
This is one of: controlled, controlling, or unknown.new, checking, connected, completed, disconnected, failed, or closed.The following properties are common to all WebRTC statistics objects.
<!-- RTCStats -->"transport", indicating the type of statistics that the object contains.This example shows a function to return the transport statistics, or null if no statistics are provided.
The function waits for the result of a call to {{domxref("RTCPeerConnection.getStats()")}} and then iterates the returned {{domxref("RTCStatsReport")}} to get just the stats of type "transport".
It then returns the statistics, or null, using the data in the report.
async function numberOpenConnections (peerConnection) {
const stats = await peerConnection.getStats();
let transportStats = null;
stats.forEach((report) => {
if (report.type === "transport") {
transportStats = report;
break;
}
});
return transportStats
}
{{Specifications}}
{{Compat}}