refine protocol, add comments. add utest for protocol bytes and timeout.