IPDC(InterPlanetary Distributed Computing) is the Distributed Computation service, A peer-to-peer hypermedia protocol to make the computation faster, open, and more scalable.
IPDC
IPDC(InterPlanetary Distributed Computing) is the Distributed Computation service, A peer-to-peer hypermedia protocol to make the computation faster, flexible, and more scalable.
Abstract
IPDC is a decentralized computing system (or service) built on IPFS.
The traditional IPFS is an InterPlanetary distributed file system, users can quickly and easily add their own computers to IPFS environment. After joining IPDC, people can upload their own files (or directory), download, sync ... and so on. IPFS is actively integrating with Ethereum with the goal of becoming the storage of the blockchain (Both the core data structure is Merkle Dag).
Even though IPFS looks highly forward-looking, it seems that most people's point of view are purely in terms of storage. However, when a large number of users join the IPFS to contribute storage space, the computing resources of these devices are also very valuable. IPDC hopes to make full use of these computing resources.
IPDC is built on IPFS and communicates with M2M through MQTT technology. IPDC is divided into five kinds of architecture currently :
- MR (Map-Reduce)
- TF (Tensorflow)
- CL (Big Crawler)
- ER (Ethereum)
- EM (Edge Computing)
Table of Contents
- IPDC MR - IPDC TF - IPDC CL - IPDC ER - IPDC EMExternal IP
IPDC is built on top of IPFS, IPFS generates a ID when it is initialized (the format such as: QmNXM4uWnd7oLqqDFg4Jo26eSYWQvZz6QCmiqtzmFgJhDD).
Native IPFS initialization will connect the officially recognized gateway. The system will find the peer through the gateway and connect with other people's IPFS through ID and IP (no matter internal IP or external IP). However, the IPFS used by IPDC is a closed IPFS that I modified the source code, the main purpose is not to let strangers connected to our IPFS cluster. We will not connect to the IPFS official gateway, so we need external IP to connect the two nodes.
In addition, the MQTT communication mechanism that we use now also uses external fixed IP. Making IP more flexible is one of the topics that IPDC can optimize in the future.
Install IPDC by Docker
Strongly suggest using docker to install IPDC now.
Unfortunately, not for mac!!! - https://github.com/docker/for-mac/issues/68
$ sudo docker pull yenkuanlee/ipdc:latest
$ sudo docker run -dti --network=host yenkuanlee/ipdc /bin/sh
$ sudo docker exec -ti $CONTAINER_ID bash
$ cd ~/IPDC
$ git pull
$ vi ipdc.conf
# modify and safe
$ python deploy.py start
IPDC Installation
You can skip the step if you have already installed IPDC by Docker.
1. Clone the IPDC project
$ git clone https://github.com/yenkuanlee/IPDC
2. Set up ipdc.conf
$ cd IPDC
$ vi ipdc.conf
# DOMAINNAME : You can only connect to peers with same domainname
# MANAGEMENT_IP : portal IP
# PROJECT : MR / TF / CL / ER / EM
3. IPDC initialization
Install some tools :
- IPFS
- MQTT (paho, mosquitto)
- Tensorflow (CPU version)
- Ethereum (geth, web3)
$ python deploy.py init
4. start IPDC
Start IPFS daemon and MQTT listener to become a IPDC node.
$ python deploy start
Starting IPDC project
In this section, we will introduce how to use each of IPDC project. All IPDC project have two python codes :
- control.py : project controller
- Dmqtt.py : mqtt listener, receive messages and do the correspond things.
IPDC MR
- IPDC MR is based on Map-Reduce framework with characteristic of decentralized, multi-master and extremely light. Users can write logic in Map.py and Reduce.py under the project. All peers in IPFS can be compute nodes for IPDC (we can set the distributed number).
- There are some core code in ER project :
- The example algorithm of this project is "WordCount".
Running IPDC MR project
- Parameter setting
$ vi test.py
# we can set the distributed number in function "SetKRunner"
- Input data
control.py: cmd = "timeout 10 ipfs add data.dat"
Dmqtt.py: os.system("rm Map.py Reduce.py output.txt data.dat")
Map.py: self.InputPath = 'data.dat'
- Mapper
- Reducer
- Run the MR job
$ python test.py
- Output
$ cat /tmp/JobID/*
Theorem of IPDC MR
- The controller determines and chooses K (distributed number) workers through the peerID hash of each node in IPDC.
- The controller will upload the input file, Map.py, Reduce.py to IPFS and notify K workers through MQTT to download the file.
- The controller call each workers by MQTTto start the Mapper. By using worker's peerID and line number of input file as key, we can assign a worker several keys to map.
- As with Hadoop, mapper eventually throws the result as Key-Value pair into the corresponding buffer.
- Each worker's Buffer finish to collect Key-Value pair and starting reduce job .
- After the end of each reducer, the results will be written into local disk and upload to IPFS. Through the MQTT, output hash will be passed to master who triggered the MR job.
- MR master collected and download all output hash of each workers,and finish the entire MR job.
IPDC TF
- IPDC node can establish tensorflow cluster
- IPDC TF is the framework of distributed tensorflow. Users fill in the virtual cluster specification file (ClusterSpec.conf). Then IPDC picks compute nodes from IPFS peers and produces real cluster specs (ClusterSpec.json) to upload to IPFS, so the controller can notify all compute nodes through MQTT to complete the establishment of distributed tensorflow cluster.
- There are some core code in TF project :
Running IPDC TF project
- Set ClusterSpec
- Generate create_worker.py
- Cluster deploy
- User coding
- Execution
$ python test.py 0
# generate create_worker.py and ClusterSpec.json
$ python test.py 1
# Set and start IPDC tensorflow cluster
$ python example.py
# run the distributed tensorflow job
$ python test.py 2
# Close all workers and delete create_worker.py and ClusterSpec.json
IPDC CL
- IPDC CL is a simple distributed framework. Each compute node will do a indepentdant operation.
- The idea comes from TAAI 2015's paper
- In this project, we use a crawler to be a CL example, which can be distributed by target url and crawl independently.
- There are some core code in CL project :
Running IPDC CL project
$ python GetData.py > data.dat
$ vi test.py
# we can set the distributed number in function "SetKRunner"
$ python test.py
# Run the CL job
IPDC ER
- IPDC ER combines IPFS node with private ethereum node. There are several benefits :
- There are three roles of IPDC ER users
- IPDC ER is just a blockchain platform. The important thing is that we can run many Dapps on IPDC.
- There are some core code in ER project :
Running IPDC ER project
- set description.conf
networkid = 13467912
chaintype = filesign
description = This is a kevin chain.
extradata = 12345
numberofnode = 3
rpcport = 8545
date = 2017-11-02T11:00:00
chainname = Kevin
- ask resource
$ python chain.py ask_resource
- After chain owner publish his request to IPDC, each resource owner will received the message and record the chain information into a sqlite database(/tmp/.db/chain.db). If one resource owner want to join this chain, he can do the following things:
$ sqlite3 /tmp/.db/chain.db
sqlite> select * from AskResource; QmRxiJ3WjG5YFQSWY3mdXAKBRgfLyyocFwL9cTBEpcfhwX|Kevin|filesign|3|13467912|12345|8545| This is a kevin chain. # You can see information of the chain
# If resource owner want to join the chain, he can do the following command. $ IPFS pin add QmRxiJ3WjG5YFQSWY3mdXAKBRgfLyyocFwL9cTBEpcfhwX
- Start a chain
$ python chain.py start - Chain owner can manage some application in a chain. - Basic ethereum transaction. - Filesign will be introduced in the next section. - After a chain is built, chain owner can add IPDC nodes to the chain. $ python chain.py add_node 2 # add two nodes to the chain - Stop a chain
$ python chain.py stop
Filesign : a Dapp example
- Filesign is a command line tool built on IPDC ER. It is an application about sending the certificate and verify the certificate. There are three roles in the filesign application :
- Filesign command line tool is put on every IPDC ER node, each IPDC ER node is a filesign sender. In the other words, a resource owner in one chain is also a filesign sender node. A filesign sender can create many account of filesign receivers and send certificate to them; A filesign receiver can request the sender to download his certificate which is stored in IPFS; A filesign varifier can upload someone's certificate to filesign sender node to varify the certificate.
- Execution
# To the path of FileSign
$ cd /path/to/ER/FileSign
For sender
$ python3 filesign.py account new
# create an receiver account
$ python3 filesign.py file send
# send certificate to a receiver
For receiver request
$ python3 filesign.py file download
# download the receiver's certificate
For varifier request
$ python3 filesign.py varify
# upload certificate and varify
IPDC EM
- IPDC EM is not a clear architecture. It is an attitude !
- IPDC EM node can become a gateway of edge computing.
- Reference Papers
Advantage of IPDC
- Extremely light
- Extremely flexible
- Scalable
- Open and fast
- Multi-Master architecture