|Software :: uP2P — micro P2P file sharing application|
Version 0.0.1 (02/15/2005), P. Felber.
This shell script was inspired by Prof. Ed Felten's TinyP2P application (as well as Matthew Skala's shorter variant MoleSter) and was developed as a follow-up to a seminar on peer-to-peer (P2P) networks organized at the University of Neuchatel. It sets up a small P2P network by sharing the content of the current directory with other peers. Files added to the directory at runtime are dynamically shared. With trivial modifications (documented in the code), it is also possible to share subdirectories.
This shell script only uses standard Unix tools. Communication is handled using 'netcat' ('nc'), a command-line interface to TCP, installed by default on most Unix systems. It must be compiled to accept the '-e' flag (try 'nc -h' to verify); this is the case, for instance, with bootable Knoppix CDs. The script has been tested on various Linux distributions.
Of course, the goal of this application is NOT to encourage illicit file sharing or facilitate copyright infringement (there exists far better and more scalable solutions), but to demonstrate how simple it is to create a non-trivial file sharing application.
The network is password protected. In order to connect to the network or download a file, one needs to know the password.
As each server knows of every other server, this application is not very scalable. It does, however, work remarkably well for exchanging files among small groups of people.
To start a server, change to the directory that you would like to share and start the script as follows:
uP2P.sh password local-ip local-port remote-ip remote-port
where 'password' is the network's password; 'local-ip' and 'local-port' are the IP address and port used by the server for listening to remote requests; 'remote-ip' and 'remote-port' are the IP address and port of some other peer in the network. The first server can be started with any remote address (even its own address) since connections to non-existing endpoints will fail silently. All 5 parameters must be specified.
To start a client, change to the directory that you would like to download files to and start the script as follows:
uP2P.sh password remote-ip remote-port pattern
where 'password' is the network's password; 'remote-ip' and 'remote-port' are the IP address and port of some server peer in the network; 'pattern' is a filter that specifies the files to download using the 'grep' regular expression syntax. Note that, because of message forwarding, redundant escape characters must be used; for instance, "\." (dot) must be specified as "\\\\.".
To end the script, kill all instances of 'nc'.
Start 4 servers on 4 hosts (or in different directories on the same host):
uP2P.sh abc 192.168.1.100 9000 192.168.1.100 9000 uP2P.sh abc 192.168.1.101 9000 192.168.1.100 9000 uP2P.sh abc 192.168.1.102 9000 192.168.1.101 9000 uP2P.sh abc 192.168.1.103 9000 192.168.1.101 9000
Download all files containing 'pdf' in their name (here using third server as entry point to the network):
uP2P.sh abc 192.168.1.102 9000 "pdf"
The short version has the following additional limitations:
How it works