blob: 4ab437885d6ccc9c220daa64f4aab2ce491e42f2 [file] [log] [blame]
Zesstra@Morgengrauen5cad50a2016-04-19 21:44:10 +02001intermud v2.5
2*************
3
4Abstract
5========
6This documents describes how intermud data is send across the internet in the
7protocol specification v2.5.
8This specification is derived from Zebedee Intermud (aka Intermud 2) and
9intends to be compatible to it, i.e. hosts conforming to both protocols should
10be able to exchange data. The aim of v2.5 is to deprecate several historic
11ambiguities, define a more consistent (stricter, less implementation-defined)
12behaviour, add some optional system services and improve reliability and
13remove spoofability of MUDs by introducing hash based message authentication
14codes.
15
16Introduction
17============
18
19Overview
20--------
21The intermud protocols define, how (players on) different muds can
22communicate with each other. There are several different variants.
23In version 2 all muds are peers and directly talking to each other. There
24is no central router. Version 2.5 keeps this behaviour but intends to
25strengthen the P2P character of the intermud by defining a default
26behaviour of learning other peers from one known peer.
27The participants of the intermud are intended to be MUDs, not
28individual players.
29
30Terminology
31-----------
32The capitalized key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
33"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
34"OPTIONAL" in this document are to be interpreted as described in BCP
3514, RFC 2119 [TERMS].
36
37MUD
38 multi user dungeon
39intermud peer
40 a participant in the intermud
41inetd
42 a program encoding and sending and receiving and decoding intermud data
43peer address
44 IP address of a peer (MUD)
45MUD name / peer name
46 a name (string) for a peer (MUD)
47peer identifier
48 a unique combination of MUD name, peer address and peer port
49
50
51Transport layer
52===============
53Data between intermud peers is sent as UDP packets (datagrams) over
54IP.
55Each peer listens on one port and uses one to send data. This kind of
56transfer is inherently unreliable, but it's fast and doesn't use up
57file descriptors.
58
59Packet length (MTU)
60-------------------
61A peer **MUST** be able to send and receive datagrams of at least 1024
62byte length. The default packet length **SHOULD** be 1024 bytes. If a peer
63announces a greater possible length limit, that **SHOULD** be used by other peers
64when sending packets to this peer.
65
66Packet format
67-------------
68All information is encoded and transferred as a string of bytes. The header
69names **SHOULD** consist of ASCII characters.
70Each packet sent consists of a string as follows:
71
72 M:xxx|V:nnn|F:nnn|header1:body1|headerN:bodyN|DATA:body-data
73
74In other words, a header name, followed by a : and then the data
75associated with this header. Each field, consisting of a header/body pair, is
76separated by the | character. This means that headers and their body cannot
77contain the | character. Peers **SHOULD** check for this in outgoing
78packets to avoid decoding errors at the receiving end.
79
80The exception to this is the DATA field. If it is present, it **MUST**
81be positioned at the end of the packet. Once a DATA header is
82found, everything following it is interpreted as the body of the DATA
83field. This means it can contain special characters without error and
84it is used to carry the main body or data of all packets.
85
86By convention, predefined system fields will use capital letters for
87field headers and custom headers used by specific applications will
88use lowercase names to avoid clashes.
89
90A header name **MUST** be unique in a packet.
91
92The fields M (hash based message authentication code), V (version) and F
93(flags) **MUST** be in this order at the start of the packet before any other
94fields.
95
96Fragmented packets
97------------------
98If a packet exceeds the maximum packet length, it **MUST** be split
99(fragmented) into individual packets small enough.
100Each fragment **MUST** start with a fragmentation header describing how the
101fragments are to be reassembled at the receiving end.
102
103These fragmentation headers are of the format:
104
105 PKT:mudname:packet-id:packet-number/total-packets|M:xxx|rest-of-packet
106
107In this case, the mudname and packet-id combine to form a unique id
108for the packet. The packet-number and total-packets information is
109used to determine when all buffered packets have been received. The
110rest-of-packet part is not parsed, but is stored while the receiver
111awaits the other parts of the packet. When/if all parts have been
112received they are concatenated and decoded as a normal packet.
113
114Each fragment **MUST** contain its own valid HMAC in the field M.
115
116The sender **SHOULD** send the fragments in the correct order. However, the
117receiver **MUST** assume the fragments arrive in any order.
118
119The sender **MUST** send all fragments of a packet within 30 s from sending the
120first fragment.
121The receiver **MUST** wait for fragments at least 60 s after the first fragment
122arrived. After this, the receiver may discard any fragments of this packet and
123therefore the packet as a whole.
124
125Packet encoding
126---------------
127Only 2 generic data types are supported (namely strings and integers). All
128other data types **MUST** be expressed as strings or integers.
129
130On encoding integers are simply converted to a corresponding string.
131Strings **MUST** be prefixed with the character $. If the first character of a
132string is the $ character, it is escaped by prepending another $ character.
133
134Packet decoding
135---------------
136On decoding, any string with a $ as its first character will have it removed
137and will then be treated as a string.
138Any other strings will be converted to integers.
139
140The fields M, V and F **SHOULD** be stripped from the packet data that is
141transferred from the inetd implementation to the application.
142
143Legacy mode packets and encoding
144--------------------------------
145Any intermud v2.5 peer **MUST** send data as described above. However, when
146receiving it **MUST** accept data in a relaxed format that is sent by older
147intermud peers. In legacy mode, the following changes are accepted:
148
149* The M, V and F fields are missing (aka: **MUST NOT** be present) or are not the
150 first three header fields.
151* A string **MAY** be prefixed with the character $, but does not have to, unless
152 there ambiguity as to wether they should be decoded as a string or an
153 integer. If a string is losslessly convertable to an integer and back to a
154 string, it **MUST** be prefixed by $.
155 This means however, that any string not starting with $ **MUST** be checked
156 whether it is to be interpreted as integer or string.
157
158If a peer sends to a peer with a known protocol version older than v2.5 it
159**MAY** send the data in the legacy mode. However, this is not recommended.
160
161
162Defined system headers / fields
163===============================
164The fields defined in this section **MUST NOT** be used in any application sending
165data via intermud. The sending inetd **SHOULD** check for this during input
166validation before assembling a packet.
167
168"RCPNT" (RECIPIENT)
169 The body of this field should contiain the recipient the message
170 is to be sent to if applicable.
171"REQ" (REQUEST)
172 The name of the intermud request that is being made of the
173 receiving mud. Standard requests that should be supported by
174 all systems are "ping" (PING), "query" (QUERY), and "reply"
175 (REPLY). The PING request is used to determine wether or not a
176 mud is active. The QUERY request is used to query a remote mud
177 for information about itself (look at the udp/query module for
178 details of what information can be requested). The REPLY request
179 is special in that it is the request name used for all replies
180 made to by mud B to an initial request made by a mud A. It is
181 mud A's responsibility to keep track of the original request
182 type so that the reply can be handled appropriately.
183"SND" (SENDER)
184 The name of the person or object which sent the request or to
185 whom replies should be directed. This is essential if a reply
186 is expected.
187"DATA" (DATA)
188 This field should contain the main body of any packet. It is
189 the only field that can contain special delimiting characters
190 without error.
191
192The following headers are used internally by the inetd and should
193not be used by external objects:
194
195"HST" (HOST)
196 The IP address of the host from which a request was received.
197 This is set by the receiving mud and is not contained in
198 outgoing packets.
199"ID" (ID)
200 The packet id. This field is simply an integer which is set by
201 the sending inetd. The number is incremented each time a packet
202 is sent (zero is never used). This field is only needed if a
203 reply is expected. REPLY packets _must_ include the original
204 request id. This is _not_ done by the inetd.
205"NAME" (NAME)
206 The name of the local mud. Used for security checking and to
207 update host list information.
208"PKT" (PACKET)
209 A special header reserved for packets which have been split.
210 See PACKET PROTOCOL / FORMAT.
211"UDP" (UDP_PORT)
212 The UDP port the local mud is receiving on. Used for security
213 checking and updating host list information.
214"SYS" (SYSTEM)
215 Contains special system flags. The only system flag used at
216 present is TIME_OUT. This is included in packets returned due
217 to an expected reply timing out to differentiate it from an
218 actual reply.
219
220
221Intermud requests / modules
222===========================
223
224Mandatory requests / modules
225----------------------------
226The following are standard request types that **MUST** be supported
227by all systems:
228
229"ping" (PING)
230 This module should return a REPLY packet that contains the
231 original requests ID in it's ID field and the SENDER in it's
232 RECIPIENT field. It should also include an appropriate string
233 in the DATA field, eg. "Mud-Name is alive.\n"
234"query" (QUERY)
235 This module expects the type of query requested to appear in the
236 recieved DATA field. It should return a REPLY packet containing
237 the original ID in the ID field, the SENDER in it's RECIPIENT
238 field, and the query type in a QUERY field. The DATA field should
239 contain the information requested.
240
241
242Optional requests / modules
243----------------------------
244