Bandwidth Tracking
Kneesnap opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
Problem: I need to debug what packets are using the most bandwidth, but I don't think the ProtocolLib API provides me the ability to determine packet size.)
Describe the solution you'd like
A ProtocolLib command which toggles on / off. While toggled on, ProtocolLib would track information about each packet type sent, on a per-player basis. Track the number of times a certain packet type has been sent, and information about how large the packets were in bytes, after compression. (On average, min, max, etc). Upon disabling this, it should be written to a text file, like how packet logs are.
Describe alternatives you've considered
An alternate solution would be:
A function in PacketContainer, or some other location accessible in the scope of a PacketListener which allows determining how many bytes (after compression), a certain packet will take when sent.
Additional context
I imagine there might be some kind of overhead by doing this, whether it be CPU time or memory allocation. Especially if there's no simple way to do this besides actually writing the packet data to some byte buffer, and getting the size. However, even if the overhead ends up being significant it shouldn't matter since it's debug only.
Hi, your suggestion can be achived using ProtocolLib and a bit of code already.
Do you mind elaborating on this? Which APIs would be used?
Well you can retrieve the network manager of the player, the wrapped channel in it and then add handlers to it and log the in/outbound traffic
Hi,
your suggestion can be achived using ProtocolLib and a bit of code already. Tracking the size of packets would to implement stuff which is unessacary in 99% of the cases, and there is currently no good way to achieve that (ProtocolLib calls packet events before/after en-/de- coding which means that there is no more access to the packet byte size at that point).