A primitive network profiler for Fabric.
Rampant network consumption is probably the last matter of performance considered by modders, after tick lag, framerate lag, and memory pressure. Heavy network traffic can be an indicator of other sorts of lag, and is generally a waste of players' bandwidth, especially those on metered connections. I hope that this tool can assist you in debugging heavy network spammers on your server or world.
Packets are intercepted by using Mixin to hook into the processing machinery.
A snooping Netty
ChannelInboundHandler is installed to intercept and examine vanilla and modded packets, except for
SUpdateTileEntityPacket, which is deferred
until the packet is actually processed, because there we have access to what tile entity type the packet was intended for.
Runtime overhead of the collection itself should be minimal.
Currently, the mod is a proof-of-concept. It can perform sampling of vanilla and modded packets and record class names. It only works on the physical client, and samples inbound packets.
I'm sorry. It could be better, but I want to get it working first.