Netcode for online gaming When milliseconds matter

Image: Capcom

For some online applications, network performance is critical. Any online gamer will agree, and timing is especially critical for online fighting games: a few milliseconds can literally make the difference between a hit and a miss.

Most readers will be aware that most applications send data over the Internet using the TCP transport protocol, sacrificing a bit of speed for reliability, or could also opt to use UDP for maximum performance, while accepting some data might never arrive. Whatever option you go with, you’ll still have to deal with unstable networks: some data might arrive quickly, while a little while later the network becomes more busy, slowing down the communication. For applications that are so dependent on timing, neither TCP nor UDP by itself is a good enough solution.

It turns out that there’s a lot more an application can do to deal with fluctuating network latency. Prepare to enter the world of Netcode, where specific code is added to the game itself to deal with this challenge.

In general there are two approaches: delay based, which is basically waiting long enough so that all data will hopefully arrive in time, or rollback, which is to just move forward in anticipation of what’s most likely to happen, and correct for any mistakes later when and if different information is received.

There’s a lot more to say about this topic. If you’re interested, I would love to refer you to this great in-depth article on arstechnica.com.

1 thought on “Netcode for online gaming

Leave a Comment

Your email address will not be published.