CSN1.info logo by Dafocus

Other rules

Send construction

The send construction can be used to differentiate a string to be used when decoding with the one to be used for encoding.

The send construction has the following syntax:

string_decoded = string_encoded

or

string_decoded send string_encoded

The send construction is used for example to force a stricter encoding and allow a more relaxed decoding.

In this example, the data is 5 bit long (value); the remaining three bits are always encoded as 000; however, when decoding, the decoder reads, accepts and discard any three bits it will find:

< 5-bit data > ::= < value: bit(5) > { bit(3) = 000 }:

The precedence of this operator is the lowest. Therefore:

< bit > < bit > = 00;

is the same of

{< bit > < bit >} = {00};

and not of

< bit > {< bit > = 0} 0;

Functions

Same informations can be taken from the message data itself to define further parts of the message.
This is the case, for example, where there is an octet telling how many other octets are following.

These values can be used with the functions:

function ( label )

The functions have the following rules:

  • they can be used in expressions, i.e. in exponents ;
  • they take their input from a label which must be in the same definition ;
  • the input data taken from the label must appear before the function in the binary string;
There are some predefined functions, while other can be defined by external description. The predefined functions are:
  • val(label) - returns the numeric value of the bits identified by label
  • len(label) - returns the length (i.e. number of bits) of the substring identified by label

The example below, captures in "data" the number of octets indicated by "length":

< Information Element > ::=
  < Tag: octet >
  < Length: octet >
  < Data: octet * (val (Length)) >;

Intersection

The & or and symbols are used to express the intersection concept:
string1 & string2

or

string1 and string2

The overall string matches only if all the strings of an interseption match on the same data.

An example of a typical use of the intersection operator is:

< my message > ::= < my information element >**;

< my information element > ::=
  < Length : bit (8) > -- Length of the value part in octets
  {
  	< octet (val(Length)) > & < IE fields >
  } ;
  
< IE fields > ::=
  < f1: octet >
  < f2: octet >
  < spare padding > ;

< spare padding > ::= < bit** > = 0**;
The goal of the above definition is to make sure that the data part (the "IE fields" substring) complies with the "Length" field. This is particularly evident when decoding a series of information elements, like in the "my message" case. Without anything limiting the first "my information element" to "Length" octets, the "spare padding" field of the first information element would consume all the bits, including those related to the following "my information element"s.
Thanks to the intersection symbol, when decoding the "spare padding" part of the "IE fields" will end its range of influence because forced to stay within the intersection with "< octet (val(Length)) >".

The precedence of the intersection operator is the same of the choice operator.

Exclusion

The exclusion symbol, "-" (dash) or "exclude", allows matching a string string1 as long as it does not match string2:
string1 - string2 or

string1 exclude string2

This is often used to represent cases where only few values have a special meaning.
In the example below, if we have a 4-bit value "x"; only if this value is "1111", is then followed by another 4-bit value "y":

< example > ::= <x: bit(4) - 1111> | <x: 1111> <y: bit(4)>;

The exclusion operator has a precedence higher than choice and intersection , but lower than concatenation .

Error indications

The error indication symbol, an exclamation mark (!), behaves exactly like a choice ; however, when that choice is taken, the decoder should consider it an error.

The example below expects 10 or 11; the remaining values are to be considered wrong:

10 | 11 ! 00 ! 01

Subclassing

The subclassing symbol, "==", is used to limit a definition reached by reference to stricter constraints.
< reference == string >

For example:

< octet == 00001111 >

Please, note that this is just a more compact and clean form of:

{ <octet> & 00001111 }

For example, a typical case where the == symbol is used can be found in 3GPP TS44.060, chapter 11.2.0:

< Downlink RLC/MAC control message > ::=
  < MESSAGE_TYPE : bit (6) == 1 00001 >	< Packet Access Reject message content > |
  < MESSAGE_TYPE : bit (6) == 0 00001 >	< Packet Cell Change Order message content > |
  ...etc

The same thing could have been written as:

< Downlink RLC/MAC control message > ::=
  < MESSAGE_TYPE : 1 00001 >	< Packet Access Reject message content > |
  < MESSAGE_TYPE : 0 00001 >	< Packet Cell Change Order message content > |
  ...etc

However, the "==" helps understanding that the "Message type" for 44.060 messages is a 6-bits field.

Integer subclassing

The integer subclassing symbol ":=" has the same semantics of the "==" symbol; however, on the right side, instead of accepting a normal CSN.1 bit string, it works with a numeric decimal value or an exadecimal value in the form 0xnn.
The value is converted into a sequence of bits whose length is the same of the definition on the left.

For example:

< xyz > ::= 
  < key: octet := 0h7F > < value: octet >
  |
  < key: octet := 0h12 > < value: octet >
  |
  ...etc

Option

The option is expressed by using the square brackets:
[ string ]

The above definition means that the string is optional. In other words, the definition above is the same of:

< string | null >

Truncations

The truncation symbol "//" can be used at the end of a concatenation. It means that the concatenation items are optional and they can be omitted starting from the right.
{ concatenation } //

For example:

{ <a> <b> <c> } //

matches the following string

<a> <b> <c>
| <a> <b>
| <a>
| null

The truncation symbol applies only to the concatenation of the highest level:

{ <a> { <b> <c> } <d> } //

matches the following string

<a> <b> <c> <d>
| <a> <b> <c>
| <a>
| null

Note that <a> <b> is not matched, because the {<b> <c>} concatenation is an element of the outer concatenation.

The truncation symbol can be used to support shorter messages for earlier versions of the protocol. For example:

< message > ::= 
  < mandatory IE 1 >
  < mandatory IE 2 >
  ...
  < mandatory IE N >
  {
	  < new addition IE 1 > -- added in 2001
	  < new addition IE 2 > -- added in 2002
  	...
	  < new addition IE N >  -- added in 2006
  } //;
With this definition, the message can be accepted even if shorter than its complete length, maintaing back compatibility with older equipment.
However, the rules of the truncation avoid to accept a message which is generically shorter: the "mandatory IEs" must be all present, while each "new addition IEs" must be either complete or missing; partial "new addition IEs" are not accepted.