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

Add data compression to PositionForwarderWialon #5455

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

TheArrex
Copy link
Contributor

If data is bigger then MTU, UDP won't allow to send this. I try to change UDP to TCP, chunk data, but compression do it's best.
Compression is described at the end of this docs: https://extapi.wialon.com/hw/cfg/Wialon%20IPS_en_v_2_0.pdf
Tested on Wialon and build looks fine.

@tananaev
Copy link
Member

  1. Can you rebase on master properly. I see duplicated changes that already exist on the master branch.
  2. It doesn't look like Wialon 1.x supports zip.
  3. We also don't support zip in our server for Wialon.

Comment on lines 157 to 148
ByteArrayOutputStream container = new ByteArrayOutputStream();

container.write(0xFF);

int dataLength = data.length;
ByteBuffer lengthBuffer = ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN);
lengthBuffer.putShort((short) dataLength);
container.write(lengthBuffer.array(), 0, 2);

container.write(data, 0, dataLength);

return container.toByteArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Netty buffers can probably make this much cleaner.

@TheArrex
Copy link
Contributor Author

  1. It doesn't look like Wialon 1.x supports zip.
  2. We also don't support zip in our server for Wialon.

Should i just wrap this feature with version.startsWith("2") condition?

And maybe we need to change protocol version from hardcode at MainModule to config option?

@tananaev
Copy link
Member

I think it would be better to just have a constructor parameter to enable/disable ZIP.

@TheArrex
Copy link
Contributor Author

I think it would be better to just have a constructor parameter to enable/disable ZIP.

Disabled by default?

@tananaev
Copy link
Member

Yes, I prefer disabled by default because then the format will be compatible with Traccar.

@@ -111,6 +129,33 @@ public void forward(PositionData positionData, ResultHandler resultHandler) {
}
}

public static byte[] compressData(byte[] data) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just combine the two methods to avoid two buffers.

@tananaev tananaev merged commit b3f1b13 into traccar:master Oct 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants