README.rst
1.. _networking_samples_common:
2
3Overview
4********
5
6Various network samples can utilize common code to enable generic
7features like VLAN support.
8
9The source code for the common sample can be found at:
10:zephyr_file:`samples/net/common`.
11
12VLAN
13****
14
15If you want to enable VLAN support to network sample application,
16then add :file:`overlay-vlan.conf` to your sample application compilation
17like in this example for echo-server sample application:
18
19.. zephyr-app-commands::
20 :zephyr-app: samples/net/sockets/echo_server
21 :host-os: unix
22 :board: native_sim
23 :conf: "prj.conf overlay-vlan.conf"
24 :goals: run
25 :compact:
26
27You host setup for the VLAN can be done like this:
28
29.. code-block:: console
30
31 $ cd tools/net-setup
32 $ ./net-setup.sh -c zeth-vlan.conf
33
34The example configuration will create this kind of configuration:
35
36* In host side:
37
38 * Normal ``zeth`` interface is created. It has ``192.0.2.2/24``
39 address. All the network traffic to Zephyr will go through this
40 interface.
41
42 * VLAN interface ``vlan.100`` is used for VLAN tag 100 network traffic.
43 It has ``198.51.100.2`` IPv4 and ``2001:db8:100::2`` IPv6 addresses.
44
45 * VLAN interface ``vlan.200`` is used for VLAN tag 200 network traffic.
46 It has ``203.0.113.2`` IPv4 and ``2001:db8:200::2`` IPv6 addresses.
47
48* The network interfaces and addresses in Zephyr side:
49
50 * The ``eth0`` is the main interface, it has ``192.0.2.1/24``
51 address and it has connection to the host.
52
53 * The ``VLAN-100`` is a virtual interface for VLAN tag 100 traffic.
54 It has ``198.51.100.1/24`` IPv4 and ``2001:db8:100::1/64`` addresses.
55
56 * The ``VLAN-200`` is a virtual interface for VLAN tag 200 traffic.
57 It has ``203.0.113.1/24`` IPv4 and ``2001:db8:200::1/64`` addresses.
58
59.. warning::
60
61 The IPv4 and IPv6 addresses used in the samples are not to be used
62 in any live network and are only meant for these network samples.
63 These IPv4 and IPv6 addresses are meant for documentation use only and
64 are not routable.
65