Networking with native_posix board
This page describes how to set up a virtual network between a (Linux) host and a Zephyr application running in a native_posix board.
In this example, the Socket Echo Server sample application from the Zephyr source distribution is run in native_posix board. The Zephyr native_posix board instance is connected to a Linux host using a tuntap device which is modeled in Linux as an Ethernet network interface.
On the Linux Host, fetch the Zephyr
net-tools project, which is located
in a separate Git repository:
git clone https://github.com/zephyrproject-rtos/net-tools
For the steps below, you will need three terminal windows:
Terminal #1 is terminal window with net-tools being the current directory (
Terminal #2 is your usual Zephyr development terminal, with the Zephyr environment initialized.
Terminal #3 is the console to the running Zephyr native_posix instance (optional).
Before starting native_posix with network emulation, a network interface should be created.
In terminal #1, type:
You can tweak the behavior of the net-setup.sh script. See various options
net-setup.sh like this:
Build and start the
echo_server sample application.
In terminal #2, type:
west build -b native_posix samples/net/sockets/echo_server west build -t run
The console window should be launched automatically when the Zephyr instance is started but if it does not show up, you can manually connect to the console. The native_posix board will print a string like this when it starts:
UART connected to pseudotty: /dev/pts/5
You can manually connect to it like this: