LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a Network card with Multiple IP Addresses

hi 

I have a network card set to the static ip of 192.168.127.110   .

using the advanced option , i added another IP Addresses on that card 192.168.127.111  . 

when i write to the TCP IP i always get that the source Ip was 192.168.127.110 . 

what should i do in order to control the TCP IP source ip  ? 

 

thanks

Ziv

0 Kudos
Message 1 of 9
(4,471 Views)

What do you mean by "using the advanced option"?

 

Network cards can only have one address, either assigned by DHCP or statically assigned.  If you have two network cards, each one would be assigned a separate IP address.

 

How does your question relate to Labview?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 9
(4,402 Views)

hi

i attached a photo with multi Ips ( static ) for a single Card . ( ...127.110 and ....127.111)

multi ips for a single NIC.png

Both of them are valid Ips from the same card and anser to pings from a remote PC .  

i always see the default IP as the source ip when i send a packet and i want to mange it . 

in C# you can manage the Source IP easly . 

my Labview issue is how to mange my Source.ip ?

thanks!

0 Kudos
Message 3 of 9
(4,395 Views)

What are you trying to do? The TCP/IP stack can manage packets directed to the additional IP address, but I think that the TCP/IP stack, when sending, always uses the default address, unless there are routing rules forcing the alternate IP. Your two addresses are in the same subnet, so for the protocol stack there is no need to use the second. If you would define instead 192.168.127.110 and 192.168.128.115, TCP/IP would use the first IP when sending to - for example - 192.168.127.100, the second when sending to 192.168.128.88.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 9
(4,383 Views)

Are you using TCP or UDP?

 

TCP: Of course you can "listen" on any specific address.

For outgoing connections, the network interface is chosen according to the destination IP and the routing tables. Most of the time, the two IP addresses are on different subnets, of course. For example, if you have one interface to the internet and default gateway and a private network with your instrument on another interface, LabVIEW knows what to use. If both IPs are on the same subnet, why would it matter?

 

UDP: You can specify the local address to use.

 

Can you explain what you are trying to achieve with all this? Seems pointless.

0 Kudos
Message 5 of 9
(4,376 Views)

hi

i want to simulate a device that has a specific IP . 

but i need to simulate as much as 20 devices at the same time ( that means 20 different Specific static IPs ) , on the same PC and multi network adapters of any kind will be too much setup and will require hubs , routers , access points and more.

 

i enabled the Hyper-V  and generated as much Ips as i needed. 

when i use Labview to write to the socket i always get the Source.ip as the network card default static ip . 

using  C#  i can manage the Source.ip . 

can it be done from Labview without the need to use Labview connectivity to .Net ? 

 

regards

ziv

0 Kudos
Message 6 of 9
(4,355 Views)

I made a quick check of the System.Net.Sockets.Socket class, but I don't see any way to control the IP in the various Send methods.

How do you do this?

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 9
(4,336 Views)

using .Net Example :

 

using System.Net;

using System.Net.Sockets;

 

public static class ConsoleApp

{

    public static void Main()

    {

        {

            // 192.168.20.54 is my local network with internet accessibility

            var localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.20.54"), port: 0);

            var tcpClient = new TcpClient(localEndPoint);

 

            // No exception thrown.

            tcpClient.Connect("stackoverflow.com", 80);

        }

        {

            // 192.168.2.49 is my vpn, having no default gateway and unable to forward

            // packages to anything that is outside of 192.168.2.x

            var localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.2.49"), port: 0);

            var tcpClient = new TcpClient(localEndPoint);

 

            // SocketException: A socket operation was attempted to an unreachable network 64.34.119.12:80

            tcpClient.Connect("stackoverflow.com", 80);

        }

    }

}

0 Kudos
Message 8 of 9
(4,331 Views)

I don't think you can do the same in LabVIEW.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 9 of 9
(4,322 Views)