gotthardp / gen_coap

Generic Erlang CoAP Client/Server
Other
106 stars 47 forks source link

Multicast Support #7

Open JonGretar opened 7 years ago

JonGretar commented 7 years ago

Multicast support would be a great for a setup I am planning here at home.

The server part is simple. Just adding the option {add_membership, {{224, 0, 1, 187}, {0,0,0,0}}} to gen_udp:open/2 when we want the server to accept multicast requests. Seems to work fine when I test it. Although I will have to read the rfc a bit better to see if more is required to be spec complete.

The problem arises with the client code in a few areas.

I'll be happy to code something up and send a pull request. Just wanted to start with a discussion on how it could operate.

gotthardp commented 7 years ago

Although the client uses channels, each client opens just a single channel. The multiplexing logic is used only for the server. Therefore, the client channel should be fine, even if the source of a response is different.

Much worse is the problem with multiple responses. This affects the coap_transport. The RFC7390 says that "ACK" is never sent in response to multicast. I am tempted to say that multicast should be supported for NON-reliable only. If we say this, a solution to this problem could be a dedicated section in coap_transport handling multicast-non requests as described in the RFC. (NON is much simpler than CON.)