Distributed Protocol Stacks: A Framework for Balancing Interoperability and Optimization