Community discussions

MikroTik App
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 5:55 pm

I have Mikrotik router hap ac3.
I have 4 sensors which produce data constantly. They are connected to router's LAN ports and the Internet port is connected to my PC's network adapter.
I want to switch over the LAN ports in order to receive the data of ONLY ONE sensor at a time.
My first thought was to disable all LAN ports and enable only the one I'm interested to. I do that automatically with a microcontroller which sends commands to the router's SSH.

Is a router the right device for this or I need something else? a managed switch maybe?

Thanks.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 5:58 pm

use ip / kid control
I leave how to your imagination @holvoetn.
Last edited by rextended on Wed Aug 10, 2022 6:06 pm, edited 1 time in total.
Reason: ;)
 
holvoetn
Forum Guru
Forum Guru
Posts: 5317
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 6:00 pm

What happens with the data when the port is not active ?
Simply discarded ?

SSH from microcontroller looks like a viable solution.
Can not think of another way (except for a leprechaun pulling the cables and inserting again at a set frequency :lol: ).

EDIT: DAMN ... IP/ Kid Control is INDEED the proper way to do this !
It's really simple.
In IP / Kid control, Kids, define your schedules with on and off as needed
In Devices use your device's MAC address to define the device and required schedule.
And off you go ...
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18958
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 6:44 pm

@rextended, on previous types of this functionality on other vendor products, if there was a session in progress the STOP time had no effect. It would not allow new sessions to commence after the stop time. Can you clarify, for the OP, if the sensor data being passed will be truncated at stop time, or will continue until the data stream associated with the current session has stopped?
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 6:48 pm

Thankfully we have microcontrollers because I hate leprechauns.
From your answers I suppose that Sensors ----LAN port----- > Router ----INTERNET PORT-----> PC is not wrong. I was concerned about that more.

Kid control sounds good. I'll give it a try. Thank you both.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 7:00 pm

@rextended, on previous types of this functionality on other vendor products, if there was a session in progress the STOP time had no effect. It would not allow new sessions to commence after the stop time. Can you clarify, for the OP, if the sensor data being passed will be truncated at stop time, or will continue until the data stream associated with the current session has stopped?
Is like the sensor send udp datagram continuosly or the server instaurate one tcp connection?

If are probably udp packet, are stopped.
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 9:21 pm

Eventually, what really prevents me from just disabling all the ethernet ports except from one?
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 9:56 pm

Eventually, what really prevents me from just disabling all the ethernet ports except from one?
Nothing - you can use scripting on Mikrotik itself to actually disable the ports if a fixed schedule suits you, or use an ssh login authenticated using the private/public key pair to let some external device issue the necessary commands when really needed. Or there is something in between, you can just send packets to particular UDP ports, or even packets of a particular size, to instruct the script on the Mikrotik which port to enable. Blocking traffic by MAC address, which is what kid control does, is not the same like disabling the Ethernet port completely.

I'm rather curious what makes you need to permit only one sensor to communicate at a time - is the data collection application unable to receive information from more than one sensor, or vice versa, do all the sensors have the same fixed IP address so they cannot be connected simultaneously? Because this latter possibility could be solved using connection tracking if at least teh application can query different addresses.
 
User avatar
Buckeye
Forum Veteran
Forum Veteran
Posts: 883
Joined: Tue Sep 11, 2018 2:03 am
Location: Ohio, USA

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:04 pm

What is the real problem you are trying to solve? This smells to me like an XY problem

To me this seems like you are trying to solve the problem with the wrong tool (the network).

Why should the router be involved? What type of sensors are involved? Is the problem that you are using a closed system and can't have it ignore data from sensors?

The point is, you may be able to have a kludge "solution" using the router to work around a problem, but it seems like you are treating the symptoms instead of the problem. And then when ROS features change your "solution" may break. For example, if kid control feature changes.

Just my opinion.
Last edited by Buckeye on Wed Aug 10, 2022 10:25 pm, edited 1 time in total.
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:14 pm

Eventually, what really prevents me from just disabling all the ethernet ports except from one?
Nothing - you can use scripting on Mikrotik itself to actually disable the ports if a fixed schedule suits you, or use an ssh login authenticated using the private/public key pair to let some external device issue the necessary commands when really needed. Or there is something in between, you can just send packets to particular UDP ports, or even packets of a particular size, to instruct the script on the Mikrotik which port to enable. Blocking traffic by MAC address, which is what kid control does, is not the same like disabling the Ethernet port completely.

I'm rather curious what makes you need to permit only one sensor to communicate at a time - is the data collection application unable to receive information from more than one sensor, or vice versa, do all the sensors have the same fixed IP address so they cannot be connected simultaneously? Because this latter possibility could be solved using connection tracking if at least teh application can query different addresses.
The software is designed to visualize only one sensor at a time. But it only asks for a fixed IP address in order to recognise the sensor and establish connection.
We're checking if it is possible to trick the software and making it believe that the router is the sensor and accept any data coming from it thus accepting data from multiple sensors one at a time. That would be a big upgrade for this software. Definetely there are more details into this, but that's the main idea.
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:28 pm

What is the real problem you are trying to solve? This smells to me like an XY problem

To me this seems like you are trying to solve the problem with the wrong tool (the network).

Why should the router be involved? What type of sensors are involved? Is the problem that you are using a closed system and can't have it ignore data from sensors?

The point is, you may be able to have a kludge "solution" using the router to work around a problem, but it seems like you are treating the symptoms instead of the problem. And then when ROS features change your "solution" may break. For example, if kid control feature changes.


Just my opinion.
I'm considered with the network part because the sensors and the software are not really configurable. They are marine sensors fyi.
I only need a way to have multiple ethernet ports and let the data of only one at a time to pass through and fed to the software.
Like a home network which has only multiple devices and only one gateway, but imagine that only one device at a time can use that gateway.
And yes, I'm really not sure if the network part is the solution, but I have to start from something.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:30 pm

The sensor just send a simply udp packet that the software receive because it coming from specific ip?

Assign to the sensors one different IPs, on that way all can be online without block something, and with NAT alter the src-address of the packet from all the sensors,
for appear to come from only one unique ip...
xyproblem detected... :roll:
 
BrainTrance
just joined
Topic Author
Posts: 21
Joined: Sat Jan 15, 2022 12:09 am

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:55 pm

The sensor just send a simply udp packet that the software receive because it coming from specific ip?

Assign to the sensors one different IPs, on that way all can be online without block something, and with NAT alter the src-address of the packet from all the sensors,
for appear to come from only one unique ip...
xyproblem detected... :roll:
Interesting.
I said in my first post that I want to receive data from only one sensor at a time, I didn't put constraints on how I should do it. Enabling/disabling ports was just an idea.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18958
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: How can I switch between multiple ethernet ports?

Wed Aug 10, 2022 10:56 pm

Hence why I beat the drum on eliciting requirements, not config possibilities!!

Who is online

Users browsing this forum: ccrsxx, GoogleOther [Bot], nickhoulton and 64 guests