Skip to content

CHIP IP stack implementation

ATmobica edited this page Feb 16, 2021 · 3 revisions

Brief

This page describes the communication over IP implementation in the CHIP project. It allows you to better understand the individual IP layers and their configuration.

Implementation approach

CHIP IP architecture diagram

According to the CHIP IP architecture diagram, the CHIP project should provide all the necessary components for device communication over IP. IP communication layers and their implementation:

Network driver layer

Project CHIP initially supports Wi-Fi and Thread for IP communication. Network drivers are provided directly from the given platform and depend on the device.

Network stack layer

LwIP, BSD/POSIX Sockets, and Network.framework are the IP stacks supported by the CHIP project.

BSD/POSIX Sockets is a Linux-specific stack.

Network.framework is stack for Apple devices.

Other embedded platform uses the LwIP.

There are three options for using IP stack:

  1. Use the LwIP implementation directly from the CHIP source source
  2. Use an external source of LwIP but create a common build config
  3. Use your own IP stack

To configure LwIP usage you need to set the 2 GN arguments:

  • chip_with_lwip - set LwIP support available
  • lwip_platform - LwIP platform definition, if it is set to "external" that means use external sources but with common build config

NOTE: For now, the only zephyr platform uses the custom IP stack. ESP32 platform which has a built-in IP stack uses the external LwIP option.

Network interface layer

The CHIP project implements the "Inet" component which is the network interface layer that corresponds to the transport layer in the OSI model. It defines classes for abstracting access to and interactions with a platform- and system-specific IP stack.

Major abstractions provided are:

  • Timers
  • Domain Name System (DNS) resolution
  • TCP network transport
  • UDP network transport
  • Raw network transport

For BSD/POSIX Sockets, event readiness notification is handled via file descriptors and a traditional poll / select implementation on the platform adaptation.

For LwIP, event readiness notification is handled via events messages and platform- and system-specific hooks for the event message system.

This layer can be used directly in applications to run UDP/TCP communication or it is implemented in the CHIP transport component.

"Inet" has also configuration GN arguments:

  • chip_inet_config_enable_ipv4 - enable IPv4 support
  • chip_inet_config_enable_dns_resolver - enable DNS resolver
  • chip_inet_config_enable_raw_endpoint - enable raw endpoint
  • chip_inet_config_enable_udp_endpoint - enable UDP endpoint
  • chip_inet_config_enable_tcp_endpoint - enable TCP endpoint

You can use them to define your own configuration of this component.