Request for Comments: 4122 Microsoft
Category: Standards Track M. Mealling
Refactored Networks, LLC
R. Salz
DataPower Technology, Inc.
July 2005
A Universally Unique IDentifier (UUID) URN Namespace
Status of This Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2005).
Abstract
This specification defines a Uniform Resource Name namespace for
UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally
Unique IDentifier). A UUID is 128 bits long, and can guarantee
uniqueness across space and time. UUIDs were originally used in the
Apollo Network Computing System and later in the Open Software
Foundation’s (OSF) Distributed Computing Environment (DCE), and then
in Microsoft Windows platforms.
This specification is derived from the DCE specification with the
kind permission of the OSF (now known as The Open Group).
Information from earlier versions of the DCE specification have been
incorporated into this document.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3. Namespace Registration Template . . . . . . . . . . . . . . . 3
4. Specification . . . . . . . . . . . . . . . . . . . . . . . . 5
4.1. Format. . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.1.1. Variant. . . . . . . . . . . . . . . . . . . . . . 6
4.1.2. Layout and Byte Order. . . . . . . . . . . . . . . 6
4.1.3. Version. . . . . . . . . . . . . . . . . . . . . . 7
4.1.4. Timestamp. . . . . . . . . . . . . . . . . . . . . 8
4.1.5. Clock Sequence . . . . . . . . . . . . . . . . . . 8
4.1.6. Node . . . . . . . . . . . . . . . . . . . . . . . 9
4.1.7. Nil UUID . . . . . . . . . . . . . . . . . . . . . 9
4.2. Algorithms for Creating a Time-Based UUID . . . . . . . . 9
4.2.1. Basic Algorithm. . . . . . . . . . . . . . . . . . 10
4.2.2. Generation Details . . . . . . . . . . . . . . . . 12
4.3. Algorithm for Creating a Name-Based UUID. . . . . . . . . 13
4.4. Algorithms for Creating a UUID from Truly Random or
Pseudo-Random Numbers . . . . . . . . . . . . . . . . . . 14
4.5. Node IDs that Do Not Identify the Host. . . . . . . . . . 15
5. Community Considerations . . . . . . . . . . . . . . . . . . . 15
6. Security Considerations . . . . . . . . . . . . . . . . . . . 16
7. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 16
8. Normative References . . . . . . . . . . . . . . . . . . . . . 16
A. Appendix A - Sample Implementation . . . . . . . . . . . . . . 18
B. Appendix B - Sample Output of utest . . . . . . . . . . . . . 29
C. Appendix C - Some Name Space IDs . . . . . . . . . . . . . . . 30
1. Introduction
This specification defines a Uniform Resource Name namespace for
UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally
Unique IDentifier). A UUID is 128 bits long, and requires no central
registration process.
The information here is meant to be a concise guide for those wishing
to implement services using UUIDs as URNs. Nothing in this document
should be construed to override the DCE standards that defined UUIDs.
There is an ITU-T Recommendation and ISO/IEC Standard [3] that are
derived from earlier versions of this document. Both sets of
specifications have been aligned, and are fully technically
compatible. In addition, a global registration function is being
provided by the Telecommunications Standardisation Bureau of ITU-T;
for details see <http://www.itu.int/ITU-T/asn1/uuid.html>.
2. Motivation
One of the main reasons for using UUIDs is that no centralized
authority is required to administer them (although one format uses
IEEE 802 node identifiers, others do not). As a result, generation
on demand can be completely automated, and used for a variety of
purposes. The UUID generation algorithm described here supports very
high allocation rates of up to 10 million per second per machine if
necessary, so that they could even be used as transaction IDs.
UUIDs are of a fixed size (128 bits) which is reasonably small
compared to other alternatives. This lends itself well to sorting,
ordering, and hashing of all sorts, storing in databases, simple
allocation, and ease of programming in general.
Since UUIDs are unique and persistent, they make excellent Uniform
Resource Names. The unique ability to generate a new UUID without a
registration process allows for UUIDs to be one of the URNs with the
lowest minting cost.
3. Namespace Registration Template
Namespace ID: UUID
Registration Information:
Registration date: 2003-10-01
Declared registrant of the namespace:
JTC 1/SC6 (ASN.1 Rapporteur Group)
Declaration of syntactic structure:
A UUID is an identifier that is unique across both space and time,
with respect to the space of all UUIDs. Since a UUID is a fixed
size and contains a time field, it is possible for values to
rollover (around A.D. 3400, depending on the specific algorithm
used). A UUID can be used for multiple purposes, from tagging
objects with an extremely short lifetime, to reliably identifying
very persistent objects across a network.
The internal representation of a UUID is a specific sequence of
bits in memory, as described in Section 4. To accurately
represent a UUID as a URN, it is necessary to convert the bit
sequence to a string representation.
Each field is treated as an integer and has its value printed as a
zero-filled hexadecimal digit string with the most significant
digit first. The hexadecimal values "a" through "f" are output as
lower case characters and are case insensitive on input.
The formal definition of the UUID string representation is
provided by the following ABNF [7]:
UUID = time-low "-" time-mid "-"
time-high-and-version "-"
clock-seq-and-reserved
clock-seq-low "-" node
time-low = 4hexOctet
time-mid = 2hexOctet
time-high-and-version = 2hexOctet
clock-seq-and-reserved = hexOctet
clock-seq-low = hexOctet
node = 6hexOctet
hexOctet = hexDigit hexDigit
hexDigit =
"0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" /
"a" / "b" / "c" / "d" / "e" / "f" /
"A" / "B" / "C" / "D" / "E" / "F"
The following is an example of the string representation of a UUID as
a URN:
urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Relevant ancillary documentation:
[1][2]
Identifier uniqueness considerations:
This document specifies three algorithms to generate UUIDs: the
first leverages the unique values of 802 MAC addresses to
guarantee uniqueness, the second uses pseudo-random number
generators, and the third uses cryptographic hashing and
application-provided text strings. As a result, the UUIDs
generated according to the mechanisms here will be unique from all
other UUIDs that have been or will be assigned.
Identifier persistence considerations:
UUIDs are inherently very difficult to resolve in a global sense.
This, coupled with the fact that UUIDs are temporally unique
within their spatial context, ensures that UUIDs will remain as
persistent as possible.
Process of identifier assignment:
Generating a UUID does not require that a registration authority
be contacted. One algorithm requires a unique value over space
for each generator. This value is typically an IEEE 802 MAC
address, usually already available on network-connected hosts.
The address can be assigned from an address block obtained from
the IEEE registration authority. If no such address is available,
or privacy concerns make its use undesirable, Section 4.5
specifies two alternatives. Another approach is to use version 3
or version 4 UUIDs as defined below.
Process for identifier resolution:
Since UUIDs are not globally resolvable, this is not applicable.
Rules for Lexical Equivalence:
Consider each field of the UUID to be an unsigned integer as shown
in the table in section Section 4.1.2. Then, to compare a pair of
UUIDs, arithmetically compare the corresponding fields from each
UUID in order of significance and according to their data type.
Two UUIDs are equal if and only if all the corresponding fields
are equal.
As an implementation note, equality comparison can be performed on
many systems by doing the appropriate byte-order canonicalization,
and then treating the two UUIDs as 128-bit unsigned integers.
UUIDs, as defined in this document, can also be ordered
lexicographically. For a pair of UUIDs, the first one follows the
second if the most significant field in which the UUIDs differ is
greater for the first UUID. The second precedes the first if the
most significant field in which the UUIDs differ is greater for
the second UUID.
Conformance with URN Syntax:
The string representation of a UUID is fully compatible with the
URN syntax. When converting from a bit-oriented, in-memory
representation of a UUID into a URN, care must be taken to
strictly adhere to the byte order issues mentioned in the string
representation section.
Validation mechanism:
Apart from determining whether the timestamp portion of the UUID
is in the future and therefore not yet assignable, there is no
mechanism for determining whether a UUID is ’valid’.
Scope:
UUIDs are global in scope.
4. Specification
4.1. Format
The UUID format is 16 octets; some bits of the eight octet variant
field specified below determine finer structure.
4.1.1. Variant
The variant field determines the layout of the UUID. That is, the
interpretation of all other bits in the UUID depends on the setting
of the bits in the variant field. As such, it could more accurately
be called a type field; we retain the original term for
compatibility. The variant field consists of a variable number of
the most significant bits of octet 8 of the UUID.
The following table lists the contents of the variant field, where
the letter "x" indicates a "don’t-care" value.
Msb0 Msb1 Msb2 Description
0 x x Reserved, NCS backward compatibility.
1 0 x The variant specified in this document.
1 1 0 Reserved, Microsoft Corporation backward
compatibility
1 1 1 Reserved for future definition.
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.
4.1.2. Layout and Byte Order
To minimize confusion about bit assignments within octets, the UUID
record definition is defined only in terms of fields that are
integral numbers of octets. The fields are presented with the most
significant one first.
Field Data Type Octet Note
#
time_low unsigned 32 0-3 The low field of the
bit integer timestamp
time_mid unsigned 16 4-5 The middle field of the
bit integer timestamp
time_hi_and_version unsigned 16 6-7 The high field of the
bit integer timestamp multiplexed
with the version number
clock_seq_hi_and_rese unsigned 8 8 The high field of the
rved bit integer clock sequence
multiplexed with the
variant
clock_seq_low unsigned 8 9 The low field of the
bit integer clock sequence
node unsigned 48 10-15 The spatially unique
bit integer node identifier
In the absence of explicit application or presentation protocol
specification to the contrary, a UUID is encoded as a 128-bit object,
as follows:
The fields are encoded as 16 octets, with the sizes and order of the
fields defined above, and with each field encoded with the Most
Significant Byte first (known as network byte order). Note that the
field names, particularly for multiplexed fields, follow historical
practice.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_low |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_hi_and_version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|clk_seq_hi_res | clk_seq_low | node (0-1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| node (2-5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4.1.3. Version
The version number is in the most significant 4 bits of the time
stamp (bits 4 through 7 of the time_hi_and_version field).
The following table lists the currently-defined versions for this
UUID variant.
Msb0 Msb1 Msb2 Msb3 Version Description
0 0 0 1 1 The time-based version
specified in this document.
0 0 1 0 2 DCE Security version, with
embedded POSIX UIDs.
0 0 1 1 3 The name-based version
specified in this document
that uses MD5 hashing.
0 1 0 0 4 The randomly or pseudo-
randomly generated version
specified in this document.
0 1 0 1 5 The name-based version
specified in this document
that uses SHA-1 hashing.
The version is more accurately a sub-type; again, we retain the term
for compatibility.
4.1.4. Timestamp
The timestamp is a 60-bit value. For UUID version 1, this is
represented by Coordinated Universal Time (UTC) as a count of 100-
nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of
Gregorian reform to the Christian calendar).
For systems that do not have UTC available, but do have the local
time, they may use that instead of UTC, as long as they do so
consistently throughout the system. However, this is not recommended
since generating the UTC from local time only needs a time zone
offset.
For UUID version 3 or 5, the timestamp is a 60-bit value constructed
from a name as described in Section 4.3.
For UUID version 4, the timestamp is a randomly or pseudo-randomly
generated 60-bit value, as described in Section 4.4.
4.1.5. Clock Sequence
For UUID version 1, the clock sequence is used to help avoid
duplicates that could arise when the clock is set backwards in time
or if the node ID changes.
If the clock is set backwards, or might have been set backwards
(e.g., while the system was powered off), and the UUID generator can
not be sure that no UUIDs were generated with timestamps larger than
the value to which the clock was set, then the clock sequence has to
be changed. If the previous value of the clock sequence is known, it
can just be incremented; otherwise it should be set to a random or
high-quality pseudo-random value.
Similarly, if the node ID changes (e.g., because a network card has
been moved between machines), setting the clock sequence to a random
number minimizes the probability of a duplicate due to slight
differences in the clock settings of the machines. If the value of
clock sequence associated with the changed node ID were known, then
the clock sequence could just be incremented, but that is unlikely.
The clock sequence MUST be originally (i.e., once in the lifetime of
a system) initialized to a random number to minimize the correlation
across systems. This provides maximum protection against node
identifiers that may move or switch from system to system rapidly.
The initial value MUST NOT be correlated to the node identifier.
For UUID version 3 or 5, the clock sequence is a 14-bit value
constructed from a name as described in Section 4.3.
For UUID version 4, clock sequence is a randomly or pseudo-randomly
generated 14-bit value as described in Section 4.4.
4.1.6. Node
For UUID version 1, the node field consists of an IEEE 802 MAC
address, usually the host address. For systems with multiple IEEE
802 addresses, any available one can be used. The lowest addressed
octet (octet number 10) contains the global/local bit and the
unicast/multicast bit, and is the first octet of the address
transmitted on an 802.3 LAN.
For systems with no IEEE address, a randomly or pseudo-randomly
generated value may be used; see Section 4.5. The multicast bit must
be set in such addresses, in order that they will never conflict with
addresses obtained from network cards.
For UUID version 3 or 5, the node field is a 48-bit value constructed
from a name as described in Section 4.3.
For UUID version 4, the node field is a randomly or pseudo-randomly
generated 48-bit value as described in Section 4.4.
4.1.7. Nil UUID
The nil UUID is special form of UUID that is specified to have all
128 bits set to zero.
4.2. Algorithms for Creating a Time-Based UUID
Various aspects of the algorithm for creating a version 1 UUID are
discussed in the following sections.
4.2.1. Basic Algorithm
The following algorithm is simple, correct, and inefficient:
o Obtain a system-wide global lock
o From a system-wide shared stable store (e.g., a file), read the
UUID generator state: the values of the timestamp, clock sequence,
and node ID used to generate the last UUID.
o Get the current time as a 60-bit count of 100-nanosecond intervals
since 00:00:00.00, 15 October 1582.
o Get the current node ID.
o If the state was unavailable (e.g., non-existent or corrupted), or
the saved node ID is different than the current node ID, generate
a random clock sequence value.
o If the state was available, but the saved timestamp is later than
the current timestamp, increment the clock sequence value.
o Save the state (current timestamp, clock sequence, and node ID)
back to the stable store.
o Release the global lock.