Topic : What is Lag?
Author : Geoff Howland
Page : << Previous 2  
Go to page :


which is well under the 340 byte per update limit.

Unfortunately modems rarely get their full speed over the Internet, and packets are often lost. If we sent more information it might not matter if a packet was lost, as we may be able to send all the information needed each time. This is usually not done just because the idea is that if you have a bad Internet connection, you may not be able to play smoothly anyway, but if you have a good connection you will most likely have a better chance of fast updates by sending less information and having the risk of having to resend the packets that are lost.

The Home of Lag: The Internet
There are many things that can happen to your packet when it enters the Internet: it can collide with another packet and need to be resent, it can get lost in the shuffle of routers if a normal connection is down or it can be delayed on a busy network or a number of them.

Since going into full detail on the life of a packet would require a lot of background and messy details, Ill skip to the real basics.

Firstly, the more network devices your packet has to travel through, the longer it will take, and the more chance it will collide with another packet and never reach its destination. In network terms, we call these hops. A packet will hop from your ISP's computer which you are connected to, to your ISP's router, then to your ISP's feed's router, then it will hop along the feed's backbone's routers a couple of times and land on the destination computer's ISP's router, then ISP's computer, then your destination computer.

That's a lot of hopping around, and a lot of chances that you will get a collision. Physical location usually means you have less hops to go once you leave your ISP to the destination ISP, but this isn't always so. You can actually track the amount of hops from your machine to a destination with a tool called "trace route" which will also give you lag times for each hop along the way, so you can find the culprit slowing down your connection. Unfortunately, there usually isn't much you can do about this, unless you find out its your ISP, then you can switch to another.

Average ping times to different sites with a good connection (T-1 or greater) can be about 11-20 milliseconds (ms), average pings to slower sites range more along 70-100 ms, slower pings can be up to 300 ms regularly and can get EXTREMELY bad where it can take several seconds to reach. Packets however don't live this long, they can only bounce around so many times before they are considered obsolete, so the information is better to just be resent.

Taking 300 ms as a time you may actually get often enough on a dial-in modem, you can see that you have a lag time of 1/3 of a second between when you send your information, and when you receive an update from the other player which is a good deal less than the 10 updates a second we said were theoretically possible above. This means that what he did 10 frames ago (on the 30 frames/second model) , you are just seeing now, which means you are very out of sync with each other. If you have a lag of 100 ms instead you will only have a 1/9 of a second or seeing what happened 3 frames ago on your system. This is an improvement by far, but if the game relied solely on this information your opponent would still seem to move in a choppy fashion and seem slow to respond. So what are the solutions?

Smoothness via Duct Tape
Since you cant make the Internet go any faster, and not everyone can have high speed connections or be in the same room or building with each other when they play game developers have had to come up with alternative solutions to how to make multiplayer games seem smooth.

What is commonly done is called interpolating the figures, this is just making an educated guess. If the player is running forward now, then player will more than likely be running forward still on the next update, so until we hear from them, we will assume that they are running forward and move them on the screen this way.

This is how you end up with false kills and things that should have been hits, but weren't, because the system was showing you something but in fact, the other player wasn't really there, you just hadn't gotten the update yet.

Other factors that are involved in this, is how the game determines what is happening and what isn't. So far I have describe the networking in what is called a client to client game. The individual computers just share information about what is happening with each other. This doesn't work very well when you start adding more people though, as you end up waiting for information on everyone, which is taking more of your valuable modem bytes per second.

So another model is what is called a client-server mode. One machine acts as the server, and all updates are sent to it. Then it sends updates back to all the clients and tells them what other clients are doing. Depending on how the game developers made the software, the server may be the machine that determines whether something is a kill or not, or it may all be individually handled on the client machines and the server just passes on the information.

How this is all accomplished could take up a whole article in itself, so let's wrap this up....

It isn't as easy as it sounds
Most likely you didn't read all of this and decide it was easy, but unfortunately, it's even harder than I described it. Normally games are sending much more information or stats then I originally provided for, and sometimes they have to provide information for thirty two, or more players. That means you can send less information with every update if you expect to do it as often or update less or some combination in between.

There is a LOT of tweaking by adjusting small amounts of "how much to send" and "how often to send it", and it just can't be done off the top of your head. This is an extremely hard process to design and implement and it becomes all the harder because the major decision maker on whether the information will get there or not is totally out of the designers hands: the Internet.

Hopefully this cleared up some of the questions you had about what lag is, why it occurs and what is being done to try to work around it. Developers are really trying to make the best multiplayer experiences they can and it takes a lot of individual tuning for each game to do it properly and a lot of testing to get it right.

-Geoff Howland
Lupine Games < http://www.lupinegames.com/ >

Page : << Previous 2