### Aeron Data Frame, the mechanism of data exchange
Aeron uses a custom binary protocol for message communication, which is optimized for low-latency, high-throughput messaging over UDP/IP and shared memory. The Aeron protocol is designed to minimize message overhead and latency, while also providing robust and reliable message delivery in the face of network congestion and packet loss.
The Aeron protocol works by encapsulating each message within a fixed-size, binary data packet called a ["data frame"](https://github.com/real-logic/aeron/wiki/Transport-Protocol-Specification#general-header-format). The data frame includes a header section that contains metadata about the message, such as the message length, message type, and message offset within the stream. The payload of the data frame contains the actual message data.
<svg viewBox="0 0 600 200" xmlns="http://www.w3.org/2000/svg">
<!-- Draw the data frame box -->
<rect x="10" y="10" width="580" height="180" fill="white" stroke="black" stroke-width="2" />
<!-- Draw the header section -->
<rect x="20" y="20" width="560" height="60" fill="#F7DC6F" stroke="black" stroke-width="1" />
<text x="30" y="45" font-size="14">Header</text>
<text x="30" y="65" font-size="12">Stream ID: </text>
<text x="120" y="65" font-size="12">[4 bytes]</text>
<text x="30" y="85" font-size="12">Session ID: </text>
<text x="120" y="85" font-size="12">[4 bytes]</text>
<text x="30" y="105" font-size="12">Term ID: </text>
<text x="120" y="105" font-size="12">[4 bytes]</text>
<text x="30" y="125" font-size="12">Term Offset: </text>
<text x="120" y="125" font-size="12">[4 bytes]</text>
<text x="30" y="145" font-size="12">Flags: </text>
<text x="120" y="145" font-size="12">[2 bytes]</text>
<!-- Draw the flags section -->
<rect x="20" y="90" width="240" height="70" fill="#D7DBDD" stroke="black" stroke-width="1" />
<text x="30" y="115" font-size="12">Beginning of Frame: </text>
<text x="180" y="115" font-size="12">[1 bit]</text>
<text x="30" y="135" font-size="12">End of Frame: </text>
<text x="180" y="135" font-size="12">[1 bit]</text>
<text x="30" y="155" font-size="12">Reserved: </text>
<text x="180" y="155" font-size="12">[6 bits]</text>
<!-- Draw the payload section -->
<rect x="20" y="140" width="560" height="30" fill="#A9DFBF" stroke="black" stroke-width="1" />
<text x="30" y="155" font-size="14">Payload</text>
<text x="30" y="175" font-size="12">Message Data: </text>
<text x="120" y="175" font-size="12">[Variable length]</text>
</svg>
```markdown
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|R| Frame Length (= header length) |
+---------------+---------------+-------------------------------+
| Version | Flags | Type (=0x05) |
+---------------+---------------+-------------------------------+
|R| Term Offset |
+---------------------------------------------------------------+
| Session ID |
+---------------------------------------------------------------+
| Stream ID |
+---------------------------------------------------------------+
| Initial Term ID |
+---------------------------------------------------------------+
| Active Term ID |
+---------------------------------------------------------------+
| Term Length |
+---------------------------------------------------------------+
| MTU |
+---------------------------------------------------------------+
| TTL |
+---------------------------------------------------------------+
```
When a message is sent over the network, it is first divided into one or more data frames, each of which is transmitted as a separate UDP packet. The recipient of the message reassembles the data frames into the original message by reading the message offset and length information from the data frame headers.
To ensure reliable message delivery, Aeron uses a variety of techniques to manage network congestion and packet loss. One of the key techniques is congestion control, which involves dynamically adjusting the rate of message transmission based on network conditions and available bandwidth. Aeron also supports retransmission of lost or delayed packets, and provides a mechanism for detecting and recovering from message delivery failures.