Basic peer protocol

It still has some flaws, but you can start working with it.