Bug 562849 - RAW codec: Odd behavior of PADDING attribute
Summary: RAW codec: Odd behavior of PADDING attribute
Status: UNCONFIRMED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: titan.core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-05 15:23 EDT by Vadim Yanitskiy CLA
Modified: 2021-04-23 10:42 EDT (History)
3 users (show)

See Also:


Attachments
Test module demonstrating the problem (3.89 KB, application/octet-stream)
2020-05-05 15:23 EDT, Vadim Yanitskiy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vadim Yanitskiy CLA 2020-05-05 15:23:47 EDT
Created attachment 282713 [details]
Test module demonstrating the problem

For a long time I've been facing odd and unpredictable behavior of the 'PADDING' attribute, so finally I found some time and came up with a test module demonstrating it. Please see the attachment.

In that module I basically define three different messages:

  * MessageType1 - always occupies 6 octets (no padding),
  * MessageType2 - shall be aligned to 8 octets ('2B'O padding),
  * MessageType3 - shall be aligned to 13 octets ('2B'O padding),

which are then grouped into a union 'MessagePayload' and prefixed with a simple header. Unlike the first message, both second and third contain a flexible octetstring called 'rest_octets' at the end with variable length. So the actual contents of the 'rest_octets' may be shorter or even omitted (i.e. an empty octetstring).

Regardless of the actual length of the 'rest_octets', both second and third messages shall be aligned to 8 and 13 octets respectively. This is what I am trying to achieve using the PADDING attributes. Note that I cannot apply padding to the final record combining the message header and the payload, because of the length constraints mentioned above.

For the sake of diversity, in case of the second message I applied padding to the whole record. For the third message, the padding is applied directly to the 'rest_octets'. Unfortunately, neither of this variants works as expected. Because of that, on practice [1][2][3] I have to work this around by adding / stripping padding bytes manually.

Interestingly enough, this (mis)behavior is not observed when padding is applied to a top-level record that is passed to the RAW codec, i.e. the 'Message' in this example. But as I stated, this is not what I need.

[1] https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18026
[2] https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15571
[3] https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15488
Comment 1 G??bor Szalai CLA 2020-05-06 02:38:12 EDT
The reference point of the padding attribute is the beginning of the message, not the beginning of the type/field applied on.


So the size of the whole message, including the header is considered when the padding was applied.

It is stated in the documentation:
"Description:  This  attribute  specifies  that  an  encoded  type  shall  end  at  a  boundary  fixed  by  a multiple of padding unit bits counted from the beginning of the message."

Yes, we know this is a limitation of the RAW encoder, and the more flexible padding implementation is on the to do list.
Comment 2 Kristof Szabados CLA 2020-06-07 03:56:16 EDT
This looks like a new feature request aiming to make the RAW coder more flexible.
Comment 3 Denis Roy CLA 2021-04-23 10:42:57 EDT
This bug was migrated to GitLab: https://gitlab.eclipse.org/eclipse/titan/titan.core/-/issues