Open maxhawkins opened 5 years ago
@maxhawkins This is an interesting one! Going back through old tickets and I want to build this! This would be amazing for people to learn and debug.
I don't think we should add toggles to enable/disable it during logging. If users want that they can implement that behavior on their own. I also don't think we can support adding them during runtime. The complexity of plumbing that in I think could be costly/error prone.
What do you think of making it configurable? Via the SettingEngine you can do the following
This could then be broken up into smaller tasks pretty easily.
PacketInterceptor
field that is a PacketConn to ice.AgentConfig
. If set it would wrap interfaces and write.PacketInterceptor
ContextOption
that is a io.Writer
to srtp
. Any packets that are encrypted/decrypted go through that first.One users told me that the best way for them to learn was via a PCAP. This could be such a huge tool, then we could write a blog post and use screenshots to learn.
Summary
Implement a pcap logger that can be enabled in debug mode to generate a packet dump of a PeerConnection.
Motivation
It's difficult to debug issues in the DTLS or RTP stacks because an external packet logger like tcpdump does not have access to the DTLS encryption keys.
To make it easier to track down issues, it should be possible to save a packet dump for analysis.
Design
To aid debugging, the pcap should include all the types of packets Pion sends and receives over its ICE connections:
These should be mapped to IP addresses and port numbers where possible so that issues with STUN and firewall hole punching can be diagnosed.
It should be possible to:
Here's a sketch of a design:
Notes
Related to pion/website#29 Partially implemented PCAP format: pion/webrtc#521