XIV Dev Wiki
Search…
Packet Structure
Game packet structures
Game packets are composed of 3 distinct parts, the packet header, the segment header and a (sometimes) optional IPC header.
While 'IPC' is incorrect terminology given the usage, SE calls it IPC so the naming has been preserved.

Packet Header

1
struct FFXIVARR_PACKET_HEADER
2
{
3
uint64_t magic[2];
4
uint64_t timestamp;
5
uint32_t size;
6
uint16_t connectionType;
7
uint16_t segmentCount;
8
uint8_t unknown_20;
9
uint8_t isCompressed;
10
uint32_t unknown_24;
11
};
Copied!
Field
Description
magic
A magic value that identifies a packet.
This is FF14ARR if you read it both in it's hexadecimal and ascii representation at the same time.
timestamp
The number of milliseconds since the unix epoch when the packet was sent
size
The size of the entire packet including its segments and data
connectionType
The connection type. This will be 1 for zone channel connections and 2 for chat.
This is only sent on the initial connection now, previously this was sent with every packet but that is no longer the case.
unknown_20
Alignment most likely
isCompressed
Whether the segments + remaining data is compressed. The header is always uncompressed
This data is compressed with zlib and there is no header - default compression settings.
unknown_24
Alignment

Segment Header

1
struct FFXIVARR_PACKET_SEGMENT_HEADER
2
{
3
uint32_t size;
4
uint32_t source_actor;
5
uint32_t target_actor;
6
uint16_t type;
7
uint16_t padding;
8
};
Copied!
Field
Description
size
The size of this segment and its data (if any)
source_actor
The actor id of the actor who effectively caused this packet to be sent.
For example, if another player casts an action, the source_actor field will contain their actor id
target_actor
The actor id of the actor who is affected by the packet
This isn't used consistently, but the same logical rules apply as source_actor.
type
The type of segment, see below for more detail.
Based on the value of this field indicates what kind of data you'd expect to find after the segment header.
padding
Alignment

Segment Types

1
enum FFXIVARR_SEGMENT_TYPE
2
{
3
SEGMENTTYPE_SESSIONINIT = 1,
4
SEGMENTTYPE_IPC = 3,
5
SEGMENTTYPE_KEEPALIVE = 7,
6
//SEGMENTTYPE_RESPONSE = 8,
7
SEGMENTTYPE_ENCRYPTIONINIT = 9,
8
};
Copied!
Type
Description
SEGMENTTYPE_SESSIONINIT
Used to login to a world or chat server.
The packet that has a segment that has a type set to this will contain a correct connectionType set in the packet header. Use this to record what kind of connection it is.
Example implementation is in Sapphire.
SEGMENTTYPE_IPC
Used for segments that contain data that should be handled by the packet router for the associated channel.
Chat messages, using actions and etc. will always be sent via this segment type and there will be a FFXIVARR_IPC_HEADER immediately following the segment header.
SEGMENTTYPE_KEEPALIVE
to-do: can't remember where this is actually used - lobby?
As a note, world (and chat?) use IPCs to ping/pong. Because reasons.
SEGMENTTYPE_ENCRYPTIONINIT
Used to initialise blowfish for the lobby channel.
The client sends a packet to lobby with it's key phrase which is then used to ''''''secure'''''' a lobby session.
Spoiler alert: it's not secure

IPC Header

Only present when the parent segment type is set to SEGMENTTYPE_IPC.
1
struct FFXIVARR_IPC_HEADER
2
{
3
uint16_t reserved;
4
uint16_t type;
5
uint16_t padding;
6
uint16_t serverId;
7
uint32_t timestamp;
8
uint32_t padding1;
9
};
Copied!
Field
Description
reserved
type
This will contain the opcode of the packet which identifies which handler the packet data following this packet should go.
padding
potentially data here and not padding but it's probably not important 🙃
serverId
to-do: write about retail server architecture
timestamp
A Unix timestamp in seconds since the epoch.
Not really sure why this exists here but it does and that's what it has in it.
padding1
Alignment

Decoding Packets

Decoding packets is reasonably simple and assuming you have a buffer that you write data in to for each connection, it's something like the following:
1
if buf.size < sizeof(FFXIVARR_PACKET_HEADER):
2
return
3
4
header = &buf[0] as FFXIVARR_PACKET_HEADER:
5
6
if buf.size < header.size:
7
return
8
9
data = slice buf from sizeof(FFXIVARR_PACKET_HEADER) to end of buf
10
11
if buf.isCompressed:
12
data = zlib_inflate(data)
13
14
pos = 0
15
while true:
16
segment = &data[pos] as FFXIVARR_PACKET_SEGMENT_HEADER
17
18
if segment.size >= buf.size
19
burn them
20
21
if segment.size >= data.size:
22
also burn them
23
24
pos = segment.size
25
26
seg_hdr_size = sizeof(FFXIVARR_PACKET_SEGMENT_HEADER)
27
28
if segment.type == SEGMENTTYPE_IPC:
29
ipc_size = segment.size - seg_hdr_size
30
ipc_data = slice segment from seg_hdr_size to ipc_size
31
32
ipc_hdr = &ipc_data[0] as FFXIVARR_IPC_HEADER
33
ipc_hdr_size = sizeof(FFXIVARR_IPC_HEADER)
34
35
packet_data = slice ipc_data from ipc_hdr_size to remaining size
36
process_channel_packet(ipc_hdr.type, packet_data)
37
38
// other segment types depend on the type of channel, but it's more of the same
39
Copied!
A lot of detail is omitted for brevity, but it's generally pretty straightforward.
A more comprehensive example of packet parsing can be found in Sapphire:
Last modified 1yr ago