This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PROTOCOL
120 lines (99 loc) · 3.92 KB
/
PROTOCOL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
MetaServer Protocol Description
--------------------------------
Overview
--------
- important concepts:
- client session, server session
- packets/process involved in creating sessions
- termination of sessions ( and expiry )
- recreating expired sessions
-
Packet Types
------------
[ NMT_NULL ]
Description: empty packet
Type Size: 4 bytes
Value: 0
Payload Size: 0
NMT_SERVERKEEPALIVE
Description: A game server keep-alive packet, part 1 of a 3-packet handshake
Type Size: 4 bytes
Value: 1 ( 00 00 00 01 )
Payload Size: 0
[ NMT_HANDSHAKE ]
Description: The metaserver response to a SERVERKEEPALIVE or CLIENTKEEPALIVE, part 2 of 3-packet handshake
Contains a random number.
Type Size: 4 bytes
Value: 3 ( 00 00 00 03 )
Payload Size: 4 bytes ( a random int )
NMT_SERVERSHAKE
Description: The game server response to a HANDSHAKE, part 3 of 3-packet handshake.
Triggers a new game server sesssion to be created, or updated.
Type Size: 4 bytes
Value: 4 ( 00 00 00 04 )
Payload Size: 4 bytes ( random int )
NMT_CLIENTKEEPALIVE
Description: The game client keep-alive packet, part 1 of 3-packet handshake
Type Size: 4 bytes
Value: 2 ( 00 00 00 02 )
Payload Size: 0
NMT_CLIENTSHAKE
Description: The game client response to a HANDSHAKE, part 3 of a 3-packet handshake
Type Size: 4 bytes
Value: 5 ( 00 00 00 05 )
Payload Size: 4 bytes ( random int )
NMT_LISTREQ
Description: A client request to give a list of servers
Type Size: 4 bytes
Value: 7 ( 00 00 00 07 )
Payload Size: 4 bytes ( int of the offset )
NMT_LISTRESP
Description: The metaserver response with the values of IPs.
Type Size: 4 bytes
Value: 8 ( 00 00 00 08 )
Payload Size: Variable
4 bytes - int total servers sent
4 bytes - int packed servers sent
4 bytes - a 4 byte block representing EACH IP of the servers. So if packed was set to 6,
this block would be 24 bytes long.
NMT_DNSREQ
Description: A client request for a DNS request packet to search for a asession
Type Size: 4 bytes
Value: 32 ( 00 00 00 20 )
Payload Size: Variable
4 bytes - dns type (See DNS_TYPE_*)
4 bytes - length of string
n bytes - sizeof(char) * length of string
NOTE: for forward lookup payload contains name, for reverse lookup payload contains IP ... in both cases AS A STRING.
NMT_DNSRESP
Description: Metaserver response to DNSREQ packet
Type Size: 4 bytes
Value: 33 ( 00 00 00 21 )
Payload Size: Variable
4 bytes - total servers
4 bytes - packed servers ( unused at present )
4 bytes * total servers - length attribute for each element of total servers
n bytes - data payload as a string
Example: a 2 server list response to the forward query for foo.com and the response is 2 IP addresses 123.123.123.123 and 2.3.4.5.
byte index - value
0 - packet type ( 33 )
4 - total servers ( 2 )
8 - packed servers ( 2 ) // unused but sent
15 - length of server 1 as string
7 - length of server 2 as string
22 - data ( 123.123.123.1232.3.4.5 )
Example Use Cases:
Use Case 1: Server Registration or Keep-alive. Only servers with sessions can perform additional
requests, such as attribute registration/removal.
1) Game Server sends a NMT_SERVERKEEPALIVE
2) MS responds with a NMT_HANDSHAKE, contains a random number, creates a handshake
3) Game Server responds with NMT_SERVERSHAKE, contains same random number AND handshake exists,
creates session ( if session exists, expiry time is adjusted )
Use Case 2: Game Server Shutdown / Quit
1) Game Server sends a NMT_TERMINATE, if session exists, it is removed.
Use Case 3: Client Registration or Keep-alive. Only clients with sessions can perform additional
requests, such as LIST, FILTER, etc.
1) Game Client sends a NMT_CLIENTKEEPALIVE
2) MS responds with a NMT_HANDSHAKE, contains random number, creates a handshake
3) Game Client responds with NMT_CLIENTSHAKE, contains same random number AND handshake exists,
creates a client session ( if session exists, expiry time is adjusted ).