IPFS (InterPlanetary File System) is a peer to peer, version controlled, content-addressed file system. It makes use of Computer Science concepts like Distributed Hash Table, BitSwap (Inspired by BitTorrent), MerkleDag (Inspired by The Git Protocol).
IPFS was created by Juan Bennet at Protocol Labs in 2015. There are multiple applications currently being built on top of IPFS.
The current default way to exchange data across the Internet is HTTP, but it fails in some cases. Large files cannot be transferred using HTTP, data is not permanent on HTTP, HTTP mainly uses a Client-Server protocol which leads to low latency and makes it difficult to establish a peer to peer connection, also real-time media streaming is difficult on HTTP. All of these failures are overcome using IPFS.
Unlike HTTP which is IP addressed, an IPFS network is content addressed. Which means, when any data is uploaded on an IPFS network, it returns a Hash and the data is then requested using that hash. Anyone can provide storage on the IPFS network and everyone is incentivized with crypto tokens. Data is distributed and replicated throughout the network which leads to data permanence. While requesting data it searches for the nearest copy of that data which leads to high latency and overcomes any bottleneck points. As the data is completely distributed, it has no scope for centralization of data.
IPFS could be seen as a single BitTorrent swarm, exchanging objects within one Git repository.
-Juan Bennet (IPFS Whitepaper)
Concepts used in IPFS:
Distributed Hash Table:
It is used to store and retrieve data across nodes in the network. It is a class which is similar to hash tables. Using a DHT, any node on the network can request the value corresponding to a hash key.
It is used in the BitTorrent Protocol (also known as BitSwap) to exchange data between nodes. It is a peer to peer file sharing protocol which coordinates data exchange between untrusted swarms.It uses a tit for tat strategy which rewards nodes that contribute to each other and punishes nodes that only request resources. This helps an IPFS node in retrieving multiple parts of data parallelly.
It uses a Merkle Tree or a Merkle DAG similar to the one used in the Git Version Control system. It is used to track change to files on the network in a distributed friendly way. Data is content-addressed, by the cryptographic hash of the content.
Every node on the network is identified using a NodeID which is nothing but the hash of its public key. Everyone on the network can store files on their local storage and they are incentivized to do so. Each node maintains a DHT which is used to find out Ids of other peers on the network and what data those peers can serve.
Getting Started with IPFS:
To get on the IPFS network we can install IPFS from the Official Website.
- After Installing it according to the given instructions, repository can be initialized in terminal or commandline using
initializing IPFS node at /home/omkar/snap/ipfs/1170/.ipfs
generating 2048-bit RSA keypair…done
peer identity: QmX8TxRjpSZeTXZ1gEF6Jy3Hq7A8PYyBMECX911tRrnXqQ
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
- Daemon can be executed it terminal as
go-ipfs version: 0.4.21-8ca278f45
Repo version: 7
System version: amd64/linux
Golang version: go1.12.6
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.0.107/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.0.107/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
- Now, Once you are online you can access the network using the HTTP to IPFS web portal. Also you can get the ids of your peers using terminal
>ipfs swarm peers
You can also find info about your node and your peers on the WebUI(Address http://127.0.0.1:5001/webui).
Advantages of IPFS:
- Users in a local network can communicate with each other, even if the Wide Area network is blocked for some reason.
- Since no servers are required, creators can distribute their work without any cost.
- Data loads faster as it has higher bandwidth.
- IPFS installation has a lot of hasseles, it is not at all user friendly.
- IPFS consumes lot of bandwidth which is not appreciated by metered internet users.
- IPFS currently is used by tech enthusiast and normal people don’t tend to set up their own node, which leads to shortage of nodes on the network.
- Difference between File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP)
- How to delete a file using PHP ?
- Saving a file in Git
- PHP | php.ini File Configuration
- Download file from URL using PHP
- How to include one CSS file in another?
- How to get file name from a path in PHP?
- robots.txt File
- How to refresh a file in Node.js ?
- File handling in Node.js
Disadvantages of IPFS:
IPFS synthesizes various best systems and protocols to date. IPFS is an ambitious vision of a new decentralized Internet infrastructure, upon which many different kinds of applications can be built in the future.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.