Network Protocol/Server/mariokartwii.master.gs.nintendowifi.net

From Custom Mario Kart
< Network Protocol‎ | Server(Redirected from MASTER)
Jump to navigation Jump to search

QUERY (0x00)

This is not used by MKWii. This packet is sent by the server and answered by the client.

FE FD 00 43 4F 52 59 FF FF 00
FE FD 			Server-Message
00			is the message type
43 4F 52 59  		is the Client-ID
FF 			indicates if server info and rules should get returned (0xFF = yes, 0x00 = no)
FF  			indicates if player info should get returned (same as above)
00 			indicates if team info should get returned (same as above)

CHALLENGE (0x01)

The packet from the Wii for Authentication looks like this:

01 82 2B 3E 31 55 71 35 72 45 70 68 79 75 30 48 38 4F 30 7A 6F 43 2F 55 2F 51 38 6B 6B 52 66 51 41 00
01			is the message type (CHALLENGE)
82 2B 3E 31 		is the Client-ID
55 71 35 72 45 70 68 \ 
79 75 30 48 38 4F 30 \
7A 6F 43 2F 55 2F 51 \
38 6B 6B 52 66 51 41	challenge
00			end

The Server-Answer for 0x01 (so starting with 0xFEFD01) has the following format:

FE FD 01 82 2B 3E 31 30 4C 7B 6F 7E 5A 30 30 30 41 30 30 30 30 30 36 39 46 31 36 00
FE FD 			Server message
01 			is the message type (CHALLENGE_RESPONSE)
82 2B 3E 31 		is the Client-ID
30 4C 7B 6F 7E 5A 30 30 is a printable ASCII (but not BASE64) string with 6 random bytes and an appended 0x3030. Challenge-string. 
30 41 30 30 30 30 30 36 is the client-external-IP4 as hexdump: "30 41" ⇒ "0a" ⇒ 10 for 10.0.0.6.
39 46 31 36 		is the external client port as hexdump: "39 46 31 36" ⇒ "9f16" ⇒ 40726
00 			end

ECHO (0x02)

This is not needed for MKWii but it might be important for other games.

The Server sends a packet starting with "0xFEFD02" to check if we are behind NAT. If the Wii sends no answer, the Server knows we are behind NAT and need NATNEG. The Wii would answer with 0x05 (ECHO_RESPONSE) if it received an answer, but this never happens because it's always behind NAT (hard-coded in game).

HEARTBEAT (0x03)

The HEARTBEAT-Record is sent by the client during a race or a connection to WFC.

It starts with one byte which is always 0x03 indicating that a HEARTBEAT-message follows. Bytes 0x2 to 0x5 are a 4-Byte-Client-ID

After that, there follows this data:

localip0.<local-IP>.
localip1.190.190.190.190.
localport.<local port (or 0)>.
natneg.<natneg>.
gamename.mariokartwii.
publicip.<latest reachable host on traceroute to client>.
publicport.<public port (or 0)>.
numplayers.<player count minus 1>.
maxplayers.<max player count>.
unknown.<dwc-profile-id>.
unknown.<dwc_mtype>.
unknown.<dwc_mver>.
unknown.<dwc_eval>.
unknown.<dwc_groupid>.
unknown.<dwc_hoststate>.
unknown.<dwc_suspend>

<max player count> is the max number of guests, so it's either 0 or 11. <natneg> indicates if NAT negotiation is needed, this is always "1" in MKWii. If <publicip> is 0 or not set, the server sends a 0xFEFD01-packet containing the IP.

Dolphin has a little bug in this packet, when using Dolphin, localip0 is always 10.0.1.30. But this is only a problem if the client is behind the same NAT than the server (and does not need natneg).

ADDERROR (0x04)

A packet starting with 0xFEFD04 is sent by the server to tell the client he is behind NAT and the echo packet didn't arrive.

ECHO_RESPONSE (0x05)

This does never happen on a Wii, since "firewall=1" is hardcoded in the games. This normally gets sent by the client to tell the server that the ECHO-message arrived.

CLIENT_MESSAGE (0x06)

There are two (or more?) different variants of message type 0x06 - the first one is very short and contains a player ID and a natneg packet. The second one contains a player ID and some other data, but no natneg. Both types are sent by the server. Sometimes a client sends the second part of type 2 (starting at 0xBB49CC4D) to the ms19-server.

Type 1

FE FD 06 EC 95 5A 32 05 8E 2B D9 FD FC 1E 66 6A B2 6A 72 00 71
FE FD 				Server-Message
06 				message-type
EC 95 5A 32  			is the client-ID
05 8E 2B D9 			is any unknown payload (seems to be upcounting)

FD FC 				start of natneg-packet
1E 66 6A B2 			is the natneg-constant
6A 72 00 71			is the client-ID of the other client

Type 2

Type 2 is a STATUS-Record send via MASTER as a proxy.

CLIENT_MESSAGE_ACK (0x07)

This is the answer of the client to 0x06.

07 EC 95 5A 32 05 8E 2B D9
07 				message-typ
EC 95 5A 32  			is the client-ID
05 8E 2B D9 			any unknown payload (same as in 0x06)

KEEPALIVE (0x08)

This is sent by the client.

08 82 2B 3E 31
08		is the message type (KEEPALIVE)
82 2B 3E 31	is the client-ID

AVAILABLE (0x09)

This packet gets handled by the available-server.

CLIENT_REGISTERED (0x0A)

The server returns that the client is logged in now. This gets sent after CHALLENGE.

FE FD 0A 3D B0 A8 D6 00 00 00 00 00 00 00 00 00 00 00
FE FD 				  Server-Message
0A 				  is the message type (RESPONSE_CORRECT)
3D B0 A8 D6			  is the client-ID
00 00 00 00 00 00 00 00 00 00 00  is the empty data.