What is a "Decentralized Uniqueness Algorithm"?
The function in COM to create a GUID (CoCreateGUID) uses a "Decentralized Uniqueness Algorithm", but my question is,开发者_如何学C what is it?
Can anybody explain?
A method to generate an ID that has some guarantee to be unique without relying on any kind of coordination through a central "ID provider" (which requires a network connection and can be hard to organize). There are basically two methods for this, neither actually providing an absolute guarantee:
- Use a reasonably unique ID for the local machine (typically its MAC address) and add a locally unique ID (e.g. timestamp + process number + autoincrementing counter).
- Use a good random number generator with a good seed to generate the ID and make it long enough that collisions are too unlikely to matter.
I have searched my local library and archives but I cannot find reference to the specific algorithm. But generally this type of algorithm is used to generate 128-bit GUID values that can only occur once. Using a standard random number generation algorithm does not generate true randomness. So in this case they have taken several values including :
- The computers Network Address
- The Computers clock time value
- Values to accommodate for Daylight Savings as well as manual changes to the system clock by the user.
By utilizing such a function the programmer can ensure that the values of GUID's are unique without having to a centralized server that tracks and generates all user GUID values.
You can read more about random number generation here
精彩评论