Yoctopuce and IPv6

Yoctopuce and IPv6

This week, we explain how to use VirtualHub 2.0 and the 2.0 libraries in a network infrastructure running on IPv6.


IPv6 is a new version of the Internet's addressing system, designed to handle the growing number of connected devices. It offers a much larger address space than its predecessor, IPv4, enabling more devices to connect and communicate on the Internet.

Most users don't use IPv6 directly, as their local network operates on IPv4. Internet service providers are responsible for bridging the gap between the IPv4-based local network and the IPv6-based Internet backbone.

But in some cases, it may be necessary to use our tools in an IPv6 network. That's why versions 2.0 of VirtualHub and its libraries support IPv6.

IPv6 URLs


Unlike the old IPv4 addresses, which were four groups of numbers separated by dots (e.g. 192.168.0.1), IPv6 addresses are longer and have a different format. When used in web browsers, IPv6 addresses are generally included in URLs in the following way:

http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:4444/



The format of an IPv6 address in a URL begins with "http://" or "https://", followed by "[", the IPv6 address itself, then "]", followed by ":" and the port number (in this case, port 4444). The IPv6 address is a hexadecimal string of eight groups of four digits, separated by colons. Each group can have leading zeros removed, simplifying the address while leaving its meaning intact.

In summary, IPv6 URLs in web browsers follow a specific format with square brackets surrounding the IPv6 address, followed by the port number to indicate the service to connect to.

VirtualHub


By default, VirtualHub 2.0 operates in IPv4 only and will therefore not respond to requests from IPv6 interfaces. If you want to use IPv6, you need to launch VirtualHub with one of the following two options: --enable_ipv6 or --only_ipv6.

The --enable_ipv6 option activates the IPv6 network stack, but keeps the IPv4 stack active. In other words, VirtualHub can use both IPv6 and IPv4 network interfaces. The --only_ipv6 option forces the use of IPv6 network interfaces.


For example, if we run VirtualHub 2.0 on the Windows machine with IP address fe80::471b:5e9a:dfd3:8c70 with the --only_ipv6 option

C:\tmp>VirtualHub.exe --only_ipv6 [2023-11-01 09:42:30] (01) Yoctopuce VirtualHub 2.0.56201 Beta (dated Aug 21 2023) [2023-11-01 09:42:30] (01) Serial is VIRTHUB2-ee2b373b74 [2023-11-01 09:42:30] (01) Use zone B [2023-11-01 09:42:30] (01) 08:42:30 Use DHCP [2023-11-01 09:42:30] (01) Restore network from .dat file [2023-11-01 09:42:30] (01) NetworkName is DESKTOP-NN7UMR4 [2023-11-01 09:42:30] (01) LogicalName is not set [2023-11-01 09:42:30] (02) Listening port 4444 (IPv6 / non secure) [2023-11-01 09:42:30] (02) Listening port 4443 (IPv6 / secure) [2023-11-01 09:42:30] (02) Port mapper server is listening port 111



It can only be reached with the URL http://[fe80::471b:5e9a:dfd3:8c70]:4444/

VirtualHub can only be accessed via the http://[fe80::471b:5e9a:dfd3:8c70]:4444/webapp.html URL
VirtualHub can only be accessed via the http://[fe80::471b:5e9a:dfd3:8c70]:4444/webapp.html URL



2.0 Libraries


Both the 2.0 libraries and the command-line API support IPv6. To connect to VirtualHub using IPv6, simply use an IPv6-formatted URL when calling RegisterHub.

string errsmg = "";
if (YAPI.RegisterHub("ws://[fe80::471b:5e9a:dfd3:8c70]:4444", ref errsmg) != YAPI.SUCCESS){
        MessageBox.Show("RegisterHub error:" + errsmg)
}



Note that, as with IPv4, you can skip the protocol and port number if you use the default port:

string errsmg = "";
if (YAPI.RegisterHub("[fe80::471b:5e9a:dfd3:8c70]", ref errsmg) != YAPI.SUCCESS){
        MessageBox.Show("RegisterHub error:" + errsmg)
}



Obviously, if you use the hostname instead of the IP address, the code still works. The OS takes care of finding the corresponding IP address and the API connects to the correct interface.

string errsmg = "";
if (YAPI.RegisterHub("mycomputer.exeample.com", ref errsmg) != YAPI.SUCCESS){
        MessageBox.Show("RegisterHub error:" + errsmg)
}




Conclusion


VirtualHub and the Yoctopuce APIs can be used in an IPv6 network infrastructure using versions 2.0 of these tools.

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.