| Author |
Message |
|
|
Post subject: Selecting specific ethernet interface for socket to send
Posted: Apr 02, 2008 - 08:53 PM
|
|
New Member
Joined: Apr 02, 2008
Posts: 4
|
|
Hello,
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?
Thanks!
Yong |
|
|
| |
|
|
|
 |
|
|
Post subject: Selecting specific ethernet interface for socket to send
Posted: Apr 02, 2008 - 08:55 PM
|
|
New Member
Joined: Apr 02, 2008
Posts: 4
|
|
Hello,
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?
Thanks!
Yong |
|
|
| |
|
|
|
 |
|
|
Post subject: Re: Selecting specific ethernet interface for socket to send
Posted: Apr 02, 2008 - 10:42 PM
|
|
QNX Master
Joined: Jul 11, 2002
Posts: 557
|
|
|
yjiangw wrote:
Hello,
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?
Thanks!
Yong
Yong,
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? |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Re: Selecting specific ethernet interface for socket to
Posted: Apr 03, 2008 - 12:41 AM
|
|
New Member
Joined: Apr 02, 2008
Posts: 4
|
|
| Thanks for your response! This is for setting up the redundant communication channels between boards/hosts. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Selecting specific ethernet interface for socket to send
Posted: Apr 03, 2008 - 06:34 AM
|
|
QNX Master
Joined: Sep 01, 2002
Posts: 2667
|
|
I will send the packet to what interface makes more sense and how the route are defined.
Typically binding is for what interface you want to listen on.
Can you describe you network set up a bit ( ip addresses, gateway etc ). |
|
|
| |
|
|
|
 |
|
|
Post subject: Re: RE: Re: Selecting specific ethernet interface for socket
Posted: Apr 03, 2008 - 07:21 AM
|
|
QNX Master
Joined: Jul 11, 2002
Posts: 557
|
|
|
yjiangw wrote:
Thanks for your response! This is for setting up the redundant communication channels between boards/hosts.
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... |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Re: RE: Re: Selecting specific ethernet interface for so
Posted: Apr 04, 2008 - 03:00 AM
|
|
New Member
Joined: Apr 02, 2008
Posts: 4
|
|
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! |
|
|
| |
|
|
|
 |
|
|
Post subject: Re: RE: Re: RE: Re: Selecting specific ethernet interface fo
Posted: Apr 04, 2008 - 09:41 PM
|
|
QNX Master
Joined: Jul 11, 2002
Posts: 557
|
|
|
yjiangw wrote:
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.
Sockets don't work like that.
1. 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.
2. 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.
So what you wanted to do is just not possible with tcp/ip and sockets. It is however possible with SCTP. QNX also supports SCTP (http://en.wikipedia.org/wiki/Stream_Control_Transmission_Protocol). |
|
|
| |
|
|
|
 |
|
|