OpenQNX :: The QNX Community Portal

May 13, 2008 - 08:37 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 52 unlogged users and 2 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
yjiangw
Post subject: Selecting specific ethernet interface for socket to send  PostPosted: 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
 
 View user's profile Send private message  
Reply with quote Back to top
yjiangw
Post subject: Selecting specific ethernet interface for socket to send  PostPosted: 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
 
 View user's profile Send private message  
Reply with quote Back to top
rgallen
Post subject: Re: Selecting specific ethernet interface for socket to send  PostPosted: 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?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
yjiangw
Post subject: RE: Re: Selecting specific ethernet interface for socket to   PostPosted: 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.
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject: RE: Selecting specific ethernet interface for socket to send  PostPosted: 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 ).
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
rgallen
Post subject: Re: RE: Re: Selecting specific ethernet interface for socket  PostPosted: 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...
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
yjiangw
Post subject: RE: Re: RE: Re: Selecting specific ethernet interface for so  PostPosted: 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!
 
 View user's profile Send private message  
Reply with quote Back to top
rgallen
Post subject: Re: RE: Re: RE: Re: Selecting specific ethernet interface fo  PostPosted: 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).
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.