Skip to content
/ bully Public

Python implementation of Bully Election Algorithm using ZMQ sockets for multiprocessor communication.

Notifications You must be signed in to change notification settings

alperari/bully

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

  • The Bully Leader Election Algorithm (BLE) is a distributed algorithm that is used to select a leader (or coordinator) among a group of processes (or nodes) in a computer network.

  • It is called the bully algorithm because it allows the processes to "bully" or challenge each other for leadership by sending special messages called election messages.

How it works?

  1. Coordinator multicasts "LEADER" message to nodes with higher IDs.
  2. If any node with higher ID is available at the moment, they will respond with "RESP". Then they will behave as a coordinator and multicast "LEADER" to higher nodes.
  3. If a coordinator doesn't receive any "RESP", then it will declare itself as the leader and broadcasts "TERMINATE" to network.

With Visuals

1

2

Specs

  • This implementation is using python's multiprocessing library to simulate a network of nodes as processes.
  • Processes communicates using ZMQ sockets (PUB-SUB)

How To Run?

Command line arguments will be:

python bully.py <numProc> <numAlive> <numStarter>

numProc: Number of nodes in the network numAlive: Number of alive nodes in the network numStarter: Number of coordinators in the beginning of algorithm

Example Run

python bully.py 10 4 2
Alives :
[ 8 , 9 , 0 , 3 ]
Starters :
[ 9 , 3 ]
PROCESS STARTS: 42004 8 False
RESPONDER STARTS: 8
PROCESS STARTS: 49092 9 True
RESPONDER STARTS: 9
PROCESS STARTS: 42836 3 True
RESPONDER STARTS: 3
PROCESS STARTS: 40496 0 False
RESPONDER STARTS: 0
PROCESS MULTICASTS LEADER MSG: 9
PROCESS MULTICASTS LEADER MSG: 3
RESPONDER RESPONDS 9 3
RESPONDER RESPONDS 8 3
PROCESS MULTICASTS LEADER MSG: 8
RESPONDER RESPONDS 9 8
PROCESS BROADCASTS TERMINATE MSG: 9

About

Python implementation of Bully Election Algorithm using ZMQ sockets for multiprocessor communication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages