| Home Page |
| Course Page |
4003-420-01/4005-740-01 Data Communications and Networks I
Prof. Alan Kaminsky -- Fall Quarter 2012
|
| ModelListener method | Message encoding |
| started() | 'G' (1 byte) |
| progress (percent) | 'P' (1 byte) Progress (1 byte) |
| found (password) | 'F' (1 byte) Password (UTF-8 string) |
| stopped() | 'S' (1 byte) |
Client-to-server messages are encoded as follows. Each message corresponds to a method in interface ViewListener.
| ViewListener method | Message encoding |
| start (hash) | 'G' (1 byte) Hash (16 bytes) |
| stop() | 'S' (1 byte) |
The Password Crack Application Version 2 is a multi-session single-client network application. The server supports multiple sessions, but each session is associated with just a single client. On the server, a "session" consists of the model object plus the view proxy object with its internal socket and reader thread. When a client sets up a connection to the server, the server creates a brand-new session and hooks up the client to that session.
Source code:
The Password Crack Application Version 3 runs in two processes. The server process contains the model. The client process contains the view. The processes communicate over the network. The application is still designed using the well-known Model-View-Controller (MVC) and Observer patterns. The application also uses the Network Proxy pattern.
The Application Layer protocol for the Password Crack Application Version 3 uses TCP at the Transport Layer. Network messages use an object encoding, are written to the socket using an ObjectOutputStream, and are read from the socket using an ObjectInputStream.
Like the Password Crack Application Version 2, the Password Crack Application Version 3 is a multi-session single-client network application. The server supports multiple sessions, but each session is associated with just a single client. On the server, a "session" consists of the model object plus the view proxy object with its internal socket and reader thread. When a client sets up a connection to the server, the server creates a brand-new session and hooks up the client to that session.
Source code:
Go is played on a 19×19 grid. Colored markers are placed on the grid intersections. For further information, see these Wikipedia articles:
The Network Go Game allows any number of players to play Go and similar games with each other from their own PCs over the network. All players see the same Go board. Each player chooses a color for his or her markers. Left-clicking on an intersection places a marker of the player's color at that point (replacing any existing marker). Right-clicking on an intersection removes the marker if any. Clicking the "Clear Board" button clears the whole board. Clicking the color swatch next to the "Clear Board" button pops up a dialog to let the player choose the marker color. Closing the window removes the player from the game; however, the player's markers if any remain on the board. The computer is not a player in the game and does not enforce any rules, taking turns, etc.; the computer is just a glorified game board.
Unlike the Password Crack Application, the Network Go Game Version 1 is a single-session multi-client network application. The server supports just one session, and all clients are part of that one session. On the server, the "session" consists of the model object plus all the view proxy objects with their internal sockets and reader threads. When a client sets up a connection to the server, the server hooks up the client to the one session.
However, there's a problem with the design so far. To draw the display, the view needs to query the model to determine whether each of the 361 intersections has a marker and what the marker's color is. But the model is in the server, and we don't want all that network traffic to query the model every time we draw the display. Instead, we'll put a clone of the model in each client. A client's view reports user interface actions to the server's model. The server's model updates the model clones in all the clients, the model clones inform their views, and the views query the client-local model clones to redraw their displays.
The Application Layer protocol for the Network Go Game Version 1 uses TCP at the Transport Layer. Network messages use a binary encoding, are written to the socket using a DataOutputStream, and are read from the socket using a DataInputStream.
Client-to-server messages are encoded as follows. Each message corresponds to a method in interface ViewListener.
| ViewListener method | Message encoding |
| addMarker (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| removeMarker (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| clearBoard() | 'C' (1 byte) |
Server-to-client messages are encoded as follows. Each message corresponds to a method in interface ModelListener.
| ModelListener method | Message encoding |
| markerAdded (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| markerRemoved (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| boardCleared() | 'C' (1 byte) |
Source code:
Unlike the Network Go Game Version 1, the Network Go Game Version 2 is a multi-session multi-client network application. The server supports multiple sessions, and each client is part of one session. On the server, each "session" consists of the model object plus all the view proxy objects with their internal sockets and reader threads. When a client sets up a connection to the server, the server hooks up the client to the Session Manager. The first message the client sends tells the server which session the client wants to join; the session name is specified on the client command line. The Session Manager processes this message by creating the session (if it does not already exist) and hooking up the client to the session. Once created, a session persists in the server forever.
The Application Layer protocol for the Network Go Game Version 2 uses TCP at the Transport Layer. Network messages use a binary encoding, are written to the socket using a DataOutputStream, and are read from the socket using a DataInputStream.
Client-to-server messages are encoded as follows. Each message corresponds to a method in interface ViewListener.
| ViewListener method | Message encoding |
| join (session) |
'J' (1 byte)
Session name (UTF-8 string) |
| addMarker (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| removeMarker (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| clearBoard() | 'C' (1 byte) |
Server-to-client messages are encoded as follows. Each message corresponds to a method in interface ModelListener.
| ModelListener method | Message encoding |
| markerAdded (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| markerRemoved (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| boardCleared() | 'C' (1 byte) |
Source code:
The Network Go Game Version 3 is the same as Version 2, except a different transport layer protocol is used.
The Application Layer protocol for the Network Go Game Version 3 uses UDP at the Transport Layer. Each network message is sent as a UDP datagram. Messages use a binary encoding, are written to the datagram payload using a DataOutputStream, and are read from the datagram payload using a DataInputStream. The same encoding is used in Versions 2 and 3.
Client-to-server messages are encoded as follows. Each message corresponds to a method in interface ViewListener.
| ViewListener method | Message encoding |
| join (session) |
'J' (1 byte)
Session name (UTF-8 string) |
| addMarker (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| removeMarker (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| clearBoard() | 'C' (1 byte) |
Server-to-client messages are encoded as follows. Each message corresponds to a method in interface ModelListener.
| ModelListener method | Message encoding |
| markerAdded (r, c, color) |
'A' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) Color (integer, 4 bytes) |
| markerRemoved (r, c) |
'R' (1 byte)
Row r (integer, 1 byte) Column c (integer, 1 byte) |
| boardCleared() | 'C' (1 byte) |
Source code:
The Network Go Game Version 3 does not address the following issues:
The Network Go Game Version 4 uses a peer-to-peer (P2P) architecture rather than a client-server architecture. The two players agree to use a certain host name and port number. Each player runs the same peer program. One peer (the first one to run) listens for a socket connection on the given host and port. The other peer (the second one to run) connects to the first peer at the given host and port. The first peer acts as the "server" for the game; it creates the same objects as the Version 2 server, plus a View object. The second peer acts as the "client" for the game; it creates the same objects as the Version 2 client. (Although Version 4 supports only two players, it could be easily changed to support more than two players by allowing the "server" to accept connections from additional peers, as in Version 2.)
The Application Layer protocol for the Network Go Game Version 4 uses TCP at the Transport Layer and is identical to Version 2.
Source code:
Like Version 4, the Network Go Game Version 5 uses a peer-to-peer (P2P) architecture rather than a client-server architecture. However, the network communication uses multicast datagrams instead of point-to-point sockets. Each peer sends UDP datagrams to and receives UDP datagrams from an agreed-upon multicast group IP address (default: 239.255.0.1) and port number (default: 56789). Whenever any peer in the multicast group sends a datagram, all the peers in the multicast group receive that datagram. Each peer has its own model object and view object. User interface actions update the peer's model object; a message with the new state of the model is then multicast to all peers in the multicast group.
The Application Layer protocol for the Network Go Game Version 5 uses UDP at the Transport Layer. Each network message is sent as a UDP datagram. Messages use a binary encoding, are written to the datagram payload using a DataOutputStream, and are read from the datagram payload using a DataInputStream. Each message corresponds to a method in interface ModelListener. The "unique ID" uniquely identifies the peer that sent the message.
| ModelListener method | Message encoding |
| playerJoined() |
Opcode = 0 (integer, 1 byte)
Unique ID (long, 8 bytes) |
| boardChanged (board) |
Opcode = 1 (integer, 1 byte)
Unique ID (long, 8 bytes) For each non-empty spot on the board: Row index (integer, 1 byte) Column index (integer, 1 byte) Color (integer, 4 bytes) End-of-board sentinel = −1 (integer, 1 byte) |
Source code:
Notes:
Like Version 5, the Network Go Game Version 6 uses a peer-to-peer (P2P) architecture and communicates using multicast datagrams. Version 6 adds two features:
The Application Layer protocol for the Network Go Game Version 6 uses UDP at the Transport Layer. Each network message is sent as a UDP datagram. Messages use a binary encoding, are written to the datagram payload using a DataOutputStream, and are read from the datagram payload using a DataInputStream. Each message corresponds to a method in interface ModelListener. The "unique ID" uniquely identifies the peer that sent the message.
| ModelListener method | Message encoding |
| playerJoined() |
Opcode = 0 (integer, 1 byte)
Unique ID (long, 8 bytes) |
| boardChanged (board) |
Opcode = 1 (integer, 1 byte)
Unique ID (long, 8 bytes) Logical clock (long, 8 bytes) For each non-empty spot on the board: Row index (integer, 1 byte) Column index (integer, 1 byte) Color (integer, 4 bytes) End-of-board sentinel = −1 (integer, 1 byte) |
Source code:
| Course Page |
| Home Page |