Giter Club home page Giter Club logo

Comments (1)

redboltz avatar redboltz commented on June 2, 2024

@anarthal

Connect Packet contains the following fields:

https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901033

Field Bytes Note async_mqtt member variable
FixedHeader 1 fixed_header_
RemainingLength 1-4 variable remaining_length_buf_
ProtocolName 6 0x00,0x04,'M','Q','T','T' protocol_name_and_level_
ProtocolVersion(Protocol Level in v3.1.1) 1 value is 5 protocol_name_and_level_
ConnectFlags 1 connect_flags_
KeepAlive 2 keep_alive_buf_

Subsequent packets are of variable length and/or optional. That makes memory gaps.

That is in common v3.1.1 and v5.

protocol_name_and_level_ already been unified. Because they are just checked on create but never access later.

The possible unification candidates are connect_flags_ and keep_alive_buf. They are fixed size.

So if I unified them, The member woud be as follows:

Field Bytes Note async_mqtt member variable
FixedHeader 1 fixed_header_
RemainingLength 1-4 variable remaining_length_buf_
ProtocolName 6 0x00,0x04,'M','Q','T','T' pn_pl_cf_ka_
ProtocolVersion(Protocol Level in v3.1.1) 1 value is 5 pn_pl_cf_ka_
ConnectFlags 1 pn_pl_cf_ka_
KeepAlive 2 pn_pl_cf_ka_

However, ConnectFlags are modified and referred in the packet member function frequently.
I can do it introducing reference or iteratoror index. But it would become a little complecated.

CONNECT packet is send only at the beggining of the session. So performance requirement is comparatively low. (I am not sure the unification could impact the performance)

Finally, I decided to remain the current code.

from async_mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.