Open marcovidonis opened 1 year ago
Yeah I would lean toward it being fine to have a WebRTC specific stats thing here. Your method on Torrent
, GetWebRtcPeerConnStats
, only returns the tracker stats, would you also want to return WebRTC (torrent) peer connections too? That would probably involve iterating the peer conns list and filtering for those that are over WebRTC. If you're not interested in that, perhaps the method could be renamed to indicate it's only the trackers that are reported.
Yeah I'm actually interested in the torrent peer connection to evaluate, for example, packet loss during file transfer. I worked on TrackerClient
because it seemed to me that that's the only place where the WebRTC peer connection struct was accessible, but perhaps I'm wrong..?
Do I need to expose something in PeerConn
perhaps?
I opened #803 in draft, as I think there might be some issue getting the stats at the right time before the peer connection is closed, which might result in missing stats. As far as I know, the connection to the tracker server should only be through a simple websocket, not a WebRTC peer connection, so I believe the stats I get should refer to the actual file transfer.
Thanks for your efforts on this. I'm not using the WebRTC stuff heavily right now, so I'm a bit in the dark about your insights.
I recently went back to the issue of WebRTC stats and I just opened #983. This builds on the previous work, but I think now stats on open peer connections are handled better.
Would be great to have your thoughts on it, @anacrolix.
I'm interested in monitoring the quality of the transport via data channel when a transfer is carried out via webtorrent. To do so, I need to access the WebRTC transport stats.
Pion provides stats for the data channel by calling
GetStats()
on thepeerConnection
struct. To be able to call this method during a transfer, I've done the following:Exposed a
GetTransportStats()
method onTrackerClient
, which has access to the wrappedpeerConnection
via theoutboundOffers
map:Exposed a
GetWebRtcPeerConnStats()
method onTorrent
that callsGetTransportStats()
on everyTrackerClient
int.cl.websocketTrackers.clients
:func (t *Torrent) GetWebRtcPeerConnStats() map[string]webRtcStatsReports { stats := make(map[string]webRtcStatsReports) trackersMap := t.cl.websocketTrackers.clients for i, trackerClient := range trackersMap { ts := trackerClient.GetTransportStats() stats[i] = ts } return stats }