R
R
Rostislav2017-03-09 21:17:39
Programming
Rostislav, 2017-03-09 21:17:39

Ways to implement p2p messaging. How blockchain can be used in creating a messenger?

Is it possible to implement an absolute (there is nothing on the network except clients) p2p messenger?
What is the easiest way to organize a p2p network for android devices.
DHT. Please explain the essence of this protocol when creating messaging systems.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2017-03-10
Makkall @viogull

It is extremely difficult to completely abandon servers or something that will say where which client is. We live in a world where there are a lot of NATs and gray ip addresses with dynamics.
In fact, you need to solve the following problems:
1) Implement a NAT punch. There are many ways and you need to consider the maximum number of them. This is UPnP, and the ability to break through a port through a neighbor that can do this and connect to another client and through it go to the general exchange network.
2) A certain mechanism of trust between clients is needed. there will be no central authorization server. There are also many ways, and most often encryption is used according to a certain key that is generated for each client for each client, after which it is stored locally. Even if a certain client pretends to be another client with his key, nothing will come of it. Messages will reach, but he will no longer be able to read them without individual keys to each client, which the attacker will no longer be able to find out.
3) Some implementation of the system will be needed to communicate the IP address and port of the clients to each other. There are already completely different options with their pros and cons. The simplest is some server that only knows ip: port: client_id, everything works with it (of course, this server does nothing more and messages and data go between clients directly).
Another option is the same server that gives and knows ip: port: client_id, but the difference is that it is dynamic and is created by the best client (the best one is selected according to certain criteria such as good Internet, dedicated ip, lack of nat, etc.). Those. the server still remained but moved to the clients themselves and, moreover, there were a lot of them. This method is DHT and the next problem grows from it.
4) Because now you have a completely decentralized network based on DHT or your own bike that also repeats DHT, the problem has grown that clients can be in different networks with these DHT and not know about each other at all. Here you will need to implement some mechanism so that DHT servers look for and know about each other. How this will be implemented is also a huge hemorrhoid question, you can make another layer in the form of DHT over DHT, you can make some central servers, you can go through a hard broadcast between DHT nodes, etc.
A fully-fledged decentralized network is possible only in a world where each piece of iron in the network has its own unique static IP and there are no firewalls at all, and the network itself is built without gateways and without division into subnets. But as is clear, this has never been and will not be, but it is possible within a small local network.
I almost forgot, such a p2p chat already exists in the form of Tox. Separately, there are similar chats in the form of plug-ins in the Vuze- bittorrent client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question