SHM segment was created with. That means, to
execute several HW-SW co-simulators, each QEMU
and SystemC simulator pair needs to use a different
key for their private SHM segment, otherwise all co-
simulators would work on a single SHM segment,
which would lead to an undefined result.
To have each co-simulation use its own private
SHM segment, the key to identify it, is supplied as
an environment variable. It is read at creation time
of the SHM segment in QEMU and again in the Sys-
temC simulator when it maps the SHM segment into
its own address space. The control over correct SHM
mapping among all co-simulators on the same host
computer is handed over to the supervisor of the smart
home network simulation.
5.2 Ethernet Simulation
In this work, we assume the nodes exchange data in
a smart home Ethernet network. We assume it is
transparent to the software if it exchanges data via
wired or wireless Ethernet. We use the Virtual Dis-
tributed Ethernet (Davoli, 2005) framework to sim-
ulate an Ethernet network, which works by start-
ing the vde switch program. It creates a socket in
/tmp/vde.ctl to which each QEMU can connect to
communicate over the simulated VDE network. No
changes were necessary to make QEMU utilize VDE,
since that support is already implemented. QEMU
needs to be started with the command line parameter
-net vde,sock=/tmp/vde.ctl amongst other.
The above method allows to simulate a limited
number of nodes, as the simulated nodes consume
processor time, until the host processor is used to ca-
pacity. vde switch allows to overcome this limita-
tion by connecting them transparently through Linux
tunnel virtual Ethernet devices with each other. A
smart home network of 10 hosts, each running 10
HW-SW co-simulators as smart home network nodes
can simulate a network of 100 nodes by tunneling the
vde switch connections.
5.3 Node Software Preparation
Regarding the example mentioned in Section 5.2 of
simulating 100 nodes, a preparation for such a simu-
lation quantity by hand would be a tedious task. To
avoid such a torture, we implemented the tool gen-
flock to generate startup scripts containing calls to
start each QEMU and prepare its disk image from a
template image and application payload per node.
For genflock, we prepared a Debian GNU/Linux
1
template disk image. Genflock expects as parame-
1
https://www.debian.org/
ters a template disk image file, the number of nodes
to generate, the size of the Random Access Mem-
ory (RAM) for each node and a hostname prefix for
each node, which will be enumerated as a suffix. If
the hostname is set to sheep, the nodes will be given
names beginning with sheep-01, sheep-02 and so on.
To prepare data, or compile and install soft-
ware, a pre-installation and post-installation hook-
mechanism can execute arbitrary tasks. If a file nn pre
exists, each line in it will be executed as a shell com-
mand. This should be used to compile software to be
installed in the image. Arbitrary directories and files
can be installed into a specific disk image, when a
directory nn payload exists. The content of this di-
rectory will be installed unmodified in the disk im-
age. If a file nn post exists, each line in it will be exe-
cuted after nn payload was copied into the disk image
filesystem tree. This allows adjustments, e.g. correct-
ing file permissions and flags. We use the program
guestmount from the libguestfs project(Jones, 2010)
to mount the first partition of our template disk image
via File System in User Space (FUSE) (Rajgarhia and
Gehani, 2010).
6 RESULTS
As we presented our implementation of our frame-
work for a smart home network simulation, our goal
is a successful generation of a test environment of 10
nodes for one host machine (See Section 8 regarding
inter-host simulation). We implement a sensor node
hardware description in SystemC, switches every 5
seconds between two fixed light intensities and sends
them to the host processor. As actuator hardware, we
implement a light controller, that prints out the cur-
rently set light intensity to the text console. To proof
working network functionality, each node uses avahi
2
to discover the remaining 9 nodes in the simulated
network. We use the Linux utility lspci to discover
the hybrid emulated/simulated hardware sensor and
actuator.
It takes 38 seconds to start 10 nodes on a Intel
Core i7 CPU, each node equipped with 256MiB of
RAM, while the disk image format is qcow2 and the
underlying file system is a Btrfs of Linux 3.16 on a
7200rpm hard disk. Figure 7 shows the output of the
service and network discovery tool avahi-browse, dis-
playing the successful discovery in QEMU of all 10
nodes in the simulated network.
Figure 8 shows the driver initialization debug out-
put of our test driver for the emulated registers and the
2
http://www.avahi.org/
Hardware-software Co-simulation of Self-organizing Smart Home Networks - Who am I and Where Are the Others?
309