PER Bit Tracing

PER provides very compact bit representations of data at the cost of complexity and, therefore, legibility. While it’s fairly simple to decode trivial messages by hand, assistance from tools is quite useful in real-life scenarios. Objective Systems provides such tools, both in our ASN.1 Viewer and Editor tool (ASN1VE) as well as our ASN1C software development kit.

To print out a bit trace using ASN1C, invoke the appropriate functions after encoding or decoding a message, and a marked-up binary dump of the PER data is produced. The employee sample program illustrates the use of bit tracing. For C, the pu_bindump function creates the binary trace output. For C++, ASN1PERMessageBuffer::binDump serves the same purpose.

The requirements for bit tracing are:

As a brief example, here is some output from the employee sample, using aligned PER:


                Dump of decoded bit fields:
                employee childrenPresent
                1xxxxxxx -------- -------- --------    80------    .---
                
                employee.name.givenName length
                -------- 00000100 -------- --------    --04----    -.--
                
                employee.name.givenName data
                -------- -------- 01001010 01101111    ----4a6f    --Jo
                01101000 01101110 -------- --------    686e----    hn--                
            

Here, a description can be seen of the field that was decoded, followed by 4 columns of a base 2 representation of the relevant input data, followed by a column with a hexadecimal representation of the same data, followed by a column with an ASCII representation of the same data. The hexadecimal and ASCII representations are only printed after all bits for a full byte have been processed, so these representations might not be printed on every line, and when they are printed, might correspond to binary bits on several preceeding lines.

The x values indicate padding bits used in aligned PER.