Teaching
6515 S '11
 
Projects
Presentations
 
Ingenious
Project 1
Project 2
Project 3
Project 4
Project 5
Project 6
Project 7
Project 8
Project 9
Project 10
Project 11
Project 12
Project 12 D

Project 12: Protocol Design

This design document has two purposes. First it demonstrates how to turn an application developed for a single machine is turned into a distributed system using the remote proxy pattern. Second, the four scenarios specify how the distributed components communicate and how it now becomes possible to replace one of the components (server, client) with a new piece of code as long as the new component implements the protocol.

My protocol design reflects two constraints that aren't explicitly stated. To reduce network traffic, the protocol uses the TCP message only when absolutely needed. To ensure information integrity, the information flow from server to client proceeds on a "by need" basis. Information is only revealed when the client has the right to ask for it; otherwise the client (or in other contexts anyone watching network traffic) may get premature access to information. (Of course, in the real world, you should use secure protocols and encryption.)


Registration


                                     server <~~~~~~~ TCP connection ~~~~~~~~~~~~~~~ client
                    new()              |                                  new()       |
 administrator <---------------------- |          proxy-administrator <---------------|
   |                                   |                  |                           |           
   |                                   |                  |                     new() |           
   |                                   |                  |        p : player <------ |
   |                                   |                  |                    |      |
   |                                   |                  |   register(String,p)      |
   |                                   |      Register    | <------------------------ |
   |                                   | <~~~~~~~~~~~~~~~ |                    |      |
   |                                   |                  |                    |      |
   |                             new() |                  |                    |      |
   |              proxy-player <------ |                  |                    |      |
   |                    |              |                  |                    |      |
   |       register(String,pp)         |                  |                    |      |
   | <-------------------------------- |                  |                    |      |
   |                    |              |                  |                    |      |
   |  accept(N,Tiles[]) |              |                  |                    |      |
   | -----------------> |              |                  |                    |      |
   |                    |                      Accept     |                    |      |
   |                    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> |                    |      |
   |                    |              |                  | accept(N,Tiles[])  |      |
   |                    |              |                  | -----------------> |      |
   |                    |              |                  |                    |      |

   Register    == <register name=String />
   Accept      == <accept player=Nat> Tile Tile Tile Tile Tile Tile </accept> 
   Tile        == <tile c0=Color c1=Color /> 

   Nat         == a natural number less than 1,000,000 


Ready to Start


             proxy-player            proxy-administrator

  players(Player[]) |                       | 
  ----------------> |                       | 
                    |      Player           | 
                    | ~~~~~~~~~~~~~~~~~~~~> |
                    |                       |       players(Player[])
                    |                       | --------------------------->

   Player    == <players> Player Player Player ... </players> 
             %% there are at least two one and at most six five
             %% Player elements in a <players> element

   Player    == <player name=String />


Take Turn


             proxy-player                 proxy-administrator 
                    |                         |           
   take-turn(p,t)   |                         |           
 ------------------>|                         |           
                    |      Turn               |           
                    | ~~~~~~~~~~~~~~~~~~~~~~> |  new(...)
                    |                         |-----------> pt: proxy-turn
                    |                         |             |
                    |                         |   take-turn(p,pt)          
                    |                         |---------------------------------> 
                    |                         |             |                     
                    |                         |             |   place!(placement) 
                    |      Place              |             | <------------------ 
  place!(placement) | <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
  <---------------  |                         |             |                     
                    |                         |             |                     
   ===============> |      TileOrFalse        |             |
   Tile or false    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> | 
                    |                         |             | ==================>
                    |                         |             |    Tile or false 
                    |                         |             |                     
                   ...                       ...           ...
       ** send messages for as many additional placement interactions as allowed
                   ...                       ...           ...     
                    |                         |             |                     
                    |                         |             |   rerack enabled()
                    |                         |             | <------------------ 
                    |                         |             | 

       ** after the first placement, it is acceptable to ask about reracking, too:
       ** if a 'bag check' is needed to check whether reracking is enabled? 
                    |                         |             | 
                    |    Rerack?              |             |                     
   rerack enabled() | <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
  <---------------  |                         |             |                     
   ===============> |      Boolean            |             |
      Boolean       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> | 
                    |                         |             | ==================>
                    |                         |             |   Boolean 
                    |                         |             |                     
                    |                         |             |                     
		    ...                     ...            ...
       ** if reracking is desired: 
                    |                         |             |                     
                    |                         |             |   rerack()
                    |      RackPlease         |             | <------------------ 
      rerack()      | <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
  <---------------  |                         |             |                     
                    |                         |             |                     
                    |                         |             |                     
                    |      Tiles              |             |
   ===============> |      Rerack             |             |
      tiles[]       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> | 
                    |                         |             | ==================>
                    |                         |             |   tiles[]
                    |                         |             |                     
                    |      End                | <================================ 
                    | <~~~~~~~~~~~~~~~~~~~~~~ |        (end of turn)              
                    |                         |             |                     
   <=============== |                         |            ---
     (end of turn)  |                         | 
 

   Turn       == <turn> Board Score Tile ... </turn>
   Board      == <board players=PlayerNumber> Placement ... </board> 
   Score      == <score orange=Nat red=Nat green=Nat yellow=Nat purple=Nat blue=Nat /> 

   Placement  == <placement c0=Color d0=Nat a0=Nat c1=Color d1=Nat a1=Nat /> 
   TileOrFalse is one of: 
                 -- Tile 
                 -- <false />

   Rerack?    == <rerackable />
   Boolean is one of: 
                 -- <true /> 
                 -- <false /> 

   RackPlease == <rerack />
   Rerack     == <rerack> Tile Tile Tile Tile Tile Tile </rerack>

   End        == <end />


Inform Players of Turn


             proxy-player                 proxy-administrator 
                    |                         |           
  res(placement[])  |                         |           
 ------------------>|                         |           
                    |      Result             |           
                    | ~~~~~~~~~~~~~~~~~~~~~~> | res(placement[])
                    |                         | ------------------>

   Result == <result name=String> Placement ... </result>     
          %% empty results: the player was kicked out