Disabling Relay feature of a node of bluetooth mesh


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi everyone !!!

I'm trying to disable relay feature of node by making these two changes

1. setting  CONFIG_BT_MESH_RELAY=n in the prj.conf file.

2. static struct bt_mesh_cfg_srv cfg_srv = {
    .relay = BT_MESH_RELAY_DISABLED,
    .beacon = BT_MESH_BEACON_ENABLED,

#if defined(CONFIG_BT_MESH_GATT_PROXY)
    .gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
#else
    .gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
#endif
    .default_ttl = 5,

    /* network retransmissions with 20ms interval */
    .net_transmit = BT_MESH_TRANSMIT(5, 20),
        /* relay retransmissions with 20ms interval */
    .relay_retransmit = BT_MESH_TRANSMIT(5, 20),
};

After these two changes, node relays all the messages it receives except ones intended for itself.
What else needs to be done to disable relay feature?

Even Android app by Silicon Labs for bluetooth mesh is not able to disable relay feature.

--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


Johan Hedberg
 

Hi Ashish,

On Thu, Dec 07, 2017, ashish.shukla@corvi.com wrote:
Hi everyone !!!

I'm trying to disable relay feature of node by making these two changes

1. setting *CONFIG_BT_MESH_RELAY=n* in the prj.conf file.

2. static struct bt_mesh_cfg_srv cfg_srv = {
* .relay = BT_MESH_RELAY_DISABLED,*
Setting CONFIG_BT_MESH_RELAY=n will actually force the value of
cfg.relay to BT_MESH_RELAY_NOT_SUPPORTED when you initialize mesh, so
trying to set it to disabled shouldn't have any effect. When the value
is NOT_SUPPORTED it can't be changed to any other value at runtime
(which is probably why your attempts with SiLabs don't succeed).

#if defined(CONFIG_BT_MESH_GATT_PROXY)
.gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
#else
.gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
#endif
.default_ttl = 5,

/* network retransmissions with 20ms interval */
.net_transmit = BT_MESH_TRANSMIT(5, 20),
/* relay retransmissions with 20ms interval */
.relay_retransmit = BT_MESH_TRANSMIT(5, 20),
};

After these two changes, node relays all the messages it receives except
ones intended for itself.
What else needs to be done to disable relay feature?

Even Android app by Silicon Labs for bluetooth mesh is not able to disable
relay feature.
Are you using the latest master branch, since there were fixes for this
feature earlier this week?

Also note that since you're setting gatt_proxy to BT_MESH_GATT_PROXY_ENABLED
it means that the node *is* expected to relay packets between the mesh
network and the GATT Client (however *not* relay packets from the mesh
network back to the mesh network).

Johan


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Johan,
I was not understanding meaning of *CONFIG_BT_MESH_RELAY=n*  correctly. Thanks for clarification.

However, when I enabled the proxy feature of a node, and disabled its relay feature, it relays messages from mesh network as well. I'm using latest version  zephyr-1.10.0-rc3.   


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Thu, Dec 7, 2017 at 4:20 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Thu, Dec 07, 2017, ashish.shukla@... wrote:
> Hi everyone !!!
>
> I'm trying to disable relay feature of node by making these two changes
>
> 1. setting  *CONFIG_BT_MESH_RELAY=n* in the prj.conf file.
>
> 2. static struct bt_mesh_cfg_srv cfg_srv = {
>    * .relay = BT_MESH_RELAY_DISABLED,*

Setting CONFIG_BT_MESH_RELAY=n will actually force the value of
cfg.relay to BT_MESH_RELAY_NOT_SUPPORTED when you initialize mesh, so
trying to set it to disabled shouldn't have any effect. When the value
is NOT_SUPPORTED it can't be changed to any other value at runtime
(which is probably why your attempts with SiLabs don't succeed).

> #if defined(CONFIG_BT_MESH_GATT_PROXY)
>     .gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
> #else
>     .gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
> #endif
>     .default_ttl = 5,
>
>     /* network retransmissions with 20ms interval */
>     .net_transmit = BT_MESH_TRANSMIT(5, 20),
>         /* relay retransmissions with 20ms interval */
>     .relay_retransmit = BT_MESH_TRANSMIT(5, 20),
> };
>
> After these two changes, node relays all the messages it receives except
> ones intended for itself.
> What else needs to be done to disable relay feature?
>
> Even Android app by Silicon Labs for bluetooth mesh is not able to disable
> relay feature.

Are you using the latest master branch, since there were fixes for this
feature earlier this week?

Also note that since you're setting gatt_proxy to BT_MESH_GATT_PROXY_ENABLED
it means that the node *is* expected to relay packets between the mesh
network and the GATT Client (however *not* relay packets from the mesh
network back to the mesh network).

Johan


Johan Hedberg
 

Hi Ashish,

On Thu, Dec 07, 2017, ashish.shukla@corvi.com wrote:
I was not understanding meaning of *CONFIG_BT_MESH_RELAY=n* correctly.
Thanks for clarification.

However, when I enabled the proxy feature of a node, and disabled its relay
feature, it relays messages from mesh network as well. I'm using latest
version zephyr-1.10.0-rc3.
As I said earlier, when the Proxy feature is enabled, the proxy *should*
be relaying messages from the network to any connected GATT client,
regardless of the Relay feature being enabled or not. If you don't want
your GATT Client to see network traffic, i.e. to only have access to
elements on the GATT Proxy itself, then you should disable the GATT
Proxy feature (have CONFIG_BT_MESH_GATT_PROXY=y but set cfg.gatt_proxy
to BT_MESH_GATT_PROXY_DISABLED).

If you're really seeing advertising to advertising relaying with rc3
(which does have all the latest fixes) there's something very strange
going on, since the logic for this is now quite simple in the code. You
can check this yourself by looking at the bt_mesh_net_relay() function
and the relay_to_adv() helper function that it uses. Both are found in
subsys/bluetooth/host/mesh/net.c.

Johan


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Johan,

Here is brief about my experimental setup :

1. NODE1 : Proxy enabled, Relay disabled
2. NODE2 : Proxy disabled, Relay disabled

Now, both nodes belong to same group, which means they are subscribed to same group address. When I published data on the same group address over GATT bearer using android app, NODE1 relays data, while NODE2 doesn't. This is as it was expected.

NODE2 is programmed for a button interrupt, which submits a task to system thread with callback function as below

static void pub_presence(struct k_work *work)

    static unsigned char led = 0;
    static unsigned char trans_id = 0;
   
    int err;    

    bt_mesh_model_msg_init(root_models[2].pub->msg, OP_GEN_ONOFF_SET);
    net_buf_simple_add_u8(root_models[2].pub->msg,led=led^1);
    net_buf_simple_add_u8(root_models[2].pub->msg,trans_id++);

    err = bt_mesh_model_publish(&root_models[2]);
    if (err) {
        printk("Error in publishing message ");
    }   
 


What I understand is this publishing is over advertising bearer, and NODE1 should not be relaying this packet. But NODE1 relays this packet as well.

 

 


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Thu, Dec 7, 2017 at 6:05 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Thu, Dec 07, 2017, ashish.shukla@... wrote:
> I was not understanding meaning of *CONFIG_BT_MESH_RELAY=n*  correctly.
> Thanks for clarification.
>
> However, when I enabled the proxy feature of a node, and disabled its relay
> feature, it relays messages from mesh network as well. I'm using latest
> version  zephyr-1.10.0-rc3.

As I said earlier, when the Proxy feature is enabled, the proxy *should*
be relaying messages from the network to any connected GATT client,
regardless of the Relay feature being enabled or not. If you don't want
your GATT Client to see network traffic, i.e. to only have access to
elements on the GATT Proxy itself, then you should disable the GATT
Proxy feature (have CONFIG_BT_MESH_GATT_PROXY=y but set cfg.gatt_proxy
to BT_MESH_GATT_PROXY_DISABLED).

If you're really seeing advertising to advertising relaying with rc3
(which does have all the latest fixes) there's something very strange
going on, since the logic for this is now quite simple in the code. You
can check this yourself by looking at the bt_mesh_net_relay() function
and the relay_to_adv() helper function that it uses. Both are found in
subsys/bluetooth/host/mesh/net.c.

Johan


Johan Hedberg
 

Hi Ashish,

On Fri, Dec 08, 2017, ashish.shukla@corvi.com wrote:
Here is brief about my experimental setup :

1. NODE1 : Proxy enabled, Relay disabled
2. NODE2 : Proxy disabled, Relay disabled

Now, both nodes belong to same group, which means they are subscribed to
same group address. When I published data on the same group address over
GATT bearer using android app, NODE1 relays data, while NODE2 doesn't. This
is as it was expected.

NODE2 is programmed for a button interrupt, which submits a task to system
thread with callback function as below

static void pub_presence(struct k_work *work)
{
static unsigned char led = 0;
static unsigned char trans_id = 0;

int err;

bt_mesh_model_msg_init(root_models[2].pub->msg, OP_GEN_ONOFF_SET);
net_buf_simple_add_u8(root_models[2].pub->msg,led=led^1);
net_buf_simple_add_u8(root_models[2].pub->msg,trans_id++);

err = bt_mesh_model_publish(&root_models[2]);
if (err) {
printk("Error in publishing message ");
}

}

What I understand is this publishing is over advertising bearer,
Publishing is not tied to any specific bearer, rather the message is
expected to be delivered to all network interfaces the network layer is
connected to, including GATT.

and NODE1 should not be relaying this packet. But NODE1 relays this
packet as well.
What exactly do you mean by relaying? If NODE2 publishes the message
over advertising and NODE1 receives it over advertising, then NODE1
should at least process the message (since it's subscribed to the group
address). However upon receiving the message NODE1 should not forward
the message to any of its GATT clients or relay it back to the
advertising bearer. If you're seeing any of these last two things
happening, then I'd like to see the debug logs with ADV and NET debugs
enabled.

Also note that since NODE2 is subscribed to the same group address the
message will also be delivered locally to NODE2.

Johan


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Johan,

NODE1 does receives the messages and process it. But it relay/forward the same message to network by reducing TTL value by 1.

In my case, GATT client is mobile phone so it isn't possible to know whether it receives something or not, for now.

I'm attaching snapshot of terminal of NODE1, when it receives messages from NODE2 on pressing the button.







--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Fri, Dec 8, 2017 at 12:23 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Fri, Dec 08, 2017, ashish.shukla@... wrote:
> Here is brief about my experimental setup :
>
> 1. NODE1 : Proxy enabled, Relay disabled
> 2. NODE2 : Proxy disabled, Relay disabled
>
> Now, both nodes belong to same group, which means they are subscribed to
> same group address. When I published data on the same group address over
> GATT bearer using android app, NODE1 relays data, while NODE2 doesn't. This
> is as it was expected.
>
> NODE2 is programmed for a button interrupt, which submits a task to system
> thread with callback function as below
>
> static void pub_presence(struct k_work *work)
> {
>     static unsigned char led = 0;
>     static unsigned char trans_id = 0;
>
>     int err;
>
>     bt_mesh_model_msg_init(root_models[2].pub->msg, OP_GEN_ONOFF_SET);
>     net_buf_simple_add_u8(root_models[2].pub->msg,led=led^1);
>     net_buf_simple_add_u8(root_models[2].pub->msg,trans_id++);
>
>     err = bt_mesh_model_publish(&root_models[2]);
>     if (err) {
>         printk("Error in publishing message ");
>     }
>
> }
>
> What I understand is this publishing is over advertising bearer,

Publishing is not tied to any specific bearer, rather the message is
expected to be delivered to all network interfaces the network layer is
connected to, including GATT.

> and NODE1 should not be relaying this packet. But NODE1 relays this
> packet as well.

What exactly do you mean by relaying? If NODE2 publishes the message
over advertising and NODE1 receives it over advertising, then NODE1
should at least process the message (since it's subscribed to the group
address). However upon receiving the message NODE1 should not forward
the message to any of its GATT clients or relay it back to the
advertising bearer. If you're seeing any of these last two things
happening, then I'd like to see the debug logs with ADV and NET debugs
enabled.

Also note that since NODE2 is subscribed to the same group address the
message will also be delivered locally to NODE2.

Johan


Johan Hedberg
 

Hi Ashish,

On Fri, Dec 08, 2017, ashish.shukla@corvi.com wrote:
NODE1 does receives the messages and process it. But it relay/forward the
same message to network by reducing TTL value by 1.

In my case, GATT client is mobile phone so it isn't possible to know
whether it receives something or not, for now.

I'm attaching snapshot of terminal of NODE1, when it receives messages from
NODE2 on pressing the button.
Are you concluding that the relaying happens because you see the
"Relaying packet" log message? If so, then that's a wrong assumption,
and the log message is indeed misleading. Please take a look at the
bt_mesh_net_relay() function in net.c. You'll see that the log message
is printed as soon as some basic checks are passed, but that does not
mean that bt_mesh_adv_send() at the end of the function will get called,
since that's still behind the relay_to_adv() check.

Johan


Johan Hedberg
 

Hi Ashish,

On Fri, Dec 08, 2017, Johan Hedberg wrote:
On Fri, Dec 08, 2017, ashish.shukla@corvi.com wrote:
NODE1 does receives the messages and process it. But it relay/forward the
same message to network by reducing TTL value by 1.

In my case, GATT client is mobile phone so it isn't possible to know
whether it receives something or not, for now.

I'm attaching snapshot of terminal of NODE1, when it receives messages from
NODE2 on pressing the button.
Are you concluding that the relaying happens because you see the
"Relaying packet" log message? If so, then that's a wrong assumption,
and the log message is indeed misleading. Please take a look at the
bt_mesh_net_relay() function in net.c. You'll see that the log message
is printed as soon as some basic checks are passed, but that does not
mean that bt_mesh_adv_send() at the end of the function will get called,
since that's still behind the relay_to_adv() check.
There's something not matching up with the description of your
configuration however. You said that NODE1 has both Relay and GATT Proxy
states disabled, however bt_mesh_net_relay() has the following test
before printing the log message that could be seen on your console:

if (rx->net_if == BT_MESH_NET_IF_ADV &&
bt_mesh_relay_get() != BT_MESH_RELAY_ENABLED &&
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_ENABLED) {
return;
}

So the function should bail out at this point for any packet received
over advertising when neither Relay nor GATT Proxy is set to enabled.
Your logs show that the packet was received over net_if 0, which is
BT_MESH_NET_IF_ADV, so based on the fact that the code continued from
this point it seems you had either Relay or GATT Proxy enabled.

Johan


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Johan,

Thanks for in detailed explanation, that clarified related issues.


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Fri, Dec 8, 2017 at 2:39 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Fri, Dec 08, 2017, ashish.shukla@... wrote:
> NODE1 does receives the messages and process it. But it relay/forward the
> same message to network by reducing TTL value by 1.
>
> In my case, GATT client is mobile phone so it isn't possible to know
> whether it receives something or not, for now.
>
> I'm attaching snapshot of terminal of NODE1, when it receives messages from
> NODE2 on pressing the button.

Are you concluding that the relaying happens because you see the
"Relaying packet" log message? If so, then that's a wrong assumption,
and the log message is indeed misleading. Please take a look at the
bt_mesh_net_relay() function in net.c. You'll see that the log message
is printed as soon as some basic checks are passed, but that does not
mean that bt_mesh_adv_send() at the end of the function will get called,
since that's still behind the relay_to_adv() check.

Johan


ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Johan,

>There's something not matching up with the description of your
configuration however.
>You said that NODE1 has both Relay and GATT Proxy
states disabled

for NODE1, Proxy is enabled. This explains relaying of messages over advertising. 



--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Fri, Dec 8, 2017 at 2:51 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Ashish,

On Fri, Dec 08, 2017, Johan Hedberg wrote:
> On Fri, Dec 08, 2017, ashish.shukla@... wrote:
> > NODE1 does receives the messages and process it. But it relay/forward the
> > same message to network by reducing TTL value by 1.
> >
> > In my case, GATT client is mobile phone so it isn't possible to know
> > whether it receives something or not, for now.
> >
> > I'm attaching snapshot of terminal of NODE1, when it receives messages from
> > NODE2 on pressing the button.
>
> Are you concluding that the relaying happens because you see the
> "Relaying packet" log message? If so, then that's a wrong assumption,
> and the log message is indeed misleading. Please take a look at the
> bt_mesh_net_relay() function in net.c. You'll see that the log message
> is printed as soon as some basic checks are passed, but that does not
> mean that bt_mesh_adv_send() at the end of the function will get called,
> since that's still behind the relay_to_adv() check.

There's something not matching up with the description of your
configuration however. You said that NODE1 has both Relay and GATT Proxy
states disabled, however bt_mesh_net_relay() has the following test
before printing the log message that could be seen on your console:

        if (rx->net_if == BT_MESH_NET_IF_ADV &&
            bt_mesh_relay_get() != BT_MESH_RELAY_ENABLED &&
            bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_ENABLED) {
                return;
        }

So the function should bail out at this point for any packet received
over advertising when neither Relay nor GATT Proxy is set to enabled.
Your logs show that the packet was received over net_if 0, which is
BT_MESH_NET_IF_ADV, so based on the fact that the code continued from
this point it seems you had either Relay or GATT Proxy enabled.

Johan