How to configure which WI-FI interface to use when calling tcpclient function

9 views (last 30 days)
I am using tcpclient function just like below:
TCPport=tcpclient('192.168.1.1', 8080,'ConnectTimeout',2)
But when I have two WI-FI interfaces with two hosts having the same IP (192.168.1.1) it often doesn't work. I presume that it is because the tcpclient function may try to use the wrong interface. Is there a way to tell Matlab which interface to use? below I paste what I get when I ask windows to show what networks I have
[~,~,wifi]=evalc('system([''netsh wlan show networks''])');
wifi =
'
Interface name : Wireless Network Connection
There are 7 networks currently visible.
SSID 1 : AdyPan
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
SSID 2 : Horizontal Versine Trolley 1
Network type : Infrastructure
Authentication : Open
Encryption : None
SSID 3 :
Network type : Infrastructure
Authentication : Open
Encryption : None
SSID 4 : WiFi_AdVa
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
SSID 5 : TP-LINK_903D_EXT
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
SSID 6 : TP-LINK_903D
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
SSID 7 : Toduti
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
Interface name : Wireless Network Connection 4
There are 3 networks currently visible.
SSID 1 : Horizontal Versine Trolley 1
Network type : Infrastructure
Authentication : Open
Encryption : None
SSID 2 : Toduti
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
SSID 3 : WiFi_AdVa
Network type : Infrastructure
Authentication : WPA2-Personal
Encryption : CCMP
Thus, what I want to do is to tell which interface to use "Wireless Network Connection" or "Wireless Network Connection 4". I need to do this because both interfaces have an IP address of 192.168.1.1
Kind regards, Marius
  1 Comment
Marius Rusu
Marius Rusu on 18 Jun 2018
Edited: Marius Rusu on 18 Jun 2018
Just thought of a workaround. If I am able to change the IP of one of the two SSIDs so that they are not the same maybe it will solve the problem.

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 18 Jun 2018
I need to do this because both interfaces have an IP address of 192.168.1.1
That's never going to work, in matlab or in any other program. Each interface must be on a different subnet (subnet is dictated by IP/mask pair). As far as I know, no programming language lets you select which NIC to use. However, you can bind to a specific sending address. If both NIC use the same IP, it's pot luck which one will be used to send the data.
You need not only to change the IP of one the network but also move to a different subnet. e.g if one uses IP 192.168.1.1 with a 255.255.255.0 mask. the other can't use any IP on 192.168.1.x (you could move onto 192.168.2.x instead).

More Answers (1)

Marius Rusu
Marius Rusu on 18 Jun 2018
Hi,
Ohh, I see, so if the host of the first Wi-Fi is 192.168.1.1, the host of the other WI-FI cannot be 192.168.1.x, I have to make sure it is something different , e.g. 192.168.2.1 (including netmask).
Many thanks!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!