Wow. That is a tall order. For some of those features such as transfer code and file chunk assembly I would browse the BitTorrent code. You could also take a look at these 2 sites
1)
http://www.openp2p.com - Part of the whole O'Reilly network. Lots of good articles and examples to look at.
2) Also check out
http://www.jxta.org, it is a set of protocols and frameworks for enabling P2P in Java. It has a lot of discovery and low level networking built into it already.
Best of luck, on your adventure, I would seriously bruch up on your basics before diving into some of these technologies too deep.