Is there a common or established algorithm for peer-nodes in a network to decide on a unique "network-channel" (or any other form of semi-secret identifier)?
The environment I'm working in is SecondLife. I am trying to figure out how to get many identical peer scripted objects to agree on a "channel" number which allows them to form a network, without interfering with other existing networks of the same kind of objects.
All objects get instantiated at roughly the same time, and have access to the (common) system time.
Approaches I've thought of:
Time-of-instantiation based. Channel is derived (by md5) from the unix time. Problem is the "roughly the same time" part. They may get instantiated right on the cusp of a new second.
Random wait. Make objects wait a random amount, and announce a (randomly generated) channel number decided upon by the first one to wake. Problem is, the system has a low time granularity, and more than one object can wake before the announcement was processed.
Combine 1 and 2. Announce a high-res timestamp after waiting a random amount, and derive channel from the lowest announced timestamp.
This has to be something smarter people than me have thought about. Any better way of doing this?