Hey,
I pretty much know how BitTorrent works:
NAT hole punching, usage of STUN protocol and P2P communication, Implementation of their own TCP protocol above UDP to enable active applications more badwith.
I can program in any language you would like, but I think its better to use the BT open-source client, and use it as a P2P client to the inner clients.
It belive it is possible to make the torrent clients address the cache server, he will download the needed files for them if they doesn't exist, but if they are it will just send it the file.