Speed Test
Implementation file: rpc_speed.go
Implement bidirectional RPC speed test: verify test parameters, send and receive binary frames of specified length, count uplink and downlink bytes and time consumption, and calculate Mbps.
This capability is used to test the RPC/DataChannel data path and does not represent a guarantee of business throughput.
Core structure and main function
| Symbol | Function |
|---|---|
SpeedTestResult | Stores uplink and downlink statistics and test time consumption. |
SpeedTestResult.UpMbps / DownMbps | Calculate upstream and downstream Mbps. |
callRPCSpeedTest | Client-side speed test process. |
handleSpeedTest | Server-side speed test streaming handler. |
validateSpeedTestRequest | Verify the uplink and downlink length and test parameters. |
writeBinaryFrames / readBinaryFrames | Write or read binary frames of the specified total length. |
mbps | Calculate Mbps based on the number of bytes and time taken. |