1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/zep_dispatch
2024-10-09 13:03:52 +02:00
..
.gitignore tools/zep_dispatch: add topology generator 2022-01-05 13:34:31 +01:00
example.topo tools/zep_dispatch: allow to pin nodes to MAC address 2022-02-22 17:35:04 +01:00
main.c treewide: apply codespell corrections 2024-10-09 13:03:52 +02:00
Makefile Merge pull request #17338 from benpicco/tools/zep_dispatch-mac_pin 2022-05-06 21:52:13 +02:00
README.md tools/zep_dispatch: send frames to virtual 802.15.4 interface 2022-08-02 10:55:59 +02:00
start_network.sh examples/gnrc_border_router: enable setting ZEP topology 2023-10-20 17:51:05 +02:00
topogen.c tools/zep_dispatch: topogen: add help text 2023-12-21 23:17:53 +01:00
topogen.sh tools/zep_dispatch: run dispatch with custom topology 2022-06-07 09:39:35 -04:00
topology.c tools/zep_dispatch: allow list of nodes in topo file 2023-12-21 23:17:53 +01:00
topology.h tools/zep_dispatch: count rx/tx frames 2023-10-19 15:02:56 +02:00
zep_parser.c tools/zep_dispatch: add function to get payload from ZEP frame 2022-06-19 23:22:23 +02:00
zep_parser.h tools/zep_dispatch: add function to get payload from ZEP frame 2022-06-19 23:22:23 +02:00

ZEP packet dispatcher

The ZEP dispatcher is a simple daemon that forwards ZEP packets to all connected nodes.

usage: zep_dispatch [-t topology] [-s seed] [-g graphviz_out] <address> <port>

By default the dispatcher will forward every packet it receives to every other connected node (flat topology).

Advanced Topology Mode

It is possible to simulate a more complex topology as well as packet loss by specifying a topology file.

The file format is:

<node_a> <node_b> [weight_ab] [weight_ba]

This line defines a connection between <node_a> and <node_b>. The weight of the edge <node_a> -> <node_b> is <weight_ab>.

An edge weight is a float value between 0 and 1 that represents the probability of a successful packet transmission on that path.

A weight of 0 would mean no connection, whereas a weight of 1 would be a perfect connection. Intermediate values are possible, e.g. 0.6 would result in a packet loss probability of 40%.

The weights can be omitted. If both weights are omitted, a perfect connection is assumed. If <weight_ba> is omitted, a symmetric connection is assumed and <weight_ab> is used for both directions.

refer to the file example.topo for an example.

There can only be as many nodes connected to the dispatcher as have been named in the topology file. Any additional nodes that try to connect will be ignored.

Packet capture

To view traffic in Wireshark you need to create a virtual 802.15.4 device to which the network traffic is sent. This can then be selected as a capture source in Wireshark.

To create the virtual device, load the mac802154_hwsim module

sudo modprobe mac802154_hwsim

This will create two wpan devices, wpan0 and wpan1.

If you then run the dispatcher with

sudo zep_dispatch -w wpan0 ::1 17754

all traffic on the simulated network will be also sent to the virtual wpan0 interface where it can be captures with Wireshark.

Network visualization

It is possible to generate a graph of the current simulated network by executing the

make graph

target. This sends a USR1 signal to the zep_dispatch process to generate a graph in Graphviz format.

Foren6

For real-time visualization of the (RPL) network, the Foren6 tool can be used.

Support for ZEP dispatcher is currently only available through a fork.

Foren6 setup

Start foren6 with the make run target and in the 'Manage Sources' menu, add a ZEP sniffer:

The 'target' field takes a hostname:port combination, but you can leave it blank. In that case the default [::1]:17754 will be used.

Foren6 usage

Foren6 will connect to a running ZEP dispatcher. If the dispatcher started after Foren6 or if the dispatcher was restarted, you have to re-connect by stopping the current capture ('Stop' button) and starting it again ('Start' button).

You should see a view of the DODAG with all nodes in the network as they send packets.

RIOT setup

A proper simulated network will need a border router and some mesh nodes. The gnrc_border_router and gnrc_networking can serve as a starting point for those.

By default the border router example will start the ZEP dispatcher with a flat topology, that is each node is connected to every other node. This makes for a very boring topology where no RPL is needed.

To run the ZEP dispatcher with a custom topology, simply run it before the gnrc_border_router example. You can use the make run target which will default to the example.topo topology. This can be changed with the TOPOLOGY environment variable.

Next, start the border router example with RPL enabled:

USEMODULE=gnrc_rpl make -C examples/gnrc_border_router all term

Verify that the border router got a prefix on it's downstream interface with ifconfig.

Iface  7  HWaddr: 36:DE  Channel: 26  NID: 0x23
          Long HWaddr: BE:92:89:04:D7:B4:B6:DE
          L2-PDU:102  MTU:1280  HL:64  RTR
          RTR_ADV  6LO  IPHC
          Source address length: 8
          Link type: wireless
          inet6 addr: fe80::bc92:8904:d7b4:b6de  scope: link  VAL
     -->  inet6 addr: 2001:db8::bc92:8904:d7b4:b6de  scope: global  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ffb4:b6de
          inet6 group: ff02::1a

Iface  6  HWaddr: 7A:37:FC:7D:1A:AF
          L2-PDU:1500  MTU:1500  HL:64  RTR
          Source address length: 6
          Link type: wired
          inet6 addr: fe80::7837:fcff:fe7d:1aaf  scope: link  VAL
          inet6 addr: fe80::2  scope: link  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ff7d:1aaf
          inet6 group: ff02::1:ff00:2

Now start as many gnrc_networking nodes as you have mesh nodes defined in your topology file:

USE_ZEP=1 make -C examples/gnrc_networking all term
USE_ZEP=1 make -C examples/gnrc_networking all term
…

The node should be able to join the DODAG as you can verify with the rpl command:

instance table:	[X]
parent table:	[X]	[ ]	[ ]

instance [0 | Iface: 7 | mop: 2 | ocp: 0 | mhri: 256 | mri 0]
	dodag [2001:db8::bc92:8904:d7b4:b6de | R: 768 | OP: Router | PIO: on | TR(I=[8,20], k=10, c=119)]
		parent [addr: fe80::6467:2e89:b035:d51f | rank: 512]

This should also be visible in Foren6.

Topology generation

To generate a random topology use the topogen.sh script. This will randomly distribute N nodes on on a W × H map. Each node has a radio range R ± V where V is a random variance that can also be set to 0.

The further away a node is from a sending node, the higher the packet loss probability. Nodes outside the sending radius have a zero probability of receiving a packet.

If you have gnuplot installed this will also generate a plot of the resulting node distribution:

example topology

A light color means that a node only has a one-way connection to the network, gray means a node is entirely isolated.