The UUID specification defines 4 predefined namespaces which it describes as "potentially interesting" - meaning among other things, "if other people have generated UUIDs in this namespace you can verify them":
6ba7b810-9dad-11d1-80b4-00c04fd430c8
for DNS6ba7b811-9dad-11d1-80b4-00c04fd430c8
for URL6ba7b812-9dad-11d1-80b4-00c04fd430c8
for ISO OID6ba7b814-9dad-11d1-80b4-00c04fd430c8
for X.500 DNWhere did these come from?
Specifically;
Namespace: A fixed UUID used in combination with the input string to differentiate between UUIDs generated in different applications, and to prevent rainbow table hacks.
UUID was standardized by the Open Software Foundation (OSF), becoming a part of the Distributed Computing Environment (DCE). Different versions of UUID follow the RFC 4122 specification. UUIDs are generated using an algorithm based on a timestamp and other factors such as the network address.
No, a UUID can't be guaranteed to be unique. A UUID is just a 128-bit random number. When my computer generates a UUID, there's no practical way it can prevent your computer or any other device in the universe from generating that same UUID at some time in the future.
As per Wikipedia, the number of UUIDs generated to have atleast 1 collision is 2.71 quintillion.
First, to be clear, this whole discussion is limited to version 3 & 5 UUIDs. In my (anecdotal) experience, version 4 (random) UUIDs are most commonly used.
4122's namespaced UUID generation algorithm ambiguously begins:
Allocate a UUID to use as a "name space ID"
There is no other mention of "name space ID" allocation, and neither I nor python have found any standardized spaces beyond the four listed in RFC 4122.
So the answer to your first question,
- If I'm generating my own namespace UUID do I need to avoid anything in particular?
You only need to avoid the four standard namespaces.
The next question,
- I'm aware how big the UUID space is, but does this have any implication on collisions?
Has two parts:
Will UUIDs within your namespace collide? Verbatim from 4122:
The UUIDs generated from two different names in [your] namespace should be different (with very high probability).
Will your namespace UUID collide with other namespaces? I couldn't find a direct answer, since there's no standard for "name space ID" allocation, but the argument in section 4.1.1 seems relevant:
Interoperability, in any form, with variants other than the one defined here is not guaranteed, and is not likely to be an issue in practice.
- Why have they chosen the 4th octet to increase as a kind of UUID 'version number'?
This one's a bit of a mystery. Luckily, we have a spec for UUIDs, so we can mine them for some insight.
Note that the (0-index) 8th octet starts with 8
in all cases, so we're dealing with RFC 4122 variant UUIDs. Phew.
Now check octet 6 for the version: 1
, we're dealing with version 1 time-based UUIDs.
This answer has a handy algorithm for extracting python datetimes from version 1 UUIDs. Applying the algorithm yields a time in February 4th, 1998. I have yet to find meaning in this date. Incrementing the 3rd octet adds the smallest encodable time interval (100ns) to the date.
- Do my questions imply that I'm missing something fundamental about UUIDs?
Nope. There is very little discussion of UUID namespaces, since random UUIDs are so easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With