add protocol layer
refactor code and extract protocol layer