Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Simple Flooding algorithm

Status
Not open for further replies.

Vivianez

Programmer
Oct 10, 2001
25
BR
Hi!
Does anybody have a simple flooding algorithm in Java to work in a distributed system?
An exemple:
3 computers with socket communication, trying to find which one will be elected the leader, which will be the one with the highest ID. That´s the simple flooding algorithm, but I need the implementation in Java.
Thanks
 
I thought the flooding algorithm was network related and it just meant sending packets down all but the line the packet arrived on?

Maybe if you gave an exact example, we could supply a java version.
 
OK, sorry about my example. It is network related.
First of all you need to know the diameter of the network.
You can tell the program this value. If the diameter is 3, you´ll apply this algorithm 3 times.
Each process knows its ID = 10(for example) and its state:
1-Unknown (this is what they are in the beginning)
2-not leader
3-leader
Each process also keeps a max ID, that in the beginning is the same as its own ID.
Process : ID = 10
max ID = 10
state = U
Each time the algorithm is applied, each process sends its ID to its neighbor and if its a higher value then its own,
the value of the max ID is changed.
After the third time the algorithm is applied if the max ID in a process is its own ID, then this process is the leader, else not leader.

So, if you have 3 processes and the max ID is 50, all of the processes will have 50 as the max ID.

The communication between the processes is via socket.
You have to supply to the algorithm the IP and the port for each process to communicate.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top