Thanks for your explaining and I have been reading the available books, but not all is 
totally clear, because when I was trying one of the comparable problem I could solve 
it but when I was trying an other one it did not work out.

I want to ask you if you can help me with this one:

Hexadecimal:   0e 80 7f ff 04 b5 42 80 80 01 01 80 00 etc etc
Function:
Set Size (1..256) OF CapabilityTableEntry OPTIONAL
Consider this function optional because in my example it is.
My thought was:
0e:  this octet contains the number of CapabilityTableEntry in the Set-of type but 
that is only once possible.
Is it possible you can help me with this one?
Thank you very much

Remco
>>> [EMAIL PROTECTED] 11/08/01 07:34PM >>>
On Tue, 6 Nov 2001, Remco Bertens wrote:

> Hi All,
>
> Can somebody help me to explain how the encoding of a SEQUENCE OF -Type ASN.1 PER 
>X.691 works. If it is possible to work out one of the following examples:
> SEQUENCE SIZE (1..256) OF INTEGER (0..15)   ,
> SEQUENCE OF MediaDistributionCapability
>
> thank you very much,

I'll ignore MediaDistributionCapability and elaborate on the first line.
Also I'll use unaligned PER for all examples.

Let's take the following example where we are asking to have three
integers encoded as a sequence.

     Example1 ::= SEQUENCE OF INTEGER
     e1 Example1 ::= {1,2,3}

In Example1, the encoded data would be

     03010101020103

See how the first octet contains the number of integers in the sequence,
and how each subsequent pair represents one of the integers. Each of the
pairs consist of a length in the first octet and a value in the second.
Looks easy, doesn't it? But that's only because it's a misleadingly simple
example.

Let's take another case, where we constrain the integers to be, as your
question asks, within the range (0..15).

     Example2 ::= SEQUENCE OF INTEGER (0..15)
     e2 Example2 ::= {1,2,3}

Since we know that the integers can only be within that limited range, we
no longer need a length to describe them. Thus the encoding would be

     031230

Ignoring the trailing 0 (which pads out the PDU), we see that each integer
no longer requires two octets, for we know that no integer within the
range (0..15) needs more than 4 bits.

Let's progress further towards what you actually ask, noting in particular
that you asked for a sequence size of (1..256) and not (0..255).

     Example3 ::= SEQUENCE SIZE(1..256) OF INTEGER (0..15)
     e3 Example3 ::= {1,2,3}

     021230

Why a sequence size of 02? Because PER transforms the (1..256) into a
single octet with range 00-FF, where
     00 represents 1,
     01 represents 2,
     ..., and
     FF represents 256.

If you had instead asked for

     Example4 ::= SEQUENCE SIZE(0..255) OF INTEGER (0..15)
     e4 Example4 ::= {1,2,3}

the transformation would be a more straight-forward

     031230

Think you understand it now? Well, it's still misleading. How would you
handle Example5 below?

     Example5 ::= SEQUENCE OF INTEGER
     e5 Example5 ::= {1,2,3,4,5,6,7,8,9,
                     10,11,12,13,14,15,16,17,18,19,
                     20,21,22,23,24,25,26,27,28,29,
                     30,31,32,33,34,35,36,37,38,39,
                     40,41,42,43,44,45,46,47,48,49,
                     50,51,52,53,54,55,56,57,58,59,
                     60,61,62,63,64,65,66,67,68,69,
                     70,71,72,73,74,75,76,77,78,79,
                     80,81,82,83,84,85,86,87,88,89,
                     90,91,92,93,95,95,96,97,98,99,
                    100,101,102,103,104,105,106,107,108,109,
                    110,111,112,113,114,115,116,117,118,119,
                    120,121,122,123,124,125,126,127,128}

All of which leads to my parting advice: read the manuals. There are two
excellent books available for download, both of them free of charge. Each
is quite comprehensive. Some readers prefer one; others prefer the other.
Please consider going to www.oss.com to the area that says FREE DOWNLOAD.
Spend some time with one of them and you'll, in the end, save time.

=====================================================================
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