InterPlanetary File System

05 Jul, 2022
Introduction: 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). 
History: IPFS was created by Juan Bennet at Protocol Labs in 2015. There are multiple applications currently being built on top of IPFS. 
Description: 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 the 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. 
Block Exchange: 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. 
Merkle DAG: 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. 
IPFS Nodes: 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 a terminal or command line using 
 >ipfs init
Output: 
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 in terminal as 
>ipfs daemon
Output: 
Initializing daemon... 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 WebUI: http://127.0.0.1:5001/webui 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
Output: 
/ip4/170.11.91.8/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ /ip4/191.236.12.16/tcp/4002/ipfs/QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ /ip4/131.121.91.93/tcp/4001/ipfs/QmWHyrPWQnsz1wxHR219ooJDYTvxJPyZuDUPSDpdsAovN5 /ip4/174.12.28.10/tcp/4001/ipfs/QmdXzZ25cyzSF99csCQmmPZ1NTbWTe8qtKFaZKpZQPdTFB
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 load faster as it has higher bandwidth. 
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 load faster as it has higher bandwidth. 
Disadvantages of IPFS:
IPFS installation has a lot of hassles, it is not at all user friendly. IPFS consumes a lot of bandwidth which is not appreciated by metered internet users. IPFS currently is used by tech enthusiasts and normal people don’t tend to set up their own node, which leads to the shortage of nodes on the network. 
IPFS installation has a lot of hassles, it is not at all user friendly. 
IPFS consumes a lot of bandwidth which is not appreciated by metered internet users. 
IPFS currently is used by tech enthusiasts and normal people don’t tend to set up their own node, which leads to the shortage of nodes on the network. 
Conclusion
IPFS synthesizes various best systems and protocols to date. IPFS is an ambitious vision of new decentralized Internet infrastructure, upon which many different kinds of applications can be built in the future. 
adnanirshad158
pall58183
Computer Networks
Web Technologies
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.