1.. _networking_with_ieee802154_qemu:
2
3Networking with QEMU and IEEE 802.15.4
4######################################
5
6.. contents::
7    :local:
8    :depth: 2
9
10This page describes how to set up a virtual network between two QEMUs that
11are connected together via UART and are running IEEE 802.15.4 link layer
12between them. Note that this only works in Linux host.
13
14Basic Setup
15***********
16
17For the steps below, you will need two terminal windows:
18
19* Terminal #1 is terminal window with ``echo-server`` Zephyr sample application.
20* Terminal #2 is terminal window with ``echo-client`` Zephyr sample application.
21
22If you want to capture the transferred network data, you must compile the
23``monitor_15_4`` program in ``net-tools`` directory.
24
25Open a terminal window and type:
26
27.. code-block:: console
28
29   cd $ZEPHYR_BASE/../net-tools
30   make monitor_15_4
31
32
33Step 1 - Compile and start echo-server
34======================================
35
36In terminal #1, type:
37
38.. zephyr-app-commands::
39   :zephyr-app: samples/net/sockets/echo_server
40   :host-os: unix
41   :board: qemu_x86
42   :build-dir: server
43   :gen-args: -DEXTRA_CONF_FILE=overlay-qemu_802154.conf
44   :goals: server
45   :compact:
46
47If you want to capture the network traffic between the two QEMUs, type:
48
49.. zephyr-app-commands::
50   :zephyr-app: samples/net/sockets/echo_server
51   :host-os: unix
52   :board: qemu_x86
53   :build-dir: server
54   :gen-args: -G'Unix Makefiles' -DEXTRA_CONF_FILE=overlay-qemu_802154.conf -DPCAP=capture.pcap
55   :goals: server
56   :compact:
57
58Note that the ``make`` must be used for ``server`` target if packet capture
59option is set in command line. The ``build/server/capture.pcap`` file will contain the
60transferred data.
61
62Step 2 - Compile and start echo-client
63======================================
64
65In terminal #2, type:
66
67.. zephyr-app-commands::
68   :zephyr-app: samples/net/sockets/echo_client
69   :host-os: unix
70   :board: qemu_x86
71   :build-dir: client
72   :gen-args: -DEXTRA_CONF_FILE=overlay-qemu_802154.conf
73   :goals: client
74   :compact:
75
76You should see data passed between the two QEMUs.
77Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
78