How to Become a Great Network Programmer: Part I

By Adam Martin [08.16.07]

 Network programmers, sometimes also called network engineers, are the people behind the technical stuff of any online multiplayer game. Just think for a moment about how complex a big MMOG is, from the ever-changing world, to the hacker sensibilities of some of the players, to the incoming credit card payments of thousands of people worldwide.

Network programmers need to know not only all the minute details of traditional game programmer, but also low-level network protocols (such as TCP-over-UDP), distributed-state management (lockstep), lag-compensation techniques (dead-reckoning), client/server architecture, and more. Additionally, they're usually responsible for all the planning, design, and implementation of the game server.

In theory, there are substantial differences between server development and client-and-protocol development, but in game development, these two jobs often are merged and handled by one person or team. It's easy enough to move between the two that I treat them as a combined subject for most of this article.

Because network programmers need to be such heavy-lifters, they're often paid handsomely. And there's more demand for network programmers now than ever.

Challenging A Network Programmer

Depending on a game's design, networking can easily be one of the top three hardest coding challenges in a development project -- sometimes the hardest. Although hardware has become faster and better infrastructures have increased bandwidth, every year the two toughest problems of networking rarely get any easier: latency and distributed state.

The deciding factor in latency is the speed of electricity in a wire, a limit that we're already close to reaching in many places. The problem with distributed states is that computers in separate physical locations will never be 100 percent in sync (unless you magically reduce latency to zero), and for the same reason you can never know exactly how out-of-sync they are until after the fact.

Bearing these challenges in mind, network programmers have three core responsibilities: 1) using tricks to reduce latency; 2) helping the rest of the development team change its systems to work with those tricks; and 3) implementing a complete game server (completely different from the client development of most games).

As more and more games seek to take advantage of the internet, either for core gameplay (as in MMORPGs, fast-action multiplayer RTS games, or first-person shooters), or for secondary activities, such as community building or modding, the demand for network programmers is at its highest now and seems to only be increasing.


"Blow For Blow": Lineage II

Education

Like all programming jobs, network programming requires a degree. Computer science is the most straightforward department in which to study, but it's feasible to take some other path as long as it's still rooted in computer science at its heart and is at an institution with a strong traditional computer science department.

It's possible to still be a good programmer without a degree, but a mainstream computer science course will teach you so much that will be directly useful to you that life is much harder without it. A game development course at an institution that does not have a computer science department probably won't give you enough traditional material to prepare for a career in game programming.
For those of you currently in college, you still almost certainly have a choice about which modules or courses to take. However, there are a few key classes you should consider, which I'll list below along with some of the major take-away ideas you'll want to get out of them.

At each university or institution, these courses might go by different titles, but you should be able to find a comparable class by reading the "What to learn" part and matching it with a course description or syllabus.

If you've already been to university and want a refresher, or just want to cover the course material without attending, you could try MIT's Open Course Ware.


 Suggested Courses

1. Data Structures and Algorithms

What to learn: How to choose the right data structures for a given problem. What data structures are available or are standard. How to make new data structures for compound problems.

This course is pretty much essential for any serious programmer, even though it's not as necessary for network programmers as it is for, say, graphics programmers. Still, it's very useful and will contribute to one's overall game programming knowledge.

2. Computational Complexity

What to learn: How to calculate the space/time complexity of any algorithm. Using computational complexity to choose which algorithm to use for a given problem.

This class is essential for server programming. The biggest single problem you will have with all server development is scalability, and this class will teach you the basics of scalable code. Without this class, no code you ever write will deliberately scale well, and you'll be forced to learn by trial and error. On the other hand, a computational complexity class lets you calculate in advance what will actually happen.

3. Information Theory

What to learn: Theories of entropy and information. Many different compression and encoding algorithms. Error-correcting encodings. Differencing and patching.

Informational theory is essential to all low-level network code. This class teaches you half of what you need to know to write good wire-protocols for transmitting basic information between different computers on a network. An information theory class will focus especially on the algorithms used to increase performance and correctness even in the face of the inaccurate and lossy internet.

4. Networking

What to learn: The ISO OSI seven-layer model. TCP's 22-state FSM. UDP and TCP packet formats. IP Routing. SYN attacks.

Look to take a networking class some time in your second year of study. You'll mostly learn specific protocols from the internet and how the internet sends data from computer to computer. You should also aim to learn what all the parts of the IP stack are and how they interact to solve (or cause) problems and increase (or reduce) performance.


Guild Wars

5. Relational Databases

What to learn: What "relational" means and why it's fast. Normal form. SQL.

Some network programmers never use SQL while others use it a lot. One thing's for sure: All multiplayer games with any persistence, either of game characters or multiplayer progression, definitely need a database, and in almost every case that's going to be an RDBMS. Databases are always the slowest part of a game server, so knowing how they work and how to achieve high performance with them is extremely helpful when designing and developing servers. Databases are also gradually becoming more prevalent in games, as designers start to persist more and more data "online."

6. Distributed Computing

What to learn: Transactions and how to implement and use them. Different architectures for clustered technology. Operating system and platform support for clustered technology. Messaging and time synchronization between distributed computers.

This is all mostly of use to server programmers, especially MMOG programmers, but it's good for anyone who's trying to make a game scale well with multiple physical servers.

7. Security

What to learn: Standard secure protocols. Threat modeling. Basic cryptography and cryptanalysis.

Although there's really only one thing you need to learn about security ("Never trust the client"), it's an area that's infamous for rarely converting good theory into practice. Classes about security are full of useful examples, interesting anecdotes, and salient warnings of the mistakes you almost certainly will make despite your best efforts, and what to do to minimize the damage. They also cover the basics of encryption, but you'll soon learn that encryption is just one small tool and that most successful attacks don't bother breaking the encryption -- hackers usually find an easier way in.

 


City of Heroes

Field Experience

A degree will only provide you with theoretical knowledge, such as algorithms, protocols, and facts. If you want to be a good network programmer, you have to learn all the nasty stuff, too, the things that shouldn't happen but always do.

In the real world, even the internet itself never quite functions the way it was originally supposed to. Everything you learned about how TCP and IP work falls open to question once you start interacting with other people's code.

That's the essential problem: On any given large network, your source code represents only a tiny fraction of the network traffic, and neither you nor your players have any control over that other traffic.

In Part II of this article, I'll outline four games that you can make in your spare time to get some experience working with real-world constraints -- and that kind of experience is what separates wisdom from knowledge.

Adam Martin, lead programmer at NCsoft Europe, likes to solve difficult problems in online game programming, having spent almost 10 years looking for them. Along the way he's patented technology, written for Game Programming Gems 4 and 5, and founded a couple of start-up companies. His blog has more advice and practical about programming.

The author thanks Jason Beardsley for his help in writing this article.

Return to the web version of this article
Copyright © UBM TechWeb