Skip to content

TexasInstruments/ti-wisunfantund

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wfantund, Userspace Wireless Field Area Network (WFAN) Network Daemon

wfantund is derived from wpantund which was written and developed by Nest Labs to make supporting Thread connectivity on Unix-like operating systems more straightforward.

wfantund is a user-space network interface driver/daemon that provides a native IPv6 network interface to TI Wi-SUN FAN Border Router operating in Network Processor (NWP) mode.

TI Wi-SUN FAN Solution are supported over TI CC13xx platforms. Refer to https://www.ti.com/wireless-connectivity/wi-sun/overview.html for more details.

TI Wi-SUN FAN embedded software running on TI CC13xx platform can be downloaded from TI CC13xx_26xx SDK (https://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK)

Software provided in this repository provides Linux Application Examples that can run over TI Wi-SUN FAN Border Router NWP software (to be obtained from TI CC13xx_26xx SDK) connected via UART to a Linux Platform.

These examples are meant to be serve as sample application examples to aid in development of a Linux OS based Wi-SUN Border Router custom applications and provide back-end connectivity.

Software can be ported to other embedded Linux platforms to develop WI-SUN FAN based Border router solution. Reference cross compilation support has been provided for TI AM64x SK Platform (https://www.ti.com/tool/SK-AM64).

wfantund is designed to marshall all access to the NCP, ensuring that it always remains in a consistent and well-defined state.

License

wfantund is based on wpantund. wfantund is open-source software released under the Apache License, Version 2.0. See the file LICENSE for more information.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the [License][4] for the specific language governing permissions and limitations under the License.

Compilation and Installation

Linux OS (Ubuntu) Support

Refer to Install.md for compiling and installing wfantund and wfanctl in Ubuntu Linux OS.

Embedded Linux OS Support

Refer to Install_AM64x_sk.md for cross-compiling and installing wfantund and wfanctl for TI AM64x SK (https://www.ti.com/tool/SK-AM64).

Usage Overview

The behavior of wfantund is determined by its configuration parameters, which may be specified in a configuration file (typically /etc/wpantund.conf) or at the command line. A typical configuration file might look like that shown below. For a more thorough explanation of available configuration parameters, see the included example.

# Try to name the network interface `wpan0`.
# If not possible, a different name will be used.
Config:TUN:InterfaceName      "wfan0"

# The pathname of the socket used to communicate
# with the NCP.
Config:NCP:SocketPath         "/dev/ttyUSB0"

# The name of the driver plugin to use. The chosen
# plugin must support the NCP you are trying to use.
Config:NCP:DriverName         "spinel"

Configuring and monioring wfantund using TI's webserver (Recommended)

TI's webserver application has been provided in the /ti-wisun-webapp folder. This application allows the user to easily configure the border router, monitor the health of the network, and build other applications on top of it.

Note: Make sure to follow the installation instructions in the ti-wisun-webapp README.md for the correct npm/node versions

This application automatically starts wfantund on detecting the border router device.

For more information, go to /ti-wisun-webapp/README.md

Steps to run demo

  • Start the webserver found in /ti-wisun-webapp/
  • Connect one TI CC13x2R7 with TI Wi-SUN BR Image to Linux PC
  • Power on one (or few) Wi-SUN FAN Router devices
  • Wi-SUN FAN Router devices will start blinking their Green LED to show that they are trying to join network
  • Rate at which they blink will go down as they connect to network
  • Wi-SUN Router devices will stop blinking after they join the network (Note: It may take around 3-5 min for a node to join)
  • The webserver application can be visualized using any standard webbrowser to display the Wi-SUN FAN network as a graph
  • The webserver is designed to be a foundation that higher level applications can be developed on top of

Configuring wfantund using wfanctl (Alternate)

To use wfanctl, first start wfantund:

sudo /usr/local/sbin/wfantund -o Config:NCP:SocketPath `<Serial Port>`
example: sudo /usr/local/sbin/wfantund -o Config:NCP:SocketPath /dev/ttyACM0

When up and running, you can use wfanctl to get or set TI Wi-SUN FAN Parameters

To start wfanctl use

   $ sudo /usr/local/bin/wfanctl 

You can also pass in the specific interface name using the -I option when connecting to an interface with a non-default name

   $ sudo /usr/local/bin/wfanctl -I wfan0

To get/set properties use the get/set command.

example:

   wfanctl:wfan0> get panid
   0xABCD

The status of TI Wi-SUN Border Router along with some other related information like the daemon version can be obtained using the status command

wfanctl:wfan0> status
wfan0 => [
	"NCP:State" => "offline"
	"Daemon:Enabled" => true
	"NCP:Version" => "TIWISUNFAN/1.0.2; RELEASE; Dec 19 2024 21:44:28"
	"Daemon:Version" => "1.00.07 (0.07.01-397-g1f99dae-dirty; Dec 30 2024 19:47:08)"
	"Config:NCP:DriverName" => "spinel"
	"NCP:HardwareAddress" => [00124B0014F7D160]
	"Network:NodeType" => "0 : Border Router"
	"Network:PANID" => 0xABCD
]

For detailed list of all supported TI Wi-SUN FAN Command, please refer to ti_wisun_commands.md

The interface and stack can be started using the following command:

wfanctl:wfan0> set interface:up true

This brings up the stack interface and starts the NCP network stack.

Status of Interface can be checked by using the status command.

wfanctl:wfan0> status
wfan0 => [
	"NCP:State" => "associated"
	"Daemon:Enabled" => true
	"NCP:Version" => "TIWISUNFAN/1.0.1; RELEASE; Oct 28 2021 14:02:58"
	"Daemon:Version" => "1.00.07 (0.07.01-397-g1f99dae-dirty; Dec 30 2024 19:47:08)"
	"Config:NCP:DriverName" => "spinel"
	"NCP:HardwareAddress" => [00124B0014F7D160]
	"Network:NodeType" => "0 : Border Router"
	"Network:PANID" => 0xABCD
]

Note: associated in TI WI-SUN FAN Context implies that the TI Wi-SUN FAN Border Router has started.

Checking wfantund daemon version

To check the version of wfantund currently installed, run wfantund --version.

> wfantund --version
wfantund 1.00.07 (0.07.01-397-g1f99dae-dirty; Dec 30 2024 19:47:08)

When wfantund is already running, you can also check the daemon version in wfanctl using the status command.

Enabling host to embedded device IP communication

By default, wfantund will assign the created interface the same IP address as the device it is connected to. This means that traffic from the host destined to this address will be routed to the loopback interface instead of physically going out to the device. Wfantund can instead be configured to use its own unique IP address for the interface, allowing traffic to go freely to and from the embedded device. To enable this option, uncomment the IPv6:WfantundGlobalAddress option from wpandtund.conf or pass in the option on the command line when starting wfantund.

The default IPv6:WfantundGlobalAddress is 2020:ABCD::/64, which will create a route for any packets destined to an address prefixed with 2020:ABCD:0000:0000 out via the wfantund interface. When using default settings on the internal DHCP server on the border router or the external DHCP server detailed below, addresses given out will match this pattern. If you change away from this default prefix, keep in mind you may need to either update the addresses given out to nodes in the Wi-SUN network to use your new prefix, or manually create routes out through the interface. Prefix sizes other than /64 are not currently supported.

Using external Authentication and/or DHCPv6 Servers

The embedded border router project can be configured to route authentication and DHCP traffic up through wfantund. To actually handle this traffic, two example servers are provided via Docker under the external-serversfolder. Refer to the readme there to see how to configure and start the containers.

Using iperf with border router and router node TUN interfaces

The iperf bandwidth measurement tool can be used to calculate network throughput via the TUN interfaces created by wfantund. It is recommended to use two separate Linux instances to host the border router and router node interfaces to prevent loopback issues and ensure packets are routed through to the embedded devices.

For data rates higher than 50kbps, it is recommended to increase the embedded NCP buffer sizes and UART baud rates to support higher traffic through the spinel interface. The following adjustments should be made on src builds of embedded router and border router devices (from TI CC13XX_CC26XX SimpleLink SDK):

  • In wisun_ncp/src/ncp_config.h: Increase CONFIG_NCP_TX_BUFFER_SIZE to 2048
  • In wisun_ncp/src/ncp_config.h: Increase CONFIG_NCP_UART_TX_CHUNK_SIZE to 2048
  • In wisun_ncp/src/ncp_config.h: Increase CONFIG_NCP_UART_RX_BUFFER_SIZE to 2048
  • In wisun_ncp/platform/uart.c: In the function otPlatUartEnable, increase params.baudRate to 460800

The following adjustment should be made to wfantund builds:

  • In src/util/socket-utils: Increase gSocketWrapperBaud value to 460800;

Using wfantund and wfanctl with Wi-SUN router node

While the Linux webserver can only be used with Wi-SUN border routers, wfantund and wfanctl can also be used with Wi-SUN router nodes. Coap nodes cannot be used, only border routers and router nodes, as they are NCP-enabled examples while coap node examples are embedded-only.

The steps to using wfantund and wfanctl for router nodes are the same. The only difference is, once the interface is brought up using set interface:up true, the device will remain in the offline state, only transistioning to the associated state once the device has joined the network.

Checking if tun Interface is up.

When the stack is up, the TUN interface will be enabled. It can be verified by checking

$ ifconfig wfan0
wfan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1280  metric 1
    inet6 fe80::212:4b00:14f7:d160  prefixlen 64  scopeid 0x20<link>
    inet6 2020:abcd::212:4b00:14f7:d160  prefixlen 64  scopeid 0x0<global>
    inet6 fe80::31b1:1233:76ab:d3e5  prefixlen 64  scopeid 0x20<link>

Checking for connected devices

User can check for connected devices using the connecteddevices property

   wfanctl:wfan0> get connecteddevices
   connecteddevices = "
   List of connected devices currently in routing table:
   2020:abcd:0000:0000:0212:4b00:14f7:d102
   2020:abcd:0000:0000:0212:4b00:14f7:d2e8`

Interacting with connected devices

Using the TUN interface, users can directly communicate to devices over IPv6.

Ping specific devices

Users can ping devices using linux ping6 application and wfan0 interface

ping6 -I wfan0 <ip address>

Preparation of TI CC13xx Images:

Feature and Architecture Summary

wfantund based on wpantund provides:

  • ... a native IPv6 interface to an NCP.
  • ... a command line interface (wfanctl) for managing and configuring the NCP.
  • ... a DBus API for managing and configuring the NCP.
  • ... a way to reliably manage the power state of the NCP.
  • ... a uniform mechanism for handling NCP firmware updates.

The architecture and design of wfantund is based on wpantund which has been motivated by the following design goals (in no specific order):

  • Portability across Unix-like operating systems (currently supports Linux. BSD support should be fairly trivial to add)
  • Require few runtime dependencies (DBus, with boost needed when building)
  • Single-threaded architecture, with heavy use of asynchronous I/O
  • Power efficiency (0% CPU usage when idle)
  • Allow management interface to be used by multiple independent applications simultaneously
  • Allow multiple instances of wfantund to gracefully co-exist on a single machine
  • Modular, plugin-based architecture (all details for communicating with a specific NCP stack are implemented as plugins)

Note that Windows is not currently supported, but patches are welcome.

The following NCP plugins are provided:

  • src/ncp-spinel: Modified from those provided by wpantund to support TI Wi-SUN FAN Border Router.
  • src/ncp-dummy: A dummy NCP plug-in implementation meant to be the starting point for implementing new NCP plug-ins

Conceptual Overview

wfantund is based on wpantund and is conceptually similar in purpose to the point-to-point daemon (pppd, commonly used on Unix platforms to provide network connectivity via a dial-up modems) except that instead of communicating with a dial-up modem, wfantund is communicating with an NCP.

wfantund communicates with the NCP via an abstraction of a asynchronous stream socket, which could be any of the following:

  • A real serial port (UART) connected to the NCP (preferably with hardware flow control)
  • The stdin and stdout from a subprocess (for supporting SPI interfaces using a translator program or debugging virtual stacks)
  • A TCP socket (for debugging, not recommended for production)

Unlike a dial-up modem, NCPs often have a rich management interface for performing operations, such as forming a network, joining a network, scanning for nearby networks, etc. To perform these operations, wfantund includes a command line utility called wfanctl. Applications that need to directly configure the network interface can also communicate directly with wfantund using its DBus API.

To expose a native IPv6 network interface to the host operating system, wfantund uses the tun driver on Linux. On Linux, the default name for the interface is wfan0.

If compiled with libreadline or libedit, wfanctl supports an convenient interactive console. All commands support online help: type help to get a list of supported commands, or add -h to a command to get help with that specific command.

Support

Submit bugs and feature requests to https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum

Authors and Contributors

The following people have significantly contributed to the design and development of wfantund: Texas Instruments Inc

wpantund Authors

  • Robert Quattlebaum
  • Marcin Szczodrak
  • Vaas Krishnamurthy
  • Arjuna Siva
  • Abtin Keshavarzian