Introduction to NETXDUO

Revision as of 07:15, 17 February 2021 by Registered User

1. Introduction

Azure RTOS NetX Duo is a dual IPv4 and IPv6 TCP/IP network stack designed specifically for deeply embedded, real-time, and IoT applications. It comes with different set of features. Alongside the TCP/IP IPv4/IPv6 network stack, it provides a crypto library implementing the standard crypto and hash methods and a TLS/DTLS library to support secure network connections.

NetXDuo Overview
  • NetXDuo core offers a full TCP/IP IPv4IPV6 compliant stack with 3 types of API: TCP/IP, UDP/IP and RAW API.
  • Crypto Core implements the common crypto cipher suites and hashing algorithms useful for securing connections and exchanging encrypted data: AES, 3DES, HMAC, RSA, SHA1, SHA224, SHA256, SHA384, SHA512, MD5, HMAC-SHA1… (Each algorithm has its own implementation file “.c” and header file “.h” which facilitate the selection and the integration of the required algorithms by the applications).
  • TLS core implements the secure connection API. Based on both the Crypto core and NetXDuo Core, it supports the TLS and DTLS protocols with their different variants. (TLS 1.0 TLS 1.2, TLS 1.3)

It also supports the “X509” public signed certificates protocol.

  • Addons protocols are a pre-supported set of network applicative protocols that ease the integration of the networking feature in the end user application. The main supported protocols are the following:

DHCP, DNS, mDNS, HTTP, HTTPS, FTP, TELNET, MQTT, SMTP, POP3, SNTP, SNMP etc...

Further details are available in the NetXDuo official documentation

NetXDuo folders are organized as explained below:

NetXDuo Folders

2. STM32 Integration

NetXDuo can run on any networking HW, like Ethernet IPs and WiFi modules, cellular modems… In the context of the STM32 CubeFW, only the following HW are supported:

  • Ethernet: Currently any STM32 board that provides an Ethernet IP, is using the Ethernet PHY microchip LAN874X (driver under “Drivers/BSP/Components” In the STM32H7Cube_FW).

Note: the NetX requires the “Zero-copy” features that is currently supported only in by the STM32H7 HAL_Eth driver.

  • WiFi: this is very specific support, as it will be focused only on WiFi modules supporting the “bypass” mode

NetXDuo requires a low-level driver to interact between the physical layer already chosen and the NetXDuo core requests (Initialize, transmit data, receive data).

NetXDuo Low Layer Interfacing

It is an interface, on top of the HAL Ethernet driver, which should be provided as part of the NetXDuo source code with possibility to tune it via configuration file.

NetXDuo Low Layer Files
  • nx_stm32_eth_config_template.h: a template config header file to tune the corresponding driver for specific STM32 MCU/Board. This file should be copied in the application source tree and renamed to “nx_stm32_eth_driver.h” then customized according to the driver needs.
  • nx_stm32_*_driver.h: the driver header file it contains the driver defines and data structure.
  • nx_stm32_*_driver_config_template.h: an application level config file that allows uses to tune some options related to the driver, a template file is provided in the driver source tree as reference.
  • nx_stm32_*_driver.c: it is referenced directly by the application and may be different between STM32 series depending on the supported features.

It is not the final version; it will be developed to add interrupt mode with the actual polling mode.

  • nx_stm32_xxx_driver_template.c/.h: an empty interface that can be used to implement a new custom driver.

Note: the WiFi driver is not usable on the STM32H7 families, because the “bypass” is not available yet. After low-level configuration, it is called in application code when IP instance is created:

2.1. Known Limitations

  • The support of BSD API is not full-compliant, this may impact the portability of legacy applications. More details are in the official NetXDuo official documentation

3. How To Use

The main APIs needed to use the NetXDuo are described in table below: (more details and full API description are available in NetXDuo official documentation)

Function Name Short Description
nx_tcp_socket_create( ) Create a TCP socket
nx_udp_socket_create( ) Create a UDP socket
nx_tcp_server_socket_listen( ) Setup TCP socket to listen
nx_udp_socket_bind( ) Bind UDP socket to the PORT
nx_tcp_server_socket_accept( ) Accept a TCP remote client socket connection
nx_tcp_socket_receive( ) Receive a packet from a TCP remote client
nx_udp_socket_receive( ) Receive a packet from a UDP remote client
nx_tcp_socket_disconnect( ) Disconnect the TCP server socket
nx_tcp_server_socket_unaccept( ) Reject the TCP server socket
nx_tcp_server_socket_relisten( ) Setup server socket for listening again

The main steps to use the NetXDuo are:

  • First, initialize nx_system from the tx_application_define function, then create a pool (named “ETH_pool” in the next example).
  • Then, create and configure an IP instance which belongs to pool already created.
  • Enable the needed NetXDuo components depending on the target application:
Function Name Short Description
nx_arp_enable( ) Enable the Address Resolution Protocol (AutoIP Protocol need ARP)
nx_icmp_enable( ) Required for Ping
nx_udp_enable( ) Enable UDP traffic (DNS & DHCP need UDP)
nx_tcp_enable( ) Enable TCP traffic

4. STM32 NetXDuo Applications

The Following figure shows the project architecture and main application’s files.

NetXDuo Application Files

STM32 Packages provide the following set of applications (supported applications list may differ between products and boards):

Application Short Description
Nx_TCP_Echo_Server It demonstrates how to develop a NetX TCP server to communicate with a a remote client using the NetX TCP socket API. [readme]
Nx_TCP_Echo_Client It demonstrates how to develop a NetX TCP client to communicate with a remote sever using the NetX TCP socket API. [readme]
Nx_UDP_Echo_Server It demonstrates how to develop a NetX UDP server to communicate with a a remote client using the NetX UDP socket API. [readme]
Nx_UDP_Echo_Client It demonstrates how to develop a NetX UDP client to communicate with a remote sever using the NetX UDP socket API. [readme]
Nx_WebServer It demonstrates how to develop Web HTTP server based application.It is designed to load files and static web pages stored in SD card using a Web HTTP server, the code provides all required features to build a compliant Web HTTP Server. [readme]