ThreadX docsThreadX docs
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
  • NetX Duo Documentation

    • Understand NetX Duo
    • NetX Duo documentation
    • Chapter 1 - Introduction to NetX Duo
    • Chapter 2 - Installation and Use of NetX Duo
    • Chapter 3 - Functional Components of NetX Duo
    • Chapter 4 - Description of NetX Duo Services
    • Chapter 5 - NetX Duo Network Drivers
    • Appendix A - NetX Duo Services
    • Appendix B - NetX Duo Constants
    • Appendix C - NetX Duo Data Types
    • Appendix D - NetX Duo BSD-Compatible Socket API
    • Appendix E - NetX Duo ASCII Character Codes
    • Auto-IP

      • Chapter 1 - Introduction to NetX Duo AutoIP
      • Chapter 2 - Installation and use of NetX Duo AutoIP
      • Chapter 3 - Description of NetX Duo AutoIP services
    • BSD

      • Chapter 1 - Introduction to NetX Duo BSD
      • Chapter 2 - Installation and use of NetX Duo BSD
      • Chapter 3 - NetX Duo BSD Services
    • Crypto

      • Chapter 1 - Introduction to NetX Duo Crypto
      • Chapter 2 - Installation and use of NetX Duo Crypto
      • Chapter 3 - Functional description of NetX Duo Crypto
      • Chapter 4 - NetX Duo Crypto API description
      • Appendix - NetX Duo Crypto CAVS test
    • DHCP Client

      • Chapter 1 - Introduction to the NetX Duo DHCP Client
      • Chapter 2 - Installation and use of NetX Duo DHCP Client
      • Chapter 3 - Description of NetX Duo DHCP Client services
      • Appendix A - Description of the Restore state feature for NetX Duo DHCP Client services
    • DHCP Server

      • Chapter 1 - Introduction to NetX Duo DHCP Server
      • Chapter 2 - Installation and Use of the NetX Duo DHCP Server
      • Chapter 3 - Description of NetX Duo DHCP server services
    • DHCPv6 Client

      • Chapter 1 - Introduction to NetX Duo DHCPv6 Client
      • Chapter 2 - Installation and use of NetX Duo DHCPv6 Client
      • Chapter 3 - NetX Duo DHCPv6 configuration options
      • Chapter 4 - NetX Duo DHCPv6 Client services
      • Appendix A - Description of the Restore State Feature for NetX Duo DHCPv6 Client
    • DHCPv6 Server

      • Chapter 1 - Introduction to NetX Duo DHCPv6 server
      • Chapter 2 - Installation and use of NetX Duo DHCPv6 server
      • Chapter 3 - NetX Duo DHCPv6 server configuration options
      • Chapter 4 - NetX Duo DHCPv6 server services
      • Appendix A – NetX Duo DHCPv6 option codes
      • Appendix B - NetX Duo DHCPv6 server status codes
      • Appendix C - NetX Duo DHCPv6 unique identifiers (DUIDs)
      • Appendix D - NetX Duo Advanced DHCPv6 server example
    • DNS

      • Chapter 1 - Introduction to the NetX Duo DNS Client
      • Chapter 2 - Installation and Use of NetX Duo DNS Client
      • Chapter 3 - Description of NetX Duo DNS Client Services
    • FTP

      • Chapter 1 - Introduction to NetX Duo FTP
      • Chapter 2 - Installation and use of FTP
      • Chapter 3 - Description of FTP services
    • HTTP

      • Chapter 1 - Introduction to NetX Duo HTTP
      • Chapter 2 - Installation and Use of NetX Duo HTTP
      • Chapter 3 - Description of NetX Duo HTTP Services
    • iperf

      • Chapter 1 - Introduction to NetX Duo Iperf
      • Chapter 2 - Installing and using NetX Duo Iperf
      • Chapter 3 - Running the UDP Transmit Test
    • mDNS

      • Chapter 1 - Introduction to NetX Duo mDNS/DNS-SD
      • Chapter 2 - Installation and use of mDNS
      • Chapter 3 - Description of internal service cache
      • Chapter 4 - Description of mDNS services
    • mqtt

      • Chapter 1 - Introduction to NetX Duo MQTT
      • Chapter 2 - Installation and use of NetX Duo MQTT client
      • Chapter 3 - Description of NetX Duo MQTT Client Services
    • NAT

      • Chapter 1 - An introduction to Network Address Translation
      • Chapter 2 - Installation and use of NAT
      • Chapter 3 - NAT configuration options
      • Chapter 4 - Description of NAT services
    • POP3 Client

      • Chapter 1 - Introduction to NetX Duo POP3
      • Chapter 2 - Installation and use of NetX Duo POP3 Client
      • Chapter 3 - Description of POP3 Client services
    • PPP

      • Chapter 1 - Introduction to the NetX Duo Point-to-Point Protocol (PPP)
      • Chapter 2 - Installation and use of NetX Duo Point-to-Point Protocol (PPP)
      • Chapter 3 - Description of NetX Duo Point-to-Point Protocol (PPP) services
    • PTP Client

      • Chapter 1 - Introduction to NetX Duo PTP Client
      • Chapter 2 - Installation and Use of NetX Duo PTP Client
      • Chapter 3 - Description of NetX Duo PTP Client Services
    • rtp

      • Chapter 1 - Introduction to the NetX Duo RTP Sender
      • Chapter 2 - Installation and use of NetX Duo RTP Sender
      • Chapter 3 - Description of NetX Duo RTP Sender Services
    • rtsp

      • Chapter 1 - Introduction to the NetX Duo RTSP Server
      • Chapter 2 - Installation and use of NetX Duo RTSP Server
      • Chapter 3 - Description of NetX Duo RTSP Server Services
    • Secure DTLS

      • Chapter 1 - Introduction to NetX Duo Secure DTLS
      • Chapter 2 - Installation and use of NetX Duo Secure DTLS
      • Chapter 3 - Functional description of NetX Duo Secure DTLS
      • Chapter 4 - Description of NetX Duo Secure DTLS services
      • Appendix A - NetX Duo Secure DTLS return/error codes
    • Secure TLS

      • Chapter 1 - Introduction to NetX Duo Secure
      • Chapter 2 - Installation and use of NetX Duo Secure
      • Chapter 3 - Functional description of NetX Duo Secure
      • Chapter 4 - Description of NetX Duo Secure services
      • Appendix A - NetX Duo Secure return/error codes
    • SMTP Client

      • Chapter 1 - Introduction to NetX Duo SMTP client
      • Chapter 2 - Installation and use of NetX Duo SMTP client
      • Chapter 3 - Client description of SMTP Client services
    • snmp

      • Chapter 1 - Introduction to NetX Duo SNMP
      • Chapter 2 - Installation and use of the NetX Duo SNMP agent
      • Chapter 3 - Description of NetX Duo SNMP agent services
    • sntp client

      • Chapter 1 - Introduction to NetX Duo SNTP
      • Chapter 2 - Installation and Use of NetX Duo SNTP Client
      • Chapter 3 - Description of NetX Duo SNTP Client Services
      • Appendix A - NetX Duo SNTP Fatal Error Codes
    • telnet

      • Chapter 1 - Introduction to NetX Duo Telnet
      • Chapter 2 - Installation and use of NetX Duo Telnet
      • Chapter 3 - Description of NetX Duo Telnet services
    • TFTP

      • Chapter 1 - Introduction to NetX Duo TFTP
      • Chapter 2 - Installation and use of NetX Duo TFTP
      • Chapter 3 - Description of NetX Duo TFTP services
    • Web HTTP

      • Chapter 1 - Introduction to HTTP and HTTPS
      • Chapter 2 - Installation and use of HTTP and HTTPS
      • Chapter 3 - Description of HTTP services
    • About the NetX Duo User Guide

Chapter 1 - Introduction to NetX Duo DHCPv6 Client

In IPv6 networks, DHCPv6 replaces DHCP for dynamic global IP address assignment from a DHCPv6 Server, and offers most of the same features as well as many enhancements. This document will explain in detail how the NetX Duo DHCPv6 Client API is used to obtain IPv6 addresses.

DHCPv6 Communication

The DHCPv6 protocol uses UDP. The Client uses port 546 and the Server uses port 547 to exchange DHCPv6 messages. The Client uses its link local address for a source address to initiate the DHCPv6 requests to the DHCPv6 server(s) available. When the Client sends messages intended for all DHCPv6 servers on the network it uses the All_DHCP_Relay_Agents_and_Servers multicast address FF02::01:02. This is a reserved, link-scoped multicast address.

DHCPv6 Process of Requesting an IPv6 Address

To begin the process of requesting a global IPv6 address assignment, a Client first sends a SOLICIT message using the nx_dhcpv6_send_solicit service:

UINT nx_dhcpv6_request_solicit(NX_DHCPV6 *dhcpv6_ptr)

This message is sent to all servers using the All_DHCP_Relay_Agents_and_Servers address. In the SOLICIT request, the Client may request the assignment of specific IPv6 address(es) as a hint to the Server. It can also request other network configuration information from the Server such as DNS server, NTP server and other options in the Option Request in the SOLICIT message.

A DHCPv6 Server that can service a Client request responds with an ADVERTISE message containing the IPv6 address(es) it can assign to the Client, the IPv6 address lease time and any additional information requested by the Client. The DHCPv6 Client protocol requires the Client to wait for a period of time to receive ADVERTISE messages from all DHCPv6 Servers on the network. It pre-processes each ADVERTISE message to be a valid message, and scans the option data for various DHCPv6 parameters. It also checks the Preference value in the Preference Option, if supplied by the Server. If more than one ADVERTISE message is received, the NetX Duo DHCPv6 Client chooses the Server with the highest preference value received by the end of the wait period.

The exception is if the Client receives an ADVERTISE message with a preference value of 255. It accepts that message immediately and discards all subsequent ADVERTISE messages.

The wait period is defined as the retransmission period that the DHCPv6 Client waits before sending another SOLICIT message if it has not received a response from any Server. The initial retransmission timeout in the SOLICIT state is defined by to the DHCPv6 protocol described in RFC 3315 to be 1 second. Subsequent retransmission intervals, if the DHCPv6 Client fails to receive a valid Server response, are doubled up to a maximum of 120 seconds.

Having chosen the Server, the Client extracts data from the ADVERTISE message and sends a REQUEST message back to the Server to accept the assigned address information and lease times. The Server responds with a REPLY message to confirm the Client IPv6 address(es) are registered with the Server as assigned to the Client.

The DHCPv6 Client registers the assigned IPv6 address(es) with the IP instance (e.g NetX Duo). If configured for the Duplicate Address Detection (DAD) protocol (enabled by default), NetX Duo will automatically send Neighbor Solicit messages to verify the assigned address(es) are unique on the network. If so, it notifies the DHCPv6 Client when the each assigned address has been promoted from TENTATIVE to VALID. The DHCPv6 Client is promoted to the BOUND state and the device may use that IPv6 address to send and transmit messages. If the DAD protocol fails, NetX Duo notifies the DHCPv6 Client and the DHCPv6 Client sends a DECLINE message for the IPv6 address(es) assigned back to the Server and resets the DHCPv6 Client state to the INIT state.

Notification of Successful Address Assignment and Validation

The application can determine the result of the DHCPv6 Client address solicitation from the state changes if the DHCPv6 Client is configured with the state change callback in the nx_dhcpv6_client_create service. If it receives no response from the Server the state change observed is from SOLICIT to INIT. If it received a response from the Server but the Server is unable to assign the address, the application will be notified by the DHCPv6 Client server error callback if configured with one (also in nx_dhcpv6_client_create). If the Client achieved the BOUND state but then failed the DAD check, it will see a state change from BOUND to INIT. Note that an application that is enabled for DAD must allow time for the DAD check after starting the request process. Typically this is about 400-500 ticks (4-5 seconds in most cases).

Relinquishing an IPv6 Address

If and when the Client needs to release an assigned IPv6 address, it informs the DHCPv6 server by calling the nx_dhcpv6_request_release service:

UINT nx_dhcpv6_request_release(NX_DHCPV6 *dhcpv6_ptr)

The DHCPv6 Client sends a unicast RELEASE message containing the assigned addresses to the Server who assigned the address and waits for a REPLY confirming the Server received the message.

Note: There is a different process for the Client that is powering down but plans to continue using the assigned IPv6 addresses on reboot. It does not send the RELEASE message on powering down unless it plans to request a new address on power up. See "Non Volatile Memory Requirements" for explanation of this situation.

DHCPv6 Lease Timeouts

The IPv6 lease assigned by the Server contains two timeout parameters, T1 and T2 in each Identity Association – Non Temporary Addresses (IANA) block. An IANA is described in elsewhere in this User Guide. If the elapsed time from when the DHCPv6 Client was bound to the assigned IPv6 address equals T1, the DHCPv6 Client automatically starts renewing the IPv6 address by sending a RENEW message. If the elapsed time equals T2, DHCPv6 Client automatically sends a REBIND message if it received no responses to its RENEW requests.

Two other IPv6 lease parameters, preferred and valid lifetime, are assigned with each Identity Association (IA) block contained in the IANA block. The preferred and valid lifetimes are when the assigned IPv6 address is deprecated or invalid, respectively. T1 must be less than the preferred lifetime. T2 must be less than the valid lifetime.

IP Thread Task Requirements

The NetX Duo DHCPv6 Client requires creation of a NetX Duo IP instance previous to creating the DHCPv6 Client to use DHCPv6 Client services.

UDP, IPv6, and ICMPv6 must be enabled on the IP instance prior to the using DHCPv6 Client.

  • nx_udp_enable

  • nxd_ipv6_enable

  • nxd_icmp_enable

Packet Pool Requirements

NetX Duo DHCPv6 Client creation requires a previously created packet pool for sending DHCPv6 messages. The size of the packet pool in terms of packet payload and number of packets available is user configurable, and depends on the anticipated volume of DHCPv6 messages and other transmissions the application will be sending.

A typical DHCPv6 message is about 200 bytes depending on the number of IA addresses and DHCPv6 options requested by the Client.

Network Requirements

The NetX Duo DHCPv6 Client requires the creation of UDP socket bound to port 546. The socket is created when the DHCPv6 Client task is created.

Non Volatile Memory Requirements

If a DHCPv6 Client releases its IPv6 lease with the DHCPv6 Server when powering down, and requests new IPv6 address(es) on reboot, then non volatile memory storage is not required. If a Client wishes to continue using its assigned lease, it must store certain information about the DHCPv6 Client to non volatile memory across reboots.

Non volatile memory requirements and the DHCPv6 Client API are discussed further in Using the NetX Duo DHCPv6 Client in Chapter Two.

NetX Duo DHCPv6 Client Limitations

The current release of the NetX Duo DHCPv6 Client has the following limitations:

  • NetX Duo DHCPv6 Client does not support the Server Unicast option for sending unicast DHCPv6 messages to the DHCPv6 Server even if the Server indicates this is permitted.

  • NetX Duo DHCPv6 Client does not support the Reconfigure request in which a Server initiates IPv6 address changes to the Clients on the network.

  • NetX Duo DHCPv6 Client does not support the Enterprise format for the DHCPv6 Unique Identifier control block. It only supports Link Layer and Link Layer Plus Time format.

  • NetX Duo DHCPv6 Client does not support Temporary Association (TA) address requests, but does support Non Temporary (IANA) option requests.

Multihome and Multiple Address Support

The DHCPv6 Client supports multiple interfaces and multiple addresses per interface. The DHCPv6 Client service, nx_dhcpv6_client_set_interface enables the Client application to set the network interface on which the application will be communicating with the DHCPv6 Server. The DHCPv6 Client defaults to the primary interface (index zero).

For multiple addresses per interface, the DHCPv6 Client keeps an internal list of addresses starting at index 0. Note that the same address registered with the DHCPv6 Client may not necessarily be located at the same index in the IP table of interface addresses.

For DHCPv6 Client services that retrieve information about the Client IPv6 address lease, some require an address index to be specified. An example for obtaining the preferred and valid lifetimes is shown below:

UINT nx_dhcpv6_get_valid_ip_address_lease_time(NX_DHCPV6 *dhcpv6_ptr, 
											  UINT address_index, 
											  NXD_ADDRESS *ip_address,
                                              ULONG preferred_lifetime, 
											  ULONG *valid_lifetime)

The Client application can also retrieve the number of valid IPv6 addresses assigned from the nx_dhcpv6_get_valid_ip_address_count service:

UINT nx_dhcpv6_get_valid_ip_address_count(NX_DHCPV6 *dhcpv6_ptr, 
										  UINT *address_count)

Legacy DHCPv6 Client services which were created before multiple addresses were supported in NetX Duo do not take an address index. Therefore, with these services, the data requested is taken from the primary global IA address, regardless how many IA addresses are assigned to the Client. An example is shown below:

UINT nx_dhcpv6_get_IP_address(NX_DHCPV6 *dhcpv6_ptr, 
                              NXD_ADDRESS *ip_address)

NetX Duo DHCPv6 Client Callback Functions

nx_dhcpv6_state_change_callback

When the DHCPv6 Client changes to a new DHCPv6 state as a result of processing a DHCPv6 request, it notifies the application with this callback function.

nx_dhcpv6_server_error_handler

When the DHCPv6 Client receives a Server reply containing a Status option with a non-zero (non successful) status, it notifies the application with this callback which includes the Server error status code.

Note: Since these callback functions are called from the DHCPv6 Client thread task, the Client application must NOT call any NetX Duo DHCPv6 Client services that require mutex control of the DHCPv6 Client such as nx_dhcpv6_start, nx_dhcpv6_stop, and any of the API that send messages directly from the callback e.g. nx_dhcpv6_request_release.

DHCPv6 RFCs

NetX Duo DHCP is compliant with RFC3315, RFC3646, and related RFCs.

Next
Chapter 2 - Installation and use of NetX Duo DHCPv6 Client