Network protocol decoding and encoding