Saturday, March 26, 2011

TF2 Netcode

Today we're going to be discussing the inner workings of the game: the netcode.

For those of you who don't know what it is, netcode is "the application code that handles how data and instructions are passed from computer to computer during a multiplayer game" to quote Basically, it's what regulates how your computer "talks" to the server, which "talks" to every other player ingame with you. It regulates what you can see and do within an online game.

Now, TF2 has a pretty terrible reputation as far as netcode is concerned. I'm sure most of you reading this have had this happen to you:

To start with, you're going to need to understand your own netcode. To do that, open up the developer's console by hitting the tilda key (~) [you may have to enable this under advanced keyboard options] and typing in net_graph 3. You'll see a bunch of numbers that look like this:
Some of these are self-explanatory, some aren't.
FPS is your frames per second. This is dependent on your CPU and GPU.
Ping: the amount of time (in milliseconds) it takes for your computer to send information to the server.
Don't worry about the two numbers immediately to the right of "in" and "out". They are statistics related to your connection, but ultimately aren't that important.
On the second row, far right, is your updaterate value. More on this later.
Below it is your cmdrate value. Again, more on this later.
Loss is a measure of the number of packets that are lost or corrupted in transmission. This relates to the internet connection between your computer and the server, as well as the server itself and the internet, and can't really be helped much by netcode.
Choke indicates that your bandwidth can't actually handle the packets that are being sent to your computer by the server, so you'll experience stuttering. [A quick explanation on that terminology: a server doesn't send a continuous stream of data out to computers; it sends bursts of information, called "packets" at an extremely high frequency]

Here's how to configure your game:
First, navigate over to C:\Program Files\Steam\Steamapps\<your username here>\Team Fortress 2\tf\cfg and create a file in notepad called "autoexec.cfg" without the quotes. This is a configuration file, which holds a list of commands, that is exected (performed) whenever you run TF2. You don't have to do a thing!
First, we'll address rate. Rate is the maximum amount of data you are allowing your computer to receive from the server. If you have your own connection, and don't have to worry about anything else on your bandwidth while you're playing tf2, set this to its maximum value of 1048576. 
Second, we'll address the cl_interp command. Interp is short for interpolation, which makes sense in context. The higher your cl_interp value is, the more your computer will make up data between packets it receives from the server. If you have a bad connection, or are far away from the server, you'll want to set this higher. However, doing so will result in a number of freak gameplay happenings, such as the one seen in the video above. 
Here's a handy dandy recommended interp guide:
 Good connections
cl_interp 0.0152 for projectile classes (demoman, soldier)
cl_interp 0.03 for hitscan classes (everything else)
cl_interp 0.04 for medic (personal preference)

Bad connections
cl_interp 0.03-0.05 for projectile classes
cl_interp 0.05-0.08 for hitscan classes

Keep your cl_cmdrate and cl_updaterate at 67. This is the highest value supported by TF2, and setting it any higher won't help you at all.

Hope this helps with y'all's frustrations! 


  1. thanks for this. I'm sure it'll be quite helpful when i'm not busy sucking at aiming.

  2. I'll get right to work with this information.

  3. Thanks for the configuration settings man, I'll have to use them next time I play.

  4. I'll have to pass this info along to a friend of mine, he's a HUGE tf2 fan. I bet he would love this.

  5. Alright! a tf2 blog, im gona follow this one closely

    tf2 = life

    hats = LIFE

  6. Used to play tf2 way too much, your post made me want to start up again

  7. lots of good info. Never played TF2 but used to play TF1......not sure why I haven't gotten back into it!

  8. This is awesome. Thanks for going in depth.

  9. so when we make the new folder it will just do the stuff listed above


Let me know what you thought about this article! Your feedback helps me write more helpful articles!