Game Development Community

Simulating latency for network testing

by Henry Todd · in Torque 3D Professional · 03/31/2010 (6:10 pm) · 4 replies

I'm testing lag-compensating hitscan weapons, and I need to be able to create scenarios with lag beyond what I can get from any of my real-world remote servers, preferably in my LAN setup. A number of engines include some functionality of this type (ie, HL/Source's fakelag command), but I'm not aware of anything similar in Torque. I see one class which refers to lag simulation (NetDelayEvent), but don't see how it would really accomplish anything.

My setup has two clients and a dedicated server. Realistically, if I could find a way to delay all incoming and outgoing traffic on the DS, that would be sufficient. I'm aware of serveral utilities in Linux that can perform this function, but I don't know of any Windows equivalent.

Is there some internal Torque mechanism for faking lag I'm not finding? It seems like someone must have, at some point, tested Torque with various simulated lag and packet loss scenarios when building the netcode (of course, it worked on Linux back when that code was written).

#1
04/01/2010 (12:00 am)
The NetDelayEvent seems to be used by the console command
ConsoleMethod(NetConnection,setSimulatedNetParams,void,4, 4,"(float packetLoss, int delay)")

Unfortunaltly, I never used it.

Nicolas Buquet
www.buquet-net.com/cv/
#2
04/01/2010 (12:01 am)
Hi Henry,

look for NetSimulateLag in scripts then in C++

I never used it for the moment, but it's there :D
I hope it will work for your testing.

Keep us updated for your hitscan testing.
#3
04/01/2010 (5:55 am)
setSimulatedNetParams() is awesome.

But be aware that it only adds lag and packet loss when sending packets, so for more realistic results you'll have to turn it on on both ServerConnection (the client->server connection) and on LocalClientConnection (the server-client connection).

Having a re-curring schedule that sets the ping to random values within a range over time to simulate latency variation is also a good idea.
#4
04/01/2010 (12:58 pm)
Exactly what I needed, thanks. Packet loss simulation is a bonus. For some reason it never occured to me to search the script end of things.

Setting up a routine to modulate the latency would be a good idea. One aspect of doing lag-compensation is being able to make some determination about the recent average lag from each client, so I'll want to test how my calculations perform in a fluctuating latency scenario.