Table of Contents
Game Networking
Networking Basics
Network Design (Topologies)
Networking in Java
A Simple Networked Game Example
Diagnostic Tools
Game Networking
Networking Basics
Networking: shifting bits from point A to point B
Internet Protocol (IP) - Network layer
The
Open Systems Interconnection model (OSI model)
defines 7 abstraction “layers” for a communications system.
Puts data bits into a network packet that tells where the packets need to go
Not reliable by itself
User Datagram Protocol (UDP) - Transport layer
Uses IP for addressing and routing
Divides the bits of a packet into groups and sends them in several successive packets
Transmission Control Protocol (TCP) - Transport layer
Guarantees reliable delivery in the order in which the packets were sent
Uses IP for addressing and routing; hence better known as TCP/IP
Socket - An endpoint in the IP protocol for sending and receiving data between networked computers
Packet - A block of data sent over the network
transmits the identities of the sending and receiving stations, error-control information, and a payload (data or messages)
Port - Where information goes into or out of a networked computer
Ports for major networked services are standardized.
HTTP is port 80, MySQL is port 3306, SSH is port 22, etc.
See
http://www.iana.org/assignments/port-numbers
for list of port numbers
Network Design (Topologies)
Most common: client-server
Other designs:
Which one of these comes closest to a P2P (peer-to-peer) model?
Networking in Java
Package: java.net.*
You will almost certainly need the package java.io.* for Java networking
Useful packages:
Socket
ServerSocket
Implementing a client: see
SocketTest.java
Implementing a server: see
SingleEchoServer.java
A Simple Networked Game Example
Download
NetworkedGame.zip
SimpleGameServer.java
is a standalone server meant to be compiled and run separately.
PlayerClient.java
is currently set to connect to
HOST=10.1.13.147 (cslin13.monmouth.edu)
.
If you run
SimpleGameServer
on a computer other than cslin13, you'll need to change what HOST is set to in
PlayerClient.java
.
A Game Server
Manage multiple players
Have some capacity
routine must exist to determine whether server is full
Add and remove players
Send data to one or multiple players
Process players' inputs
A Game Client
Connect to game server
Read and process data from server
Send data to server (for it to process)
Render the content
Diagnostic Tools
Netcat - The network “Swiss-army knife;” reads and writes data across TCP or UDP network connections
Wireshark
- For sniffing and analyzing packets
nmap
- Network mapper; determines open ports and server software installed on a machine