<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Extending Osate 2 for Custom Simulation of Virtual Devices</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Faber D. Giraldo</string-name>
          <email>fdgiraldo@uniquindio.edu.co</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Monica M. Villegas</string-name>
          <email>mmvillegasa@uqvirtual.edu.co</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Juan E. Medina</string-name>
          <email>juan@smartenit.com</email>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Smartenit Inc.</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>San Juan Capistrano</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>SINFOCI Research Group University of Quindío</institution>
          ,
          <country country="CO">Colombia</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>- When developers test cyber-physical systems, there may be a lack of enough physical devices. In such cases, a tool that allows virtual simulation of the devices is useful. In this work, we propose an extension named Custom Simulation of Virtual Devices (CSVD) developed for OSATE1 2, an Eclipse-based tool that supports Architecture and Analysis Design Language (AADL2) models. The CSVD extension allows the simulation of virtual serial devices specified in an AADL model inside the QEMU3 emulator, which is configured using the parameters specified in the AADL model of the designed system. An example of a system in this context is a local network of devices connected by a serial bus to a gateway with the purpose of simulating a data flow between the gateway and a device with serial connection.</p>
      </abstract>
      <kwd-group>
        <kwd>OSATE 2</kwd>
        <kwd>AADL</kwd>
        <kwd>QEMU</kwd>
        <kwd>Simulation</kwd>
        <kwd>CPS</kwd>
        <kwd>Model</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>INTRODUCTION</title>
      <p>
        Nowadays,  the  design  of  digital  systems  that  involve  the 
communication  between  external  devices  and  embedded 
systems has increased, for instance, in the area of automation, 
sensors  networking  or  IoT  design,  where  the  interaction 
between  devices  and  embedded  platforms  is  common. When 
the  software  for  such  embedded  systems  is  developed, 
simulating  the  devices  for  validating  the  software  becomes 
necessary. 
 
The  focus  of  this  work  is  to  present  an  extension  of  the 
OSATE  2  tool,  an  environment  that  supports  AADL  models 
and is based on the Eclipse4 platform. The extension presented 
in  this  work,  named  Custom  Simulation  of  Virtual  Devices 
(CSVD) is an Eclipse plugin that allows the analysis of AADL 
models  for  the  generation  of  files  that  are  needed  for  the 
execution of the simulation of devices specified in the AADL 
model.  The  simulation  is  executed  using  the  QEMU  [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] 
emulator, which is configured by the parameters defined in the 
AADL model of the designed system. 
The CSVD extension is useful for the OSATE 2 tool because it 
provides  an  environment  to  simulate  custom  virtual  devices, 
1 http://www.osate.org
2 http://www.aadl.info
3 https://www.qemu.org
4 https://www.eclipse.org
such  as  sensors  connected  to  a  gateway  through  a  device, 
responsible for collecting information and sending data over a 
serial  bus.  This  specific  scenario  emulates  a  system  where  a 
Zigbee5  dongle  is  used  for  controlling  a  network  of  sensors 
reporting  temperature  and  humidity  measurements 
periodically.  
 
The simulation runs in the QEMU emulator, which is launched 
using  the  configuration,  such  as  a  modeled  gateway.  The 
configuration  specifies  the  desired  platform  (supported  by 
QEMU), the operating system image, the kernel image, RAM 
size, and storage values.  
 
The usage of the CSVD extension is simple. The user needs to 
select the AADL model of the system, execute the generation 
of  required  files  for  the  simulation/emulation,  and  if  the 
process finishes successfully, proceed with the execution of the 
simulation  inside  the  emulator.  Debug  messages  are  also 
provided in the GUI of the CSVD extension in case the AADL 
model is not valid or if there were problems in the generation. 
 
Section 2 of this paper provides an introduction to the AADL 
language  as  an  AADL  review.  Section  3  presents  an 
introduction  to  the  OSATE  2  tool,  as  an  OSATE  2  review. 
Section  4  includes  a  description  of  related  tools.  Section  5 
contains  a  description  of  the  CSVD  extension  of  OSATE  2. 
Section  6  describes  a  case study to show a usage example of 
the  CSVD  extension.  Section  7  concludes  the  paper  and 
finally, Section 8 provides some future work proposed for this 
project.
      </p>
      <p>
        II.
Architecture  Analysis  &amp;  Design  Language  (AADL)  is  a 
modeling  language used for modeling embedded systems and 
representing  their  architecture  as  a  hierarchy  of  interacting 
components that allow the analysis of the modeled system.  
 
AADL  is  a  unifying  framework  for  model-based  software 
systems  engineering  which  can  be  used  to  capture  the static 
modular  software  architecture,  the  runtime  architecture 
5 http://www.zigbee.org
regarding  communicating  tasks,  the  computer  platform 
architecture  on  which  the  software  is  deployed,  and  any 
physical  system  or environment that the system interacts with 
[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. 
 
AADL  models  are  composed  of  components, properties, and 
notations.  For  components,  AADL  defines  the  categories  of 
data  type,  thread,  thread  group,  subprogram,  process, 
memory, bus, processor, device, virtual processor, virtual bus, 
system  and  abstract.  For  properties, predefined property sets, 
such  as  deployment  properties,  thread  properties,  timing 
properties,  communication  properties,  memory  properties, 
programming  properties,  modeling  properties,  and  AADL 
project  properties  [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].  As  an  example,  a  system  can  be 
modeled  from its abstraction, where a system is composed of 
subsystems, or a system can be composed of only devices. As 
shown  in  Figure  1,  an  AADL  model  of  a  system  can  have 
features and annexes. Features, in this case, is the specification 
of a serial bus in the system, and annexes can be used for extra 
details  that  are  not  considered  in  the  AADL  meta-model.  In 
Figure  2  is  shown  the  diagram  of  the  AADL  specified  in 
Figure 1, generated by the OSATE tool. 
 
 
OSATE  2  is  an  open  source  platform  that  fully  supports  the 
AADL  meta-model  and  which  is  based  on  the  Eclipse 
platform.  OSATE  2  provides  a  complete  textual  editor  for 
AADL and a set of simple analysis tools [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. This tool can be 
extended  to  allow,  for  instance,  the  addition  of  a 
simulation/emulation  launching  method.  Figure  3  shows  a 
snapshot  of  the  OSATE  2  environment,  containing  the 
example shown in Figures 1 and 2. 
 
After a review of extensions of OSATE 2 that provide analysis 
of  AADL  models  we  found  some  related  works  that  will be 
mentioned as follows: Delange et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] described an approach 
for  the  modeling,  verification,  and  implementation  of 
ARINC653  systems  using  AADL.  It  details  a  modeling 
approach  exploiting  the  new  features of AADL version 2 for 
the  design  of  ARINC653  architectures.  Delange’s  work  also 
proposed  modeling  patterns  to  represent  other  safety 
mechanisms  such  as  the  use  of  Ravenscar  for  critical 
applications.  
 
Hamdane et al. [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] proposed an approach for the verification of 
the  AADL  architecture,  which  is  assisted  by  a  toolchain. 
Hamdane’s  work  [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] defined a source meta-model for AADL 
and  a  target  meta-model  for  the  timed  automata  formalism. 
The  transformation  process  works  in  two  steps,  a 
Model2Model  transformation,  which  takes  an  AADL  Model 
and  produces  the  appropriate  timed  automata  model,  and  a 
transformation of a Model2 Text which takes a timed automata 
model  and  generates  code,  which  is  accepted  by  the  Uppaal 
toolbox.  
 
The  difference  between  works [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], and the one presented 
in this paper, is that our proposal is focused on the simulation 
of  serial  devices  inside  an  emulated  environment  with 
controlled parameters from the architectural model.  
 
Our  work  allows  the  interaction  with  the  devices  modeled 
inside  the  emulator,  and  is  useful  for  the  validation  of 
embedded  software,  such  as  software  for  ARM-based 
platforms. 
      </p>
    </sec>
    <sec id="sec-2">
      <title>CSVD EXTENSION FOR OSATE 2 TOOL</title>
      <p>For  using the CSVD extension, it is necessary to click on the 
CSVD launching icon that is located in the Toolbar of OSATE 
2  as  shown  in  Figure  5.  After  clicking  the  CSVD  launching 
icon,  a  graphical  user  interface  (GUI)  is  displayed  as 
illustrated in Figure 6, which allows the loading of the AADL 
model, the generation of the required files and the executing of 
the  simulation.  The  button  for  the  simulation  execution  is 
enabled  if  the  generation  process  is  successfully  finished. 
Also,  below  the  ‘Execute  Generation’  button  is  a  label  that 
shows  the  messages  related  to  the status of the generation of 
required files, allowing the user to know if the process had an 
error or if it finished successfully. 
 
 
 
The  generation  of  the  required  files  is  based  on  a  python 
process that loads specific rules written in JSON format, rules 
that  are  specified by the user/developer and which are related 
to  the  way  specific  commands  and  configurations  will  be 
generated  from  the  AADL  model  of  the  designed  system. 
After  the  Python  process  generates  the  required  files,  the 
Operating System (OS) image that QEMU starts with, must be 
reconfigured through an OS image modifier. The modification 
to the OS image is done by a process that unpacks it, adds the 
generated  and  required  files  including  the  process  that 
simulates  the  devices  and  a  script  to  launch  the  simulation 
inside  the  emulator.  After  the  addition  of  the  files  is 
completed, the OS image is re-packed and ready to be started. 
 
The  launch  of  the  QEMU  emulator  is  executed  through  the 
button  in  the  Plugin GUI. After the window of the QEMU is 
displayed  and  the  OS  starts,  the  data  stream  received  on the 
serial  port  from  the  simulated  devices  inside  the  QEMU 
emulator  can  be  read  and  made  available  to be processed by 
specific software. 
In  this  section, a system composed of two sensors, one serial 
device receiving data from the two sensors and one serial bus 
that connects the serial device with the gateway is modeled as 
an  example  (shown  in  Figure  7).  Each  sensor  has  a  MAC 
address which can be used to identify them.  
 
Figure  8  shows  the declaration of the systems and devices of 
the  model,  where  the  extra details are specified, for instance, 
QEMU  kernel  image  path,  OS  image path and CPU type for 
the  emulation.  For  the  sensors,  the  MAC  address,  and  the 
mean  and  deviation  parameters  for  the  random  values 
generated from the sensors are specified. 
 
Fig. 7. System Modeled. </p>
      <p> 
 
 </p>
      <p>The  expected  output  of  this  simulation  is  to view data being 
generated  on  the  virtual  serial  port  in  the  QEMU  emulator 
with  the  MAC  address  of  each  sensor  modeled.  This  data 
could  be  used  by  a  software  process,  by  reading  and 
processing  it  according  to  specific  requirements,  such  as 
temperature values from a sensor, where a data package could 
contain start and end bytes, the MAC address and the payload 
including the temperature value of the sensor. 
 
Figure  9  describes  the  implementation  of  the  systems  and 
devices. The connections between the devices and systems are 
specified. The subcomponents area specifies the RAM size and 
CPU type for the gateway.  
 
Figure 10 shows the interface of the virtual port created from 
the AADL model inside QEMU. Two virtual ports are created, 
one  for  reading  and  one  for  writing  to  the  simulated  serial 
device.  Currently,  the  version  of  this  extension  supports 
reading data from the devices but not writing.  
 
Figure 11 shows the data being received from the serial device 
that collects the data from the sensors. The simple verification 
is  to  check  that  the  data  is  from  the  modeled  sensors  by 
analyzing  the  values  in  the  data  package  and  comparing  the 
MAC  address  with  the  one  specified  in  the  model,  this, 
because  the  MAC  address  inside  the  data  package  (marked 
with blue in Figure 11) must match the MAC address of each 
sensor specified in the model (Figure 8). With this, a software 
that  needs  data  from  several  simulated  devices  can  read  the 
port and process the information received.  
 
For this example, only two sensors were modeled, but both the 
language and the simulation/emulation system supports several 
more devices. 
 
The  CSVD  plugin  developed  for  OSATE  2  is  extensible.  It 
allows the addition of new types of models and systems. In its 
current  state,  the  support  is  limited  regarding  specific 
simulation  systems  that  can  be  customized.  The  work 
described in this paper could be useful for future modifications 
or  specific  code  generation  with  simulation/emulation 
purposes.  Modifications  to  the  plugin  can  be  done  easily  by 
adding  new  support,  allowing  developers  to  create  new 
simulations  of  other  kinds  of  devices  available in the AADL 
language  and  that  can  be  somehow  linked  to  other  kinds  of 
simulators and emulators.  
 
The primary idea of the CSVD plugin is to provide serial data 
packages for them to be used in software processes running in 
the  QEMU  emulator,  such  as  processes  that  need  serial data 
for testing purposes. 
 
We  propose  the  addition  of  other  QEMU  like emulators that 
can  be  used  for  simulating  the  system  on  other  embedded 
systems  architectures.  We also propose to continue extending 
the  functionalities  of  the  “files  generation”  and  “execute 
simulation”  components  to  add  support  for  new  devices  and 
protocols. </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Peter  H. Feiler</surname>
          </string-name>
          , David P. Gluch, 
          <article-title>“Model-Based Engineering with  AADL”</article-title>
          ,
          <source>Addison-Wesley</source>
          <year>2012</year>
           
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2] SEI,  “AADLv2  Cheat  Sheet:  Basics”,  Available:  https://wiki.sei.cmu.edu/aadl/images/a/ac/Aadlsheet_letter.pdf, 
          <source>Accessed: July</source>
          <year>2017</year>
           
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3] SEI,  “Osate  2”,  Available:  https://wiki.sei.cmu.edu/aadl/index.php/Osate_2,  Accessed:  July 
          <year>2017</year>
           
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Julien</surname>
          </string-name>
            Delange,  Laurent  Pautet,  Alain  Plantec,  Mickael  Kerboeuf,  Frank  Singhoff, and Fabrice Kordon. 
          <year>2009</year>
          . Validate,  simulate, 
          <article-title>and implement ARINC653 systems using the AADL</article-title>
          .  In  Proceedings  of  the  ACM  SIGAda  annual  international  conference  on  Ada  and  related  technologies  (SIGAda  '
          <volume>09</volume>
          ).  ACM,  New  York,  NY,  USA, 
          <volume>31</volume>
          -
          <fpage>44</fpage>
          .  DOI=http://dx.doi.org/10.1145/1647420.1647435 
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5] QEMU,  “QEMU”,  Available: http://www.qemu.org/, Accessed: 
          <source>July</source>
          <year>2017</year>
           
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>M.</surname>
          </string-name>
           Hamdane, A. Chaoui and M. Strecker, 
          <article-title>"Toolchain Based on  MDE  for  the  Transformation  of  AADL  Models  to  Timed  Automata  Models,"</article-title>
            Journal  of  Software  Engineering  and  Applications,  Vol. 
          <volume>6</volume>
            No. 
          <volume>3</volume>
          , 
          <year>2013</year>
          ,  pp. 
          <fpage>147</fpage>
          -
          <lpage>155</lpage>
          .  doi: 
          <volume>10</volume>
          .4236/jsea.
          <year>2013</year>
          .
          <volume>63019</volume>
          . 
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>