[Qt-interest] QUuid with QUuid::Time
Jason H
scorp1us at yahoo.com
Mon Jun 14 17:39:16 CEST 2010
Having extensively used UUIDs, there is no 100% unique algorithm. That is because randomness in a discrete computer is not unique. It at the fundamental level has bit granularity.
A central registry is the only way to assure uniqueness of a randomly generated UUID, however for large collections of UUIDs the table will be huge and the cost (time) to generate (and centrally ensure) uniqueness goes up.
Out of all the UUIDs I've ever used, I only came across one dupe, and that was a InstallSheild component UUID from a popular product with a product we were also shipping.
MAC addresses are not reliable, because many are assignable in software now, also these are allocated by manufacturers in blocks, and when they run out sometimes they just recycle the block because it is years apart and its is unlikely two cards with the same MAC will end up on the same network.
The Windows SID looks like a good way to base your uniqueness off of, but it is hard to read. Apps need Admin level access to that part of the registry, and it is different from installation rights.
If you want to ensure the uniqueness at reasonable cost, then you need a central server with a monotonically increasing int, that is incremented every time it is read. I do this in oracle with a sequence. This is then appended to the machine identifier. This isn't a guid, but you can make it look like one. But immediately you have issues with "assigning authority". That is, how unique is your domain? For my apps, machine-level domain uniqueness (ip addr) works fine, because each machine on the domain is unique. (e.g. 192.168.1.12.45432) However if you are spanning networks, you need a database that also spans networks, which gets you into a web service and needing internet access.
----- Original Message ----
From: Konrad Rosenbaum <konrad at silmor.de>
To: qt-interest at trolltech.com
Sent: Mon, June 14, 2010 9:41:15 AM
Subject: Re: [Qt-interest] QUuid with QUuid::Time
On Mon, June 14, 2010 12:51, metin d wrote:
> Documentation says that QUuid::createUuid () creates an UUID using
> QUuid::Random. On the other hand, I want to get UUID's by using
> QUuid::Time, because I want to get UUIDs which are exactly unique. Do you
> have any suggestion?
Why do people keep pretending that a 128 bit value with about a dozen
fixed bits could come anywhere close to "unique"? Sigh.
Time based UUIDs are no more unique than random based, or MAC based UUIDs.
The probability of a collision varies between one in 2^32 and one in 2^48
(or something thereabouts, some bits are missing because they are fixed
and implementations vary).
With the algorithms given and the width of the value you don't get
anything better. The correct name for this thing would be QLUID - quite
likely unique ID, but UUID with the first "U" being translated as
"universally" was better marketing... ;-)
So:
If you want a value that is unique inside the one instance of the program
that is running - use a counter! It is computationally cheaper and safer
against collisions.
If you want something that is probably unique and works across several
instances, including instances running on different machines: use UUID and
be prepared to fail gracefully in case of a collision (which will happen
once per blue moon if you use a LOT of UUIDs or even never if you need
only the occasional one).
If you need something that is absolutely unique: use a central registry.
If you need something that is cryptographically secure: forget UUIDs, they
are quite guessable. Use proper certificates and public key crypto.
Konrad
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list