Network tools for testing with Qemu
Switch branches/tags
Nothing to show
Clone or download
jukkar radvd: Add support for native_posix board
Use zeth interface if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Latest commit a39a3ff Aug 16, 2018
Permalink
Failed to load latest commit information.
libcoap libcoap: Add missing m4 definitions Jan 25, 2017
mbedtls-2.4.0 mbedtls: Import mbedtls version 2.4.0 to net-tools Aug 1, 2017
systemd systemd: added unit files to start tap0 Apr 17, 2017
tinydtls-0.8.2 tinydtls: Fix compilation errors Jan 25, 2017
virtual-hub virtual-hub: Component to connect multiple 802.15.4 qemu nodes Feb 1, 2018
.gitignore virtual-hub: Component to connect multiple 802.15.4 qemu nodes Feb 1, 2018
.shippable.yml ci: do no rebase commits Aug 5, 2017
Makefile throughput-client: Send UDP packets to peer Feb 1, 2018
README.legacy readme: Clarified the instructions in readme file Aug 30, 2016
README.md README.md: fix section header Aug 5, 2017
avahi-daemon.conf avahi: Add example config and start script for mDNS testing Oct 17, 2017
avahi-daemon.sh avahi: Add example config and start script for mDNS testing Oct 17, 2017
big-file.html http: Add a simple HTTP server for testing May 5, 2017
coap-client.c Fix compilation warnings Jan 25, 2017
dnsmasq.conf dnsmasq: Change the default listening port Oct 17, 2017
dnsmasq.sh dnsmasq: Add www.zephyrproject.org to address lists Jun 5, 2017
dtls-client.c dtls-client: Convert to use mbedtls Aug 1, 2017
dtls-server.c dtls-server: Convert to use mbedtls Aug 1, 2017
echo-apps-cert.pem stunnel: Add info how to run echo apps over encrypted link Jun 30, 2017
echo-apps-key.pem stunnel: Add info how to run echo apps over encrypted link Jun 30, 2017
echo-client.c echo-client: Add -p option to setup the peer port Jun 30, 2017
echo-server.c echo-server: Try to recover from errors Jan 17, 2018
http-server.py http: Add a simple HTTP server for testing May 5, 2017
https-server.pem https: Add a simple HTTPS server for testing Jun 6, 2017
https-server.py https: Add a simple HTTPS server for testing Jun 6, 2017
index.html http: Add a simple HTTP server for testing May 5, 2017
loop-radvd.sh radvd: Add support for native_posix board Aug 17, 2018
loop-slip-tap.sh tunslip6: reload slip without restarting tap Jun 14, 2017
loop-slip.sh loop-scripts: Fix the location of net-tools directory Feb 27, 2017
loop-socat.sh loop-socat.sh: Remove /tmp/slip.sock on start. Apr 13, 2017
monitor_15_4.c monitor_15_4: Do not access uninitialized variables Oct 19, 2017
radvd_native_posix.conf radvd: Add support for native_posix board Aug 17, 2018
radvd_slip.conf radvd: Add support for native_posix board Aug 17, 2018
stunnel.conf stunnel: Add info how to run echo apps over encrypted link Jun 30, 2017
stunnel.sh stunnel: Add info how to run echo apps over encrypted link Jun 30, 2017
tcptest.py tcptest: Fix wrong variable type in in print() call Nov 30, 2016
throughput-client.c throughput-client: Send UDP packets to peer Feb 1, 2018
tunslip6.c tunslip6: increase SLIP buffer size to fit escape characters Feb 7, 2018

README.md

Run Status

Networking Tools

The comments and instructions below are for the new IP stack in Zephyr.

Here are instructions how to communicate between Zephyr that is running inside QEMU, and host device that is running Linux.

You need to run socat and tunslip to create a minimally working network setup.

There are convenience scripts (loop-socat.sh and loop-slip-tap.sh) for running socat and tunslip6 processes. For running these, you need two terminals.

Terminal 1:

$ ./loop-socat.sh

Terminal 2:

$ sudo ./loop-slip-tap.sh

After running these scripts you do not need to manually restart them when qemu process stops.

In the Qemu side, you need to compile the kernel with proper config. Minimally you need these settings active in your project config file.

CONFIG_NETWORKING=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_YAIP=y
CONFIG_NET_UDP=y
CONFIG_NET_LOG=y
CONFIG_NET_SLIP=y
CONFIG_SLIP_TAP=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_TEST_RANDOM_GENERATOR=y

After you have the loop scripts and Qemu running running you can communicate with the Zephyr.

If your have echo-server running in the Qemu, then you can use the echo-client tool in net-tools directory to communicate with it.

# ./echo-client -i tap0 2001:db8::1

The IP stack responds to ping requests if properly configured.

$ ping6 -I tap0 -c 1 2001:db8::1

You can attach wireshark to tap0 interface to see what data is being transferred.

If building with CONFIG_NET_TCP=y in your project config file, it's possible to run the echo-server sample in Zephyr, and then test the TCP stack using the supplied tcptest.py script:

$ ./tcptest.py tap0 2001:db8::1

This script will send numbers to the echo-server program, read them back, and compare if it got the exact bytes back. Transmission errors, timeouts, and time to get the response are all recorded and printed to the standard output.

Be sure to use Python 3, as it requires a function from the socket module that's only available in this version (wrapper around if_nametoindex(3)).

Using encrypted SSL link with echo-* programs

Install stunnel

Fedora:

$ dnf install stunnel

Ubuntu:

$ apt-get install stunnel4 -y

Finally run the stunnel script in Linux

$ ./stunnel.sh

And connect echo-client to this SSL tunnel (note that the IP address is the address of Linux host where the tunnel end point is located).

$ ./echo-client -p 4243 2001:db8::2 -t

If you are running echo-client in Zephyr QEMU, then run echo-server like this:

$ ./echo-server -p 4244 -i tap0

If you want to re-create the certificates in echo-server and echo-client in Zephyr net samples, then they can be created like this (note that you do not need to do this as the certs have been prepared already in echo-server and echo-client sample sources):

$ openssl genrsa -out echo-apps-key.pem 2048
$ openssl req -new -x509 -key echo-apps-key.pem -out echo-apps-cert.pem \
    -days 10000 -subj '/CN=localhost'

The cert that is to be embedded into test_certs.h in echo-server and echo-client, can be generated like this:

$ openssl x509 -in echo-apps-cert.pem -outform DER | \
    hexdump -e '8/1 "0x%02x, " "\n"' | sed 's/0x  ,//g'

The private key to be embedded into test_certs.h in echo-server can be generated like this:

$ openssl pkcs8 -topk8 -inform PEM -outform DER -nocrypt \
    -in echo-apps-key.pem | hexdump -e '8/1 "0x%02x, " "\n"' | \
    sed 's/0x  ,//g'

Using DTLS link with echo-* programs

For DTLS client functionality, you can do this

$ ./dtls-client -c echo-apps-cert.pem 2001:db8::1

or

$ ./dtls-client -c echo-apps-cert.pem 192.0.2.1

For DTLS server functionality, you can do this

$ ./dtls-server

TLS connecitivity errors

If you see this error print in zephyr console

[net/app] [ERR] _net_app_ssl_mainloop: Closing connection -0x7180 (SSL - Verification of the message MAC failed)

Then increasing the mbedtls heap size might help. So you can set the option CONFIG_MBEDTLS_HEAP_SIZE to some higher value.

Example:

CONFIG_MBEDTLS_HEAP_SIZE=30000