-
Notifications
You must be signed in to change notification settings - Fork 37
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
Avoid redundant query, announcement and unregistration overhaul #239
Avoid redundant query, announcement and unregistration overhaul #239
Conversation
It's a good question, and I need to dig more as well. Here is my thoughts so far:
The "bound" part is true, although for "join" it's not using the network interface index for IPv4. It's using the IP address. IPv6 seems different.
That's true. However the source address will be different. Suppose we only send out one message for both subnet A and subnet B from a source address in subnet A, the receiver on subnet B would see it with the source address from a different subnet, which I'm not sure if its valid, or possible at all. I don't think the mdns message is routable.
Do you mind paste the |
Yes your are right about IPv4, we are using the IP Address to join. But this has the same effect as binding to the interface index from my understanding.
I don't think the subnet matters at all, when receiving message. No-one will look at the senders address and do something with it in regards of mDNS. And yes, according to the standard, the IPv4 mDNS Multicast address is not routable. Source. IPv6 is a different matter.
In this case we would send 5 messages instead of just 2. Avahi for example randomly uses one of those IPv4 addresses and happily sends queries for example using 192.168.70.92 and is albe to discover services of the other subnets without issues.
In this case we would send 4 messages instead of 2 as mentioned above. I'm not having any apple products, therefore I can't say anything about I also can provide network traces as evidence if needed. |
In most cases, I agree it probably doesn't matter. But what if we need to support Unicast Responses in future? And in Known-Answers multi-packet, we also need to know about the source address although we cannot support it now. Of course, one option is to ignore such incoming message if the source is in a different subnet not in the current interface. (In general I felt your approach is nice, just wanted to understand all the impacts) |
Ah ok, I was not aware of those two future use cases. But in general, I think my approach does not put any obstacles in the way of these two points, as its main intent is to reduce the outgoing multicast traffic. |
…gration_success test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. A couple of comments inline.
I think so too. Given that currently we don't specify / limit the source address when browsing services, I think it's worth to go with this optimization. I submitted the review. And thanks for providing the details about the IP interface and addresses info previously. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! A few minor comments inline.
src/service_daemon.rs
Outdated
|
||
/// A struct to track multicast notification status for a network interface. | ||
#[derive(Debug, Eq, Hash, PartialEq)] | ||
struct MulticastNotificationTracker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think IfIndexTracker
(or MulticastSendTracker
) would be easier to understand / map to what it does. It's up to you to decide though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with MulticastSendTracker, thx for the suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This integratest the following two changes: - keepsimple1/mdns-sd#239 - keepsimple1/mdns-sd#240
I had a second thought about the "already sent query or announcemnet in the subnet approach".
Using a "subnet" to filter already notified multicast groups on IPv4 or IPv6 is not a effective method in a multicast context.
The socket used to send multicast traffic is acutally bound to the "any" address associated with the respective address family and is joined on the mDNS multicast_v(4|6) address using the network interface index.
If we have multiple IPv6 or IPv4 addresses on the same network interface in different subnets, this will result in redundant traffic to be sent when sending queries, unregistration messages or announcements, as we still sent those to the same multicast group on the same interface.
I've came up with another approach. We use a tuple(interface index , adress family ) in a set to track already "used" notifications.
This reduces the number of messages sent drastically for example on my windows machine, i'm getting 3 IPv6 addresses and one IPv4 address. Before this change this would result in 4 messages being send on that interface. With this change we only send 2.
@keepsimple1 Please, let me know if there are any problems with the approach.