mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-08 19:14:12 +00:00
fake packet stuff hooked up to qsb
This commit is contained in:
parent
b5f2eb9258
commit
08e5101ad1
@ -86,6 +86,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
||||
// Steam uses milliseconds
|
||||
_steamTransport.Timeout = QSBCore.Timeout * 1000;
|
||||
_steamTransport.TestIpAddress = QSBCore.DebugSettings.SteamTestIpAddress;
|
||||
_steamTransport.DoFakeNetworkErrors = QSBCore.DebugSettings.SteamFakeNetworkErrors;
|
||||
}
|
||||
|
||||
{
|
||||
@ -171,6 +172,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
||||
|
||||
_steamTransport.Timeout = QSBCore.Timeout * 1000;
|
||||
_steamTransport.TestIpAddress = QSBCore.DebugSettings.SteamTestIpAddress;
|
||||
_steamTransport.DoFakeNetworkErrors = QSBCore.DebugSettings.SteamFakeNetworkErrors;
|
||||
|
||||
if (QSBCore.IsInMultiplayer)
|
||||
{
|
||||
|
@ -42,6 +42,9 @@ public class DebugSettings
|
||||
private string _steamTestIpAddress;
|
||||
public string SteamTestIpAddress => DebugMode ? _steamTestIpAddress : null;
|
||||
|
||||
private bool _steamFakeNetworkErrors;
|
||||
public bool SteamFakeNetworkErrors => DebugMode && _steamFakeNetworkErrors;
|
||||
|
||||
public void Update(IModConfig config)
|
||||
{
|
||||
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
||||
@ -57,5 +60,6 @@ public class DebugSettings
|
||||
_latencySimulation = config.GetSettingsValue<int>("latencySimulation");
|
||||
_logQSBMessages = config.GetSettingsValue<bool>("logQSBMessages");
|
||||
_steamTestIpAddress = config.GetSettingsValue<string>("steamTestIpAddress");
|
||||
_steamFakeNetworkErrors = config.GetSettingsValue<bool>("steamFakeNetworkErrors");
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,12 @@
|
||||
"type": "text",
|
||||
"value": "",
|
||||
"tooltip": "[DEBUG] If not empty, the steam transport will use this ip:port when listening/connecting. Host should probably use 0.0.0.0:port."
|
||||
},
|
||||
"steamFakeNetworkErrors": {
|
||||
"title": "[DEBUG] Steam Fake Network Errors",
|
||||
"type": "toggle",
|
||||
"value": false,
|
||||
"tooltip": "[DEBUG] Aggressively simulates common network errors (loss, lag, reordering, duplication) to test resiliency."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ public class SteamTransport : Transport
|
||||
/// </summary>
|
||||
public int Timeout;
|
||||
/// <summary>
|
||||
/// whether or not to simulate fake packet loss, reorder, and dup
|
||||
/// whether or not to simulate fake packet loss, lag, reorder, and dup
|
||||
/// </summary>
|
||||
public bool DoFakePacket;
|
||||
public bool DoFakeNetworkErrors;
|
||||
|
||||
public override bool Available() => true;
|
||||
|
||||
|
@ -66,8 +66,8 @@ public static class Util
|
||||
}
|
||||
});
|
||||
|
||||
// 50% change of doing all (dont do lag cuz thats all packets), delay max 1 second
|
||||
if (transport.DoFakePacket)
|
||||
// 50% change of doing all, delay .5 seconds
|
||||
if (transport.DoFakeNetworkErrors)
|
||||
{
|
||||
result.Add(new SteamNetworkingConfigValue_t
|
||||
{
|
||||
@ -88,6 +88,24 @@ public static class Util
|
||||
}
|
||||
});
|
||||
result.Add(new SteamNetworkingConfigValue_t
|
||||
{
|
||||
m_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_FakePacketLag_Send,
|
||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
||||
{
|
||||
m_int32 = 500
|
||||
}
|
||||
});
|
||||
result.Add(new SteamNetworkingConfigValue_t
|
||||
{
|
||||
m_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_FakePacketLag_Recv,
|
||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
||||
{
|
||||
m_int32 = 500
|
||||
}
|
||||
});
|
||||
result.Add(new SteamNetworkingConfigValue_t
|
||||
{
|
||||
m_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_FakePacketReorder_Send,
|
||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Float,
|
||||
@ -111,7 +129,7 @@ public static class Util
|
||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
||||
{
|
||||
m_int32 = 1000
|
||||
m_int32 = 500
|
||||
}
|
||||
});
|
||||
result.Add(new SteamNetworkingConfigValue_t
|
||||
@ -138,7 +156,7 @@ public static class Util
|
||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
||||
{
|
||||
m_int32 = 1000
|
||||
m_int32 = 500
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ public static class Program
|
||||
transport.Log = Console.WriteLine;
|
||||
transport.TestIpAddress = "127.0.0.1:1234";
|
||||
transport.Timeout = 1000;
|
||||
transport.DoFakeNetworkErrors = true;
|
||||
|
||||
transport.OnServerError = (conn, error, s) => Console.Error.WriteLine($"ERROR {conn} {error} {s}");
|
||||
var theConn = -1;
|
||||
@ -120,6 +121,7 @@ public static class Program
|
||||
transport.Log = Console.WriteLine;
|
||||
transport.TestIpAddress = "127.0.0.1:1234";
|
||||
transport.Timeout = 1000;
|
||||
transport.DoFakeNetworkErrors = true;
|
||||
|
||||
transport.OnClientError = (error, s) => Console.Error.WriteLine($"ERROR {error} {s}");
|
||||
transport.OnClientDataReceived = (bytes, i) => Console.WriteLine($"RECV {bytes.Join()} {i}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user