Advertisement

Simulating Internet Lag

Started by August 23, 2003 11:14 AM
9 comments, last by RonHiler 21 years, 5 months ago
The way I would do this is to simlpy add a "delay" and "packet loss %" field(s) to my internal packet headers. Since I already have an intermediary step (a buffer) between calling my API's Send() and the data actually being sent, it wouldn't be very hard to iterate over this buffer and decrement each packet's "delay" field every update. If the delay reaches 0, it's time to actually send it, otherwise keep it around for the next update. Would also be easy to do a random check to see if a packet should be dropped, which could have a cascade effect on a certain number of packets after it (lag spike). Could also randomly re-arrange packets in the buffer to simulate out-of-order, although this would be something best left for the receiving end because your seemingly out-of-order packets may end up getting re-ordered by accident by a bad router

Now that I think of it, I wonder where is the best place to perform these tricks? Should it be done before sending out the packets, or after they've been received? I suppose it doesn't make all that much difference since they get manipulated either way. The only thing you don't want is to do it on both sides, or you end up with twice the simulated lag

The downside to simulating lag is that you need bigger buffer to hold the packets that you're playing around with. It also requires more CPU time to play all those tricks behind the scenes. However, it would be very worthwhile to implement such a system. I'm almost motivated to crack open my net code and doing it... but I have to work with UnrealScript now

[edited by - foofightr on August 29, 2003 7:38:17 PM]

This topic is closed to new replies.

Advertisement