Conf42 Cloud Native 2025 - Online

- premiere 5PM GMT

Decetralized P2P networks

Video size:

Abstract

Learn the core concepts of p2p networks, their main components and principles these networks are based on. The speech will help you to broaden your horisons and undertstand how popular p2p networks like BitTorrent and IPFS work.

Summary

Transcript

This transcript was autogenerated. To make changes, submit a PR.
Hello, my name is Akim and today I will be talking about foundation of P2P networks. Thank you for joining my talk. I hope, this talk will be interesting to you. And today I will be talking about P2P networks and how they work, how they can be used in the real projects and what benefit they bring in our world and the application we built. Okay. Let's start with the. features, of decentralized P2P networks, the first feature is, that each member of the network is equal to any other member. What does it mean? For example, in our regular client server model, where there is a server and there is a client, the server defines rules, its API, permissions, and other stuff, and regulates which client can connect and which cannot connect, and so on. And the client, has to abide to those rules, otherwise the client cannot connect to the server. And this inequality, doesn't apply in P2P networks. Because in P2P networks, each peer is equal, and each peer can connect to others without any limitations. The second feature of the P2P networks is that each member communicates to others directly, meaning that For example, if there is, three peers, A, B, C, A connected to B and B connected to C, and at some point A wanted to connect to C, it cannot go through B peer. It has to ask B, do you know, peer named C? And B says, yes, I know, here's, his address. And then after obtaining an address, The peer A can connect to C, peer, and communicate to it directly. So they cannot use B as a proxy. Okay. And the application which utilizes those P2P networks, they can Like, do a lot of useful things, for example, distributing processing power between many peers in the network, or distributing storage. And we're not talking about avoiding bans or limitation based on country or other kinds of regulation. So that was networks are really wonderful in terms of, distribution and, like new concepts. So let's, talk about their, components and describe each one separately. So overall, there are four components I decided to underline in this talk. It's, P2P protocols. It's application level protocols, the first component. and actually this is a very. big component in terms of, the P two P protocols, unite a lot of internal stuff. We'll talk about it. okay. And besides p P two P protocols, there's a second component. Peer discovery. it's about finding and other peers in the network. Also transports and naturals. We'll talk about all of this in detail. On the next slides, let's start with P2P protocols. What are those? Those are an application layer protocol, which defines basic component. In P2P networks, each P2P networks have to, implement, a couple of, I would say not a couple, a dozen of, protocols, a dozen of, interface. Like peer identity, addressing, messaging, connection logic, peer discovery, peer routing, and other stuff, handshakes, transport, and a lot of other things, and all of those. Depending on their implementation, build a structure for P2P protocol. And also good to mention libP2P ecosystem, we'll talk about it later, which, provides basic implementation for most of these, interfaces. And, a lot of modern P2P protocols actually built on top of libP2P. let's carry on. There's, Next concept of, P2P networks is a peer discovery. It's all about, finding other peers in the network. and connecting with each other, like in the picture demonstrated on this slide. so when the new peer appears in the network, first of all, that peer, has to find other peers. Otherwise, it cannot do any useful work for us. to do That peer would use peer discovery mechanism implemented in one or other way. the very popular, peer discovery mechanism is, for example, Translates, translating a global message, through each peer in the network that new peer has appeared and other peers try to contact it and share their information or there are bootstrap peer which has known and there are bootstrap peer which has like known list of peers in it and the newly created peer can connect to the bootstrap node and ask for the list of closest network participants. And after the peer discovery, there is a very similar challenge is a peer routing is, actually, when a newly created peer has to find a way to other peers to connect through them, to find a like road and, go through one or other and third, and peers to reach their destination. And usually it's implemented by maintaining a specific routing table, which is, which has a graph like structure and used for this purpose. Okay, that was the second component. The third component is transport. transport is, data transfer protocols like TCP or UDP. they have, alternative, although, those two are very popular and used almost everywhere. And, good alternative would be Quick protocol, which, actually an, implementation, which is layered atop of UDP protocol and acts like a WebSocket, WebSocket with UDP. And also there are modern protocols like WebTransport and WebRTC, which are efficient ways of communication in browser environment. Very useful. They're used for data transfer, for example, video transfer. And they are really efficient in this, in these cases. The fourth mechanism of, P2P networks I chose to talk about is NAT traversal. it's a mechanism that allows communication between public, peer, and peer to peer networks like laptop connected to home Wi Fi router, for example, if you like have a laptop and you're working on it, and you want to interact with outside world with the deployed network on some public machines somewhere in the world, those public, servers cannot reach you because your laptop is behind your router. And, to overcome this, you would, you can try to configure your Wi Fi. router, to allow some, to allow accepting, external connection to your laptop. But this is difficult for many users, so that's why, natural cell mechanism was designed. there are quite, A few ways to implement that and very popular one is just setting up a really public peer, which are accessible to your private network. And, if your laptop point to, interact with the P two P network, your laptop have to connect that. Relaypeer and keep a long live connection and while your laptop keeps a connection Other peers can communicate first to Relaypeer and Relaypeer just redirect data package to you without Interacting them in any way. yeah. that's how they work. Let's, move on. good examples of P2P networks. first example is IPFS. Also there is a BitTorrent. Those two protocols are really, popular. And they're used for file sharing. Though they are slightly different. Also there is a Fluence Network Protocol, which I want to talk today about. And also very popular Ethereum, Decentralized Blockchain Protocol. I hope almost all of you know about it. The first the first protocol I want to talk is IPFS. What is IPFS? IPFS is distributed system for storing and accessing files, website, application, and data. I would say almost anything which could be saved, in storage. And IPFS, means interplanetary file system. Okay, let's, let's look at the IPFS in more details. yeah, as I mentioned, IPFS as a P two P networks, it's used for storing data and, the good use cases is that, for example, you can store your file in A-I-P-F-S and that file would be distributed to any other P of IPFS in the world. And for example, if, we choose some, popular centralized server like Google or Amazon. And they have some limitation for file sharing in some countries through IPFS. You can, avoid those limitations and share your file everywhere, where internet is available and other use case would be much faster, downloading of the file. Which is also utilized by BitTorrent protocol, because if your file is deployed in many places, like many peers in the network, you can open connections to all those peers and start downloading them. content for them simultaneously, which greatly speeds up, speed of downloading that file. there are also a lot of other features listed in that websites and, implementation details, and I really recommend you guys checking this, IPFS protocol. It has really cool documentation, but now let's move to the. Next slide, and next slide is about Fluent Network Protocol. That protocol is about, workload distribution. for example, if you want to build a report or do some computation or heavy calculation, solve complex math, sorry, solve complex math problem, you can use a Fluent Network Protocol, which can distribute your calculations and optimize them. Let's see how it works in detail. there is a documentation of Fluence network protocol. there are some features like it fast, secure. let's see how it works. actually Fluence network is built of, peers. Some of these peers are providers which provide, as you can judge by their name and provide computer powers and allow you to utilize that computing power and. clients, client peer, which can also work as a providers. but they also send, like a request or, express a desire to do some work. for example, in this, very small snippet of code, The workload is very simple, it's just setting status online, just updating the string, but it could be much more complicated. And there is also a specific language, written for interacting with peers in that protocol, it's called Aqua language. And, it, allows specifying execution model and, allows one to choose a peer where that code should be executed. And that's just, really top of an iceberg of that language. But the main idea of that protocol is that, user first write the code and specify execution model. And after doing that, the, protocol allows, the protocol executes that code and distribute your workload on many different nodes. Why is this protocol useful? It's because it's decentralized. if you distribute your work through Fluence, you do not rely on. Central provider like Google or Amazon, which can change, like requirements or conditions and you have to abide. Otherwise, you have to change your architecture to other providers, which could be really time consuming. and also using Fluent Protocol is cheaper because there is a free market and each peer can participate in that. protocol by proving that it has necessary powers to execute your code and other features. there is also cool documentation, here, and there are many example projects. influence, protocol ecosystem. for example, right now I'm looking at FRPC substrate example is, it's a example of application, which, connects to the centralized apps and allow, distributing, their. Access to the RPC, to the blockchain gates, so we won't talk about it in details right now. But if you are interested, feel free to follow this website, just Google Fluence and see how they work. And now we're getting back to our presentation. the next slide is about, additional information. It's actually about, libp2p. let's look a bit, what is libp2p. Like I mentioned before, libp2p is a great foundation for building your own, decentralized protocol. It has a implementation for, many different, many fundamentals. Which, almost every, every decentralized protocol consists of. For example, it's addressing, peer discovery, peer routing, peer identity, peer, info. There's also some transports. Secure communication, stream multiplexing, and a lot of different stuff, which I mentioned today. Some of this stuff I mentioned, some of them I didn't mention. yeah, it's really good to go through the documentation. At least there's some introduction, passages, and just get a basic understanding of what it is and how you can use it. I believe that's it. That's all, for today's talk, thanks for listening guys, see you soon, that's all. Thank you.
...

Akim Mamedov

Lead Software Engineer @ 1tab

Akim Mamedov's LinkedIn account



Join the community!

Learn for free, join the best tech learning community for a price of a pumpkin latte.

Annual
Monthly
Newsletter
$ 0 /mo

Event notifications, weekly newsletter

Delayed access to all content

Immediate access to Keynotes & Panels

Community
$ 8.34 /mo

Immediate access to all content

Courses, quizes & certificates

Community chats

Join the community (7 day free trial)