WebTransport: getStats() method

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers

The getStats() method of the WebTransport interface asynchronously returns an object containing HTTP/3 connection statistics.

Syntax

js
getStats()

Parameters

None.

Return value

A Promise that resolves to a object containing HTTP/3 connection statistics. The returned object may have the following properties/statistics:

timestamp

A DOMHighResTimeStamp indicating the timestamp at which the statistics were gathered, relative to Jan 1, 1970, UTC.

bytesSent

A positive integer indicating the number of bytes sent on the QUIC connection, including retransmissions. Note that this count does not include additional data from protocols used by QUIC, such as UDP, or any other outer framing.

packetsSent

A positive integer indicating the number of packets sent on the QUIC connection, including those that are known to have been lost.

packetsLost

A positive integer indicating the number of packets lost on the QUIC connection. This value will increase as packets are declared lost, and decrease if they are subsequently received.

numOutgoingStreamsCreated

A positive integer indicating the number of outgoing QUIC streams created on the QUIC connection.

numIncomingStreamsCreated

A positive integer indicating the number of incoming QUIC streams created on the QUIC connection.

bytesReceived

A positive integer indicating the total number of bytes received on the QUIC connection. This count includes duplicate data from streams, but does not include additional data for protocols used by QUIC, such as UDP, or any other outer framing.

packetsReceived

A positive integer indicating the total number of packets received on the QUIC connection, including packets that were not processable.

smoothedRtt

A DOMHighResTimeStamp containing the smoothed round-trip time (RTT) currently observed on the connection, calculated as an exponentially weighted moving average of an endpoint's RTT samples after taking account of acknowledgement delays.

rttVariation

A DOMHighResTimeStamp containing the mean variation in round-trip time samples currently observed on the connection.

minRtt

A DOMHighResTimeStamp containing the minimum round-trip time observed on the entire connection.

datagrams

An object containing statistics for datagram transmission over the connection. The object has the following properties:

timestamp

A DOMHighResTimeStamp indicating the timestamp at which the statistics were gathered, relative to Jan 1, 1970, UTC.

expiredOutgoing

A positive integer indicating the number of datagrams that were dropped from the queue for sending because they expired. Note that the maximum age before a datagram in the send-queue expires can be found in outgoingMaxAge.

droppedIncoming

A positive integer indicating the number incoming datagrams that were dropped. Incoming datagrams are dropped if the application does not read them before new datagrams overflow the readable stream receive queue.

lostOutgoing

A positive integer indicating the number of sent datagrams that were declared lost. Note that a datagram may be declared lost if, for example, no acknowledgement arrived within a timeout, or an acknowledgement for a later datagram was received first.

Examples

The example below uses await to wait on the Promise returned by getStats(). When the promise fulfills, the result for the bytesSent property in the stats object is logged to the console.

js
const stats = await transport.getStats();
console.log(`Bytes send: ${stats.bytesSent}`);

Specifications

Specification
WebTransport
# dom-webtransport-getstats

Browser compatibility

BCD tables only load in the browser