This document primarily introduces how to perceive the quality of the current network.
Detecting Network Quality during Call
TRTC provides a callback event called onNetworkQuality, which reports the current network quality to you every two seconds. Its parameters include two parts: localQuality and remoteQuality.
localQuality: Represents your current network quality, which is divided into 6 levels, namely Excellent, Good, Poor, Bad, VeryBad, and Down.
remoteQuality: Represents the network quality of remote users. This is an array where each element represents the network quality of a remote user.
Quality
Name
Description
0
Unknown
Unperceived
1
Excellent
The current network is excellent.
2
Good
The current network is good.
3
Poor
The current network is moderate.
4
Bad
The current network is poor, and obvious lag and call latency may occur.
5
VeryBad
The current network is very poor. TRTC can only barely keep-alive, but cannot guarantee communication quality.
6
Down
The current network fails to satisfy the minimum requirements of TRTC, and normal audio and video calls cannot be performed.
You only need to listen to TRTC's onNetworkQuality and provide corresponding notifications on the interface:
// Create a TRTC instance.
const trtcCloud =TRTCCloud.sharedInstance();
// Listen to the onNetworkQuality callback and perceive changes in the current network status.
The principle of speed test is that the SDK sends a batch of probe packets to the server node, then calculates the quality of the returned packets, and notifies the speed test results through the callback API.
The speed test results will be used to optimize the SDK's subsequent server selection strategy. Therefore, it is recommended that you perform a speed test before the user's first call. This will help us select the best server. Meanwhile, if the test results are highly unsatisfactory, you can prompt the user through a prominent UI to choose a better network.
Downlink packet Jitter (ms), indicating the stability of data communication under the current network environment for the user. The smaller this value, the better. The normal value range is 0 ms - 100 ms. -1 means the speed test did not successfully measure a valid value. Generally, the Jitter of a WiFi network is slightly larger than that in a 4G/5G environment.
downLostRate
Downstream packet loss rate. The value ranges from [0 - 1.0]. For example, 0.2 means when receiving 10 packets from the server, 2 may be lost midway.
errMsg
Error information of the bandwidth test.
ip
Server IP address.
quality
Internal network quality calculated by the evaluation algorithm. Details as follows:
quality = 0: undefined.
quality = 1: The current network is excellent.
quality = 2: The current network is good.
quality = 3: The current network is moderate.
quality = 4: The current network is poor.
quality = 5: The current network is very poor.
quality = 6: The current network fails to satisfy the minimum requirements of TRTC.
rtt
Latency (ms): Refers to the Round-Trip Time (RTT) from the current device to the TRTC server. The smaller the value is, the better. The normal value range is 10ms - 100ms.
success
Whether the test is successful.
upJitter
Uplink packet Jitter (ms): Refers to the stability of data communication under the current network environment of the user. The smaller the value is, the better. The normal value range is 0ms - 100ms. -1 represents that no valid value was successfully measured in this speed test. Generally, the Jitter of a WiFi network is slightly larger than that in a 4G/5G environment.
upLostRate
Uplink packet loss rate. The value ranges from [0 - 1.0]. For example, 0.3 means when sending 10 packets to the server, 3 may be lost midway.