Changes between Initial Version and Version 1 of PortableRrdFormat


Ignore:
Timestamp:
Jun 20, 2007, 9:35:46 PM (15 years ago)
Author:
oetiker
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortableRrdFormat

    v1 v1  
     1= Creating a portable RRD format =
     2
     3== Current Situation ==
     4
     5The RRD data format is native. This means it depends on the architecture of the machine
     6as well as on the OS used to write the data. This has the advantage of being fast and simple.
     7The downside of this is, that data can in general not be accessed from two different HW/OS combinations.
     8
     9There are some provisions in RRD to detect such cross architecture access. But detection is not perfect. Some combinations are bound to even almost work. SPARC to PPC only differs in the representation of NANs.
     10
     11== Creating a portable RRD format ==
     12
     13The portable RRD format works on all platforms transparently. The first Idea was to use Suns XDR format for RRD. Unfortunately, XDR does not handle NANs which are pretty essential for RRDtool. So I did some investigations into binary representation of IEEE 754 floating point data. I found that it is actually pretty simple to bridge the gap between sparc, ppc and x86 at least, so I assume it won't be rocket science todo other CPUs as well. The following program helped a lot in this task. It shows the binary representation of a few 'interesting' floating point values.
     14
     15{{{
     16#!c
     17#include <stdio.h>
     18#include <inttypes.h>
     19typedef union INSPECTOR {
     20    uint8_t   b[8];
     21    double    f;
     22} INSPECTOR;
     23
     24int main(
     25    int argc,   
     26    char *argv[])
     27{
     28    int i,ii;
     29    double number[] = {
     30        0,1,-1,0.0/0.0,1.0/0.0,-1.0/0.0,2,4,8,16,8.642135E130
     31    };
     32    for (i=0;i<11;i++){
     33        INSPECTOR native;
     34        native.f = number[i];
     35        printf("%16e -> ",native.f);
     36        for (ii=0;i<8,ii++)
     37            printf(" %02x",native.b[ii]);
     38        printf("\n");
     39    }
     40    return 0;
     41}
     42}}}
     43
     44I used this to figure the floating point representation for a number of different architectures:
     45
     46SPARC 32 and 64 bit:
     47{{{
     48    0.000000e+00 -> 00 00 00 00  00 00 00 00
     49    1.000000e+00 -> 3f f0 00 00  00 00 00 00
     50   -1.000000e+00 -> bf f0 00 00  00 00 00 00
     51             NaN -> 7f ff ff ff  ff ff ff ff
     52             Inf -> 7f f0 00 00  00 00 00 00
     53            -Inf -> ff f0 00 00  00 00 00 00
     54    2.000000e+00 -> 40 00 00 00  00 00 00 00
     55    4.000000e+00 -> 40 10 00 00  00 00 00 00
     56    8.000000e+00 -> 40 20 00 00  00 00 00 00
     57    1.600000e+01 -> 40 30 00 00  00 00 00 00
     58   8.642135e+130 -> 5b 1f 2b 43  c7 c0 25 2f
     59}}}
     60
     61PPC 32 bit
     62{{{
     63    0.000000e+00 -> 00 00 00 00  00 00 00 00
     64    1.000000e+00 -> 3f f0 00 00  00 00 00 00
     65   -1.000000e+00 -> bf f0 00 00  00 00 00 00
     66             nan -> 7f f8 00 00  00 00 00 00
     67             inf -> 7f f0 00 00  00 00 00 00
     68            -inf -> ff f0 00 00  00 00 00 00
     69    2.000000e+00 -> 40 00 00 00  00 00 00 00
     70    4.000000e+00 -> 40 10 00 00  00 00 00 00
     71    8.000000e+00 -> 40 20 00 00  00 00 00 00
     72    1.600000e+01 -> 40 30 00 00  00 00 00 00
     73   8.642135e+130 -> 5b 1f 2b 43  c7 c0 25 2f
     74}}}
     75
     76x86 32 and 64 bit
     77{{{
     78    0.000000e+00 -> 00 00 00 00  00 00 00 00
     79    1.000000e+00 -> 00 00 00 00  00 00 f0 3f
     80   -1.000000e+00 -> 00 00 00 00  00 00 f0 bf
     81             nan -> 00 00 00 00  00 00 f8 7f
     82             inf -> 00 00 00 00  00 00 f0 7f
     83            -inf -> 00 00 00 00  00 00 f0 ff
     84    2.000000e+00 -> 00 00 00 00  00 00 00 40
     85    4.000000e+00 -> 00 00 00 00  00 00 10 40
     86    8.000000e+00 -> 00 00 00 00  00 00 20 40
     87    1.600000e+01 -> 00 00 00 00  00 00 30 40
     88   8.642135e+130 -> 2f 25 c0 c7  43 2b 1f 5b
     89}}}

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.