From f5ade69f6de41859d041cd01e6283c5427847be1 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 22 Mar 2024 00:18:38 +0100 Subject: [PATCH] Show MTU in network debug panel. --- .../CustomControls/DebugMonitorControls/DebugNetPanel.cs | 2 +- Robust.Shared/Network/INetChannel.cs | 8 +++++++- Robust.Shared/Network/NetManager.NetChannel.cs | 2 ++ Robust.UnitTesting/RobustIntegrationTest.NetManager.cs | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugNetPanel.cs b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugNetPanel.cs index ce06806b46..70a6de84e2 100644 --- a/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugNetPanel.cs +++ b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugNetPanel.cs @@ -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"); } } } diff --git a/Robust.Shared/Network/INetChannel.cs b/Robust.Shared/Network/INetChannel.cs index 802d1bdd6e..90fd25044d 100644 --- a/Robust.Shared/Network/INetChannel.cs +++ b/Robust.Shared/Network/INetChannel.cs @@ -67,6 +67,13 @@ namespace Robust.Shared.Network /// bool IsHandshakeComplete { get; } + /// + /// Diagnostic indicating the maximum transmission unit being used for this connection. + /// + /// + [ViewVariables] + public int CurrentMtu { get; } + /// /// Creates a new NetMessage to be filled up and sent. /// @@ -94,6 +101,5 @@ namespace Robust.Shared.Network /// Reason why it was disconnected. /// If false, we ghost the remote client and don't tell them they got disconnected properly. void Disconnect(string reason, bool sendBye); - } } diff --git a/Robust.Shared/Network/NetManager.NetChannel.cs b/Robust.Shared/Network/NetManager.NetChannel.cs index 7bc9074bd4..2bf2cd0b12 100644 --- a/Robust.Shared/Network/NetManager.NetChannel.cs +++ b/Robust.Shared/Network/NetManager.NetChannel.cs @@ -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; + /// /// Creates a new instance of a NetChannel. /// diff --git a/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs b/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs index 04f822384a..29a5d333dd 100644 --- a/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs +++ b/Robust.UnitTesting/RobustIntegrationTest.NetManager.cs @@ -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);