smp: Add forward tree protocol#49
Draft
nandojve wants to merge 2 commits into
Draft
Conversation
6277063 to
2e726f1
Compare
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: TWhich 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 |
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>
2e726f1 to
afd1596
Compare
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.
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:
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
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:

CC: @otavio