2012-05-21 8 views
57

Perché gli UUID sono presentati nel formato "8-4-4-4-12" (cifre)? Ho dato un'occhiata per il motivo ma non riesco a trovare la decisione che lo richiede.Formato UUID: 8-4-4-4-12 - Perché?

Esempio di UUID formattato come stringa esadecimale: 58D5E212-165B-4CA0-909B-C86B9CEE0111

risposta

40

è separata da time, version, clock_seq_hi, clock_seq_lo, node, come indicato nella RFC followoing.

Dal IETF RFC4122:

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)       | 
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
+6

Perché era la scissione timestamp in tre parti? – immibis

+3

La modalità di generazione dei campi dipende dalla versione UUID. Il metodo preferito non utilizza il tempo poiché indica il momento in cui è stato generato l'ID (un potenziale problema di sicurezza). http://en.wikipedia.org/wiki/Universally_unique_identifier#Variants_and_versions – pmont

+0

@pmont "Preferred"? –

9

Il formato è definito in IETF RFC4122 nella sezione 3. Il formato di output è definito in cui si dice "UUID = ..."

3.- Namespace Registrazione Modello

ID spazio: UUID Informazioni di registrazione: Data di registrazione: 2003-10-01

dichiarata registrante del namespace: JTC 1/SC6 (ASN.1 relatore Group)

Dichiarazione della struttura sintattica: Un UUID è un identificatore univoco attraverso spazio e nel tempo, rispetto al spazio di tutti gli UUID. Poiché un UUID è una dimensione fissa e contiene un campo orario, è possibile per i valori di rollover (intorno a 3400 A.D., a seconda dell'algoritmo specifico utilizzato). Un UUID può essere utilizzato per più scopi, dalla codifica di oggetti con una durata estremamente breve, per identificare in modo affidabile gli oggetti molto persistenti su una rete.

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"