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:
+11
-1
@@ -61,7 +61,7 @@ public class PacketStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSentPacketsLastMinute() {
|
public int getSentPacketsLastMinute() {
|
||||||
long now = System.nanoTime() - 1_000_000_000L;
|
long now = System.nanoTime() - 60_000_000_000L;
|
||||||
|
|
||||||
synchronized (sentPacketList) {
|
synchronized (sentPacketList) {
|
||||||
return (int) sentPacketList.stream()
|
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() {
|
public int getReceivedBytesLastMinute() {
|
||||||
long now = System.nanoTime() - 60_000_000_000L;
|
long now = System.nanoTime() - 60_000_000_000L;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -150,11 +150,11 @@ public class LocalTeamspeakClientSocket
|
|||||||
response.add(new CommandSingleParameter("connection_bandwidth_sent_last_second_" + name,
|
response.add(new CommandSingleParameter("connection_bandwidth_sent_last_second_" + name,
|
||||||
Integer.toString(stats.getSentBytesLastSecond())));
|
Integer.toString(stats.getSentBytesLastSecond())));
|
||||||
response.add(new CommandSingleParameter("connection_bandwidth_sent_last_minute_" + name,
|
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,
|
response.add(new CommandSingleParameter("connection_bandwidth_received_last_second_" + name,
|
||||||
Integer.toString(stats.getReceivedBytesLastSecond())));
|
Integer.toString(stats.getReceivedBytesLastSecond())));
|
||||||
response.add(new CommandSingleParameter("connection_bandwidth_received_last_minute_" + name,
|
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)));
|
response.add(new CommandSingleParameter("connection_server2client_packetloss_total", Integer.toString(0)));
|
||||||
|
|||||||
Reference in New Issue
Block a user