Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Native ASN.1 PER encoding/decoding
Native ASN.1 PER encoding/decoding [message #1858261] Sat, 25 March 2023 11:04 Go to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi Titan ASN.1 experts,

I understand that you guys are working on native/built-in ASN.1 PER codecs and I am very interested in experimenting with it, even if it is not yet complete.

Do you have a simple project for experimenting with ASN.1 PER encoding/decoding which you could share in this forum?

Regards,
Olaf
Re: Native ASN.1 PER encoding/decoding [message #1858290 is a reply to message #1858261] Mon, 27 March 2023 14:20 Go to previous messageGo to next message
Lenard Nagy is currently offline Lenard NagyFriend
Messages: 54
Registered: September 2016
Member
Hi Olaf,

Thank you for your interest, but we are really not there yet. As soon as there will be anything to play around with we will let the community know.
Re: Native ASN.1 PER encoding/decoding [message #1858294 is a reply to message #1858290] Mon, 27 March 2023 19:03 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
ok - Lenard, thanks.
Olaf
Re: Native ASN.1 PER encoding/decoding [message #1861654 is a reply to message #1858294] Wed, 25 October 2023 12:55 Go to previous messageGo to next message
Adam Knapp is currently offline Adam KnappFriend
Messages: 54
Registered: November 2020
Member
Hi Olaf,

We are at the stage, where native PER encoder can be tested. Most types are supported. Nevertheless bugs can still exist as it is not tested extensively yet. I think the community can also give a try. Feedbacks would be really appreciated!
Here is the commit containing the documentation related to PER: https://gitlab.eclipse.org/eclipse/titan/titan.core/-/commit/7b5356d60fa3f32c11f96d85753572763bf17be7
Clicking on "View file @..." at the up left corner will render the file properly, however, the changes are more clearer in this view.
Re: Native ASN.1 PER encoding/decoding [message #1861667 is a reply to message #1861654] Thu, 26 October 2023 08:55 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi Adam,

I could not make it run in the simple project attached below, the encoding fails, at least it does not match the Pycrate encoded value.

Maybe some incorrect compiler options?

Olaf
  • Attachment: T1.zip
    (Size: 6.76KB, Downloaded 72 times)
Re: Native ASN.1 PER encoding/decoding [message #1861683 is a reply to message #1861667] Fri, 27 October 2023 08:44 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi Adam,

In the project I attached yesterday for encoding I use an external function and use it as follows
 v_Encoded := fx_enc_PUSCH_Config(tsc_PUSCH_Config);


I would like to get rid of this external function and instead use encvalue as is used in the 3GPP ATSs
 v_Encoded := encvalue(tsc_PUSCH_Config);


How can I achieve this?

Regards,
Olaf
Re: Native ASN.1 PER encoding/decoding [message #1861716 is a reply to message #1861683] Mon, 30 October 2023 17:25 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Hi Olaf,

the difference between the two decoded values is that our decoder leaves the missing extension addition field 'dmrs-Uplink-r16' as unbound, while in 'tsc_PUSCH_Config' it is set to 'omit'.

You also haven't set which version of PER to use in your external function implementation (i.e. unaligned or aligned, and basic or canonical), but it seems to be working anyway.

For example:
p_PUSCH_Config.encode(*p_PUSCH_Config.get_descriptor(), buffer, TTCN_EncDec::CT_PER, 0);

or

p_PUSCH_Config.encode(*p_PUSCH_Config.get_descriptor(), buffer, TTCN_EncDec::CT_PER, PER_ALIGNED);


In order to use PER with 'encvalue' and 'decvalue' you need to set the string encoding parameter to "PER", like this:
v_Encoded := encvalue(tsc_PUSCH_Config, "", "PER");

There is no option to set the alignment or canonicalness in this case, encvalue and decvalue always uses unaligned, basic PER currently.

Best regards,
Botond
Re: Native ASN.1 PER encoding/decoding [message #1861717 is a reply to message #1861716] Mon, 30 October 2023 17:57 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi Botond,

The example project I provided ]shows 2 bugs in Titan's PER implementation:

- encvalue does not always result in the correct value 'E0009240'O : In more than 30% of the executions the encoding is incorrect (I am using OpenSuse 15.4)
- decvalue fails with an internal error. It seems that in your machine decvalue returns an object but not a value: a valid value is without unbound leaves.

What OS are you using, so that I could try using your OS?

Regards,
Olaf

Re: Native ASN.1 PER encoding/decoding [message #1861734 is a reply to message #1861717] Tue, 31 October 2023 15:31 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Hi Olaf,

I'm using an Ubuntu 22.04 virtual image.
About the decoding: I can change it so optional extension additions are set to 'omit' instead of 'unbound', if they are absent in the PER encoding, but mandatory extension additions cannot be set to 'omit', so those will still remain 'unbound' if they're absent.
About the encoding: have you added the extra parameter to 'p_PUSCH_Config.encode' that I mentioned? Because otherwise it probably just uses whatever it finds in the memory to determine which version of PER to use.

Best regards,
Botond
Re: Native ASN.1 PER encoding/decoding [message #1861735 is a reply to message #1861734] Tue, 31 October 2023 15:48 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Also, if all your external functions do is PER encoding and decoding, then there's no need to implement them manually. You could use extension attributes to tell the compiler to implement them, like this (for unaligned PER):

external function fx_enc_PUSCH_Config(in PUSCH_Config p_PUSCH_Config) return bitstring
    with { extension "prototype(convert) encode(PER)" }
  external function fx_dec_PUSCH_Config(inout bitstring b, out PUSCH_Config p_PUSCH_Config)return integer
    with { extension "prototype(sliding) decode(PER)" }


Or like this if you want it to use aligned PER:
external function fx_enc_PUSCH_Config(in PUSCH_Config p_PUSCH_Config) return bitstring
    with { extension "prototype(convert) encode(PER:ALIGNED)" }
  external function fx_dec_PUSCH_Config(inout bitstring b, out PUSCH_Config p_PUSCH_Config)return integer
    with { extension "prototype(sliding) decode(PER:ALIGNED)" }
Re: Native ASN.1 PER encoding/decoding [message #1861743 is a reply to message #1861735] Wed, 01 November 2023 08:53 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Hi Botond,

Following your hints, I made the corrections in attached revised project. Further I prepared the test environment on OpenSuse and Ubuntu. Good new: results are identical on both machines.

- encvalue works fine producing correct results

- decvalue has definitely a bug : It terminates with a runtime error, decvalue shall return a TTCN value and/or an error code.
And, yes, you must set optional elements to 'omit' if they are absent in the encoded data.

Regards,
Olaf
  • Attachment: T1-r1.zip
    (Size: 6.19KB, Downloaded 155 times)
Re: Native ASN.1 PER encoding/decoding [message #1861767 is a reply to message #1861743] Thu, 02 November 2023 15:29 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Hi Olaf,

I've made the change to set absent extension additions to 'omit' if they're optional. See: https://gitlab.eclipse.org/eclipse/titan/titan.core/-/commit/4706e79692402cb0702a1ab1f0f7739cfdb7c4ec

I'm not getting a runtime error using decvalue in the attached project (though I am running it with the newest Titan, which sets absent extensions to 'omit'). Are you sure it's not caused by attempting to match a structure containing an unbound field after decoding?

Best regards,
Botond
Re: Native ASN.1 PER encoding/decoding [message #1861768 is a reply to message #1861767] Thu, 02 November 2023 15:41 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Wow, Botond, now decvalue/envcalue work fine!

Attached a project testing your PER implementation with real world data, i.e. using the official 5G ASN.1. Thanks to Virginie @ETSI/TF160 for providing the test data. It works!

The only problem now is that the compilation takes around 3 hours and produces lib + exe of around 400 MBytes!

Is there a compiler option to tell Titan to generate only PER unaligned related code and nothing else?

Regards,
Olaf
  • Attachment: T2.zip
    (Size: 168.88KB, Downloaded 44 times)
Re: Native ASN.1 PER encoding/decoding [message #1861769 is a reply to message #1861768] Thu, 02 November 2023 16:36 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Hi Olaf,

that's great news!

Unfortunately, there is no compiler option to generate only unaligned PER, and it wouldn't help much if there was one. There aren't that many differences between aligned and unaligned PER, and most of those differences are in the TTCN-3 runtime library, not the generated code. The ASN.1 file in the attached project contains 1 MB's worth of type declarations; that's always going to generate a lot of C++ code and take a long time to compile.

Best regards,
Botond
Re: Native ASN.1 PER encoding/decoding [message #1861813 is a reply to message #1861769] Mon, 06 November 2023 08:21 Go to previous messageGo to next message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Good morning Botond,

there seems to bee an inconsistency when handling ASN.1 extentsion markers {...}. To investigate this easily I prepared a simple project attached below.

Consider template tsc_SIB1

  const BCCH_DL_SCH_Message tsc_SIB1 := 
    {
    message_ := {
      c1 := {
	systemInformationBlockType1 := {
	  cellSelectionInfo := {
	    q_RxLevMin := -55,
            q_RxLevMinOffset := omit,
            q_RxLevMinSUL := omit,
            q_QualMin := omit,
            q_QualMinOffset := omit
	  },
	  ims_EmergencySupport := true_, 
          eCallOverIMS_Support := omit,
          ue_TimersAndConstants := 
          {
            t300 := ms1000,
            t301 := ms1000,
            t310 := ms1000,
            n310 := n1,
            t311 := ms30000,
            n311 := n1,
            t319 := ms1000
          },
	  eCallOverIMS_Support2 := true_
	} // systemInformationBlockType1
      } //c1
    } // message
    };


When encoding this template we get

      '760796D18500'O   <-- Titan PER encoding
      '7607ADA30A'O  <-- Pycrate based encoding


Do you or someone else have access to commercial tools to decode these octet strings and find out whether the Titan implementation has a bug or not?


Regards,
Olaf
  • Attachment: T3.zip
    (Size: 5.71KB, Downloaded 46 times)
Re: Native ASN.1 PER encoding/decoding [message #1861828 is a reply to message #1861813] Tue, 07 November 2023 08:58 Go to previous messageGo to next message
Botond Baranyi is currently offline Botond BaranyiFriend
Messages: 55
Registered: February 2016
Member
Hi Olaf,

I don't have access to other PER encoders right now, but I've figured out the issue and fixed it in Titan. Enumerated types with only one possible value were not encoded properly. It should work now with the latest commit.

Best regards,
Botond
Re: Native ASN.1 PER encoding/decoding [message #1861829 is a reply to message #1861828] Tue, 07 November 2023 09:43 Go to previous message
Olaf Bergengruen is currently offline Olaf BergengruenFriend
Messages: 127
Registered: November 2018
Senior Member
Great, Botond!

The reference encoding I used was done as follows: Titan OER encoding followed by Pycart OER to PER conversion. But this is error prone and was not sure whether it worked, and I cannot inspect the encoded octet string as you do :-)

I conform that now all my tests PASS.
Olaf


Previous Topic:TTCN timers controlled via a virtual clock
Next Topic:TTCN-3 standard compliancy
Goto Forum:
  


Current Time: Wed Oct 09 19:41:42 GMT 2024

Powered by FUDForum. Page generated in 0.06536 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top