CodeWhore.com
 Networking: Division of Labor   Home 

A networked simulation should be designed in layers, each performing a specific task. The most logical and convenient division of labor is three-fold:

Networking is simply an abstraction layer that determines how the hosts send and receive data. On top of that, the modeling layer adds the gameplay, so that players and objects interact. Finally, the interface displays the simulation to the screen so that the user can interact with it.

The network layer manages the physical link between hosts in the session It hides the details of network protocols, packet formats, and addresses from the upper layers. It provides the following services to the modeling engine:

[Networking]
  • Creating a new session and advertising it to others
  • Finding and joining advertised sessions
  • Recognizing when a host joins or leaves the session
  • Exchanging status updates quickly between hosts
  • Exchanging state changes reliably between hosts
 

The modeling layer is the most important part of the software, because it drives and enforces all of the gameplay logic. In addition, it must keep the simulation consistent across hosts in the network session:

[Modeling]
  • Adding and removing objects in the world
  • Tracking and modifying object properties over time
  • Handling object interactions, such as collisions
  • Enforcing the rules, whether physics or Checkers
  • Updating team alliances, point scores, and kill ratios.
 

A simulation without any interface is pretty boring. Most games let the user observe the world from a fixed point, or interact with it using an agent. The user interface reads from the modeling layer and displays all or some of it to the user, filling the screen with fancy graphics and the speakers with whizzy sound effects:

[Interface]
  • Selecting which game to play and changing player preferences.
  • Describing the world to the user with text, 2D, or 3D graphics.
  • Overlaying the graphic display with indicators and gauges.
  • Adding to the experience with sound effects or music tracks.
  • Checking for user input via keyboard, mouse, or joystick.
 

By enforcing this design, each part of the software can be improved or exchanged easily. The 3D graphics engine for your first person shooter can be used to make even battleship interesting, or you can implement Tetris on top of the same networking library you used for a space exploration game.

Copyright (c) 1999-2003 Matt Slot and Ambrosia Software, Inc.