Show MTU in network debug panel.

This commit is contained in:
Pieter-Jan Briers
2024-03-22 22:19:17 +01:00
parent 9bfe889c86
commit f5ade69f6d
4 changed files with 11 additions and 2 deletions
@@ -90,7 +90,7 @@ namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls
contents.TextMemory = FormatHelpers.FormatIntoMem(_textBuffer,
$@"UP: {sentBytes / ONE_KIBIBYTE:N} KiB/s, {sentPackets} pckt/s, {LastSentBytes / ONE_KIBIBYTE:N} KiB, {LastSentPackets} pckt
DOWN: {receivedBytes / ONE_KIBIBYTE:N} KiB/s, {receivedPackets} pckt/s, {LastReceivedBytes / ONE_KIBIBYTE:N} KiB, {LastReceivedPackets} pckt
PING: {NetManager.ServerChannel?.Ping ?? -1} ms");
PING: {NetManager.ServerChannel?.Ping ?? -1} ms, MTU: {NetManager.ServerChannel?.CurrentMtu} B");
}
}
}
+7 -1
View File
@@ -67,6 +67,13 @@ namespace Robust.Shared.Network
/// </summary>
bool IsHandshakeComplete { get; }
/// <summary>
/// Diagnostic indicating the maximum transmission unit being used for this connection.
/// </summary>
/// <seealso cref="CVars.NetMtu"/>
[ViewVariables]
public int CurrentMtu { get; }
/// <summary>
/// Creates a new NetMessage to be filled up and sent.
/// </summary>
@@ -94,6 +101,5 @@ namespace Robust.Shared.Network
/// <param name="reason">Reason why it was disconnected.</param>
/// <param name="sendBye">If false, we ghost the remote client and don't tell them they got disconnected properly.</param>
void Disconnect(string reason, bool sendBye);
}
}
@@ -51,6 +51,8 @@ namespace Robust.Shared.Network
// Only used on server, contains the encryption to use for this channel.
public NetEncryption? Encryption { get; set; }
[ViewVariables] public int CurrentMtu => _connection.CurrentMTU;
/// <summary>
/// Creates a new instance of a NetChannel.
/// </summary>
@@ -440,6 +440,7 @@ namespace Robust.UnitTesting
public NetUserData UserData { get; }
// integration tests don't simulate serializer handshake so this is always true.
public bool IsHandshakeComplete => true;
public int CurrentMtu => 1000; // Arbitrary.
// TODO: Should this port value make sense?
public IPEndPoint RemoteEndPoint { get; } = new(IPAddress.Loopback, 1212);