Project

General

Profile

DiningHackersProtocol » History » Version 5

Matthieu Herrb, 2018-08-01 12:21

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