{"id":16694821,"url":"https://github.com/metanet/p2p","last_synced_at":"2025-04-30T21:30:05.584Z","repository":{"id":54333250,"uuid":"50194363","full_name":"metanet/p2p","owner":"metanet","description":"A simple unstructured P2P network implementation","archived":false,"fork":false,"pushed_at":"2024-04-19T07:55:12.000Z","size":34,"stargazers_count":157,"open_issues_count":1,"forks_count":56,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-30T20:05:24.429Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metanet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-22T16:49:21.000Z","updated_at":"2025-02-16T06:59:25.000Z","dependencies_parsed_at":"2024-10-27T12:00:40.177Z","dependency_job_id":null,"html_url":"https://github.com/metanet/p2p","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metanet%2Fp2p","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metanet%2Fp2p/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metanet%2Fp2p/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metanet%2Fp2p/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metanet","download_url":"https://codeload.github.com/metanet/p2p/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251785264,"owners_count":21643448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T16:48:25.297Z","updated_at":"2025-04-30T21:30:05.532Z","avatar_url":"https://github.com/metanet.png","language":"Java","funding_links":[],"categories":["网络编程"],"sub_categories":["Spring Cloud框架"],"readme":"Introduction\n================\n\nThis is an experimental work to build a unstructured P2P network using Java and Netty. \n\nIt has following capabilities:\n\n- Join to the P2P network\n- Leave the network\n- List peers in the network\n- Leader election\n\nP2P network is unstructured. Once a peer is started, it can join by connecting to any of the peers in the network. \n \nTo maintain connectivity of the P2P network, each peer connects to more than one peer in the network randomly. \n\nPeers send periodic keep alive messages to their neighbours to notify them about their presence. If a peer does not receive a message from a neighbour for a configured amount of time, it drops the connection.\n \nA peer can discover other peers in the network with a Ping-Pong process by sending a Ping message to its neighbours and waiting for the Pong messages for some time. This message also contains how many hops it can go over the network. When a peer receives a Ping message from a neighbour, it replies with a Pong message and dispatches the Ping message to its own neighbours after decreasing the hop count.\n  \nThis mechanism is a very basic implementation of the Ping-Pong mechanism described in the Gnutella P2P network protocol v0.4. To read more about Gnutella, please see [The Annotated Gnutella Protocol Specification v0.4](http://rfc-gnutella.sourceforge.net/developer/stable/)  and [Gnutella Wikipedia](https://en.wikipedia.org/wiki/Gnutella). \n \nIn the image below, you can see a Ping-Pong flow. \n \n![Ping Pong](http://rfc-gnutella.sourceforge.net/developer/stable/GnutellaProtocol-v0.4-r1.6_files/gnutella-ping-pong-routing.gif)\n\n\nIt also implements [Bully Algorithm](https://en.wikipedia.org/wiki/Bully_algorithm) for leader election. Since bully algorithm assumes a fully connected network under the hood, it is users' responsibility to create a connection between each peer before running the election. \n\nAll network messages are sent with a fire-and-forget manner without any acknowledgement or retry system.\n\nYou can see available configuration options in [Config class](https://github.com/metanet/p2p/blob/master/src/main/java/com/basrikahveci/p2p/peer/Config.java). Main class is also [here](https://github.com/metanet/p2p/blob/master/src/main/java/com/basrikahveci/p2p/Main.java).\n\n\nBuild\n================\n\nThis is a very simple Maven project which requires Java 8. \n \nIt can be compiled with `mvn clean compile` and final jar can be produced with `mvn clean package`.\n\n\n \nRun\n================\n  \nYou can start a peer by starting a java process with the produced jar file as follows:\n  \n`java -jar -DpeerName=Peer1 p2p.jar -n Peer1 -b 50670` \n\nThis command starts a peer with name `Peer1` and binds it to port `50670`. It is the user's responsibility to guarantee uniqueness among names of the peers. \n\n`-DpeerName=...` is not necessary if you change default logging configuration of the project.\n \n After starting the peer, you can type `help` to see available commands.\n \n \n \n \nContribution is welcomed\n================\nThis project is only tested by starting peers in terminal and creating connections among them. Therefore, unit tests and integration tests are welcomed.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetanet%2Fp2p","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetanet%2Fp2p","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetanet%2Fp2p/lists"}