> I took place in your ASN.1 course in the beginning of December and I have a
> question about the PER that we studied. As we studied the choice in PER will
> be encoded as the index of the wanted choice when the indexes run from 1 to
> n. 
> We are having a protocol analyser, and we recieved from one of our clients a
> trace of the H.245 protocol which show that the first choice of the spec is
> sometimes transmitted as '0' when I would think it can take only values from
> 1 to 4.
> If you can explain again the way PER's Choice is handled, I will be
> gratefull. 

Dear Mr. Ravid:

The index does indeed begin with 0. What is likely confusing you is
that the index is not ordered by occurrence within the choice, but
by sorting the choices in tag order. Thus, for the case

Z   ::= CHOICE {a INTEGER, b BOOLEAN}
z Z ::= a:12

the index is 1, not because a is first, but because a is second.
Remember that the default tag for BOOLEAN is [UNIVERSAL 1] while the
default tag for INTEGER is [UNIVERSAL 2], so a tag order sort puts
b first (index 0) and a second (index 1).

On the other hand, for the case

Z   ::= CHOICE {a [1] IMPLICIT INTEGER, b [2] IMPLICIT BOOLEAN}
z Z ::= a:12

the index is 0. As you might recall from the course, the keyword
IMPLICIT says that the specified tag replaces the default tag, thus
a has an index of 0 and b an index of 1.

If we put the latter case through a quick run of the asn1step product,
we would see a PER aligned encoding of 00010C and an unaligned 
encoding of 008600.


---------- Run 1 of the PER ALIGNED Encoder ----------

 Unencoded PDU...

value Z ::= a : 12

 Checking constraints...

Constraints checking succeeded

 Tracing Information from the PER ALIGNED Encoder...

Z CHOICE [index = 0]
  a INTEGER [length = 1.0]
    12
Total PDV length = 3.0

PDU successfully encoded, in 3 bytes:
00010C

========== Run 1 of the PER ALIGNED ossPrintPER ==========

 ossPrintPER output...

value Z ::= 
  --TYPE INFORMATION: CHOICE
  --OFFSET: 0,0
  --choice index: <.0> (index = 0)
  a : 12
    --TYPE INFORMATION: INTEGER
    --OFFSET: 0,1; LENGTH: 2,7
    --padding: <0000000>
    --length: .01 (decoded as 1)
    --contents: .0C
--TOTAL LENGTH: 3,0

  ossPrintPER finished...


---------- Run 1 of the PER UNALIGNED Encoder ----------

 Unencoded PDU...

value Z ::= a : 12

 Checking constraints...

Constraints checking succeeded

 Tracing Information from the PER UNALIGNED Encoder...

Z CHOICE [index = 0]
  a INTEGER [length = 1.0]
    12
Total PDV length = 2.1

PDU successfully encoded, in 3 bytes:
008600

========== Run 1 of the PER UNALIGNED ossPrintPER ==========

 ossPrintPER output...

value Z ::= 
  --TYPE INFORMATION: CHOICE
  --OFFSET: 0,0
  --choice index: <.0> (index = 0)
  a : 12
    --TYPE INFORMATION: INTEGER
    --OFFSET: 0,1; LENGTH: 2,0
    --length: <0000000.1> (decoded as 1)
    --contents: <0000110.0>
--PDU padding: <0000000>
--TOTAL LENGTH: 3,0

  ossPrintPER finished...


=====================================================================
Conrad Sigona                         Toll Free      : 1-888-OSS-ASN1  
OSS Nokalva                           Voice Mail     : 1-732-302-9669 x400  
[EMAIL PROTECTED]                        Fax            : 1-419-831-5035
http://www.oss.com                    My direct line : 1-315-845-1773


Reply via email to