Trying to understand the Bytes of a message sent, during a connection.

Hi dear, I'm make the tests with send and receive informations using the code base mesh.
I need help to better understand the transport of this data


Initially I set my BUF to 26 Bytes, with OP_ONOFF_SET_UNACK
BT_MESH_MODEL_BUF_DEFINE(buf, OP_ONOFF_SET_UNACK, 26);

I'm using the net_buf_simple_add_u8() method 26 times to add 26 Bytes in the buf

static uint8_t tid;
bool var = val_led;
net_buf_simple_add_u8(&buf, tid++);
net_buf_simple_add_u8(&buf, val_led);

for (i = 0; i < 24; i++) {
  uint8_t new_byte = 1;
  net_buf_simple_add_u8( &buf, new_byte);
}

I'm sending the buf with bt_mesh_model_send method
bt_mesh_model_send(&models[3], &ctx, &buf, NULL, NULL);

I can receive every bytes if net_buf_simple_pull_u8()

unt8_t tid = net_buf_simple_pull_u8(buf);
uint8_t val = net_buf_simple_pull_u8(buf);
for (i = 0; i < 24; i++) {
  uint8_t new_byte = net_buf_simple_pull_u8(buf);
  printk("\n%zu bytes : Value: %d", sizeof(new_byte), new_byte);
}

I print the buf before sending and after receiving in the bt_mesh_access.c file
I realized that the length of buf when I send is every 2 Bytes lager than the buf when I receive.

My Log, When I send 26 Bytes
[00:00:03.138,336] <dbg> bt_mesh_access: bt_mesh_access_send: --> Tx (len 28) (siz 32): 82030001010101010101010101010101010101010101010101010101
[00:00:50.232,147] <dbg> bt_mesh_access: bt_mesh_model_recv: --> Tx (len 26) (siz 28): 0100010101010101010101010101010101010101010101010101


My Log, When I send 2 Bytes
[00:00:43.658,538] <dbg> bt_mesh_access: bt_mesh_access_send: --> Tx (len 4) (siz 32): 82030001
[00:00:48.075,256] <dbg> bt_mesh_access: bt_mesh_model_recv: --> Tx (len 2) (siz 11): 0001


System Log, When I send 2 Bytes
SEND
[00:00:28.784,790] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x00000004 friend_match 0
[00:00:28.784,820] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload 7883531e2dcf6c5067
[00:00:28.784,851] <dbg> bt_mesh_transport_legacy: trans_unseg: AFK 1 AID 0x38

RECEIVE
[00:00:25.634,307] <dbg> bt_mesh_transport_legacy: sdu_recv: AKF 1 AID 0x38
[00:00:25.634,460] <dbg> bt_mesh_transport_legacy: sdu_recv: Decrypted (AppIdx: 0x000)
[00:00:25.634,490] <dbg> bt_mesh_access: bt_mesh_model_recv: app_idx 0x0000 src 0x5bf0 dst 0xffff
[00:00:25.634,521] <dbg> bt_mesh_access: bt_mesh_model_recv: len 4: 82030401


1.1) Are these 2 Bytes that I mentioned previously the header? What would they be headers? Is it the PDU header? Should the MIC bytes not appear?

1.2) What would this Payload be?
[00:00:28.784,820] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload 7883531e2dcf6c5067



From what I read here, in the link below
academy.nordicsemi.com/.../
"MTU has a default value of 23 bytes, and data length has a default value of 27 bytes." -> Bluetooth 4.2
"Data Length Extension (DLE) was introduced to allow the data length to be increased from the default 27 bytes to up to 251 bytes"


2) Is there any method I can use to know if the "data length" is set to 27 bytes or 251 bytes?

--------------------

3)

When I increased it to 10 Bytes, I noticed that in the logs of the transport_legacy.c file, different messages started to appear,
I would like to understand some messages.

3.1) Does this log mean that the message was broken into 2 parts?
[00:04:28.040,252] <dbg> bt_mesh_transport_legacy: send_seg: SeqZero 0x0028 (segs: 2)

3.2) Does this log mean that the first part is being sent?
[00:04:28.040,405] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 0/1

3.3) what content is this?
[00:04:28.040,283] <dbg> bt_mesh_transport_legacy: send_seg: seg 0: 87df25f0ff7f237ea4c8770e
[00:04:28.040,344] <dbg> bt_mesh_transport_legacy: send_seg: seg 1: 9ac0f04d47e48947

3.4) What would this account be? result 20
[00:04:28.105,285] <dbg> bt_mesh_transport_legacy: trans_seg: Target len 1 * 12 + 8 = 20

Complete log of the Node you sent (Mesh)

[00:04:28.040,069] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_send: net_idx 0x0000 app_idx 0x0000 dst 0xffff
[00:04:28.040,100] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_send: len 12: 820308010101010101010101
[00:04:28.040,222] <dbg> bt_mesh_transport_legacy: send_seg: src 0x5bf0 dst 0xffff app_idx 0x0000 aszmic 1 sdu_len 20
[00:04:28.040,252] <dbg> bt_mesh_transport_legacy: send_seg: SeqZero 0x0028 (segs: 2)
[00:04:28.040,283] <dbg> bt_mesh_transport_legacy: send_seg: seg 0: 87df25f0ff7f237ea4c8770e
[00:04:28.040,344] <dbg> bt_mesh_transport_legacy: send_seg: seg 1: 9ac0f04d47e48947
[00:04:28.040,374] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 4
[00:04:28.040,405] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 0/1
[00:04:28.040,649] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x00000028 friend_match 0
[00:04:28.040,679] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a00187df25f0ff7f237ea4c8770e
[00:04:28.040,710] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.040,710] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 0 SegN 1
[00:04:28.040,740] <dbg> bt_mesh_transport_legacy: seg_rx_alloc: New RX context. Block Complete 0x00000003
[00:04:28.040,771] <dbg> bt_mesh_transport_legacy: trans_seg: Received 0/1
[00:04:28.104,797] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.104,919] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 4
[00:04:28.105,010] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 1/1
[00:04:28.105,163] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x00000029 friend_match 0
[00:04:28.105,224] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a0219ac0f04d47e48947
[00:04:28.105,224] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.105,255] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 1 SegN 1
[00:04:28.105,255] <dbg> bt_mesh_transport_legacy: trans_seg: Existing RX context. Block 0x00000001
[00:04:28.105,285] <dbg> bt_mesh_transport_legacy: trans_seg: Target len 1 * 12 + 8 = 20
[00:04:28.105,316] <dbg> bt_mesh_transport_legacy: trans_seg: Received 1/1
[00:04:28.105,316] <dbg> bt_mesh_transport_legacy: trans_seg: Complete SDU
[00:04:28.105,346] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.105,346] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.105,377] <dbg> bt_mesh_transport_legacy: sdu_recv: AKF 1 AID 0x38
[00:04:28.105,468] <dbg> bt_mesh_transport_legacy: sdu_recv: Decrypted (AppIdx: 0x000)
[00:04:28.105,499] <dbg> bt_mesh_access: bt_mesh_model_recv: app_idx 0x0000 src 0x5bf0 dst 0xffff
[00:04:28.105,529] <dbg> bt_mesh_access: bt_mesh_model_recv: len 12: 820308010101010101010101
[00:04:28.105,560] <dbg> bt_mesh_access: bt_mesh_model_recv: OpCode 0x00008203
[00:04:28.105,590] <err> bt_mesh_access: No OpCode 0x00008203 for elem 0x5bf0
[00:04:28.105,621] <dbg> bt_mesh_access: bt_mesh_model_recv: --> Tx (len 10) (siz 12): 08010101010101010101
[00:04:28.105,651] <dbg> bt_mesh_transport_legacy: seg_rx_reset: rx 0x200053c0
[00:04:28.187,225] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.187,316] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 4
[00:04:28.237,457] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 3
[00:04:28.237,487] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 0/1
[00:04:28.237,701] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002a friend_match 0
[00:04:28.237,762] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a00187df25f0ff7f237ea4c8770e
[00:04:28.237,762] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.237,792] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 0 SegN 1
[00:04:28.237,792] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.237,823] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.237,823] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.297,821] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.297,912] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 3
[00:04:28.298,004] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 1/1
[00:04:28.298,187] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002b friend_match 0
[00:04:28.298,217] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a0219ac0f04d47e48947
[00:04:28.298,248] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.298,248] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 1 SegN 1
[00:04:28.298,278] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.298,278] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.298,309] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.375,183] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.375,305] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 3
[00:04:28.425,384] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 2
[00:04:28.425,415] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 0/1
[00:04:28.425,628] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002c friend_match 0
[00:04:28.425,689] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a00187df25f0ff7f237ea4c8770e
[00:04:28.425,689] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.425,720] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 0 SegN 1
[00:04:28.425,720] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.425,750] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.425,750] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.487,091] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.487,213] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 2
[00:04:28.487,274] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 1/1
[00:04:28.487,457] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002d friend_match 0
[00:04:28.487,487] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a0219ac0f04d47e48947
[00:04:28.487,518] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.487,518] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 1 SegN 1
[00:04:28.487,548] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.487,548] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.487,579] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.562,133] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.562,225] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 2
[00:04:28.612,365] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 1
[00:04:28.612,396] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 0/1
[00:04:28.612,609] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002e friend_match 0
[00:04:28.612,701] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a00187df25f0ff7f237ea4c8770e
[00:04:28.612,701] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.612,731] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 0 SegN 1
[00:04:28.612,731] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.612,762] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.612,762] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.673,400] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.673,492] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 1
[00:04:28.673,583] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: Sending 1/1
[00:04:28.673,736] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: src 0x5bf0 dst 0xffff seq 0x0000002f friend_match 0
[00:04:28.673,797] <dbg> bt_mesh_transport_legacy: bt_mesh_trans_recv: Payload f880a0219ac0f04d47e48947
[00:04:28.673,858] <dbg> bt_mesh_transport_legacy: trans_seg: ASZMIC 1 AKF 1 AID 0x38
[00:04:28.673,889] <dbg> bt_mesh_transport_legacy: trans_seg: SeqZero 0x0028 SegO 1 SegN 1
[00:04:28.673,889] <dbg> bt_mesh_transport_legacy: trans_seg: Got segment for already complete SDU
[00:04:28.673,919] <dbg> bt_mesh_transport_legacy: send_ack: SeqZero 0x0028 Block 0x00000003 OBO 0
[00:04:28.673,919] <dbg> bt_mesh_transport_legacy: send_ack: Not sending ack for non-unicast address
[00:04:28.748,992] <dbg> bt_mesh_transport_legacy: schedule_retransmit:
[00:04:28.749,114] <dbg> bt_mesh_transport_legacy: seg_tx_send_unacked: SeqZero: 0x0028 Attempts: 1

Related