Skip to content

Implementation of the Chord DHT Peer-to-Peer algorithm with visualization of the network and key retrieval

License

Notifications You must be signed in to change notification settings

ShaeBrown/chord-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Chord DHT

Implementation of the Chord DHT Peer-to-Peer algorithm using Flask.
Visualization of the network and key retrieval using D3

Build front end

If you don't have node.js download here

cd visualize
npm install
webpack

If you have yarn, you can use the yarn command instead. You can edit the parameters in visualize.html to preview how the front end works.

Build back end

Install requirements

Ensure you have python installed.
If you do not have virtualenv installed you can do so by pip install virtalenv
Now you can make a virtual environment and install the requirements:

virtualenv .venv
pip install -r requirements.txt
source .venv/bin/activate

Install redis

sudo apt-get install redis-server

Run nodes

Run a redis server for each chord node

redis-server --port 6000
redis-server --port 6001
redis-server --port 6002
redis-server --port 6003

Now you can initalize each dht server

python runserver.py -p=5000 -r=6000
python runserver.py -p=5001 -r=6001
python runserver.py -p=5002 -r=6002
python runserver.py -p=5003 -r=6003

Join nodes

I used postman to send requests. You can also use curl

curl --location --request PUT "localhost.localdomain:5000/dht/join" \
  --data "localhost.localdomain:5001
localhost.localdomain:5002
localhost.localdomain:5003"

Put key

curl --location --request PUT "localhost.localdomain:5000/db/keyval" \
  --data "this is the data"

Get key

curl --location --request GET "localhost.localdomain:5002/db/keyval"

Visualize network

Open in browser: localhost.localdomain:5000/dht/peers/view

This is an example of what a visualization of the peer to peer network would look like: peer

Visualize key path

localhost.localdomain:5000/db/view/somekey

This is an example of what a path would look like when trying to find the key keypath

Run tests

Postman tests can be run by calling this script, which starts all the chord nodes, and redis servers.

Or if you have postman installed:

Run in Postman

Just make sure there are 5 servers running on port 5000, 5001, 5002, 5003, 5007, each with a redis server

Unit tests can be run using:

cd dht
python -m test.dht_node_test

About

Implementation of the Chord DHT Peer-to-Peer algorithm with visualization of the network and key retrieval

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published