Framework for peer-to-peer networks