compose & decompose functions for formatting packets.