Decoding Atom Stream Examples
This page shows examples of atom streams and how they are decoded. It assumes the reader is familiar with the concepts covered on the Decoding Atom Streams page.
Decoding an At Token
This example shows how to decode an atom stream transferred across the network.
The atom stream starts at the begining of the data portion of a P3 packet.
The first field is token, and is always two bytes. For this example, the
token is At:
Token: At
│
▼
┌─────┐
0000 │41 74│04 0F 25 20 01 0D 25 08 44 65 63 65 70 74
└─────┘
0010 69 6F 20 02
The stream_id field for At tokens is 3 bytes long and starts at
offset 0x02:
stream_id
│
▼
┌────────┐
0000 41 74│04 0F 25│20 01 0D 25 08 44 65 63 65 70 74
└────────┘
0010 69 6F 20 02
1. uni_start_stream Atom
The atoms immediately follow the stream_id field. For this example the first
atom starts at byte offset 0x05. The first field in an encoded atom is
the style field, and is contained in the leftmost three bits:
┌──┐
0000 41 74 04 0F 25│20│01 0D 25 08 44 65 63 65 70 74
└──┘
0010 69 6F 20 02
┌───────────────┐
Byte │ 20 │
└───────────────┘
Bit 0 0 1 0 0 0 0 0
└─────┴─────────┘
▲
│
style: 1
Since style is 1, the atom information is encoded according to the
length style. The protocol_num, args_len, and atom_num fields are
encoded across two bytes starting at offset 0x05.
┌──┬──┐
0000 41 74 04 0F 25│20│01│0D 25 08 44 65 63 65 70 74
└──┴──┘
0010 69 6F 20 02
┌───────────────┬───────────────┐
Byte │ 20 │ 01 │
└───────────────┴───────────────┘
Bit 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 0 │
│ │
protocol_num: 0 atom_num: 1
The protocol_num and atom_num values are 0 and 1
respectively. Together they represent the uni_start_stream atom.
Since args_len is 0, this atom has no arguments.
2. async_set_screen_name Atom
The next atom starts at byte offset 0x07. The style field is
represented in the leftmost three bits:
┌──┐
0000 41 74 04 0F 25 20 01│0D│25 08 44 65 63 65 70 74
└──┘
0010 69 6F 20 02
┌───────────────┐
Byte │ 0D │
└───────────────┘
Bit 0 0 0 0 1 1 0 1
└─────┴─────────┘
▲
│
style: 0
The value 0 for style means the atom information is encoded
according to the full style. The next four fields are protocol_num,
atom_num, sizeof_args_len and args_len. These fields are contained in
three bytes starting at offset 0x07:
┌──┬──┬──┐
0000 41 74 04 0F 25 20 01│0D│25│08│44 65 63 65 70 74
└──┴──┴──┘
0010 69 6F 20 02
┌───────────────┬───────────────┬───────────────┐
Byte │ 0D │ 25 │ 08 │
└───────────────┴───────────────┴───────────────┘
Bit 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0
└─────┴─────────┴───────────────┴─┴─────────────┘
▲ ▲ ▲ ▲
│ │ │ │
│ atom_num: 0x25 │ args_len: 8
│ │
protocol_num: 0x0D sizeof_args_len: 0
The pair of protocol_num (0x0D) and atom_num (0x25)
represent the async_set_screen_name atom. The sizeof_args_len is
0 which means the args_len field is the following 7 bits.
In this example value for args_len is 8.
The args field (atom arguments) for this atom start at offset 0x0A.
┌─────────────────
0000 41 74 04 0F 25 20 01 0D 25 08│44 65 63 65 70 74
─────┐ └─────────────────
0010 69 6F│20 02
─────┘
args: 0x44 0x65 0x63 0x65 0x70 0x74 0x69 0x6F
The value for args are the bytes 0x44, 0x65, 0x63,
0x65, 0x70, 0x74, 0x69, and 0x6F.
For the async_set_screen_name atom these represent the string
Deceptio.
3. uni_end_stream Atom
The next atom starts at offset 0x12. The encoding style information is
contained in the leftmost three bits.
0000 41 74 04 0F 25 20 01 0D 25 08 44 65 63 65 70 74
┌──┐
0010 69 6F│20│02
└──┘
┌───────────────┐
Byte │ 20 │
└───────────────┘
Bit 0 0 1 0 0 0 0 0
└─────┴─────────┘
▲
│
style: 1
The value for style is 1, which means the atom information is
encoded according to the length style. The protocol_num, args_len, and
atom_num fields are encoded across two bytes starting at offset
0x12.
0000 41 74 04 0F 25 20 01 0D 25 08 44 65 63 65 70 74
┌──┬──┐
0010 69 6F│20│02│
└──┴──┘
┌───────────────┬───────────────┐
Byte │ 20 │ 02 │
└───────────────┴───────────────┘
Bit 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 0 │
│ │
protocol_num: 0 atom_num: 2
The values for protocol_num and atom_num are 0 and 2
respectively. This pair represents the uni_end_stream atom. There are no
arguments for this atom since args_len is 0.
Final Disassembly
The final disassembly for the three atoms is:
Decoding a main.idx Entry
The next example shows an atom stream from the main.idx file. For this example
the token and s_id fields are not present, as they only exist for atom
streams in P3 packets.
1. uni_start_stream Atom
The first atom starts at offset 0x00. The style field is contained in
the leftmost three bits.
┌──┐
0000 │40│01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
└──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 40 │
└───────────────┘
Bit 0 1 0 0 0 0 0 0
└─────┴─────────┘
▲
│
style: 2
The value for style is 2, which means the atom information is
encoded using the data style. The protocol_num, args, and atom_num fields
are next.
┌──┬──┐
0000 │40│01│01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
└──┴──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 40 │ 01 │
└───────────────┴───────────────┘
Bit 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args: 0 │
│ │
protocol_num: 0 atom_num: 1
The protocol_num and atom_num (0 and 1) represent the
uni_start_stream atom. The args field is 0 which means this atom
is processed with 0 (as a single byte) as its argument.
2. man_start_object Atom
The first byte of the next atom is located at offset 0x02. The style
field is encoded in the leftmost three bits.
┌──┐
0000 40 01│01│00 09 01 44 6F 63 75 6D 65 6E 74 30 28
└──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 01 │
└───────────────┘
Bit 0 0 0 0 0 0 0 1
└─────┴─────────┘
▲
│
style: 0
The style value is 0, so the atom information is encoded according
to the full style. The protocol_num, atom_num, sizeof_args_len, and
args_len fields are contained across three bytes starting at offset
0x02.
┌──┬──┬──┐
0000 40 01│01│00│09│01 44 6F 63 75 6D 65 6E 74 30 28
└──┴──┴──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┬───────────────┐
Byte │ 01 │ 00 │ 09 │
└───────────────┴───────────────┴───────────────┘
Bit 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1
└─────┴─────────┴───────────────┴─┴─────────────┘
▲ ▲ ▲ ▲
│ │ │ │
│ atom_num: 0 │ args_len: 9
│ │
protocol_num: 1 sizeof_args_len: 0
The values 1 and 0 for protocol_num and atom_num
represent the man_start_object atom.
Since sizeof_args_len is 0, args_len is encoded in 7
bits. The value for args_len is 9, so the args field is
9 bytes long. The args field starts at offset 0x05.
┌──────────────────────────┐
0000 40 01 01 00 09│01 44 6F 63 75 6D 65 6E 74│30 28
└──────────────────────────┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
args: 0x01, Document
The args for this atom are the bytes 0x01, 0x44,
0x6F, 0x63, 0x75, 0x6D, 0x65,
0x6E, and 0x74. For the man_start_object atom this
translates to ind_group and the string Document.
3. mat_orientation Atom
The next atom starts at offset 0x0E. The leftmost three bits encode the
style.
┌──┐
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74│30│28
└──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 30 │
└───────────────┘
Bit 0 0 1 1 0 0 0 0
└─────┴─────────┘
▲
│
style: 1
The information for this atom is encoded according to the length style, since
style is 1. The next three fields are protocol_num, args_len,
and atom_num. These fields are encoded in two bytes starting at offset
0x0E.
┌──┬──┐
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74│30│28│
└──┴──┘
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 30 │ 28 │
└───────────────┴───────────────┘
Bit 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 1 │
│ │
protocol_num: 0x10 atom_num: 8
The protocol_num and atom_num (0x10 and 0x08) represent
the mat_orientation atom. The args_len field is 1, so the
args field is 1 byte long.
The args field starts at offset 0x10.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 │5B│E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
args: 0x5B
The value for args is 0x5B which for mat_orientation decodes to
vff.
4. Prefix Encoded Byte
The next byte processed is at offset 0x11. The style field is
encoded in the leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B│E4│50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ E4 │
└───────────────┘
Bit 1 1 1 0 0 1 0 0
└─────┴─────────┘
▲
│
style: 7
The value for style is 7, which means this byte encodes information
according to the prefix style. Recall that prefix style does not encode an
atom, but instead encodes information that modifies the protocol_num and
atom_num values for atoms that follow.
The protocol_offset, atom_offset, and keep_prefix fields are encoded
in the byte currently being processed (0xE4).
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B│E4│50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ E4 │
└───────────────┘
Bit 1 1 1 0 0 1 0 0
└─────┴───┴───┴─┘
▲ ▲ ▲
│ │ │
│ │ └─ keep_prefix: 0
│ │
│ └─ atom_offset: 2
│
protocol_offset: 0
Since keep_prefix is 0, the computed protocol_offset and
atom_offset values will only apply to the atom that immediately follows the
current byte.
Before continuing, we must compute the values for protocol_offset and
atom_offset (using bit masking and shifting).
Computing the Protocol Offset
To compute the protocol_offset value, first apply a bitmask of 0x18
to isolate the two relevat bits by using a bitwise AND.
┌───────────────┐
Byte │ E4 │
└───────────────┘
Bit 1 1 1 0 0 1 0 0
────────────────
Mask (0x18) 0 0 0 1 1 0 0 0
────────────────
Result 0 0 0 0 0 0 0 0
Since neither of the two bits relevant to protocol_offset were set (that is,
neither were 1) the result is 0. To compute the final value
for protocol_offset, shift the bits two positions to the left.
Result 0 0 0 0 0 0 0 0
────────────────
Left Shift 2 0 0 0 0 0 0 0 0
Since the result of the mask was 0, the result of the bit shift is
also 0.
Computing the Atom Offset
To compute the atom_offset value, apply the bitmask 0x06 to isolate
the relevant bits.
┌───────────────┐
Byte │ E4 │
└───────────────┘
Bit 1 1 1 0 0 1 0 0
────────────────
Mask (0x06) 0 0 0 0 0 1 1 0
────────────────
Result 0 0 0 0 0 1 0 0
The result of the bitmask is 4 (00000100 in binary). Next
shift the bits four positions to the left.
Result 0 0 0 0 0 1 0 0
────────────────
Left Shift 4 0 1 0 0 0 0 0 0
The final value for atom_offset is 0x40 (64 in decimal).
5. mat_position Atom
The next atom starts at offset 0x12. The style field is encoded in
the leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4│50│A0 E2 30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 50 │
└───────────────┘
Bit 0 1 0 1 0 0 0 0
└─────┴─────────┘
▲
│
style: 2
Since style is 2, the atom information is encoded according to the
data style. The protocol_num, args, and atom_num fields are encoded in
two bytes starting at offset 0x12.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┬──┐
0010 5B E4│50│A0│E2 30 7A 20 00 10 21 20 08 30 57 37
└──┴──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 50 │ A0 │
└───────────────┴───────────────┘
Bit 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args: 5 │
│ │
protocol_num: 0x16 atom_num: 0
The extracted values for protocol_num and atom_num are 0x10 and
0 respectively. However since this atom was preceeded by a prefix
encoded byte, the protocol_offset and atom_offset fields need to be applied
to determine the values used for processing.
Applying the Protocol Offset
The protocol_offset from the previous prefix encoded byte is 0x00.
Doing a bitwise OR with this value leaves the current protocol_num unchanged.
Applying the Atom Offset
The atom_offset from the previous prefix encoded byte is 0x40. Doing
a bitwise-OR with this value leads to 0x40 as the final value for
atom_num.
The final values protocol_num and atom_num are 0x10 and
0x40 respectively. This corresponds to the mat_position atom.
The value of args is 5, which for mat_position means
center_center.
6. Prefix Encoded Byte
The next byte to process is at offset 0x14. The style field is
encoded in the leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0│E2│30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
└─────┴─────────┘
▲
│
style: 7
Since style is 7, this is another prefix encoded byte. The
protocol_offset, atom_offset, and keep_prefix fields are encoded in the
byte currently being processed (at offset 0x14).
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0│E2│30 7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
└─────┴───┴───┴─┘
▲ ▲ ▲
│ │ │
│ │ └─ keep_prefix: 0
│ │
│ └─ atom_offset
│
protocol_offset
Similar to the previous prefix encoded byte, keep_prefix is 0. So
the final protocol_offset and atom_offset values will only be applied to
the atom that immediately follows this prefix encoded byte.
Computing the Protocol Offset
To compute the protocol_offset value, isolate the relevant bits by performing
a bitwise AND using the bitmask 0x18.
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
────────────────
Mask (0x18) 0 0 0 1 1 0 0 0
────────────────
Result 0 0 0 0 0 0 0 0
Like the previous prefix encoded byte, neither of the two relevant bits are
set. To compute the final protocol_offset value, shift the bits two positions
to the left.
Result 0 0 0 0 0 0 0 0
────────────────
Left Shift 2 0 0 0 0 0 0 0 0
Since the result of the mask was 0, the shift did not change the final
value (also 0).
Computing the Atom Offset
To compute the atom_offset value, isolate the relevant bits by performing a
bitwise AND with the bitmask 0x06.
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
────────────────
Mask (0x06) 0 0 0 0 0 1 1 0
────────────────
Result 0 0 0 0 0 0 1 0
The result of the bitmasking is 2 (00000010 in binary). To
compute the final value, shift the bits four positions to the left.
Result 0 0 0 0 0 0 1 0
────────────────
Left Shift 4 0 0 1 0 0 0 0 0
The final atom_offset value is 0x20 (32 in decimal).
7. mat_style_id Atom
The next atom starts at offset 0x15. As with all atoms, style
is encoded in the leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0 E2│30│7A 20 00 10 21 20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 30 │
└───────────────┘
Bit 0 0 1 1 0 0 0 0
└─────┴─────────┘
▲
│
style: 1
The style is 1, which means the atom information is encoded
according to the length style. The protocol_num, args, and atom_num
values are encoded in two bytes starting at offset 0x15.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┬──┐
0010 5B E4 50 A0 E2│30│7A│20 00 10 21 20 08 30 57 37
└──┴──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 30 │ 7A │
└───────────────┴───────────────┘
Bit 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 3 │
│ │
protocol_num: 0x10 │
│
atom_num: 0x1A
The extracted values of protocol_num and atom_num are 0x10
(16 in decimal) and 0x1A (26 in decimal)
respectively. To determine the values used for processing, the
protocol_offset and atom_offset need to be applied.
Applying the Protocol Offset
Since the current value of protocol_offset is 0, doing a bitwise OR
leaves the protocol_num value unchanged.
Applying the Atom Offset
The current value of atom_offset is 0x20, and doing a bitwise OR
with atom_num results in 0x3A.
The final values of protocol_offset and atom_num used for processing are
0x20 (16 in decimal) and 0x3A (58 in
decimal) respectively. This translates to the mat_style_id atom.
The value of args_len is 3, so the next three bytes (which start at
offset 0x17) represent the arguments for the atom.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌────────┐
0010 5B E4 50 A0 E2 30 7A│20 00 10│21 20 08 30 57 37
└────────┘
0020 0F CB E2 C7 21 02 71 40 02
args: 0x20 0x00 0x10
The value of args are the bytes 0x20, 0x00, and
0x10. For the mat_style_id atom this translates to the
global id 32-16.
8. man_start_object Atom
The next atom starts at offset 0x1A and contains the style in the
leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0 E2 30 7A 20 00 10│21│20 08 30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 21 │
└───────────────┘
Bit 0 0 1 0 0 0 0 1
└─────┴─────────┘
▲
│
style: 1
Since style is 1 the atom information is encoded according to the
length style. The protocol_num, args_len, and atom_num fields are
encoded in two bytes starting at offset 0x1A.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┬──┐
0010 5B E4 50 A0 E2 30 7A 20 00 10│21│20│08 30 57 37
└──┴──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 21 │ 20 │
└───────────────┴───────────────┘
Bit 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 1 │
│ │
protocol_num: 1 atom_num: 0
The values for protocol_num and atom_num are 1 and 0.
Together these represent the man_start_object atom.
The args for this atom is 1 byte long (as described by args_len)
and starts at offset 0x1C.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20│08│30 57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
args: 0x08
The value of args is 0x08, which for the man_start_object
atom represents the value view and an empty string ("").
9. mat_size Atom
The next atom starts at offset 0x1D and has style encoded in the
leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┐
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08│30│57 37
└──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┐
Byte │ 30 │
└───────────────┘
Bit 0 0 1 1 0 0 0 0
└─────┴─────────┘
▲
│
style: 1
Since style is 1, the atom information is encoded according to the
length style. The protocol_num, args_len, and atom_num fields are in two
bytes starting at offset 0x1D.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──┬──┐
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08│30│57│37
└──┴──┘
0020 0F CB E2 C7 21 02 71 40 02
┌───────────────┬───────────────┐
Byte │ 30 │ 57 │
└───────────────┴───────────────┘
Bit 0 0 1 1 0 0 0 0 0 1 0 1 0 1 1 1
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 2 │
│ │
protocol_num: 0x10 │
│
atom_num: 0x17
The values for protocol_num and atom_num are 0x10 and
0x17 respectively. Together these represent the mat_size atom.
Since args_len is 2, args is in the two bytes that follow (args
starts at offset 0x1F).
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
┌──
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57│37
──┐ └──
0020 0F│CB E2 C7 21 02 71 40 02
──┘
args: 0x37 0x0F
The value of args are the bytes 0x37 and 0x0F. For the
mat_size atom this represents the values 55 and 15.
10. mat_relative_tag Atom
The next atom starts at offset 0x21. The style is encoded in the
three leftmost bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F│CB│E2 C7 21 02 71 40 02
└──┘
┌───────────────┐
Byte │ CB │
└───────────────┘
Bit 1 1 0 0 1 0 1 1
└─────┴─────────┘
▲
│
style: 6
Since style is 6 the atom information is encoded according to the
one style. With one style, the only other field is atom_num.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F│CB│E2 C7 21 02 71 40 02
└──┘
┌───────────────┐
Byte │ CB │
└───────────────┘
Bit 1 1 0 0 1 0 1 1
└─────┴─────────┘
▲
│
│
│
atom_num: 0x0B
The value of atom_num is 0x0B (11 in decimal). With one
style the protocol_num is reused from the previous atom, which in this
case is 0x10 (16 in decimal). Together, these represent the
mat_relative_tag atom.
The one style, there is no args field in the stream. However when processing
the atom, it is given a single argument with the value 1. For the
mat_relative_tag atom this is the relative id 1.
11. Prefix Encoded Byte
The next byte to be processed is at offset 0x22. The style is
encoded in the leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB│E2│C7 21 02 71 40 02
└──┘
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
└─────┴─────────┘
▲
│
style: 7
Since style is 7, this byte encodes information using the prefix
style. The protocol_offset, atom_offset, and keep_prefix are also encoded
in this byte.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB│E2│C7 21 02 71 40 02
└──┘
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
└─────┴───┴───┴─┘
▲ ▲ ▲
│ │ │
│ │ └─ keep_prefix: 0
│ │
│ └─ atom_offset
│
protocol_offset
Since keep_prefix is 0, the final protocol_offset and
atom_offsetvalues will only be used for the atom immediately after the
current byte.
Computing the Protocol Offset
To compute the protocol_offset value, ioslate the relevant bits by performing
a bitwise AND using the bitmask 0x18.
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
────────────────
Mask (0x18) 0 0 0 1 1 0 0 0
────────────────
Result 0 0 0 0 0 0 0 0
As with the previous examples of prefix styles, none of the bits for
protocol_offset were set. This yields the value 0 after the bitmask.
Shifting this value two bits to the left also yields 0 as shown.
Result 0 0 0 0 0 0 0 0
────────────────
Left Shift 2 0 0 0 0 0 0 0 0
Computing the Atom Offset
To compute the value of atom_offset, isolate the relevant bits by peforming a
bitwise AND with the bitmask 0x06.
┌───────────────┐
Byte │ E2 │
└───────────────┘
Bit 1 1 1 0 0 0 1 0
────────────────
Mask (0x06) 0 0 0 0 0 1 1 0
────────────────
Result 0 0 0 0 0 0 1 0
The result of the bitmasking is 2 (00000010 in binary). Next
shift the bits to the left by four.
Result 0 0 0 0 0 0 1 0
────────────────
Left Shift 4 0 0 1 0 0 0 0 0
The final value of atom_offset is 0x20 (32 in decimal).
12. mat_bool_writeable Atom
The next atom starts at offset 0x23. The style is encoded in the
three leftmost bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2│C7│21 02 71 40 02
└──┘
┌───────────────┐
Byte │ C7 │
└───────────────┘
Bit 1 1 0 0 0 1 1 1
└─────┴─────────┘
▲
│
style: 6
Since style is 6, the atom information is encoded according to the
one style. The only other field present is atom_num.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2│C7│21 02 71 40 02
└──┘
┌───────────────┐
Byte │ C7 │
└───────────────┘
Bit 1 1 0 0 0 1 1 1
└─────┴─────────┘
▲
│
atom_num: 7
The value of atom_num is 7. The value of protocol_num is reused
from the previously processed atom, and is 0x10
(16 in decimal).
Before continuing, the protocol_offset, and atom_offset fields need to be
applied.
Applying the Protocol Offset
Since protocol_offset is 0, the value of protocol_num is
unchanged.
Applying the Atom Offset
Applying the atom_offset value yields a final atom_num value of
0x27 (39 in decimal).
Collectively, a protocol_num of 0x10, and an atom_num of
0x27 represent the mat_bool_writable atom.
Since this atom is encoded using one style, the args field is an implied
1, which for the mat_bool_writable atom means yes.
13. man_end_object Atom
The next atom starts at offset 0x24. The leftmost three bits contain
the encoded style.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2 C7│21│02 71 40 02
└──┘
┌───────────────┐
Byte │ 21 │
└───────────────┘
Bit 0 0 1 0 0 0 0 1
└─────┴─────────┘
▲
│
style: 1
Since style is 1, the atom information is encoded according to the
length style. The protocol_num, args_len, and atom_num are encoded in the
two bytes starting at offset 0x24
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┬──┐
0020 0F CB E2 C7│21│02│71 40 02
└──┴──┘
┌───────────────┬───────────────┐
Byte │ 21 │ 02 │
└───────────────┴───────────────┘
Bit 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args_len: 0 │
│ │
protocol_num: 1 atom_num: 2
The protocol_num is 1 and the atom_num is 2. These
represent the man_end_object atom. Since args_len is 0,
there is no associated args for this atom.
14. man_update_display Atom
The next atom starts at offset 0x26. The style is encoded in the
leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2 C7 21 02│71│40 02
└──┘
┌───────────────┐
Byte │ 71 │
└───────────────┘
Bit 0 1 1 1 0 0 0 1
└─────┴─────────┘
▲
│
style: 3
Since style is 3, the atom information is encoded according to the
atom style. The only other field present is atom_num.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2 C7 21 02│71│40 02
└──┘
┌───────────────┐
Byte │ 71 │
└───────────────┘
Bit 0 1 1 1 0 0 0 1
└─────┴─────────┘
▲
│
atom_num: 0x11
The value of atom_num is 0x11 (17 in decimal). The
protocol_num field is reused from the previously processed atom, and is
1. Together these two fields represent the
man_update_display atom.
15. uni_end_stream Atom
The final atom starts at offset 0x27. The style is encoded in the
leftmost three bits.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┐
0020 0F CB E2 C7 21 02 71│40│02
└──┘
┌───────────────┐
Byte │ 40 │
└───────────────┘
Bit 0 1 0 0 0 0 0 0
└─────┴─────────┘
▲
│
style: 2
Since style is 2, the atom information is encoded according to the
data style. The protocol_num, args, and atom_num fields are represented
in two bytes starting at offset 0x27.
0000 40 01 01 00 09 01 44 6F 63 75 6D 65 6E 74 30 28
0010 5B E4 50 A0 E2 30 7A 20 00 10 21 20 08 30 57 37
┌──┬──┐
0020 0F CB E2 C7 21 02 71│40│02│
└──┴──┘
┌───────────────┬───────────────┐
Byte │ 40 │ 02 │
└───────────────┴───────────────┘
Bit 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0
└─────┴─────────┴─────┴─────────┘
▲ ▲ ▲
│ │ │
│ args: 0 │
│ │
protocol_num: 0 atom_num: 2
The protocol_num is 0 and the atom_num is 2. Collectively
they represent the uni_end_stream atom.
The value for args is 0, and concludes the stream.
Final Disassembly
The final disassembly for this atom stream is: