What is a UUID?

来源:互联网 发布:歌词创作软件 编辑:程序博客网 时间:2024/05/17 02:17
UUID stands for a Universal Unique IDentifier. These are 128 bit numbers assigned to any object within a DCE cell which is guaranteed to be unique. The mechanism used to guarantee that UUIDs are Unique is through combinations of hardware addresses, time stamps and random seeds.

There is a reference in the UUID to the hardware address of the first network card on the host which generated the UUID - this reference is intended to ensure the UUID will be unique in space as the MAC address of every network card is assigned by a single global authority and is guaranteed to be unique. (Alternate addresses might be a problem here, but the author has not tested creating a UUID on a machine with an alternate address set)

The next component is a timestamp which, as DCE always moves clocks forward, will be unique in time.

Just in case some part of the above goes wrong, there is a random component placed into the UUID as a catch-all for uniqueness.

The timestamp component though is one of the reasons why DCE does not react well to clocks going backwards.

A UUID may be generated using the uuidgen command, the following is an example of a generated UUID:-
58f202ac-22cf-11d1-b12d-002035b29092

This has come from a machine with the hardware address shown in the output of the command below:-
lscfg -vl ent0
DEVICE LOCATION DESCRIPTION
ent0 01-01 IBM ISA Ethernet Adapter
Network Address.............002035B29092
From this it may be observed that the Network address of the ethernet adapter matches the last portion of the uuid.

Application programmers may make their applications permanently identified with a UUID by creating their Interface Definition Language file with the uuidgen command, giving it the "-i" option. An example is given below.
[
uuid(5a389ad2-22dd-11d1-aa77-002035b29092),
version(1.0)
]
interface INTERFACENAME
{
}

The programmer would take this file, change the interfacename to one of their own devising then add the prototypes for the C functions they are going to implement over the network in their cell.
[
uuid(5a389ad2-22dd-11d1-aa77-002035b29092),
version(1.0)
]
interface computron
{
error_t debit_account( [ in ] long account_number,
[ in ] long amount,
[ in,out] long *balance);
error_t credit_account( [ in ] long account_number,
[ in ] long amount,
[ in,out] long *balance);
}

Would be an example of a more complete IDL file, which itself would be compiled into a useful form using the idl compiler, with the command
idl computron.idl
which would create object files which should be linked with the server and client programs to implement the distributed application.

原创粉丝点击