Low level protocol encoding and decoding