getNetworkStats()
getNetworkStats()
Returns the latest stats representing the current network, calculated from the WebRTC stats. These statistics are updated approximately once every two seconds. You can poll the getNetworkStats()
method to continually read the current network performance.
Return type
Returns a Promise that resolves to an object with a set of the latest
calculated stats, some overall call stats, and some high level assessments of the current overall network health.
If, for a given two second period, a value can not be determined, it will be set to null
. This most commonly occurs for packetLoss
calculations due to the values it relies upon being missing or stale, or media not being transmitted. For instance, if you join a call with audio and video off, your bitrates will be 0 and packetLoss
will be null
because it is unknown.
networkState
:'good'
|'warning'
|'bad'
|'unknown'
an assessment of the current network quality. The threshold value is calculated from network stats averaged over an approximately 30-second rolling window. Calculations are based on send/recv packet loss, round trip times, and availableOutgoingBitrate. In prebuilt, we lower the bandwidth used for the call when the network quality drops to
warning
, and we turn off the local camera when the network quality drops tobad
.networkStateReasons
:an array of reasons for the current network state. Possible values are:
'sendPacketLoss'
,'recvPacketLoss'
,'roundTripTime'
,'availableOutgoingBitrate'
. If thenetworkState
is'good'
or'unknown'
, this field will be an empty array.averageNetworkRoundTripTime
: average round trip time over the course of the call.worstAudioRecvPacketLoss
: highestaudioRecvPacketLoss
number seen over a reporting interval during the callworstAudioSendPacketLoss
: highestaudioSendPacketLoss
number seen over a reporting interval during the callworstVideoRecvPacketLoss
: highestvideoRecvPacketLoss
number seen over a reporting interval during the callworstVideoSendPacketLoss
: highestvideoSendPacketLoss
number seen over a reporting interval during the callworstVideoRecvJitter
: highestvideoRecvJitter
value seen over a reporting interval during the callworstVideoSendJitter
: highestvideoSendJitter
value seen over a reporting interval during the callworstAudioRecvJitter
: highestaudioRecvJitter
value seen over a reporting interval during the callworstAudioSendJitter
: highestaudioSendJitter
value seen over a reporting interval during the callthreshold
: [DEPRECATED in 0.77.0. UsenetworkState
instead]'good'
|'low'
|'very-low'
, an assessment of the current network quality. The threshold value is calculated from network stats averaged over an approximately 30-second rolling window. In prebuilt, we lower the bandwidth used for the call when the network quality drops tolow
, and we turn off the local camera when the network quality drops tovery-low
.quality
: [DEPRECATED in 0.77.0]a subjective calculation of the current network quality on a scale of 1-100, suitable for display in a user interface.
latest
: a collection of statistics from the most recent reporting interval, which occurs approximately once every two seconds. Below are the keys and descriptions of the values in thelatest
object:
Key | Description |
---|---|
timestamp | a unix timestamp (seconds since the epoch), set to when the latest was calculated |
recvBitsPerSecond | total data received in the reporting interval from video and/or audio in bits per second |
sendBitsPerSecond | total data sent in the reporting interval from video and/or audio in bits per second |
networkRoundTripTime | average latest round trip time reported from all connections |
audioRecvBitsPerSecond | total payload data from audio received in the reporting interval in bits per second |
audioRecvPacketLoss | estimated percentage of packets lost from incoming audio over the reporting interval |
audioSendBitsPerSecond | total payload data from audio sent in the reporting interval in bits per second |
audioSendPacketLoss | estimated percentage of packets lost from the audio being sent over the reporting interval |
availableOutgoingBitrate | average latest available outgoing bitrate reported from all connections |
videoRecvBitsPerSecond | total payload data from video received in the reporting interval in bits per second |
videoRecvPacketLoss | estimated percentage of packets lost from incoming video over the reporting interval |
videoSendBitsPerSecond | total payload data from video sent in the reporting interval in bits per second |
videoSendPacketLoss | estimated percentage of packets lost from the video being sent over the reporting interval |
totalSendPacketLoss | estimated overall percentage of packets lost from the audio and video being sent over the reporting interval |
totalRecvPacketLoss | estimated overall percentage of packets lost from the received audio and video over the reporting interval |
videoRecvJitter | average jitter across inbound video streams over the reporting interval |
videoSendJitter | average jitter across outbound video streams over the reporting interval |
audioRecvJitter | average jitter across inbound audio streams over the reporting interval |
audioSendJitter | average jitter across outbound audio streams over the reporting interval |
Firefox users:
The Firefox browser does not provide adequate information to calculate send-side packet loss or jitter for audio and therefore audioSendPacketLoss
and audioSendJitter
will always be null
. worstAudioSendJitter
will report as 0. Firefox also does not provide adequate information to calculate availableOutgoingBitrate
, networkRoundTripTime
, or averageNetworkRoundTripTime
.
Sample response
{"networkState": "bad","networkStateReasons": ["sendPacketLoss","recvPacketLoss"],"threshold": "good","quality": 37,"stats": {"averageNetworkRoundTripTime": 0.01992261904761905,"latest": {"audioRecvBitsPerSecond": 23050.048937297845,"audioRecvJitter": 0.026,"audioRecvPacketLoss": 0.15053763440860216,"audioSendBitsPerSecond": 30177.83704675053,"audioSendJitter": null,"audioSendPacketLoss": null,"availableOutgoingBitrate": 2889866,"networkRoundTripTime": 0.02,"recvBitsPerSecond": 1700344.1895481267,"sendBitsPerSecond": 1724499.7493844875,"timestamp": 1743011906315,"totalRecvPacketLoss": 0.11670020120724346,"totalSendPacketLoss": 0.08984375,"videoRecvBitsPerSecond": 1567291.2594309496,"videoRecvJitter": 0.036,"videoRecvPacketLoss": 0.10891089108910891,"videoSendBitsPerSecond": 1589251.349980054,"videoSendJitter": 0.008922,"videoSendPacketLoss": 0.08984375},"worstAudioRecvJitter": 0.026,"worstAudioRecvPacketLoss": 0.23232323232323232,"worstAudioSendJitter": 0.003166,"worstAudioSendPacketLoss": 0.1953125,"worstVideoRecvJitter": 0.036,"worstVideoRecvPacketLoss": 0.10891089108910891,"worstVideoSendJitter": 0.014355,"worstVideoSendPacketLoss": 0.13671875}}
getNetworkStats() in action
We display network stats outside of the Daily iframe
in our Daily Prebuilt demo:
- Test the live demo
- See sample code in our demo repository