LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bind to a specific NIC on a multihomed machine.

All,

  I am trying to bind a Client to a specific network adapter using LabWindows CVI 2009.  My application will run on a multihomed box running Windows 7 Ultimate with a I7 processor.  Has anyone done this?  Is WMI the only way? 

 

Thanks,

Matt l.

 

0 Kudos
Message 1 of 7
(4,576 Views)

If you are using UDP protocol, the function CreateUDPChannelConfig() allows a specific local network interface card to be targetted, via its IP address.

 

JR

0 Kudos
Message 2 of 7
(4,560 Views)

Thanks for your reply.

 

I am using TCP.  I am looking at the Winsock functions, but it seems the WMI is the way to go.  Seems like there would be a easy way to bind a client to a specific network adapter.

 

I would like to get the available network adapters "user friendly" names and associated IP addresses and bind the TCP client port accordingly.  I have a local network and a "external" network connection on the same computer.

 

Can WMI be used on a C compiler?  Are there any examples of WMI in C?  I have found examples of WMI in C++.  From the research I have done, NI says to use the low level socket functions, but leaves it at that.  It seems with all the multihomed machines, there would be a straight forward way to do this.

 

Thanks,

Matt l.

 

0 Kudos
Message 3 of 7
(4,540 Views)

Why do you need to bind a TCP Client in this way? In my experience of TCP the underlying network subsystem is quite adept at finding a route to the specified TCP Server, no matter which network interface it is physically connected to.

 

JR

0 Kudos
Message 4 of 7
(4,536 Views)

I didn't know that.  So, if one of my network adapters goes to a WAN and the other to a local switch, TCP should know which one is correct?  I have a hard time trusting that!  For instance, if I have a local switch address of 192.168.01 and there is also a WAN 192.168.01.  That may not be likely, but I don't know what this equipment will be connected to after it is delivered.

 

Does the TCP check on both network adapters for a connection?  Do you know if WMI can be used with C specifically with LabWindows?

 

Thanks,

Matt l.

 

0 Kudos
Message 5 of 7
(4,527 Views)

On any given network, you cannot have two devices with the same IP address. If you are spanning multiple networks using bridges, then instead of using hard coded IP addresses on the various machines, you can let Windows find the routing details via the DHCP mechanism - in this case you can connect your client by specifying the network/computer name of the server instead of its IP address.

 

One of my recent projects was installed on a customer's machine which had two network cards. His cabling was a bit untidy, so he disconnected the network cables, re-arranged them and plugged them all back in. While the application was still running. It took a few seconds, but the connection re-established itself without any dramas and the application continued to work - now using a different card, as he connected up to the 'wrong' interface.

 

So, yes, I would trust the network sub-system to work it all out.

 

The WMI interface is available in the CVI/Windows SDK, if you want to go down that route, but I have never used it so I can't offer any advice here.

 

JR

0 Kudos
Message 6 of 7
(4,503 Views)

JR, thanks for the reply, that is very helpful.  I am still learning about networking and probably will be from now on! Smiley Happy  

 

While looking into WMI, as stated previously could not find a C example.  If anyone finds a WMI example in C, please post. WMI looks very useful for future projects that require more control over a machine.

 

Also noticed the "IP Helper Functions" from MSDN: http://msdn.microsoft.com/en-us/library/aa366071(VS.85).aspx

The IP helper functions will get the adapter name and IP address information for each adapter.  Then all you need to do is bind the IP to that port.  The IP Helper functions examples I have looked at are written in C.

 

Let me know if I have left out or misrepresented anything,

 

Thanks,

Matt

0 Kudos
Message 7 of 7
(4,488 Views)