W3cubDocs

/Web APIs

RTCTransportStats

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The RTCTransportStats dictionary of the WebRTC API provides information about the transport (RTCDtlsTransport and its underlying 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 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 RTCStatsReport returned by RTCPeerConnection.getStats() until you find a report with the type of transport.

Instance properties

bytesReceived Optional

The total number of payload bytes received on this transport (bytes received, not including headers, padding or ICE connectivity checks).

bytesSent Optional

The total number of payload bytes sent on this transport (bytes sent, not including headers, padding or ICE connectivity checks).

dtlsCipher Optional

A string indicating the name of the cipher suite used for the DTLS transport, such as TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.

dtlsRole Optional Experimental

A string indicating the DTLS role of the associated RTCPeerConnection. This is one of: client, server, unknown (before the DTLS negotiation starts).

dtlsState

A string indicating the current state of the underlying RTCDtlsTransport. This is one of: new, connecting, connected, closed, failed.

iceLocalUsernameFragment Optional Experimental

A string indicating the local username fragment that uniquely identifies the ICE interaction session managed by this transport.

iceRole Optional Experimental

A string indicating the ICE role of the underlying RTCIceTransport. This is one of: controlled, controlling, or unknown.

iceState Optional Experimental

A string indicating the current state of the underlying RTCIceTransport. This is one of: new, checking, connected, completed, disconnected, failed, or closed.

localCertificateId Optional

A string containing the id of the local certificate used by this transport. Only present for DTLS transports, and after DTLS has been negotiated.

packetsReceived Optional Experimental

The total number of packets received on this transport.

packetsSent Optional Experimental

The total number of packets sent over this transport.

remoteCertificateId Optional

A string containing the id or the remote certificate used by this transport. Only present for DTLS transports, and after DTLS has been negotiated.

selectedCandidatePairChanges Optional

The number of times that the selected candidate pair of this transport has changed. The value is initially zero and increases whenever a candidate pair selected or lost.

selectedCandidatePairId Optional

A string containing the unique identifier for the object that was inspected to produce the RTCIceCandidatePairStats associated with this transport.

srtpCipher Optional

A string indicating the descriptive name of the protection profile used for the Secure Real-time Transport Protocol (SRTP) transport.

tlsVersion Optional

A string containing the negotiated TLS version. This is present for DTLS transports, and only exists after DTLS has been negotiated.

Common instance properties

The following properties are common to all WebRTC statistics objects.

id

A string that uniquely identifies the object that is being monitored to produce this set of statistics.

timestamp

A DOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.

type

A string with the value "transport", indicating the type of statistics that the object contains.

Examples

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 RTCPeerConnection.getStats() and then iterates the returned 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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
RTCTransportStats 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
bytesReceived 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
bytesSent 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
dtlsCipher 80 80 No 67 14.1 80 No 57 14.5 13.0 80 14.5
dtlsRole 103 103 No 89 No 103 No 71 No 20.0 103 No
dtlsState 80 80 No 67 14.1 80 No 57 14.5 13.0 80 14.5
iceLocalUsernameFragment 103 103 No 89 No 103 No 71 No 20.0 103 No
iceRole 103 103 No 89 No 103 No 71 No 20.0 103 No
iceState 103 103 No 89 No 103 No 71 No 20.0 103 No
id 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
localCertificateId 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
packetsReceived 86 86 No 72 No 86 No 61 No 14.0 86 No
packetsSent 86 86 No 72 No 86 No 61 No 14.0 86 No
remoteCertificateId 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
selectedCandidatePairChanges 80 80 No 67 No 80 No 57 No 13.0 80 No
selectedCandidatePairId 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
srtpCipher 80 80 No 67 14.1 80 No 57 14.5 13.0 80 14.5
timestamp 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4
tlsVersion 80 80 No 67 14.1 80 No 57 14.5 13.0 80 14.5
type 80 80 No 67 13.1 80 No 57 13.4 13.0 80 13.4

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCTransportStats