NKN client enables free . end to end data transmission in a purely decentralized way Prior to NKN, if a sender client (a mobile app, for example) wants to send some data to a receiver client, (public IP address, open ports), which is not practical for consumer applications, , which will introduce additional cost (to build a relay service or pay for the service) and security vulnerability (data exposed to centralized server or 3rd party service). the receiver needs to be publicly accessible or they have to be both connected to some centralized server or platform With NKN client, both sender and receiver and stay private in any network condition, and they don’t need any centralized server or platform. The data will be routed and delivered in a purely decentralized way, end to end encrypted, and free. This is made possible thanks to the NKN public Blockchain. NKN client uses a : each packet only contains information about src, dest, payload, and some other necessary information related to signature chain. very simple protocol similar to UDP A bare minimal NKN client does not create or manage session/stream, and does not guarantee packet ordering, ACK or re-transmission. The bare minimal protocol works well for some applications, e.g. messaging, real time gaming. However, if someone wants to , a few other problems needs to be solved: boosting throughput, packet ordering and re-transmission, etc. transmit large files using NKN client That might sound familiar to you since it’s basically what does. TCP There are more than one ways to achieve the above goals and the best one depends on the application. As a starting point, we created , a simple application/library based on NKN client that can fast and securely send and receive files between peers without any centralized servers. nkn-file-transfer It is . written in Golang and uses nkn-sdk-go , multiple concurrent clients similar to nkn-multiclient-js , and simple TCP-like flow control NKN-file-transfer has 4 modes: send, receive, get, . host should be paired with to send file to remote peer, while should be paired with to fetch file from remote peer. Send mode receive mode get mode host mode Under the hood, both sender and receiver creates multiple clients by adding certain prefix string to the identifier part of NKN address. When a file is being sent, it is first cut into many small chunks (each chunk is 1024 bytes by default) and each chunk is labeled by a sequence number. Then sender sends chunks concurrently using different path and waits for ACK of each chunk from receiver. Only a certain buffer size of unacknowledged chunks may be sent at any time (sliding window). If a chunk is not acknowledged after a timeout, it will be resent using a different path. On the receiver side, when he receives a chunk, he will send an ACK of that chunk back to the sender. , nkn-file-transfer can be turned into a few quite useful applications: Combining these modes Using , you can send a large or sensitive file to someone on the other side of the planet for free. The speed is quite descent, and content is end to end encrypted, without any other people being able to see the actual content of the file, and everything is decentralized. send/receive mode Using (say A) while (say B), A can get file from B or put file to B, just like a standard file server. get + send mode on one side receive + host mode on the other There is also a that can be enabled together with host and receive mode. It can accept HTTP GET/PUT/HEAD request with route remoteAddr/fileName. It accepts HTTP GET request with Range header so browser can stream video while downloading (the latency is high as you may have expected, but the throughput should be good enough). HTTP mode It can be used as a Golang library to be in other applications. embedded With nkn-file-transfer, you can often get close to . We have tested the throughput of nkn-file-transfer by sending a 32MB file from our US office (California) to China office (Beijing) and compared it with WeChat and QQ, two of China’s largest IM that supports file transfer. 10Mbps speed to most long range global destinations The throughput of nkn-file-transfer is (which uses a centralized server to store file) and (which uses a centralized server to relay data but not storing file). 460% of WeChat 160% of QQ Our nkn-file-transfer is at . We should address that, it is using a simple flow control algorithm to show how to use NKN client to create high throughput decentralized applications. open sourced https://github.com/nknorg/nkn-file-transfer We would be happy to see someone achieving better performance using more complicated and throughput-optimized algorithms. (Featured Image by Yilun Zhang, CTO of NKN.org)