Hi brother_bill-ga,
The .NET Framework Guid.NewGuid method calls the Windows API
function CoCreateGuid that calls UuidCreate to generate globally
unique 128-bit numbers.
You can find more information on the UuidCreate function here:
- MSDN Library: UuidCreate
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/uuidcreate.asp)
To answer your questions:
1. How many GUIDs in Microsoft Windows can one computer generate without
rolling over or running out?
From the following article on Code Project:
- Generating GUIDs on the Pocket PC
(http://www.codeproject.com/netcf/PPCGuidGen.asp)
"Question: How many GUID combinations are there?
Answer: There are 122 random bits (128 ? 2 for variant - 4 for
version) so this calculates to 2^122 or
5,316,911,983,139,663,491,615,228,241,121,400,000 possible
combinations."
2. At exhaustion, will it restart (roll over), or fail to generate
additional ones (crash)?
Since the GUID is essentially a numeric value generated at run
time, it will eventually start repeating values. However, this
shouldn't be much of a concern for you, since due the the sheer number
of values available, a GUID is either guaranteed to be different from
all other UUIDs/GUIDs generated until 3400 A.D. or extremely likely to
be different (depending on the algorithm used).
Rest assured that the function won't crash after all the unique
values have been generated.
For more information, check out the following:
- UUIDs and GUIDs
(http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt)
- The Old New Thing: Sure, we do that
(http://blogs.msdn.com/oldnewthing/archive/2004/02/11/71307.aspx)
- joeware: "GUIDs" or "Having unique in the name doesn?t make it so..."
(http://blog.joeware.net/2005/06/19/42/)
------------------------------------------------------------
Hope this helps.
If you need any clarifications, just ask!
Regards,
Theta-ga
:)
=========================================================
Google Search Terms Used:
when will guids run out
windows generate guid |
Request for Answer Clarification by
brother_bill-ga
on
09 Aug 2005 02:45 PDT
OK, so there are 2^122 different GUIDs in the entire universe.
Would a specific machine start with a fixed sub-bit code, say 64 bits,
say from a network card ID and then have the remaining bits vary? In
this case, the variation would be in (122-64) bits or 2^(122-64)
random numbers.
Or does each machine pick a random number within the 2^122 possible
choices, so that there is a theoretical possible of 2 machines
generating the same GUID, but on a practical view is extremely
unlikely?
The purpose of this exercise is to determine whether generating GUIDs
is sufficient to generate a random character string based on each
GUID.
|
Clarification of Answer by
theta-ga
on
09 Aug 2005 04:20 PDT
Hi brother_bill-ga,
On systems running versions of Windows older than Windows 2000, the
UuidCreate method generates version 1 UUID's. These devote 48 bits of
the 128 bit GUID to the MAC address of the network card. For systems
with multiple IEEE 802 addresses, any available address can be used.
For systems that do not have a network card installed, a randomly
generated value is used.
On Windows 2000 and later, the UuidCreate method generates version 4
UUIDs, which *always* use a random number instead of the MAC address.
In case of both v1 and v4 UUID's there is a theoretical possible of
2 machines generating the same GUID, but on a practical view this is
extremely
unlikely.
This is so in case of v1 UUID's because even though in theory a
systems MAC address is supposed to be unique across all machines, in
practice it is possible to find multiple machines with the same MAC
address. In this case, there is a theoretical possibility, however
small that a GUID generated on these machines may be the same.
For more details on this topic, you can refer to the articles I
linked to in my initial posting.
Hope this helps.
If you need further clarifications, just ask.
Regards,
Theta-ga
:)
|
Request for Answer Clarification by
brother_bill-ga
on
09 Aug 2005 13:36 PDT
Last clarification (maybe ;-) )
OK, so it isn't truly "Globally Unique" (marketing for you).
If I want to use part of the GUID as a base for a unique ASCII
graphical identifier, is one part (substring) of the GUID better than
another?
That is, is one part of the GUID static, where another part varies widely.
If so, I would want to extract from the varying part.
BTW, I do tip ;-)
|
Clarification of Answer by
theta-ga
on
09 Aug 2005 20:43 PDT
Hi brother_bill-ga,
There is no need to worry about the clarifications. We will work
through this till you are satisfied. :)
Coming back to your question, as you are aware for v4 GUIDs, 6 bits
out of the 128 bits are used to store information such as version
number and variant.
The following article gives a breakup of the various parts of a GUID:
- Generating GUIDs on the Pocket PC: The GUID Format
(http://www.codeproject.com/netcf/PPCGuidGen.asp#The_GUID_Format)
As you can see from the breakup, the High field of the timestamp and
the two clock sequence fields can be considered less random than
others because they are used to store data. The remaining fields
should serve your purpose.
Hope this helps.
If you need any clarifications, you know what to do! ;)
Regards,
Theta-ga
:)
|