Skip to content

smp: Add forward tree protocol#49

Draft
nandojve wants to merge 2 commits into
JPHutchins:mainfrom
OSSystems:forward_tree
Draft

smp: Add forward tree protocol#49
nandojve wants to merge 2 commits into
JPHutchins:mainfrom
OSSystems:forward_tree

Conversation

@nandojve
Copy link
Copy Markdown

@nandojve nandojve commented Sep 13, 2025

smp: Add forward tree protocol

Introduce the Forward Tree protocol (FT). The FT route data downstream in a tree of MCUmgr devices. The Flag 0x80 was selected to indicate that the data payload contains additionally the FT 8 bytes. This 8 bytes are placed at end of regular group payload.

The FT payload is composed by 16 nimbles. The first nimble is the number of hops down in the tree, which in total can handle 15. The remaining nimbles identify the downstream port index.

The FT is a generic downstream route protocol mechanism and it is not designed to create network were a downstream device can send communication upstream or downstream.

    FT example:
                              host
                               |
                               D1
                              /|\
                         ----- | -----
                        /      D3     \
                       D2      |      D4
                              / \
                      D5------   ------D6

The host is the controller which sends SMP requests. This means that data flows from host to devices in the downstream direction. A response from a device to host is the upstream direction.

In this scenario, all upstream messages are processed as a transparent forward response to the host or without any changes the content.

A downstream message needs to be inspected when the FORWARD_TREE flag bit (0x80) is set. The FT payload format is compose by 16 nimbles. The most left nimble is the hops counter. All the other nimbles are port indexes.

           ---- Nimble 15       ---- Nimble 1
          /                    /
      0xH0'00'00'00'00'00'00'0N
        \
         --- hops

Assuming that the host wants to send data to D4 device:

1- set the hops property to 1
2- add the FT port[0] nimble as 2

The correspondent FT big endian data payload in the wire will be:

                                ---- Nimble 1
                               /
      0x10'00'00'00'00'00'00'02
        \
         --- hops

In this case, when host send the data to D1 the device will inspect the
content and forward downstream in the D1 port[2], where D4 is connected.

In the same way, when host wants to send a request to D6:

1- set the hops property to 2
2- set the FT port[1] nimble to 1 and port[0] nimble to 1

                                ---- Ninble 1
                               /---- Nimble 0
                              //
      0x20'00'00'00'00'00'00'11
        \
         --- hops

This means that each time a device must inspect the FT payload and forward downstream the hops count should be reduced by 1 and when hops is evaluated to 0 the device must consume the package.

The system will use the hops value to index the correspondent FT port nimble. In summary, the FT lower port index represents the route closer to the destine and the high port index represents the node closer to the device that start the request.

Forward Tree Protocol proposal:
image

CC: @otavio

@JPHutchins
Copy link
Copy Markdown
Owner

@nandojve This looks like a powerful feature!

I think that it may be easier to implement after #46.

We get this unflattened structure:

class Frame(NamedTuple, Generic[T]):
    """A deserialized SMP message frame."""

    header: smpheader.Header
    smp_data: T

Which means that extensions like this one are simpler to define:

class FrameForwardTree(NamedTuple, Generic[T]):
    """A deserialized SMP message frame using the Forward Tree protocol."""

    header: smpheader.Header
    smp_data: T
    ft: ForwardTree

@nandojve
Copy link
Copy Markdown
Author

Hi @JPHutchins ,

I appreciate the feedback, thanks!

Let's see how Zephyr people will react : )

If you see points of improvements let me know.

Introduce the Forward Tree protocol (FT). The FT route data downstream
in a tree of MCUmgr devices. The Flag 0x80 was selected to indicate
that the data payload contains aditionally the FT 8 bytes. This 8 bytes
are placed at end of regular group payload.

The FT payload is composed by 16 nimbles. The first nimble is the number
of hops down in the tree, which in total can handle 15. The remaining
nimbles identify the downstream port index.

The FT is a generic downstream route protocol mechanism and it is not
designed to create network were a downstream device can send
communication upstream or downstream.

FT example:
                          host
                           |
                           D1
                          /|\
                     ----- | -----
                    /      D3     \
                   D2      |      D4
                          / \
                  D5------   ------D6

The host is the controller which sendis SMP requests. This means that
data flows from host to devices in the downstream direction. A response
from a device to host is the upstream direction.

In this scenario, all upstream messages are processed as a transparent
forward response to the host or without any changes the content.

A downstream message needs to be inspected when the FORWARD_TREE flag
bit (0x80) is set. The FT payload format is compose by 16 nimbles. The
most left nimble is the hops counter. All the other nimbles are port
indexes.

       ---- Nimble 15       ---- Nimble 1
      /                    /
  0xH0'00'00'00'00'00'00'0N
    \
     --- hops

Assuming that the host wants to send data to D4 device:

1- set the hops property to 1
2- add the FT port[0] nimble as 2

The correspondent FT big endian data payload in the wire will be:

                            ---- Nimble 1
                           /
  0x10'00'00'00'00'00'00'02
    \
     --- hops

In this case, when host send the data to D1 the device will inspect the
content and forward downstream in the D1 port[2], where D4 is connected.

In the same way, when host wants to send a request to D6:

1- set the hops property to 2
2- set the FT port[1] nimble to 1 and port[0] nimble to 1

                            ---- Ninble 1
                           /---- Nimble 0
                          //
  0x20'00'00'00'00'00'00'11
    \
     --- hops

This means that each time a device must inspect the FT payload and
forward downstream the hops count should be reduced by 1 and when hops
is evaluated to 0 the device must consume the package.

The system will use the hops value to index the correspondent FT port
nimble. In summary, the FT lower port index represents the route closer
to the destine and the high port index represents the node closer to
the device that start the request.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
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