DiningHackersProtocol » History » Version 2
Matthieu Herrb, 2018-08-01 12:19
1 | 1 | Matthieu Herrb | h1. THE DINING HACKERS PROTOCOL |
---|---|---|---|
2 | |||
3 | April 14th 2001 |
||
4 | Felipe Bergo @<bergo@seul.org>@ |
||
5 | |||
6 | _"You may have read April 1st RFCs, but no text ever came so close to a February-30th-RFC as this"_ |
||
7 | |||
8 | |||
9 | h2. ABSTRACT |
||
10 | |||
11 | This document describes a protocol meant to provide a centralized service for clients ('dining hackers') who are fighting (more literally than in previous similar protocols) for a finite set of resources. |
||
12 | |||
13 | h2. INTRODUCTION |
||
14 | |||
15 | The Dining Hacker protocol implements a situation similar to that shown in Dijkstra's Dining Philosophers paper. |
||
16 | A finite set of clients with different personalities are competing for a set of resources (chopsticks). |
||
17 | |||
18 | The situation is a round table with at N hackers, N <= 256. |
||
19 | There are always N chopsticks and N chinese food boxes on the table. |
||
20 | Hackers wish to eat, but one must first acquire the two chopsticks adjacent to his own position to start eating. |
||
21 | How much time and how frequently a hacker will eat depends on the client. |
||
22 | But conflict resolution is arbitrated by the server, using RPG-like character sheets. |
||
23 | |||
24 | The protocol itself is divided into 2 sub-protocols, each running on a TCP connection. |
||
25 | |||
26 | h2. CLIENT SUB-PROTOCOL |
||
27 | |||
28 | The Client Sub-Protocol is used to connect a client (hacker) to the dinner table (server). The client connects to TCP 8081 of the server, which will send a greeting message and wait for requests. |
||
29 | |||
30 | The greeting message is terminated by a newline (0x0a) and the only requirement is that it contains the "DINNERD" string (in uppercase characters). Usually it will contain also a version number. |
||
31 | |||
32 | The following operations can be triggered by the client: |
||
33 | |||
34 | h3. GROUP 1 : SET PROPERTIES |
||
35 | |||
36 | Each client has an associated "character sheet", with 5 |
||
37 | properties: name (up to 16 octets), ST (Strength, 1 octet), |
||
38 | DX (Dexterity, 1 octet), Aggr (Aggressivity, 1 octet) and |
||
39 | HT (Health, 1 octet). All properties are read/write, |
||
40 | except HT which starts at 100 and is read only. |
||
41 | |||
42 | 2 | Matthieu Herrb | *Operations* |
43 | 1 | Matthieu Herrb | |
44 | # SET NAME |
||
45 | Client sends 0x30 (up to 16 octets) 0x0a. |
||
46 | The command always succeeds. |
||
47 | # SET ST |
||
48 | Client sends 0x31 ST-octet |
||
49 | The command always succeeds. |
||
50 | # SET DX |
||
51 | Client sends 0x32 ST-octet |
||
52 | The command always succeeds. |
||
53 | # SET Aggr |
||
54 | Client sends 0x33 Aggr-octet |
||
55 | The command always succeeds. |
||
56 | 2 | Matthieu Herrb | |
57 | h3. GROUP 2: GET PROPERTIES |
||
58 | |||
59 | *Operations* |
||
60 | |||
61 | # GET NAME |
||
62 | Client sends 0x3f 0x30 ("?0") |
||
63 | Server replies with 16 octets. The name is |
||
64 | a zero-terminated string. |
||
65 | The command always succeeds. |
||
66 | # GET ST |
||
67 | Client sends 0x3f 0x31 ("?1") |
||
68 | Server replies with the ST octet. |
||
69 | The command always succeeds. |
||
70 | # GET DX |
||
71 | Client sends 0x3f 0x32 ("?2") |
||
72 | Server replies with the DX octet. |
||
73 | The command always succeeds. |
||
74 | # GET Aggr |
||
75 | Client sends 0x3f 0x33 ("?3") |
||
76 | Server replies with the Aggr octet. |
||
77 | The command always succeeds. |
||
78 | # GET HT |
||
79 | Client sends 0x3f 0x34 ("?4") |
||
80 | Server replies with the HT octet. |
||
81 | The command always succeeds. |
||
82 | |||
83 | |||
84 | h3. GROUP 3: RESOURCE USAGE |
||
85 | |||
86 | # REQUEST LEFT CHOPSTICK |
||
87 | Client sends 0x4c ("L") |
||
88 | Server replies 0x30 on failure, 0x31 on success. |
||
89 | # REQUEST RIGHT CHOPSTICK |
||
90 | Client sends 0x52 ("R") |
||
91 | Server replies 0x30 on failure, 0x31 on success. |
||
92 | # DROP LEFT CHOPSTICK |
||
93 | Client sends 0x6c ("l") |
||
94 | The command always succeds. |
||
95 | # DROP RIGHT CHOPSTICK |
||
96 | Client sends 0x72 ("r") |
||
97 | The command always succeds. |
||
98 | |||
99 | h3. GROUP 4: OTHER |
||
100 | |||
101 | |||
102 | # SUICIDE |
||
103 | Client sends 0x51 ("Q") |
||
104 | The command always suceeds. The hacker and his |
||
105 | chopstick are removed from the table. |
||
106 | Disconnecting has the same effect. |
||
107 | |||
108 | h2. INITIALIZATION |
||
109 | |||
110 | The character sheet is generated from random bits upon |
||
111 | connection. Until the client supplies data with SET |
||
112 | requests, he'll have a random 3-character name, HT 100, |
||
113 | ST in [5,15], DX in [5,15] and Aggr in [5,15]. |
||
114 | |||
115 | h2. RESOURCE MANAGEMENT |
||
116 | |||
117 | The great difference from the Dining Philosophers |
||
118 | situation is that hackers have an attitude. They won't |
||
119 | starve while the neighbour is eating happily. They'll |
||
120 | attack their neighbours phisically with punches. |
||
121 | |||
122 | The ST, Aggr and DX stats shape the behavior. A |
||
123 | situation when a hacker may hit a neighbour is |
||
124 | called a hit roll, and is performed by the server. |
||
125 | Clients only find out they've been hit by checking the |
||
126 | HT with GET requests. |
||
127 | |||
128 | A hit roll is performed when a hacker already has |
||
129 | acquired a chopstick, tries to acquire the second |
||
130 | and fails. The hacker is anger at the neighbour who |
||
131 | caused the request to fail, and the server performs |
||
132 | a hit roll. |
||
133 | |||
134 | First the server rolls 3D6 (3 6-faced dice) against |
||
135 | the hacker's Aggr parameter. If the roll is greater |
||
136 | than Aggr, the hacker wasn't upset enough, and won't |
||
137 | proceed with the hit. |
||
138 | |||
139 | If the hacker proceeds with the hit, the server |
||
140 | rolls a dexterity dispute between the attacker |
||
141 | and the defender, with a +2 innitiative bonus for the |
||
142 | attacker. The roll is : |
||
143 | |||
144 | * Attacker: Attacker.DX + 1D6 + 2 |
||
145 | * Defender: Defender.DX + 1D6 |
||
146 | |||
147 | If the defender's result is greater or equal than the |
||
148 | attacker's result, he successfully dodged the punch, and |
||
149 | the hit roll is over. |
||
150 | |||
151 | Else, the punch hit, and the server will roll the |
||
152 | damage, which is |
||
153 | |||
154 | (Attacker.ST x 1D6) / 3 |
||
155 | |||
156 | The damage is subtracted from the defender's HT. |
||
157 | A character is knocked out if his HT reaches 0 or |
||
158 | less. Knocked out characters are disconnected from |
||
159 | the server, and both the character and his associated |
||
160 | chopstick are removed from the table. |
||
161 | |||
162 | h2. STARVATION |
||
163 | |||
164 | The starvation timeout is ST x 3 seconds. The server |
||
165 | knocks off starved hackers. |
||
166 | |||
167 | h2. OBSERVATION SUB-PROTOCOL |
||
168 | |||
169 | The server also provides a secondary protocol for |
||
170 | processes willing to observe the global table |
||
171 | situation. The watcher makes a TCP connection |
||
172 | to port 8082. There's no greeting message, the |
||
173 | server starts listening for requests immediatelly. |
||
174 | To request a global overview the client sends |
||
175 | any octet to the server. |
||
176 | |||
177 | The server replies with a table snapshot made of |
||
178 | |||
179 | 1 octet - H# : NUMBER OF ACTIVE HACKERS |
||
180 | |||
181 | and H# hacker state messages. Adjacent messages |
||
182 | represent adjacent hackers. Each message is 21 |
||
183 | octets long: |
||
184 | |||
185 | 16 octets - hacker name, zero-terminated |
||
186 | 1 octet - ST |
||
187 | 1 octet - HT |
||
188 | 1 octet - DX |
||
189 | 1 octet - Aggr |
||
190 | 1 octet - eating flag, non-zero if the hacker |
||
191 | currently has two chopsticks in his |
||
192 | possession, zero otherwise. |