encode packet structure