There are two CPU-tsec ports in our boards(MPC8641D CPU) and I am trying to have the sockets to send messages out through a specific port/Ethernet interface. It looks like that the sockets always send messages through interface “en0”. I want to send messages through interface “en1” and tried a few things but couldn’t make it to work, I tried binding the socket to the IP address for “en1”, and using the setsockopt() with SO_DONTROUTE on, as well as setsockopt() SO_BINDTODEVICE to be “en1”, but none of these change the behavior. Does any one know what this problem might be? any suggestion I should do?
There are two CPU-tsec ports in our boards(MPC8641D CPU) and I am trying to have the sockets to send messages out through a specific port/Ethernet interface. It looks like that the sockets always send messages through interface “en0”. I want to send messages through interface “en1” and tried a few things but couldn’t make it to work, I tried binding the socket to the IP address for “en1”, and using the setsockopt() with SO_DONTROUTE on, as well as setsockopt() SO_BINDTODEVICE to be “en1”, but none of these change the behavior. Does any one know what this problem might be? any suggestion I should do?
Tcp/ip routes by destination address. You can’t send a packet destined for a network to an interface that is not connected to the appropriate network, and it is generally illegal to have two interfaces homed on the same network from a single host.
Typically, this is only an issue for multicast or broadcast addresses for which the destination network can apply to multiple interfaces.
Perhaps you should explain what it is, you are trying to achieve?
Why not just use Qnet then? It is a total no brainer. Just run Qnet on each board, with two interfaces connecting them, Qnet will auto-discover the redundant paths, and automatically load-balance (i.e. aggregate) across the links, and if you lose one, the bandwidth just drops in half…
The reason we didn’t use qnet is that there is possibility in the future that boards running in different OS need to be supported within the system.
I have got it working already now, by setting up the routing table with entries to specify the transmit interfaces. I initially thought that by binding the socket to the specific interface or using the setsockopt() can do it according the publication I read, but for some reason I coulnd’t make it to work in that way. Thanks for the help!
The SO_DONTROUTE option you were talking about sets a bit in the packet, that makes it a non-routable packet, but has no effect on which interface it leaves the host on.
Binding has no effect on which interface is used, all it does is control what the source address is. The only thing that matters for selecting the interface is the destination address.