LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating through two ethernet ports on the same computer.

I am working on a project that required me to send data through one ethernet prot and then recieve the data on a different ethernet port. Both of these ethernet ports are on the same computer and have seperate IP adresses. TCP/IP listen allows me to set up a ethernet port to read the incoming data. However, TCP/IP open connection does not allow me to specify which ethernet port to send from. It only allows me to tell it the adress it needs to connect to.

 

How can I specify which of the two ethernet ports to send data from?

 

Any help is greatly appreciated.

Thanks

 

 

 

0 Kudos
Message 1 of 19
(18,177 Views)

When you say "port" do you mean NIC? The TCP Open does allow you to specify an IP Address and a remote TCP port. You can actually specify the local TCP port but it is best to let the system chose this. If you want the data to be transmitted on a specific NIC, the only way you can really achieve this is by setting a persistent route on the computer which would force the traffic for IP addresses in a specific range to use a particular NIC.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 19
(18,170 Views)

As Mark already said, if you want to set the local port number then you can do that for the TCP Open Connection too. However if you want to set the local ethernet interface to use, that is quite useless. On Winsock level this is in principle possible, but seldom done, since the routing rules should be able to much better determine, which network interface to use to reach a specific IP address.

 

If your IP network setup is made to allow communication to a specific address to go through both interfaces, and your rules are not setup properly to make it go through one specific address, you can easily end up with generic routing problems for the entire network, causing much of a headache.

 

So in general, if your network is setup in such a way that there is no prefered routing through one specific interface for a specific IP address range you have a serious network topology problem, and if it is setup properly to assign specific NON-OVERLAPPING address ranges to the different network adapters you don't need to specify the local IP address for outgoing connection based protocols.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 19
(18,149 Views)

Yes, when I said port, I meant NIC.

 

Let me specify my problem. I am running an experiment to test the Bir Error Rate of free space optical communication. I have a computer NIC(1) connected to an optical transmitter which sends data to a receiver which is connected to a second NIC(2) on the same computer. The conversion from RJ45 connectors to optical connectors is done through media converters. Basically, it is the same as connecting NIC(1) to NIC(2) using a crossover cable.

I need to send data from NIC(1) to NIC(2).

 

I understand that TCP Open allows me to choose a IP adress and port number to connect to. But does it allow me to specify which IP adress and port to send data from?

 

"If you want the data to be transmitted on a specific NIC, the only way you can really achieve this is by setting a persistent route on the computer which would force the traffic for IP addresses in a specific range to use a particular NIC."

 

That seems to be the solution I need. Can you give me any tips on how to acheive this?

 

0 Kudos
Message 4 of 19
(18,133 Views)

Not in detail. But you will probably have to go through the command line and setup a route using the command line utility "route". Something like "route ADD xxx.xxx.xxx.xxx MASK xxx.xxx.xxx.xxx  xxx.xxx.xxx.xxx". But messing up your routing table really can disconnect you completely from the network, by causing endless loops, or routes going into nothing.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 19
(18,124 Views)

 


@rolfk wrote:

Not in detail. But you will probably have to go through the command line and setup a route using the command line utility "route". Something like "route ADD xxx.xxx.xxx.xxx MASK xxx.xxx.xxx.xxx  xxx.xxx.xxx.xxx". But messing up your routing table really can disconnect you completely from the network, by causing endless loops, or routes going into nothing.


 

THis is true but if you restrict your routes to very specific IP addresses and not broad range you should be fine. I use multiple NICs in my computer and have defined a persisentent route. In my case I have a corporate network and a test network. The test netowkr is extensive and has 27 VLANs on it. For most people in the office they only use a single NIC and our corporate network does route traffic from specific subnets to the test network. However, when using two NICs like I do the default routing would send all my test network traffic with the exception of the single subnet matching my second NIC's IP address over the corporate network. I don't want this since I send corrupted packets as well as DOS attacks over the test network. I set a persistent route which forces all of my test network traffic (a very specific address range) over my second NIC.

 

If possible you can always initiate your connections from one side. You can send and receive on this connection so you can test both directtions but this would ensure the routing.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 19
(18,114 Views)

Hi Mark, i have a similar trouble with two network on my aplication, but i don´t know how make the setup  for rectrict the routes and define a persistent route. Can you help me with a example?

 

thanks

 

 
0 Kudos
Message 7 of 19
(18,025 Views)

On a Windows PC you would use the route command.You need to determine which addresses will be available on which interface. If you have more than one subnet on an interface you must know the gateway address for that subnet to route the addresses correctly.

 

Here is the help printed by the command:

 

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\WINDOWS>route

Manipulates network routing tables.

ROUTE [-f] [-p] [command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]

  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.
  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes. This
               option is not supported in Windows 95.
  command      One of these:
                 PRINT     Prints  a route
                 ADD       Adds    a route
                 DELETE    Deletes a route
                 CHANGE    Modifies an existing route
  destination  Specifies the host.
  MASK         Specifies that the next parameter is the 'netmask' value.
  netmask      Specifies a subnet mask value for this route entry.
               If not specified, it defaults to 255.255.255.255.
  gateway      Specifies gateway.
  interface    the interface number for the specified route.
  METRIC       specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
    Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
    Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
             The route addition failed: The specified mask parameter is invalid.
 (Destination & Mask) != Destination.

Examples:

    > route PRINT
    > route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
             destination^      ^mask      ^gateway     metric^    ^
                                                         Interface^
      If IF is not given, it tries to find the best interface for a given
      gateway.
    > route PRINT
    > route PRINT 157*          .... Only prints those matching 157*
    > route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

      CHANGE is used to modify gateway and/or metric only.
    > route PRINT
    > route DELETE 157.0.0.0
    > route PRINT

C:\WINDOWS>



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 19
(18,016 Views)

Hi

I have read all the suggestions but I still think that the loop between the two ETH ports will be closed internally in the PC

and will not travel through the cable. I am getting Ping response even with the cable disconnected.

0 Kudos
Message 9 of 19
(17,984 Views)

This is expected behavior if the computer is talking to itself. It is smart enough to not send the data over the wire. If you need it to go over the wire you could use the broadcast address. If you are on a live network (other users are using it) you may want to be careful of the type of broadcast data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 19
(17,960 Views)