-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IP_MULTICAST_LOOP / IPV6_MULTICAST_LOOP option configuration #1497
Comments
Several things here. IP_MULTICAST_LOOP is for IPv4 sockets. With it enabled, an application sending a multicast packet, this multicast packet will be received by any other application listening on a different socket on the same host. I do not think this is supported for IPv6. With IPV6_MULTICAST_LOOP enabled, this allows the transmitting socket to also receive the multicast packet. As I read it, this has not control over other sockets on the same host added to the same multicast group. It probably is best to add in a new function (like |
@mrdeep1 thank you for the fast response. Thanks for the hint just realized the mixup. I also found the multicast binding coap_mcast_set_ipv6_loop(coap_session_t *session, bool enable);
coap_mcast_set_ipv4_loop(coap_session_t *session, bool enable); Would you like some help with the implementation? |
For historical code compatibility reasons, bool is not currently supported, so these parameters would have to be an int with value 0 or 1. For IPv6, using It is unclear to me as to what is your actual use case here. |
The use case; I have multiple servers listening on the same multicast address + port and sending to the same multicast address + port. |
OK, so if I understand you correctly, you have a server A (well more than one, named B, C, D etc.) listening on a multicast address (group) + port. Then someone sends a multicast packet X, received by server A, and this server then decides to send out a multicast packet Y to the same multicast IP (group) and port. So, server B (and C, D etc) receive the original multicast packet X (but don't send out a multicast packet otherwise you will likely get a packet storm) as well as the multicast packet Y transmitted by A. So, your issue is that Server A gets confused when it also sees the multicast packet Y it just sent. If that is the case, then IPV6_MULTICAST_LOOP simply needs to be disabled when |
Exactly the issue, From the example, A is a router with two interfaces and the function |
OK - then I think that all is needed is to disable |
Let me verify, disabling
|
Yes, it will only disable the sending socket receiving the multicast packet it just transmitted. |
So disabling via |
You probably have understood it fully, but just to ensure we are on the same page, here a test implementation to verify: https://github.com/BitFis/example-multicast , At least thats my current understanding of this configuration. |
Ok. So one application is listening on socket that has multicast enabled as a server. It then opens new connection, sends multicast packet on new connection which is then picked up on the server side listening socket. Not sure how to fix this for IPv6. Need to research this. |
I think we simply need to disable IPV6_MULTICAST_LOOP when creating client type sockets. |
Works for me, thought do you want to provide an option to enable loopback if desired? Aka. provide the new api anyways? |
After checking further and having a few discussions, I would recommend not disabling In case its disabled no other local process will be able to receive the multicast message of the coap_client which might lead to issues for some setups on only one host. By example if a client and a server (router) are on the same machine and the client wants to send/publish an mcast message to all devices and the server (router). Also for testing and debugging this could confuse developers and may lead to unnecessary questions / bug reports. I would recommend the May I open an PR to create a first draft for this new api functions? |
Sure - go ahead and create a PR. I do think that the client socket created by |
See #1502 which should fix your loop back issue for the client part of your application sending a mcast packet which is picked up by the server part of your application. |
Will verify this, thanks. A side question, there is currently no functionality which detects duplicate messages via message id? |
Not sure what you are trying to ask here - client or server side? There is some code that does this checking but possibly not in the areas you are thinking about. Please give a Use Case. |
Hello, its a bit off topic of this issue, but I am thinking of server side in context of RFC7252 - 4.5. Message Deduplication.
I am aware there some relaxation options, but just curious on if and how this is implemented. |
Confirmable (CON) messages are explicitly not allowed for Multicast packets, so this is definitely off topic and should be raised in another issue. |
Is your feature request related to a problem? Please describe.
Unable to configure IP_MULTICAST_LOOP which
is important to define the correct behavior for sending multicast ipv6 packages.
Describe the solution you would like
Probably would be best to provide a function to retrieve the socket file descriptor.
Describe alternatives you have considered
Trying to retrieve the fid from
coap_context_get_coap_fd
.Not possible since the fid is well hidden in the epoll context.
Alternatively directly accessing the socket fid,
thought I prefer not to make libcoap a compile time depedency by using the internal includes.
Alternatively an api for the
IP_MULTICAST_LOOP
behavior could be provided,Thought providing access to the fid would also support other socket option configurations without requiring
new functions and therefore may be more future proof.
Example API:
Additional context
Happy to alternatives. Also would provide an PR if support is welcome.
The text was updated successfully, but these errors were encountered: