UUID Version 1 (Timestamp + MAC Address)
Explore UUID v1: how it combines a 60-bit timestamp with a node ID (MAC address), its privacy implications, and why newer versions have largely replaced it.
Detailed Explanation
UUID Version 1 was one of the original UUID formats defined in RFC 4122 (2005). It generates identifiers by combining a high-resolution timestamp with the generating machine's MAC address, guaranteeing uniqueness across both time and space.
Bit layout (128 bits total):
- Bits 0-31:
time_low(least significant 32 bits of timestamp) - Bits 32-47:
time_mid(next 16 bits of timestamp) - Bits 48-51: Version
0001(1) - Bits 52-63:
time_hi(most significant 12 bits of timestamp) - Bits 64-65: Variant
10 - Bits 66-79: Clock sequence (14 bits)
- Bits 80-127: Node ID (48 bits, typically the MAC address)
The timestamp is a 60-bit value representing 100-nanosecond intervals since October 15, 1582 (the Gregorian calendar reform date). This gives v1 UUIDs roughly 3,600 years of unique timestamps from that epoch.
The MAC address problem: The inclusion of the MAC address means anyone who sees a UUID v1 can extract the generating machine's network interface identifier. This was a significant privacy concern that led to the adoption of UUID v4 for most use cases. You can also use a random 48-bit node ID instead, but this weakens the spatial uniqueness guarantee.
Important caveat on sorting: Despite containing a timestamp, UUID v1 is NOT lexicographically sortable by time. The timestamp bits are split across non-contiguous fields (time_low comes first, but it holds the least significant bits). This means string comparison does not yield chronological order. UUID v6 was created specifically to fix this by rearranging the v1 timestamp bits into big-endian order.
Clock sequence: The 14-bit clock sequence field handles the case where the system clock is set backward or the node ID changes. It is typically initialized randomly and incremented when a backward clock adjustment is detected.
Generation in Python:
import uuid
id = uuid.uuid1()
# Extract timestamp: id.time (100-ns intervals since 1582-10-15)
# Extract node: id.node (48-bit integer, usually MAC address)
Current recommendation: RFC 9562 recommends UUID v7 over v1 for new applications. UUID v7 provides time-ordering without leaking hardware identifiers and uses a simpler, more intuitive timestamp layout.
Use Case
UUID v1 is still found in legacy systems like Apache Cassandra (which uses a variant called TimeUUID) and older enterprise Java applications that rely on time-based ordering with hardware-bound uniqueness.