Somacon.com: Articles on websites & etc.

§ Home > Index > Linux and FreeBSD

Length of Unique ID in Apache mod_unique_id

Notes regarding the length of the Unique ID field produced by the Apache mod_unique_id module.

In the mod_unique_id documentation, it says:

The UNIQUE_ID environment variable is constructed by encoding the 112-bit (32-bit IP address, 32 bit pid, 32 bit time stamp, 16 bit counter) quadruple using the alphabet [A-Za-z0-9@-] in a manner similar to MIME base64 encoding, producing 19 characters.

However, under Apache 2.2.3 on FreeBSD 6.0 i386, the Unique ID is 24 characters. This is with mod_unique_id enabled, and specified in LogFormat like this "%{UNIQUE_ID}e".

In Apache 2.2.3 mod_unique_id.c, the unique_id structure is defined as:

typedef struct {
     unsigned int stamp;
     unsigned int in_addr;
     unsigned int pid;
     unsigned short counter;
     unsigned int thread_index;
} unique_id_rec;

In Apache 1.3.36 mod_unique_id.c, the unique_id structure is defined as:

typedef struct {
     unsigned int stamp;
     unsigned int in_addr;
     unsigned int pid;
#ifdef MULTITHREAD
     unsigned int tid;
#endif
     unsigned short counter;
} unique_id_rec;

If Apache 1.3 does not have MULTITHREAD defined in the build options (found by running httpd -V), it will produce 19 characters. In Apache 2.0+, multi-threading is part of the core. Thus, the old structure is 112 bits (divide by 6 to get psuedo-UUencoded base64 value), or 19 characters. The new structure (or the old one with multi-threading) is 144 bits, which translates to 24 characters. Therefore, in all 2.0+ versions of Apache on typical 32-bit systems, the UniqueID will be 24 characters. However, it will still vary based on the size of integral types on the host system.

If one wants to eventually store the UniqueID in a MySQL Archive table, then it helps to know the fixed size for the the field in the table.

From posts to Apache users mailing list.


Have you heard of the new, free Automated Feeds offered by Google Merchant Center? Learn more in Aten Software's latest blog post comparing them to traditional data feed files.
Created 2006-11-01, Last Modified 2011-07-24, © Shailesh N. Humbad
Disclaimer: This content is provided as-is. The information may be incorrect.