open-dis / open-dis-cpp

C++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
BSD 2-Clause "Simplified" License
90 stars 65 forks source link

Issue with Data Length #84

Open crhowell3 opened 1 year ago

crhowell3 commented 1 year ago
void SignalPdu::marshal(DataStream &dataStream) const {
  RadioCommunicationsFamilyPdu::marshal(
      dataStream); // Marshal information in superclass first
  dataStream << _encodingScheme;
  dataStream << _tdlType;
  dataStream << _sampleRate;
  dataStream << (short)_data.size();  // ISSUE
  dataStream << _samples;
  for (auto byte : _data) {
    dataStream << byte;
  }
}

There is an issue related to the PDUs that inherit from the RadioCommunicationsFamilyPdu (the IntercomSignalPdu and SignalPdu classes) where the size of the data being marshaled into the datastream is incorrect and not compliant with the DIS Standard. The data length should be the size of the data in bits (as per the SISO-STD-001-2015 standard), whereas the size being marshaled in currently is in bytes. I will open a PR to fix this issue.

It is possible that this issue is present elsewhere in the code, so I will do a once-over before requesting merge.

leif81 commented 1 year ago

@crhowell3 I believe you are correct about it being a bug in SignalPDU. We saw the same problem in the Java implementation and fixed it. Note that I think this has been logged before against the CPP implementation, see this issue #10 for more info and how it was fixed in Java. A PR would be very welcome

leif81 commented 1 year ago

I was going to mark as a duplicate of #10, but this one mentions the problem affects not only Signal Pdu but also Intercom Signal Pdu, so I will leave this as a separate issue.