IPFS: InterPlanetary File System

From HTTP to IPFS

HTTP is the transmission protocol for the World Wide Web (WWW) server to transmit hypertext to local browsers — Hyper Text Transfer Protocol.

How does the World Wide Web work with HTTP?

The answer is related with TCP/IP communication protocol.

To put it simply, suppose A uploads a file to the browser on the computer, and B needs to download the file, then their computers will process this way:

First, TCP will decompose the file, which is sent by A, into a lot of data, and then compress it into multiple compressed packages.

These compressed packages are all loaded into an IP, and send a request to the HTTP server (the WEB server) through URL.

After receiving the request, the web server sends a response message to the client, and the file of A is successfully uploaded.

When B downloads this file, he or she needs to enter an IP address or domain name so that the computer knows where to find the corresponding information (Location based addressing).

After that, the computer will send a request to the WEB server, and TCP will restore the downloaded compressed data in order.

If the receiving TCP finds that part of the file is damaged, it will request to send it again.

In other words, 1) On the Internet, all data is stored on a central server. Whether you upload / download files, users need to get data from the server. Once fail, or being restricted, or being attacked, a file loss or a web page cannot be opened (error 404).

2) There is also uncertainty in location-based addressing. For example, once the IP is deleted, or the server is broken, the user will not be able to download the file.

3) If this file is needed by many people, but each one has to download it before put into use, and it will lead to a huge waste of storage space.

Therefore, although the Internet is well-connected and covers a wide range of information, it is inevitably limited.

IPFS is very similar to the Internet in building a bridge of information exchange. The difference is that IPFS is decentralized.

That is to say, IPFS does not have a central server, so there is no problem of information loss or tampering. And IPFS can save storage space.

Second, IPFS’s minimalism

Protocol Labs also has a deep meaning when it is called “InterPlanetary File System” when creating IPFS.

Protocol Labs hopes to build a peer-to-peer distributed file system that makes it easy for everyone around the world to extract files from IPFS systems without the firewall. Even if the technology develops to a certain extent and needs to transmit information about the planet, IPFS can also provide a service for quickly storing files.

1. Storage

In IPFS, information can be stored in blocks in an IPFS system, and can store up to 256 kb of data, which can also be linked to other IPFS blocks.

When storing a file smaller than 256kb, you only need to put this file into a block.

Files larger than 256kb are divided into multiple 256kbs and placed in the block, after which IPFS will create an empty block that will link to all other parts of the file.

This empty block is similar to a large envelope that covers all parts of the entire file.

The system will generate a hash function for each block of the same file. After the hash functions of all blocks is calculated, all the hash functions will be pieced together into hash function b, and then the hash function will be calculated. Get the final hash functions c. Finally, the final hash functions c is bundled with the original file to form an object, thereby forming an index structure d. The block and the final index structure d are uploaded to the IPFS node and the files are synchronized to the network.

In addition, there is a small file smaller than 1kb, if these small files are also placed in a single block, it will also cause some waste. Therefore, IPFS directly puts the data content less than 1 kb and the hash index together to upload to the IPFS node, and no additional one block is occupied.

It can be seen that the creative concept of IPFS is to use storage space as little as possible and store files as scattered as possible.

In addition, for the same file, IPFS only creates a folder, the system will automatically delete duplicate files and modify the version history, which can greatly save storage space, ensure the running speed of the entire system, and ensure the security of stored files. , and the convenience of use.

2. Read

Also as a basis for the exchange of information values, users are no longer location-based addressing, but content-based addressing, when uploading or using files on IPFS. That is to say, the instruction of “Where to find information” is replaced by the instruction of “what to look for.”

In the Internet, downloading files or browsing information requires an IP address or domain name. In IPFS, each file has its own hash function, and a hash function corresponds to only one file. There is no problem with a file having multiple hashes, or multiple hashes corresponding to the same file. Therefore, the user only needs to input the hash function of the required file in the IPFS, and the corresponding file will be found in the system. These files are distributed and stored, so as long as one user has a corresponding file, even if some nodes are struck or not online, it will not affect the reading of the file.

Specifically, when downloading files in the IPFS system, first, the miner needs to search the index structure of the hash according to the final hash value and download it. The user can then search for the location of the node where the file is located based on the hash index. After the user downloads the blocks on the node, IPFS will reassemble the files according to the order of the hash arrays, and the user can use them.

It can be seen that IPFS subdivides the files, making the uploads slightly more complicated, and the purpose is to make the users more convenient to download. After all, the download of small files is much simpler and more convenient than large files.

Third, IPFS defects and countermeasures

  1. Information is irrevocable and non-tamperable is the advantage of IPFS. However, if it is a file to be operated, or a file with incorrect content or information to be updated, then irrevocable and unchangeable will become a very troublesome thing.The corresponding measures given by IPFS are: the modified files can be uploaded to IPFS, IPFS will also update files, and all historical records of updated files can be searched in IPFS.
  2. IPFS stores large files in different blocks, and there is inevitably a hidden danger. That is, if some nodes that store files are not available offline, and the file is not backed up, the entire file is unavailable. of.There are two solutions to this. One is to motivate more nodes to store this information, and the other is to actively distribute files so that more nodes can store this information.

Others

In May 2014, Juan Benet invented IPFS with several of his Stanford classmates. After that, he was successfully selected and joined the top incubator Y-Combinator (the incubator once rejected Gonetwork) and established the Protocol Lab. Subsequently, Protocol Lab released IPFS, and since then, IPFS has made great progress in organizations across various industries.

In 2016, IPFS was once one of the most popular technologies in the blockchain industry, and thousands of developers called it “the future of WEB.” In the same year, the protocol lab also created libp2p, IPLD, multiformats, Orbit, and other projects. Until now, IPFS has maintained a very good development schedule.

So far, many projects have been developed based on IPFS, including Akasha, BlockCat, Mana, DistrictOx, TokenClub and so on. AtoX Chain was also developed based on IPFS.

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
AtoX Chain

A Multiwallet and token exchange Platform based on the AtoX Blockchain.