Difference between revisions of "Network Protocol"
Line 82: | Line 82: | ||
} | } | ||
__attribute__ ((packed)) header_t;</pre> | __attribute__ ((packed)) header_t;</pre> | ||
+ | |||
+ | RACE records are send from every client to all other clients during a race including the race preparation. Each clients send every 1/30s one record to one other client. | ||
The following table shows: | The following table shows: |
Revision as of 22:22, 12 June 2015
This page describes the network protocol used by Mario Kart Wii.
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 Wii-Homebrew.com (English and German) or at mariokartwii.com (English).
Terms and definition
General description
The Mario Kart Wii traffic starts with some name resolutions. Then it will use TCP connection to the servers and UDP packets for the player to player data transfer.
First it connects the Wiimmfi server (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 the Wiimmfi-Server(s)
When 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
- naswii.nintendowifi.net
("nintendowifi.net" replaced with "wiimmfi.de" for the Wiimmfi server)
Then it starts the communication with nintendos servers and the first packet goes to mariokartwii.available.gs.nintendowifi.net.
→ More Details about the servers
Point to point communication
The Wii uses a frequency of 59.94Hz (based on NTSC, about 1/60s) as time base. All clients send a status packet to one of the other clients every second pulse (~1/30s). When there are 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 only done every 1/15s. This update time is reduced to 11/30s (~1/3s), when there are 12 clients in a race. And that's the reason for the many lagging effects when playing with many players.
The average packet length is about 220 bytes, so the total traffic is about 6.6 KB/s (52.8 KBit/s) in both directions, independent of the number of clients.
Main records ("RACE" records)
Each UDP packet can be split in records. Records are logical units.
A race packet consists of records. The main race header has 8 bytes.
typedef struct header_t { /*00*/ u8 header_len; // always 0x10 (length of checksum record + length of this header) /*01*/ u8 raceheader1_len; // length of the first race header. 0x28 or 0x00 /*02*/ u8 raceheader2_len; // length of the 2nd race header. 0x28 or 0x00 /*03*/ u8 room_select_len; // length of the ROOM or SELECT record. 0x04 (for room), 0x38 (for select), probably 0x3b for both, or 0x00 /*04*/ u8 racedata_len; // length of RACEDATA. 0x40 or 0x00 /*05*/ u8 user_len; // length of USER. 0xc0 or 0x00 /*06*/ u8 item_len; // length of ITEM. 0x08 or 0x00 /*07*/ u8 event_len; // length of EVENT. 0x00, or 0x18 or greater /*08*/ } __attribute__ ((packed)) header_t;
RACE records are send from every client to all other clients during a race including the race preparation. Each clients send every 1/30s one record to one other client.
The following table shows:
- A name used by mkw-ana.
- Data length
- Description.
Name | Length | Description |
---|---|---|
RACEHEADER_1 | ? | Race header |
RACEHEADER_2 | ? | Another race header |
ROOM | 0x04 | The first byte decides the sub type:
Room records are only sent in room events. There is a prefix record "GLOBAL" for non-room-events. |
SELECT | 0x38 | This record is send while selecting driver and track. It is always placed before an USER record. One byte decides the phase:
|
RACEDATA | ? | Actual race data. May exist twice if there are two players on one console. |
USER | 0xc0 ? | A user information including a FC and 2 Miis for both users of the client. |
ITEM | ? | Record indicating the item status |
EVENT | ? | Record indicating the event status |
Additional records
The following table shows:
- A name used by mkw-ana.
- Value of the first 2-4 bytes (Record ID, big endian, hex).
- Length of the record.
- Description.
Name | Record ID | Length | Description |
---|---|---|---|
CHECKSUM | 0000.0000 | 0x08 | A checksum record used for the most data records. |
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 problems, 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 0x08 describes the status type. One task is to select and advice client slots to clients. |
HANDSHAKE | fdfc | 0x14+N | Different handshake records with different length. At the moment, an announce from Nintendo (with ip+port) and a little handshake between host and guest are known. |
QUIT | fefe.68 | 0x03 | This Record is sent when a client quits a rooms or a race. This record isn't prefixed by a CHECKSUM-Record. |
Stages
Room
Table
Prepare a race
Count down
First finished
All finished
Links
- Wiimms mkw-ana (tool)
- Discussion at mariokartwii.com
- Wiimmfi-Project (Project to create own MKWii servers)