>     First thanks for the reply. It help me identify the problem (I think
> ;-) ). The ITU-T document makes 2 seperate statements on Constrained Whole
> Number encoding. First that, when the range is less than or equal to 255 it
> takes the minimum bit field. And that if its exactly 256 then one octet (I
> got the impression that for the 1st it does not become an octet for cases
> when range is greater than 128) which is octet aligned. The bifurcation of
> the two sentences made me look for a significant difference. If there is a
> difference in significance to these 2 stmts please elucidate on the same. I
> understand the significance as follows -  when the octet represents a range
> of 256, it is octet aligned while it represents an octet (or less) of a
> range < 256 it is not octet aligned. Kindly advise. Bye.

I presume you're only interested in aligned PER, right?

Let's take the example

   Z ::= SEQUENCE { a BOOLEAN,
                    b OCTET STRING (SIZE(0..7))
   }

in which case the length of the OCTET STRING will be represented as a
constrained whole number. Its range is 8, so it will need 3 bits.  Those 3
bits would not be aligned but appended immediately following the BOOLEAN.

Let's use the concrete case

   z Z ::= { a TRUE, b '1234'H }

which encodes using aligned PER into hex A01234. Only the A0 is of
interest to us and it breaks down as follows:

A0  1xxx xxxx  boolean true
    x010 xxxx  length of octet string
    xxxx 0000  padding

Note
- how the length needs 3 bits to represent a range of 8,
- how the 3 bit field is not aligned but appended directly after the
  boolean, and
- how the octet is padded so as to align the actual value ('1234'H), which
  follows, on an octet boundary.

Now let's take the same values, but change the size constraint

   Z ::= SEQUENCE { a BOOLEAN,
                    b OCTET STRING (SIZE(0..255))
   }

and we end up with the aligned PER encoding of 80021234. Only the 8002 is
of interest here

80  1xxx xxxx  boolean true
    x000 0000  padding

02  0000 0010  length of octet string

Note
- how the length needs 8 bits to represent a range of 256,
- how because it's exactly a range of 256, we use a full octet for the
  length, and we align it, and
- how, since the length is aligned, the actual value which follows needs
  no further alignment.

Finally, let's change the size constraint to

   Z ::= SEQUENCE { a BOOLEAN,
                    b OCTET STRING (SIZE(0..250))
   }

You might think that, since we have a range of 251, we still need 8 bits
and so it would be aligned, just like in the previous example, but the
encoded aligned PER turns out to be 81001234. Let's analyze it

81  1xxx xxxx  boolean true
    x000 0001  leftmost 7 bits of the octet string length

00  0xxx xxxx  rightmost bit of the octet string length
    x000 0000  padding

Note
- how the length still needs 8 bits to represent a range of 251,
- how, since the range is not exactly 256, although the length does need
  8 bits, it is nevertheless NOT aligned, and
- how the 2nd octet is padded to align the actual value ('1234'H) which
  follows.

I hope I have cleared the water and not further muddied it.

=====================================================================
Conrad Sigona                         Voice Mail     : 1-732-302-9669 x400
OSS Nokalva                           Fax            : 1-419-831-5035
[EMAIL PROTECTED]                        My direct line : 1-315-845-1773






Reply via email to