CS3103 Project
- Install python 3 and pip3 on your local development pc.
git clone
the current repopip3 install virtualenv
source /cs3103-env/bin/activate
- Start developing
Please start an instance of the dns server first by running python3 p2pdns.py
To start an instance of the p2p node, run:
python3 p2pmain.py 127.0.X.X
If you ever download a third-party python library, remember to
pip3 freeze > requirements.txt
to update the dependencies list.
- Install Vagrant and Virtualbox
cd
to the directoryvagrant up
and wait for it to initialisevagrant ssh dns/alpha/beta/charlie/delta/echo
into either vm.- To transfer file, run
vagrant config-ssh
to check the port of the vm - cd to parent dir and
sudo scp -P <PORT> -i ./cs3103-p2p/.vagrant/machines/<VM NAME>/virtualbox/private_key -r cs3103-p2p/ [email protected]:/home/vagrant
- Run
p2pdns.py
indns
vm. - Run
p2pmain.py
in the other peers
P2P DNS server serves as a introducer whenever a new peer wants to join the network. The information is stored in a sqlite3 db.
This the the main program that the user will run. It is a wrapper for P2P Client and P2P Server. P2P Client will handle the various user interactions. P2P Server will handle file uploading, file downloading and DHT queries. P2P Client will communicate with P2P Server using Unix Domain Sockets (UDS) while the communication between P2P Server of different peer will be done using standard TCP sockets.
The different protocols implemented provides a systematic manner for different components to communicate with each other. Furthermore, since we are using TCP Byte Stream sockets, we need a way to delimit where our messages end. Hence -- protocols.
General Format: op
[...args]\r\n
JOIN <peer_id> <ip-addr>
General Format:
code
message
content-length\r\n
dataline...\r\n
dataline...\r\n
General Format: op
[...args]\r\n
GET_NEIGHBOURS <node_id> <node_ip_addr>
RET_NEIGHBOURS <predecessor_id> <predecessor_ip_addr> <successor_id> <successor_ip_addr> <next_successor_id> <next_succcessor_ip_addr>
UPDATE_NEXT_SUCCESSOR <next_successor_id> <next_succcessor_ip_addr>
UPDATE_PREDECESSOR <predecessor_id> <predecessor_ip_addr>
INIT_PEER_TABLE
LIST_ALL_FILES
SEARCH <filename>
DOWNLOAD <filename>
UPLOAD <filename>
General Format:
code
message
content-length\r\n
dataline...\r\n
dataline...\r\n