Difference between revisions of "Server List Ping"

From wiki.vg
Jump to navigation Jump to search
(Added an example ping transcript)
 
(First update for 1.6. Feel free to expand/change around/etc)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
Minecraft supports querying the MOTD, player count, max players and server version via the usual port. Unlike [[Query]], the server list ping interface is always enabled.
 
Minecraft supports querying the MOTD, player count, max players and server version via the usual port. Unlike [[Query]], the server list ping interface is always enabled.
  
== Client -> Server ==
+
== 1.6 - ==
  
The client initiates a TCP connection to the minecraft server on the standard port. Instead of doing auth and logging in (as detailed in [[Protocol Encryption]]), it sends the two byte sequence <code>FE 01</code>. This is a [[Protocol#Server_List_Ping_.280xFE.29|0xFE server list ping]] packet. If the second byte (the 0x01) is missing, the server waits about 1000ms then replies with the [[#Server_-.3E_Client_format_used_in_1.3_and_earlier|Server -> Client format used in 1.3 and earlier]].
+
=== Client -> Server ===
  
== Server -> Client ==
+
The client initiates a TCP connection to the minecraft server on the standard port. Instead of doing auth and logging in (as detailed in [[Protocol Encryption]]), it sends the following data, expressed in hexadecimal:
 +
 
 +
# <code>FE</code> - packet identifier for a [[Protocol#0xFE|server list ping]]
 +
# <code>01</code> - server list ping's payload (always 1)
 +
# <code>FA</code> - packet identifier for a [[Protocol#0xFA|plugin message]]
 +
# <code>00 0B</code> - length of following string, in characters, as a big-endian short (always 11)
 +
# <code>00 4D 00 43 00 7C 00 50 00 69 00 6E 00 67 00 48 00 6F 00 73 00 74</code> - the string "MC|PingHost" encoded as a big-endian [http://en.wikipedia.org/wiki/UTF-16/UCS-2 UCS-2] string
 +
# <code>XX XX</code> - length of the rest of the packet, as a big-endian short
 +
# <code>XX</code> - protocol version - currently 73 (decimal)
 +
# <code>XX XX</code> - length of following string, in characters, as a big-endian short
 +
# <code>XX XX ...</code> - hostname the client is connecting to, as a big-endian UCS-2 string
 +
# <code>XX XX</code> - port the client is connecting to, as a big-endian short.
 +
 
 +
=== Server -> Client ===
  
 
The server responds with a [[Protocol#Disconnect.2FKick_.280xFF.29|0xFF kick]] packet. The packet begins with a single byte identifier <code>ff</code>, then a two-byte big endian short giving the length of the proceeding string in characters. You can actually ignore the length because the server closes the connection after the response is sent.
 
The server responds with a [[Protocol#Disconnect.2FKick_.280xFF.29|0xFF kick]] packet. The packet begins with a single byte identifier <code>ff</code>, then a two-byte big endian short giving the length of the proceeding string in characters. You can actually ignore the length because the server closes the connection after the response is sent.
Line 28: Line 41:
 
     0000040: 0000 3000 0000 3200 30                  ..0...2.0
 
     0000040: 0000 3000 0000 3200 30                  ..0...2.0
  
== Example ==
+
== 1.4 - 1.5 ==
 
 
A parsed transcript of a server list ping follows:
 
 
 
127.0.0.1:26603 connected, there is now 1 client connected
 
====PROTOCOL ANALYSIS====
 
127.0.0.1:26603 ==> Server - Packet of type 0xFE
 
====2 BYTES====
 
0xFE 0x01
 
====PAYLOAD====
 
#1 - Signed Byte: 1
 
127.0.0.1:26603 pinged
 
====PROTOCOL ANALYSIS====
 
Server ==> 127.0.0.1:26603 - Packet of type 0xFF
 
====59 BYTES====
 
0xFF 0x00 0x1C 0x00 0xA7 0x00 0x31 0x00
 
0x00 0x00 0x36 0x00 0x31 0x00 0x00 0x00
 
0x31 0x00 0x2E 0x00 0x35 0x00 0x2E 0x00
 
0x32 0x00 0x00 0x00 0x54 0x00 0x65 0x00
 
0x73 0x00 0x74 0x00 0x20 0x00 0x53 0x00
 
0x65 0x00 0x72 0x00 0x76 0x00 0x65 0x00
 
0x72 0x00 0x00 0x00 0x30 0x00 0x00 0x00
 
0x32 0x00 0x30
 
====PAYLOAD====
 
#1 - Unicode String (28 graphemes, 28 code points): "§1 61 1.5.2 Test Server 0 2
 
0"
 
127.0.0.1:26603 disconnected, there are now 0 clients connected
 
  
'''NOTE''': <code>§1 61 1.5.2 Test Server 0 20</code> is actually <code>§1\061\01.5.2\0Test Server\00\020</code> where <code>\0</code> is the null character (i.e. U+0000).
+
Prior to the Minecraft 1.6, the client -> server operation is much simpler, and only sends <code>FE 01</code>, with none of the following data beginning <code>FA ...</code>
  
== Server -> Client format used in 1.3 and earlier ==
+
== Beta 1.8 - 1.3 ==
  
The packet-structure is the same as above. Only the content of the big-endian UCS-2 string is different.
+
Prior to Minecraft 1.6, the client only sends <code>FE</code>.  
  
This one contains 3 fields delimited by <code>§</code>:
+
Additionally, the response from the server only contains 3 fields delimited by <code>§</code>:
  
 
# Message of the day (e.g. <code>A Minecraft Server</code>)
 
# Message of the day (e.g. <code>A Minecraft Server</code>)
Line 80: Line 67:
  
 
* [https://gist.github.com/1209061 Python]
 
* [https://gist.github.com/1209061 Python]
* [http://forums.bukkit.org/threads/solved-minecraft-server-list-ping-php-script-for-1-4.108096/#post-1395553 PHP]
+
* [https://gist.github.com/5795159 PHP]
 
* [https://gist.github.com/4574114 Java]
 
* [https://gist.github.com/4574114 Java]

Revision as of 04:15, 2 July 2013

Minecraft supports querying the MOTD, player count, max players and server version via the usual port. Unlike Query, the server list ping interface is always enabled.

1.6 -

Client -> Server

The client initiates a TCP connection to the minecraft server on the standard port. Instead of doing auth and logging in (as detailed in Protocol Encryption), it sends the following data, expressed in hexadecimal:

  1. FE - packet identifier for a server list ping
  2. 01 - server list ping's payload (always 1)
  3. FA - packet identifier for a plugin message
  4. 00 0B - length of following string, in characters, as a big-endian short (always 11)
  5. 00 4D 00 43 00 7C 00 50 00 69 00 6E 00 67 00 48 00 6F 00 73 00 74 - the string "MC|PingHost" encoded as a big-endian UCS-2 string
  6. XX XX - length of the rest of the packet, as a big-endian short
  7. XX - protocol version - currently 73 (decimal)
  8. XX XX - length of following string, in characters, as a big-endian short
  9. XX XX ... - hostname the client is connecting to, as a big-endian UCS-2 string
  10. XX XX - port the client is connecting to, as a big-endian short.

Server -> Client

The server responds with a 0xFF kick packet. The packet begins with a single byte identifier ff, then a two-byte big endian short giving the length of the proceeding string in characters. You can actually ignore the length because the server closes the connection after the response is sent.

After the first 3 bytes, the packet is a big-endian UCS-2 string. It begins with two characters: §1, followed by a null character. On the wire these look like 00 a7 00 31 00 00.

The remainder is null character (that is 00 00) delimited fields:

  1. Protocol version (e.g. 47)
  2. Minecraft server version (e.g. 1.4.2)
  3. Message of the day (e.g. A Minecraft Server)
  4. Current player count
  5. Max players

The entire packet looks something like this:

                   <---> first character
   0000000: ff00 2300 a700 3100 0000 3400 3700 0000  ....§.1...4.7...
   0000010: 3100 2e00 3400 2e00 3200 0000 4100 2000  1...4...2...A. .
   0000020: 4d00 6900 6e00 6500 6300 7200 6100 6600  M.i.n.e.c.r.a.f.
   0000030: 7400 2000 5300 6500 7200 7600 6500 7200  t. .S.e.r.v.e.r.
   0000040: 0000 3000 0000 3200 30                   ..0...2.0

1.4 - 1.5

Prior to the Minecraft 1.6, the client -> server operation is much simpler, and only sends FE 01, with none of the following data beginning FA ...

Beta 1.8 - 1.3

Prior to Minecraft 1.6, the client only sends FE.

Additionally, the response from the server only contains 3 fields delimited by §:

  1. Message of the day (e.g. A Minecraft Server)
  2. Current player count
  3. Max players

The entire packet looks something like this:

                   <---> first character
   0000000: ff00 1700 4100 2000 4d00 6900 6e00 6500  ....A. .M.i.n.e.
   0000010: 6300 7200 6100 6600 7400 2000 5300 6500  c.r.a.f.t. .S.e.
   0000020: 7200 7600 6500 7200 a700 3000 a700 3100  r.v.e.r.§.0.§.1.
   0000030: 30                                       0


Sample code