Skip to content

This repository contains the implementation of a Peer-to-Peer (P2P) network. P2P networks are decentralized systems where each node (peer) acts as both a client and a server, allowing direct data sharing without the need for a centralized server.

License

Notifications You must be signed in to change notification settings

rdxkeerthi/p2p-Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P2P Network Project

THE PROJECT

What is Peer-to-Peer Network

P2P network is a distributed network architecture that doesn't need a central server for communication. In p2p network, each computer that joined the network called Peer (or Node) and they are connected to each other directly. Mainly this network is used in file sharing and blockchain applications.

About the project

This project is a simple implementation of a peer-to-peer network using Python. The project will include the following features:

  • Node creation: Each node will have a unique id and will be able to connect to other nodes.
  • Message sending: Each node will be able to send messages to other nodes.
  • Message receiving: Each node will be able to receive messages from other nodes.
  • Node discovery: Each node will be able to discover other nodes in the network.
  • Network visualization: The network will be visualized using a graph library.
  • Node removal: Each node will be able to remove itself from the network.
  • Network shutdown: The network will be able to shut down.
  • Node status: Each node will be able to check its status in the network.
  • Network status: The network will be able to check its status.
  • Network size: The network will be able to check its size.

How does it work

The project will use the following components:

  • Node class: This class will represent each node in the network. It will have methods for connecting to other nodes, sending messages, receiving messages, discovering other nodes, removing itself from the network, checking its status, and shutting down the network.
  • Network class: This class will represent the network. It will have methods for discovering nodes, checking the network status, and shutting down the network.
  • Graph library: This library will be used to visualize the network.
  • Message class: This class will represent messages sent between nodes.
  • Connection class: This class will represent connections between nodes.
  • Discovery class: This class will be used to discover other nodes in the network.
  • Status class: This class will be used to check the status of nodes and the network
  • Shutdown class: This class will be used to shut down the network.

File structure

│   commands.py
│   Message.py
│   Network.py
│   Node.py
│   node1.py
│   node2.py
│
│
├───helpers
│   │   cmd_helper.py
│   │   terminal_helper.py
│   │   __init__.py
│
│
├───settings
│   │   includes.py
│   │   terminal_set.py
│   │   __init__.py
│


Usage

In Node .py file , there a Node class , which includes all attritibues and methods of a Node.

Network.py consists of a Network class which inherited from Node class. So, a connection is established by using an instance of this class.

In Node class, there are GENESIS_NODE_ADDR and GENESIS_NODE_PORT variables which is the genesis node's connection address known by everyone.

Run

python3 node1.py

Use Another Terminal

python3 node2.py

More

The-Peer-to-Peer-blockchain-network-structure-8-and-the-infrastructure-of-edge

About

This repository contains the implementation of a Peer-to-Peer (P2P) network. P2P networks are decentralized systems where each node (peer) acts as both a client and a server, allowing direct data sharing without the need for a centralized server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages