Report a minute's bandwidth as bytes per second

setconnectioninfo sent the bytes of the whole last minute where the
server expects the minute's average rate, so others saw our bandwidth
60 times too high. PacketStatistics gains the per-second averages, and
the packets-last-minute count looked at the last second only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 20:26:59 +00:00
co-authored by Claude Opus 5.5
parent 90bf6e030c
commit a4ce0feb61
2 changed files with 13 additions and 3 deletions
@@ -61,7 +61,7 @@ public class PacketStatistics {
}
public int getSentPacketsLastMinute() {
long now = System.nanoTime() - 1_000_000_000L;
long now = System.nanoTime() - 60_000_000_000L;
synchronized (sentPacketList) {
return (int) sentPacketList.stream()
@@ -124,6 +124,16 @@ public class PacketStatistics {
}
}
/** Average bytes per second sent over the last minute, as TeamSpeak reports a minute's bandwidth. */
public int getSentBandwidthLastMinute() {
return getSentBytesLastMinute() / 60;
}
/** Average bytes per second received over the last minute. */
public int getReceivedBandwidthLastMinute() {
return getReceivedBytesLastMinute() / 60;
}
public int getReceivedBytesLastMinute() {
long now = System.nanoTime() - 60_000_000_000L;
@@ -150,11 +150,11 @@ public class LocalTeamspeakClientSocket
response.add(new CommandSingleParameter("connection_bandwidth_sent_last_second_" + name,
Integer.toString(stats.getSentBytesLastSecond())));
response.add(new CommandSingleParameter("connection_bandwidth_sent_last_minute_" + name,
Integer.toString(stats.getSentBytesLastMinute())));
Integer.toString(stats.getSentBandwidthLastMinute())));
response.add(new CommandSingleParameter("connection_bandwidth_received_last_second_" + name,
Integer.toString(stats.getReceivedBytesLastSecond())));
response.add(new CommandSingleParameter("connection_bandwidth_received_last_minute_" + name,
Integer.toString(stats.getReceivedBytesLastMinute())));
Integer.toString(stats.getReceivedBandwidthLastMinute())));
}
response.add(new CommandSingleParameter("connection_server2client_packetloss_total", Integer.toString(0)));