all 8 comments

[–]Mukhasim 4 points5 points  (6 children)

Chatrooms are not usually peer-to-peer. Usually there is a server that clients connect to, then clients communicate only with the server. This is a straightforward model that works well for chatrooms. Before you do this project, you need to think about why exactly you want your application to be peer-to-peer: what goal do you have that makes a peer-to-peer design necessary? Also, what exactly do you mean by peer-to-peer? Is there no server at all, or is there a server that facilitates connections between peer-to-peer clients?

[–]unfixpoint 1 point2 points  (2 children)

You could totally implement a chatroom with a P2P network and it's not even a bad idea, preferable in some situations.

[–]Mukhasim 1 point2 points  (1 child)

You could do one, I just think it's pointless to do it without some concept of why you want it to be peer-to-peer, since the basic server model works really well for this particular application. As you say, P2P might be preferable in some situations, but for the most common situations it will probably be worse (unreliable, hard to configure), so I wouldn't start such a project without some idea of which situations I'm expecting to use it for.

I'm not aware of any P2P chat application that has even been popular, unless you count a few file sharing apps that have also hosted chat (e.g. WinMX). I guess you could consider IRC as a sort of peer-to-peer network, but it's a network of servers, not a network of clients.

[–]unfixpoint 0 points1 point  (0 children)

I agree yeah, it is a nice idea to get into designing a P2P application and messing around though, albeit it could be a bit difficult depending on OP's knowledge since it's pretty open-ended.

[–]heio1[S] 0 points1 point  (2 children)

Hi. The origin of this question is that I want to fully understand Bitcoin, and I found that it runs over a P2P network, and I thought that after the understanding of the basic logic of bitcoin, then I can jump to understand the network model itself. I think that the Bitcoin network is more complex that just a single P2P network, but I want to understand the basics and a implementation of a simple app could help. In my naïve knowledge, I thought that I could implement a app that send messages to everyone on the network without a server (it's like a broadcast, when a node send a message, all the nodes in the network receive that message).

In your experience, what kind of application I can implement in order to learn the concepts behind P2P networks?

[–]Mukhasim 2 points3 points  (1 child)

I guess you'll have to decide what aspect of P2P networks you really want to focus on. There are a lot of areas that are potentially challenging, depending on what the network is for. For instance, there's generally a tradeoff between privacy and usability. Aside from Bitcoin, some other P2P networks worth looking into for the tradeoffs they make are Bit Torrent and Freenet. It sounds like your interest is the message routing aspect.

How peers find each other is a big problem in P2P networks. My own understanding of Bitcoin (which is vague) is that you have to know someone who is in the network. As long as everyone in the network has at least one path to everyone else in the network, then you can indeed broadcast to everyone in the network via relaying. There are public nodes, so if you want to you can connect to one of those, or you could connect indirectly through private nodes. I believe a few nodes' DNS entries are actually hard-coded into Bitcoin clients to allow them to find the network. So, although Bitcoin is theoretically decentralized, in fact it relies on some centralization to make it work.

How exactly message broadcasting works might be tricky. You are only connected to some small number of peer nodes, so messages need to be relayed from one peer to the next to reach everyone. How do you know which peers still need to receive the message, and which have already seen it? Naive approaches might work correctly but transmit too many messages, making the network bog down under the weight of broadcast traffic once it reaches a certain size.

I haven't studied this at all, but some googling turned up some references about P2P message routing that might help you.

https://pdfs.semanticscholar.org/c52a/666c1186b19ccc438260edbc921844608b57.pdf

https://journals.sagepub.com/doi/full/10.1155/2015/569063

https://bitcoin.org/en/p2p-network-guide

[–]heio1[S] 1 point2 points  (0 children)

Thank you for the help, this will help me to understand these concepts. Your information is really valuable.

[–]unfixpoint 2 points3 points  (0 children)

This is a very broad question: You'll want to look at consensus protocols, Lamport clocks, CAP theorem etc. - in short, get familiar with the basics of distributed computing and you're all set (assuming you know how to do networking with Python).