4.4. Algorithms for Creating a UUID from Truly Random or
The version 4 UUID is meant for generating UUIDs from truly-random or
The algorithm is as follows:
o Set the two most significant bits (bits 6 and 7) of the
clock_seq_hi_and_reserved to zero and one, respectively.
o Set the four most significant bits (bits 12 through 15) of the
time_hi_and_version field to the 4-bit version number from
o Set all the other bits to randomly (or pseudo-randomly) chosen
See Section 4.5 for a discussion on random numbers.
4.5. Node IDs that Do Not Identify the Host
This section describes how to generate a version 1 UUID if an IEEE
802 address is not available, or its use is not desired.
One approach is to contact the IEEE and get a separate block of
addresses. At the time of writing, the application could be found at
<http://standards.ieee.org/regauth/oui/pilot-ind.html>, and the cost
A better solution is to obtain a 47-bit cryptographic quality random
number and use it as the low 47 bits of the node ID, with the least
significant bit of the first octet of the node ID set to one. This
bit is the unicast/multicast bit, which will never be set in IEEE 802
addresses obtained from network cards. Hence, there can never be a
conflict between UUIDs generated by machines with and without network
cards. (Recall that the IEEE 802 spec talks about transmission
order, which is the opposite of the in-memory representation that is
discussed in this document.)
For compatibility with earlier specifications, note that this
document uses the unicast/multicast bit, instead of the arguably more
correct local/global bit.
Advice on generating cryptographic-quality random numbers can be
found in RFC1750 .
In addition, items such as the computer's name and the name of the
operating system, while not strictly speaking random, will help
differentiate the results from those obtained by other systems.
The exact algorithm to generate a node ID using these data is system
specific, because both the data available and the functions to obtain
them are often very system specific. A generic approach, however, is
to accumulate as many sources as possible into a buffer, use a
message digest such as MD5  or SHA-1 , take an arbitrary 6
bytes from the hash value, and set the multicast bit as described