Difference between revisions of "Network Protocol"
Line 86: | Line 86: | ||
! Name !! Record ID !! Length !! Description | ! Name !! Record ID !! Length !! Description | ||
|- | |- | ||
− | | [[MKWii Network Protocol/CHECKSUM|CHECKSUM]] || 0000.0000 || 0x08 | + | | [[MKWii Network Protocol/CHECKSUM|CHECKSUM]] || <tt>0000.0000</tt> || 0x08 |
| A checksum record used for the most data records. | | A checksum record used for the most data records. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/USER|USER]] || 0000.000x || 0xc0 | + | | [[MKWii Network Protocol/USER|USER]] || <tt>0000.000x</tt> || 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. | | 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. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/ANNOUNCE|ANNOUNCE]] || 1000.0000 || 0x08 or 0xc8 | + | | [[MKWii Network Protocol/ANNOUNCE|ANNOUNCE]] || <tt>1000.0000</tt> || 0x08 or 0xc8 |
| 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. | | 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.xxxx || ? | + | | ''unknown'' || <tt>1000.0000.xxxx</tt> || ? |
| ? | | ? | ||
|- | |- | ||
− | | [[MKWii Network Protocol/ROOM|ROOM]] || 1000.0004 || 0x0c | + | | [[MKWii Network Protocol/ROOM|ROOM]] || <tt>1000.0004</tt> || 0x0c |
| A [[MKWii Network Protocol/ROOM|ROOM]] record is always placed before an [[MKWii Network Protocol/USER|USER]] record. The byte at offset 8 decides the sub type: | | A [[MKWii Network Protocol/ROOM|ROOM]] record is always placed before an [[MKWii Network Protocol/USER|USER]] record. The byte at offset 8 decides the sub type: | ||
* '''0:''' ''unknown'' | * '''0:''' ''unknown'' | ||
Line 107: | Line 107: | ||
Room records are only sent in room events. There is a prefix record "GLOBAL" for non-room-events. | Room records are only sent in room events. There is a prefix record "GLOBAL" for non-room-events. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/SELECT|SELECT]] || 1000.0038 || 0x40 | + | | [[MKWii Network Protocol/SELECT|SELECT]] || <tt>1000.0038</tt> || 0x40 |
| This record is send while selecting driver and track. It is always placed before an [[MKWii Network Protocol/USER|USER]] record. The byte at offset 0x3d decides the phase: | | This record is send while selecting driver and track. It is always placed before an [[MKWii Network Protocol/USER|USER]] record. The byte at offset 0x3d decides the phase: | ||
* '''0:''' Prepare the race. | * '''0:''' Prepare the race. | ||
Line 114: | Line 114: | ||
|- | |- | ||
| [[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]] | ||
− | | 1028.2800 || 0x58<br/>+U*0x40<br/>+U*0x08<br/>+0x18<br/>+N | + | | <tt>1028.2800</tt> || 0x58<br/>+U*0x40<br/>+U*0x08<br/>+0x18<br/>+N |
| Record send during race and battle. The content of race and battle records are different. | | Record send during race and battle. The content of race and battle records are different. | ||
The record is followed by 1 or 2 extensions ([[MKWii Network Protocol/RACEDATA|RACEDATA]], each 0x40 bytes) for 1 or 2 users of the client. | The record is followed by 1 or 2 extensions ([[MKWii Network Protocol/RACEDATA|RACEDATA]], each 0x40 bytes) for 1 or 2 users of the client. | ||
After the user extensions a list with items and events is appended. | After the user extensions a list with items and events is appended. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/SLOT|SLOT]] || 46fc.570x || 0x08 | + | | [[MKWii Network Protocol/SLOT|SLOT]] || <tt>46fc.570x</tt> || 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. | | 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. | 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. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/STATUS|STATUS]] || bb49.cc4d || 0x14+N | + | | [[MKWii Network Protocol/STATUS|STATUS]] || <tt>bb49.cc4d</tt> || 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. | | 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. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/HANDSHAKE|HANDSHAKE]] || fdfc.1e66 || 0x14+N | + | | [[MKWii Network Protocol/HANDSHAKE|HANDSHAKE]] || <tt>fdfc.1e66</tt> || 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. | | 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. | ||
|- | |- | ||
− | | [[MKWii Network Protocol/QUIT|QUIT]] || fefe.68 || | + | | [[MKWii Network Protocol/QUIT|QUIT]] || <tt>fefe.68</tt> || 0x03 |
− | | This Record is sent when a client quits | + | | This Record is sent when a client quits a rooms or a race. |
|} | |} | ||
Revision as of 09:20, 26 January 2014
This page describes the network protocol used by Mario Kart Wii. It is very incomplete at this moment.
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
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.
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 | 0x08 or 0xc8 | 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.xxxx | ? | ? |
ROOM | 1000.0004 | 0x0c | A ROOM record is always placed before an USER record. The byte at offset 8 decides the sub type:
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:
|
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. |
QUIT | fefe.68 | 0x03 | This Record is sent when a client quits a rooms or a race. |