Difference between revisions of "Network Protocol"

From Custom Mario Kart
Jump to navigation Jump to search
m
m (→‎Records: SELECT-Record)
Line 98: Line 98:
 
* '''1:''' Before first race: Driver selection. All races track selection by user.
 
* '''1:''' Before first race: Driver selection. All races track selection by user.
 
* '''2:''' Track lottery. Before start of the lottery, the host sends to all clients the winning user and track.
 
* '''2:''' Track lottery. Before start of the lottery, the host sends to all clients the winning user and track.
 +
So, the lottery is only a show with a predefined outcome.
 
|-
 
|-
 
| [[MKWii Network Protocol/RACE|RACE]]<br/>[[MKWii Network Protocol/RACEDATA|RACEDATA]]<br/>[[MKWii Network Protocol/ITEM|ITEM]]<br/>[[MKWii Network Protocol/EVENTHEAD|EVENTHEAD]]<br/>[[MKWii Network Protocol/EVENTDATA|EVENTDATA]]
 
| [[MKWii Network Protocol/RACE|RACE]]<br/>[[MKWii Network Protocol/RACEDATA|RACEDATA]]<br/>[[MKWii Network Protocol/ITEM|ITEM]]<br/>[[MKWii Network Protocol/EVENTHEAD|EVENTHEAD]]<br/>[[MKWii Network Protocol/EVENTDATA|EVENTDATA]]

Revision as of 12:31, 6 September 2013

This page describes the network protocol used by Mario Kart Wii. It is very incomplete at this moment.



In Progress
This article is managed by Wiimm and will grow slowly. Feel free to edit typos and grammatical or speech issues. If you have additional information, please complete this page.


Introduction

The analysis of the data is done with the tool mkw-ana. So the naming of mkw-ana for objects (records, stages, ...) is used here. Because of the very early phase of the analysis, names and structures may completely change.

You can discuss this topic at mariokartwii.com.

Terms and definition

Template:MKWii Network Terms

General description

The Mario Kart Wii traffic starts with some name resolutions. Then it will use only UDP packets.

First it connects Nintendos servers (N-server). In a room or while racing, all Wiis communicate directly to each other. In a race, only some alive records are send to a N-server.

Connecting Nintendo servers

If entering the Mario Kart WFC, the Wii started with DNS queries to find out the IP addresses of the following servers:

  • gpcm.gs.nintendowifi.net
  • gpsp.gs.nintendowifi.net
  • gamestats.gs.nintendowifi.net
  • gamestats2.gs.nintendowifi.net
  • mariokartwii.available.gs.nintendowifi.net
  • mariokartwii.natneg1.gs.nintendowifi.net
  • mariokartwii.natneg2.gs.nintendowifi.net
  • mariokartwii.natneg3.gs.nintendowifi.net
  • mariokartwii.master.gs.nintendowifi.net
  • mariokartwii.gamestats.gs.nintendowifi.net
  • mariokartwii.gamestats2.gs.nintendowifi.net
  • mariokartwii.ms19.gs.nintendowifi.net

Then it starts the communication with nintendos servers and the first packet goes to mariokartwii.available.gs.nintendowifi.net.

Point to point communication

The Wii use a frequency of 59.94Hz (based on NTSC, about 1/60s) as time base. All clients send every second pulse (~1/30s) a status packet to one of the other clients. If there for example 3 clients A, B and C, then A sends first a packet to B and then, 1/30s later, a packet to C, and again 1/30s later, the next packet to B. this means, that the individual status update is done only every 1/15s. This update time is reduced to 11/30s (~1/3s), if 12 clients are playing. And that's the reason for the many lagging effects if playing with many players.

The average packet length is about 220 bytes, so the the total traffic is about 6.6 KB/s (52.8 KBit/s) in both directions, independent of the number of clients.

Records

Each UDP packet can be split in records. Records are logical units. The following table shows:

  • A name used by mkw-ana.
  • Value of the first 4-6 bytes (Record ID, big endian, hex).
  • Length of the record.
  • Description.
List of Records
Name Record ID Length Description
CHECKSUM 0000.0000 0x08 A checksum record used for the most data records.
USER 0000.000x 0xc0 A user information including a FC and 2 Miis for both users of the client. x is 1 for 1 player or 3 for 2 players.
ANNOUNCE 1000.0000.0000 0x08 Announce a new user by sending it's FC4. This record is send by a Nintendo Server to the host and the new guest. After receiving an announce, both clients start with a little handshake.
unknown 1000.0000.00c0 0xc8 ?
unknown 1000.0000.xxxx ? ?
ROOM 1000.0004 0x0c A ROOM record is always placed before an USER record. The byte at offset 8 decides the sub type:
  • 0: unknown
  • 1: Send by host: Start an event (GP, Team, Ballon or Coin).
  • 2: unknown
  • 3: unknown
  • 4: Send a room message (online chat).

Room records are only sent in room events. There is a prefix record "GLOBAL" for non-room-events.

SELECT 1000.0038 0x40 This record is send while selecting driver and track. It is always placed before an USER record. The byte at offset 0x3d decides the phase:
  • 0: Prepare the race.
  • 1: Before first race: Driver selection. All races track selection by user.
  • 2: Track lottery. Before start of the lottery, the host sends to all clients the winning user and track.

So, the lottery is only a show with a predefined outcome.

RACE
RACEDATA
ITEM
EVENTHEAD
EVENTDATA
1028.2800 0x58
+U*0x40
+U*0x08
+0x18
+N
Record send during race and battle. The content of race and battle records are different.

The record is followed by 1 or 2 extensions (RACEDATA, each 0x40 bytes) for 1 or 2 users of the client. After the user extensions a list with items and events is appended.

SLOT 46fc.570x 0x08 The following message is related to client slot x (default: for the sender). This is mainly used in combination with ANNOUNCE and USER to tie information to specific client slots.

If a client has bandwidth problem, it can use another client as proxy to reduce its own traffic during the race. Such indirect packets are also prefixed by a SLOT record.

STATUS bb49.cc4d 0x14+N A status record with 5 different extensions. Byte 9 describes the extension length N and is 0, 4, 8, or 16. One task is to select and advice client slots to clients.
HANDSHAKE fdfc.1e66 0x14+N Different handshake records with different length. At the moment an announce of Nintendo (with ip+port) and a little handshake between host and guest are known.

Stages

Room

Table

Prepare a race

Count down

First finished

All finished

Links


Template:MKWii Network Protocol