Add protocol determine code; Close #24