1https://en.wikipedia.org/wiki/Internet_Protocol_version_4
2
3IPv4 header format
4+---------+-------+---------------------------------------+---------------------------------------+---------------------------------------+---------------------------------------+
5| Offsets | Octet |                   0                   |                   1                   |                   2                   |                   3                   |
6|  Octet  |  Bit  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
7+---------+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
8|    0    |   0   | Version [4]       | IHL [>=5]         | DSCP                        | ECN     | Total length [>=20, >=4*IHL]                                                  |
9+---------+-------+-------------------+-------------------+-----------------------------+---------+----+----+----+----------------------------------------------------------------+
10|    4    |  32   | Identification                                                                |  0 | DF | MF | Fragment offset                                                |
11+---------+-------+---------------------------------------+---------------------------------------+----+----+----+----------------------------------------------------------------+
12|    8    |  64   | Time to Live                          | Protocol                              | Header checksum                                                               |
13+---------+-------+---------------------------------------+---------------------------------------+-------------------------------------------------------------------------------+
14|   12    |  96   | Source address                                                                                                                                                |
15+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
16|   16    | 128   | Destination address                                                                                                                                           |
17+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
18|   20    | 160   | Options (if IHL > 5)                                                                                                                                          |
19|   ..    | ...   |                                                                                                                                                               |
20|   56    | 448   |                                                                                                                                                               |
21+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
22
23https://en.wikipedia.org/wiki/IPv6_packet
24
25Fixed header format
26+---------+-------+---------------------------------------+---------------------------------------+---------------------------------------+---------------------------------------+
27| Offsets | Octet |                   0                   |                   1                   |                   2                   |                   3                   |
28|  Octet  |  Bit  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
29+---------+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
30|    0    |   0   | Version [6]       | Traffic class (DSCP 6 + ECN 2 bits)   | Flow label                                                                                        |
31+---------+-------+-------------------+---------------------------------------+-------------------+---------------------------------------+---------------------------------------+
32|    4    |  32   | Payload length                                                                | Next header                           | Hop limit                             |
33+---------+-------+-------------------------------------------------------------------------------+---------------------------------------+---------------------------------------+
34|    8    |  64   | Source Address                                                                                                                                                |
35|   12    |  96   |                                                                                                                                                               |
36|   16    | 128   |                                                                                                                                                               |
37|   20    | 160   |                                                                                                                                                               |
38+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
39|   24    | 192   | Destination address                                                                                                                                           |
40|   28    | 224   |                                                                                                                                                               |
41|   32    | 256   |                                                                                                                                                               |
42|   36    | 288   |                                                                                                                                                               |
43+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
44
45https://en.wikipedia.org/wiki/ICMPv6
46
47ICMPv6 header (4 bytes): u8 type, u8 code, u16 checksum
48(4 bytes in) Message body...  (but note in practice it's actually 4 bytes reserved, then 'real' message body at 8 bytes in)
49
50https://en.wikipedia.org/wiki/Transmission_Control_Protocol
51
52TCP segment header
53+---------+-------+---------------------------------------+---------------------------------------+---------------------------------------+---------------------------------------+
54| Offsets | Octet |                   0                   |                   1                   |                   2                   |                   3                   |
55|  Octet  |  Bit  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
56+---------+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
57|    0    |   0   | Source port                                                                   | Destination port                                                              |
58+---------+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
59|    4    |  32   | Sequence number                                                                                                                                               |
60+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
61|    8    |  64   | Acknowledgment number (if ACK set)                                                                                                                            |
62+---------+-------+-------------------+-------------------+----+----+----+----+----+----+----+----+-------------------------------------------------------------------------------+
63|   12    |  96   | Data Offset       | Reserved (zero)   | CWR| ECE| URG| ACK| PSH| RST| SYN| FIN| Window size                                                                   |
64+---------+-------+-------------------+-------------------+----+----+----+----+----+----+----+----+-------------------------------------------------------------------------------+
65|   16    | 128   | Checksum                                                                      | Urgent pointer (if URG set)                                                   |
66+---------+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
67|   20    | 160   | Options (if data offset > 5. Padded at the end with "0" bits if necessary.)                                                                                   |
68|   ..    | ...   |                                                                                                                                                               |
69|   56    | 448   |                                                                                                                                                               |
70+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
71
72https://en.wikipedia.org/wiki/User_Datagram_Protocol
73
74UDP datagram header (8 bytes): be16 source port, destination port, length, checksum
75+---------+-------+---------------------------------------+---------------------------------------+---------------------------------------+---------------------------------------+
76| Offsets | Octet |                   0                   |                   1                   |                   2                   |                   3                   |
77|  Octet  |  Bit  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
78+---------+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
79|    0    |   0   | Source port                                                                   | Destination port                                                              |
80+---------+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
81|    4    |  32   | Length                                                                        | Checksum                                                                      |
82+---------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
83