public synchronized void frame(final MessageData message, final ByteBuf output) {
    Preconditions.checkArgument(
        message.getSize() < LENGTH_MAX_MESSAGE_FRAME, "Message size in excess of maximum length.");
    // Compress message
    if (compressionEnabled) {
      // Extract data from message
      // Compress data
      final byte[] compressed = compressor.compress(message.getData().toArrayUnsafe());
      // Construct new, compressed message
      frameMessage(new RawMessage(message.getCode(), Bytes.wrap(compressed)), output);
    } else {
      frameMessage(message, output);
    }
  }
Frames a message for sending to an RLPx peer, encrypting it and calculating the appropriate
MACs.

@param message The message to frame.
@param output The {@link ByteBuf} to write framed data to.
ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java