Skip to content

Application protocol framing and parsing

Application protocol framing and parsing defines how messages are structured and identified at the application layer, allowing network applications to transmit data without managing lower-level transport details.^[600-developer__java__java-io__java-socket.md]

Framing Methods

To reconstruct messages from a continuous stream of data (such as TCP), protocols use specific framing techniques to determine where a message begins and ends.

Delimiter-based framing

This method uses a unique marker to indicate the end of a message. The sender appends a specific byte sequence after the data is transmitted^[600-developer__java__java-io__java-socket.md].

  • Constraint: The unique marker must not appear within the transmission data itself^[600-developer__java__java-io__java-socket.md].
  • Exception: Padding techniques can be used to escape or modify delimiters if they naturally occur in the data, preventing the receiver from misidentifying them as message terminators^[600-developer__java__java-io__java-socket.md].
  • Use Case: This approach is typically employed for text-encoded messages^[600-developer__java__java-io__java-socket.md].

Explicit length encoding

This method involves prefixing a variable-length field or message with a fixed-size field^[600-developer__java__java-io__java-socket.md].

  • Mechanism: The prefix indicates the exact byte count of the subsequent content^[600-developer__java__java-io__java-socket.md].
  • Use Case: This approach is primarily used for binary-encoded messages^[600-developer__java__java-io__java-socket.md].

Sources

^[600-developer__java__java-io__java-socket.md]