RTCS multiple interfaces and default gateways

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTCS multiple interfaces and default gateways

2,005 Views
erikisaksson
Contributor I

Hello,

i have a twrk60n512 where I have set up two network interfaces, one wired ethernet and one GPRS (PPP over serial, using ittyd:), with the intention of having two redundant paths to the internet. The operation would then be something like 1. create and bind a tcp socket to the primary interface (wired ethernet) and try to connect. If connection is not complete in say 10 seconds, then close the socket and 2. create and bind another tcp socket to the secondary interface (GPRS) and try to connect.

Now I realize there might be some issues here. First, i'm not sure if the socket bind function can be used to determine which interface will be used for an outgoing connection. Second, there seems to be no straight-forward way of setting the socket connect timeout to anything less than 3 minutes. Third, the two interfaces are bound through DHCP and IPCP respectively, so I guess there would be a need for a separate default gateway for each interface, but this is not supported by RTCS?

Any suggestions on how to solve these issues?

Best Regards,

Erik

Labels (1)
0 Kudos
7 Replies

1,126 Views
DavidS
NXP Employee
NXP Employee

Hi Erik,

I'm not expert but I did ask around and received this reply.  Hopefully it helps.

/*********REPLY START*************/

If the two interfaces are on the
same subnet, you only want one enabled at a time. If RTCS has multiple paths to
a subnet, it will spread the traffic between both paths, and that is not what
you want in this scenario.

If the interfaces are on
different subnets, then enable both, try to connect on the primary, if that
fails, connect on the secondary.

RTCS supports many gateways. You
set up a gateway to external subnets. The default gateway it the gateway to use
if no other gateway matches, and therefore there is only one.

*********REPLY END*******/

Regards,

David

1,126 Views
erikisaksson
Contributor I

Hi David,

thanks for the reply, but the questions remain...

Yes, the interfaces are on different subnets (e.g. 192.168.1.70/24 and 46.194.255.3/32), but both interfaces will be used to reach any arbitrary internet address (e.g. 192.88.156.10). So which interface should be targeted by the default gateway? One thought is to change the default gateway to point to the desired interface before doing the connect, but what would happen to existing connections if the default gateway is changed?

I did the same setup on my windows vista machine: two network connections, one ethernet and one dial-up, and it seems the routing table contains two default gateways:

IPv4 Route Table

=====================================================================

Active Routes:

Network Destination        Netmask          Gateway       Interface

          0.0.0.0          0.0.0.0      192.168.1.1     192.168.1.70

          0.0.0.0          0.0.0.0         On-link      46.194.255.3

So I guess there is no way of achieving this with RTCS?


Best Regards,

Erik


0 Kudos

1,126 Views
EAI
Contributor IV

Erik;

With respect to Windows and multiple gateways, read: http://windows.microsoft.com/en-us/windows-vista/configuring-multiple-gateways-on-a-network. Specifically: If you have multiple network adapters in your computer and you configure a default gateway (which creates a default route in the IP routing table for all destinations that are not located on the subnet) for each adapter, information on your network might not be routed to the correct destinations if you connect to disjoint networks—separate networks that are not designed to communicate directly. Only a single gateway is used for all destinations that are not located on the subnet, even when you configure multiple default gateways.

With respect to changing the gateway in RTCS, you can dynamically change gateways without touching the socket.

Craig

1,126 Views
erikisaksson
Contributor I

Ok, let's forget about multiple default gateways, maybe it's not needed after all. Let's focus on how to make this work with RTCS.

So, again, two interfaces 192.168.1.70/24 (Ethernet) and 46.194.255.3/32 (PPP), default gateway 192.168.1.1. Create a stream socket (unbound) and connect to arbitrary address. The Ethernet interface will be used since the default gateway points this way, right? Now, say the connection attempt failed due to a broken down router or something, so I want to force the next connection attempt to the PPP interface. How? Bind the socket to 46.194.255.3? Change the default gateway to 46.194.255.3? Or none of the above?

Best Regards,

Erik

0 Kudos

1,126 Views
EAI
Contributor IV

Change the default gateway.

0 Kudos

1,126 Views
CaesarI
Contributor III

An other scenario - same problem (exact specification of the interface to use for communication)

Two interfaces too, but added successively.

-first install Ethernet on 192.168.1.70/24, default gateway 192.168.1.1 (device is behind a separate router including NAT)

-install TCP server (Ethernet)

-open connection A from 192.168.1.10 and transfer data bidirectional

-open connection B from 192.168.2.1 (via the router) and transfer data bidirectional

-open UDP connection C to 192.168.2.1 (via the router) to send debug messages

-than install GPRS interface resp. connection (PPP over serial, using ittyd), interface got IP address 37.85.159.2

now connection A still works fine

communication on connection B is out of order: TCP packets were received, but send() returns "error 0x1510" (no route to host)

UDP debug message sending (connection C) returns "error 0x1510" (no route to host), every reopen of the socket now takes not the former used interface (Ethernet on 192.168.1.70/24, default gateway 192.168.1.1) but the GPRS interface and sends the messages to 192.168.2.1 via GPRS/PPP - these packets get lost because the receiver on 192.168.2.1 is'nt a global reachable IP address

-open connection D from 80.85.192.37 (GPRS/PPP) and transfer data bidirectional (works fine)

-trying to reopen connection B via router results every time "error 0x1510" (no route to host)

Questions:

How to specify the interface to use by RTCS? (setsockopt option SO_BINDTODEVICE is not supported in MQX)

We did'nt unterstand the system how MQX 'find the best route to host'. While adding the PPP interface, the route struct will be modified - than the return path for working connections are corrupted.... Is there a fix to prevent these? Is RTCSCFG_ENABLE_VIRTUAL_ROUTES required to work in the scenario above ?

best regards,

Caesar

0 Kudos

1,126 Views
erikisaksson
Contributor I

Tried, and it works!

Unfortunately, switching the default gateway from Ethernet to GPRS also disrupted any existing connections on the ethernet interface. Which is not ok. I really need a solution where the socket can be forced to a specific interface without affecting the rest of the system...

BR,

Erik

0 Kudos