mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-12-11 20:15:10 +01: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
|
// Steam uses milliseconds
|
||||||
_steamTransport.Timeout = QSBCore.Timeout * 1000;
|
_steamTransport.Timeout = QSBCore.Timeout * 1000;
|
||||||
_steamTransport.TestIpAddress = QSBCore.DebugSettings.SteamTestIpAddress;
|
_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.Timeout = QSBCore.Timeout * 1000;
|
||||||
_steamTransport.TestIpAddress = QSBCore.DebugSettings.SteamTestIpAddress;
|
_steamTransport.TestIpAddress = QSBCore.DebugSettings.SteamTestIpAddress;
|
||||||
|
_steamTransport.DoFakeNetworkErrors = QSBCore.DebugSettings.SteamFakeNetworkErrors;
|
||||||
|
|
||||||
if (QSBCore.IsInMultiplayer)
|
if (QSBCore.IsInMultiplayer)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -42,6 +42,9 @@ public class DebugSettings
|
|||||||
private string _steamTestIpAddress;
|
private string _steamTestIpAddress;
|
||||||
public string SteamTestIpAddress => DebugMode ? _steamTestIpAddress : null;
|
public string SteamTestIpAddress => DebugMode ? _steamTestIpAddress : null;
|
||||||
|
|
||||||
|
private bool _steamFakeNetworkErrors;
|
||||||
|
public bool SteamFakeNetworkErrors => DebugMode && _steamFakeNetworkErrors;
|
||||||
|
|
||||||
public void Update(IModConfig config)
|
public void Update(IModConfig config)
|
||||||
{
|
{
|
||||||
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
||||||
@ -57,5 +60,6 @@ public class DebugSettings
|
|||||||
_latencySimulation = config.GetSettingsValue<int>("latencySimulation");
|
_latencySimulation = config.GetSettingsValue<int>("latencySimulation");
|
||||||
_logQSBMessages = config.GetSettingsValue<bool>("logQSBMessages");
|
_logQSBMessages = config.GetSettingsValue<bool>("logQSBMessages");
|
||||||
_steamTestIpAddress = config.GetSettingsValue<string>("steamTestIpAddress");
|
_steamTestIpAddress = config.GetSettingsValue<string>("steamTestIpAddress");
|
||||||
|
_steamFakeNetworkErrors = config.GetSettingsValue<bool>("steamFakeNetworkErrors");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,6 +144,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"value": "",
|
"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."
|
"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>
|
/// </summary>
|
||||||
public int Timeout;
|
public int Timeout;
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool DoFakePacket;
|
public bool DoFakeNetworkErrors;
|
||||||
|
|
||||||
public override bool Available() => true;
|
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
|
// 50% change of doing all, delay .5 seconds
|
||||||
if (transport.DoFakePacket)
|
if (transport.DoFakeNetworkErrors)
|
||||||
{
|
{
|
||||||
result.Add(new SteamNetworkingConfigValue_t
|
result.Add(new SteamNetworkingConfigValue_t
|
||||||
{
|
{
|
||||||
@ -88,6 +88,24 @@ public static class Util
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
result.Add(new SteamNetworkingConfigValue_t
|
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_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_FakePacketReorder_Send,
|
||||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Float,
|
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Float,
|
||||||
@ -111,7 +129,7 @@ public static class Util
|
|||||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
||||||
{
|
{
|
||||||
m_int32 = 1000
|
m_int32 = 500
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
result.Add(new SteamNetworkingConfigValue_t
|
result.Add(new SteamNetworkingConfigValue_t
|
||||||
@ -138,7 +156,7 @@ public static class Util
|
|||||||
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
|
||||||
m_val = new SteamNetworkingConfigValue_t.OptionValue
|
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.Log = Console.WriteLine;
|
||||||
transport.TestIpAddress = "127.0.0.1:1234";
|
transport.TestIpAddress = "127.0.0.1:1234";
|
||||||
transport.Timeout = 1000;
|
transport.Timeout = 1000;
|
||||||
|
transport.DoFakeNetworkErrors = true;
|
||||||
|
|
||||||
transport.OnServerError = (conn, error, s) => Console.Error.WriteLine($"ERROR {conn} {error} {s}");
|
transport.OnServerError = (conn, error, s) => Console.Error.WriteLine($"ERROR {conn} {error} {s}");
|
||||||
var theConn = -1;
|
var theConn = -1;
|
||||||
@ -120,6 +121,7 @@ public static class Program
|
|||||||
transport.Log = Console.WriteLine;
|
transport.Log = Console.WriteLine;
|
||||||
transport.TestIpAddress = "127.0.0.1:1234";
|
transport.TestIpAddress = "127.0.0.1:1234";
|
||||||
transport.Timeout = 1000;
|
transport.Timeout = 1000;
|
||||||
|
transport.DoFakeNetworkErrors = true;
|
||||||
|
|
||||||
transport.OnClientError = (error, s) => Console.Error.WriteLine($"ERROR {error} {s}");
|
transport.OnClientError = (error, s) => Console.Error.WriteLine($"ERROR {error} {s}");
|
||||||
transport.OnClientDataReceived = (bytes, i) => Console.WriteLine($"RECV {bytes.Join()} {i}");
|
transport.OnClientDataReceived = (bytes, i) => Console.WriteLine($"RECV {bytes.Join()} {i}");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user