CS594
Internet Draft
Intended Status: Chess Class Project Specification
Expires: April 2023
This memo describes the communication protocol for a networked chess client/server system for the Internetworking Protocols class at Portland State University.
- Introduction
- Basic Information
- Message Infrastructure
3.1. Message Format
3.2. Field Definitions
3.3. Operation Codes
3.4. Error Messages - Messages
---
This specification describes a simple Networked Chess protocol by which clients can play chess games against one another. This system employs a central server which relays the board position and moves played to other connected clients.
Clients can join chess games, which are a pair of clients subscribed to the same game move stream. Any move played on that game will be forwarded to the opponent of that game.
---
All communication descibed in this protocol takes place over TCP/IP, with the server listening for connections on port 8088. Clients connect to this port and maintain a persistent connection to the server. The client can send requests to the server over this open channel, and the server can reply over the same channel. This protocol is asynchronous, as the client is able to send messages to the server at any time, and the server may reply back.
The server has a user limitation and will only allow a finite amount of users and games at this time. The server will notify users with an error code if they attempt to connect when the server is at its capacity. The server and client may choose to terminate the connection at any time for any reason.
---
struct Packet {
opcode: u8,
length: u8,
payload: [u8; self.length]
}
opcode
: specifies what kind of message is contained in the payloadlength
: specifies how many bytes are contained in the payloadpayload
: variable length payload
Op Code | Byte Value |
---|---|
Err | 0x00 |
KeepAlive | 0x01 |
Join | 0x02 |
ListGames | 0x03 |
ListGamesResp | 0x04 |
CreateGame | 0x05 |
CreateGameResp | 0x06 |
JoinGame | 0x07 |
JoinGameResp | 0x08 |
LeaveGame | 0x09 |
LeaveGameResp | 0x0A |
SendMove | 0x0B |
SendMoveResp | 0x0C |
RecvMove | 0x0D |
ShowGame | 0x0F |
ShowGameResp | 0x10 |
Packet {
opcode: 0x00,
length: 1,
payload: [error_code]
}
Error message may be sent by either the client of the server prior to closing the TCP connection. If the client or the server receives this message, the connection should be considiered terminated.
Op Code | Byte Value |
---|---|
Unk | 0x00 |
IllegalOpcode | 0x01 |
IllegalLen | 0x02 |
NameExists | 0x03 |
IllegalMove | 0x04 |
UserLimit | 0x05 |
GameLimit | 0x06 |
BadAddr | 0x07 |
AlreadyInGame | 0x08 |
GameDoesntExist | 0x09 |
MalformedPacket | 0x0A |
InvalidAccess | 0x0B |
---
Packet {
opcode: 0x01,
length: 1,
payload: [0xFF]
}
Provides an application-layer notification of a disconnected peer. Must be sent at least once every 5 seconds by both client and server to notify the other party that they are still connected.
Connection will be terminated upon missing 5 keep alive check-ins.
Packet {
opcode: 0x02,
length: variable,
payload: [(username in bytes)]
}
Packet {
opcode: 0x03,
length: 0,
payload: []
}
Packet {
opcode: 0x05,
length: 0,
payload: []
}
Packet {
opcode: 0x07,
length: 4,
payload: [(id of game in bytes)]
}
Packet {
opcode: 0x09,
length: 0,
payload: []
}
Packet {
opcode: 0x0B,
length: 8,
payload: [(move in bytes)]
}
Packet {
opcode: 0x0F,
length: 0,
payload: []
}