testRTC has two different techniques to collect its WebRTC metrics:
- By using webrtc-internals
- By using gestats
If you open a tab in your Chrome browser and direct it to chrome://webrtc-internals, you will be able to see there a collection of all WebRTC related traffic flowing in your browser on other tabs.
You will also be able to download a text file (JSON actually) of that data (here’s quick video on how to collect webrtc-internals dump).
The default mechanism that testRTC uses to collect WebRTC metrics is exactly this – we open up the webrtc-internals dump and make sure to download the contents of it at the end of the test.
While this works nicely, it comes with two main limitations:
- It can miss the metrics you need since Chrome is garbage collecting the metrics automatically once peer connections close
- It is limited to collecting up to 15 minutes of test data only – longer than that and it starts throwing away metrics you’ll need
If you need to close the connections in your script, or you are experiencing scenarios where you are absolutely certain that there’s media flowing using WebRTC but you get a “No WebRTC data collected” messages, then you can use the other collection mechanism described here.
The other collection mechanism testRTC employs is to override all WebRTC calls in the browser and to call WebRTC’s webstats API collecting the stats automatically on our own.
To use this method, add to the run options of the test the option #getstats.
Why not use getstats all the time? Because it might fail to catch the APIs of WebRTC (it happens from time to time, depending on the way your application is implemented in the browser).