cs498gd:networking
Table of Contents
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:
- 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
cs498gd/networking.txt · Last modified: 2013/11/15 20:25 by jchung