Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong IFFDataRecord implementation in Java and missing on C++ #92

Open
quonn77 opened this issue Nov 18, 2022 · 1 comment
Open

Wrong IFFDataRecord implementation in Java and missing on C++ #92

quonn77 opened this issue Nov 18, 2022 · 1 comment

Comments

@quonn77
Copy link

quonn77 commented Nov 18, 2022

Hi, I'am actually implementing IFFDataPdu for the C++ side and trying to figure out how to deal with the record length attributes when marshalling and unmarshalling I discovered also that this part is wrong in the Java side.
https://github.com/open-dis/open-dis-java/blob/master/src/main/java/edu/nps/moves/dis7/IFFData.java
Specification says that: Record Length—16-bit unsigned integer (6 + K1 + P1) but on the java code i found
dos.writeShort((short) iffData.length);

this should be
dos.writeShort((short)( 6 + iffData.length));

and also no check is performed to assure that the iffData array has been padded in a way to adhere to the 32 bit boundary of the whole record.

At page 281 of the IEEE 1278.1 2012 document it states:

"Record Length. This field shall indicate the record length expressed as the total number of
octets in the record. The value of the Record Length shall be the sum of the sizes of the Record
Type field, the Record Length field, all Record-Specific fields, and any padding required to end
the record on a 32-bit boundary. All Record Length values shall be a multiple of 4. The Record
Length shall be represented by a 16-bit unsigned integer."

So, for me, this means that the whole IFFDataRecord shall be a multiple of 32bit and so due to the fact that recordType and record length are already 6 bytes long the IFFDataRecord shall be of a minimum of 8 bytes long

EDIT:
I have noticed that also the unmarshall is wrong
recordLength = (int) dis.readUnsignedShort(); iffData = new byte[recordLength];
should be something like
recordLength = (int) dis.readUnsignedShort(); iffData = new byte[recordLength-6];
but the specification it's not clear how handle the padding....
What do you think about it? Have you any idea how to find how many bytes are for the data and how many for the padding....
the only things I have found is to differentiate according to the recordtype...each record type has different lengths... most are 16 bit some 128...

Please note, that I'am actually developing the C++ side following this approach

@leif81
Copy link
Member

leif81 commented Mar 7, 2024

@quonn77 an IFF PDU was recently added for DIS 7 here in the Java implementation. Take a look in the PR #131 , does that help answer your question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants