Dear Forum members,
I am very new to this forum and this is my first question. If this is not a right place sorry in first place and let me know the right place to post this question.
N numbers of devices are connected with wires. One device will act as a master; it will discover all the devices in the connected wire.
Network formation method:
1) Master will send discovery message (broadcast) with its MAC address
2) Slaves will respond to the discovery with its MAC address
a. With this master will register all the slaves who are responded to the discovery message
b. Register confirmation will be sent back to the respective slaves.
3) Step 1 and 2 will be done periodically to discover any new slave added to network or not. So the network formation will be dynamic.
4) Once network is formed the master will send a Poll message to all the registered slaves periodically.
a. With this Master will make sure the availability of slaves.
b. If a slave is not responding to the poll request, master will remove the slave from its registered slaves list.
5) Step 1 ~ 4 Master only initiate any message and slaves can respond to that or ignore that if it is not indented slave.
6) Master will send a “token” to each slave. If the salve has to send any data then it has to hold the token and send the data. If no data then return the token back to the master.
a. Only one device can send data at a time.
b. If any slave has data to be sent, it has to wait until it receive “token” from its master.

Now the problem statement:
1) If 2 or more masters are present in the connected wire and they have their own networks formed with its slaves. How to make an algorithm so that 2 or more devices should not access the carrier at a same time?
2) If 2 or more devices trying to send data in the carrier then data loss will occur. Since masters are the devices which initiates the data sending. I need an algorithm to solve this issue.
Please provide me with right algorithm to sort out the above problem. For any clarification please let me know.
Thanks in advance

Balaji S