Replies: 3 comments
-
|
I did play around with using Unishox2 and used compression when it made sense. The other issue is as a user pointed out when encrypting it happing in block of 16 bytes so we wont be saving that much. At best we can send longer messages within the limit we have now. According to AI, our best option would be changing encryption method from AES to something like Ascon-128a and some afford has been done on it here #1450 before compression gives any usfull results. |
Beta Was this translation helpful? Give feedback.
-
|
I've added the work I did here #1959 |
Beta Was this translation helpful? Give feedback.
-
|
I think compression of the text can be very beneficial. I don't know much about the details of the compression tech being considered, but I asked the AI about some things and it had a lot to say. LZW Message Compression Roadmap ItemThe roadmap includes IntentThe likely intent is straightforward:
Why this fits MeshCore:
Roadmap InterpretationA reasonable interpretation of this roadmap item is:
That suggests the initial scope is probably:
Current Protocol ConstraintsRelevant constraints in the current implementation:
So compression is not just a local optimization. It changes:
UncertaintiesThe roadmap item leaves several important questions open.
Where The Complexity IsThe hard part is not the compressor itself. The hard parts are protocol and compatibility.
That logic is in src/helpers/BaseChatMesh.cpp. If compressed text is introduced, receive code can no longer assume
A naive LZW implementation can still be too heavy if:
For many short messages, compression is not worth it.
That needs a precise rule. LZW-Specific ConcernsLZW is plausible, but it is not obviously the only or best option. Pros:
Cons:
Important detail:
AlternativesThese are worth considering before locking on LZW.
A practical interpretation of the roadmap item is that the system may still choose raw text for many messages, even after compression support exists. ExtensibilityThe clean way to make this extensible is to separate:
A good long-term shape would be:
That avoids spending whole payload types on encoding variants. If broader packet-version work lands later, payload versioning could absorb this. For incremental delivery, a text-level encoding field is simpler. Recommended DesignA narrow first phase is the safest interpretation of the roadmap item:
Concrete framing idea:
Using a separate Phased Implementation PlanPhase 0: Protocol DecisionOutput:
Decisions required:
Suggested decisions:
Phase 1: Codec Library In FirmwareAdd:
Requirements:
This phase should be standalone and not yet wired into packets. Phase 2: Direct-Message Send And Receive SupportModify:
Behavior:
That keeps ACK semantics stable even if compression choice changes. Phase 3: Capability NegotiationNeed a way to know whether the remote endpoint supports compressed text. Options:
Recommended:
This phase turns the feature from experimental to usable. Phase 4: App SupportUpdate:
Requirements:
Phase 5: Optional Group Text SupportOnly after compatibility strategy is proven. Additional rules needed:
A conservative approach is:
Phase 6: Optional Signed Text And MultipartAfter the base path is stable:
Suggested Wire-Format SketchOne conservative approach inside decrypted text body: For raw text: For compressed text: Where:
That is easy to wire into current parsing. If extensibility matters more, use: Then:
This is cleaner, but it changes parsing more broadly. Decision Rules Worth Adopting
Main Risks
Bottom LineThis roadmap item makes sense, but only if treated as a protocol compatibility project, not just a firmware optimization. The actual complexity is in:
A sensible interpretation of the roadmap is to deliver this in phases, starting with direct plain-text messages and explicit fallback behavior, then expanding only after interoperability is proven. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In the general todos it is stated that lzw compression be introduced for meshcore payload. I did not find a discussion elsewhere on this, apologies if I missed it. Because I find LZW quite heavyweight, here is a very minimal approach
Proposal:
Benefits / Comparison static huffman vs LZW
Expected compression on typical chat messages (roughly!): Huffman ~30%, LZW ~0-10% (sometimes negative). YMMW though, count this as rough voodoo speculation.
Future / Thoughts
The approach is extendable. Above, the simplest case was sketched: Very generic huffman lookup tables, in the most general case just on bytes (probably less efficient but content independent), or, probably with better practicability here, on character level with a cross-language character frequency table for utf-8 text messages.
We could however also add different freq tables for different language clusters (vs languages, because there is clusters of languages that are quite compatible to each other in char frequencies, e.g., western) even other kinds of data, different hardcoded frequency tables; like code pages. I imagine a specific "western" code page vs. the completely generic. We need to be aware however that any new code page is a new message type, and such codepages are carved in stone after creation, so some cautuiousness is required.
Challenge
Backwards compatibility to uncompressed messages.
Note: I accidentally posted as issue before; sorry. After posting the idea here I will close the issue.
Beta Was this translation helpful? Give feedback.
All reactions