Skip to content
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

switch off udp receiving of other hosts if network_mode=local #1231

Closed

Conversation

rex-schilasky
Copy link
Contributor

Description

If network mode is set to local (network_enabled=false) in the ecal global configuration (ecal.ini) the receiving of any kind of udp samples is switched off.

Related issues

Fixes #1191

Cherry-pick to

  • none

@rex-schilasky rex-schilasky marked this pull request as draft October 26, 2023 18:01
@rex-schilasky rex-schilasky added the enhancement New feature or request label Oct 27, 2023
@rex-schilasky
Copy link
Contributor Author

THIS approach is not working :-(

@KerstinKeller
Copy link
Contributor

So it still receives traffic from other hosts?

@rex-schilasky
Copy link
Contributor Author

rex-schilasky commented Oct 30, 2023

So it still receives traffic from other hosts?

No, but not from own host either. :-)

@FlorianReimold
Copy link
Member

I am writing this comment without checking back with the Internet, but I think "127.0.0.1" just isn't a multicast address. There is no multicast group you can join on that. To whom is this suppost to be multicasted to, anyways? there is just 1 machine on 127.0.0.1. You should be able to just unicast that address.

check sender/source udp datagram address in udp_receiver_asio.cpp and udp_receiver_npcap.cpp implementation to not process none local host packages in local network mode
if (m_localhost)
{
// if this is not a local address, return 0
if (!isLocalAddress(m_sender_endpoint.address()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your definition of a "Local address" has nothing to do with a loopback address (-> localhost)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't name that unambiguously. What is meant is that the network packets come from your own machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But your isLocalAddress doesn't check if that IP belongs to your own machine. It checks whether the IP belongs to any machine in any local area network.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I got it .. yes that is true. So this approach will not work at all I think.

if (address.is_v4())
{
uint32_t ip = address.to_v4().to_ulong();
return ((ip & 0xFF000000) == 0x0A000000) || // 10.0.0.0/8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am puzzled why you would care about those. Why not just use a loopback address (127.0.0.0 - 127.255.255.255 https://de.wikipedia.org/wiki/Loopback)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first approach. On my local system, however, I see packets that have my own IPv4 address as the sender 10.x.x.x instead of "127.x.x.x". I need to investigate this further - IT's A DRAFT :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news is that with this draft fix all gtest (including local UDP Pub/Sub) and all samples are running correctly with and without local mode setting and with and without activated npcap mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but then you are probably using DNS to resolve your hostname. Just skip DNS and just send to 127.0.0.1 directly. Why use DNS, if you already know the IP.

Btw, there is no guarantee that DNS will resolve your hostname to a local IP. It could also be a public IP, if you have one. I guess you rather want to check whether the resolved IP address is a multicast or a unicast address. But still I think you don't need DNS at all to send to a loopback adapter.

@rex-schilasky
Copy link
Contributor Author

This will fixed in an upcoming new udp layer implememtation.

@rex-schilasky rex-schilasky deleted the bugfix/external-udp-receiving-in-local-mode branch February 15, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitoring traffic from other hosts visibile, even if Network Mode = local
3 participants