<!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>An Approach for the Engineering of Protocol Software from Coloured Petri Net Models: A Case Study of the IETF WebSocket Protocol</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Lars Michael Kristensen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Invited Talk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computing, Bergen University College</institution>
          ,
          <country country="NO">Norway</country>
        </aff>
      </contrib-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>The vast majority of software systems today can be characterised as
concurrent and distributed systems as their operation inherently relies on protocols
executed between independently scheduled software components. The
engineering of correct protocols can be a challenging task due to their complex behaviour
which may result in subtle errors if not carefully designed. Ensuring
interoperability between independently made implementations is also challenging due to
ambiguous protocol specifications. Model-based software engineering offers
several attractive benefits for the implementation of protocols, including automated
code generation for different platforms from design-level models. Furthermore,
the use of formal modelling in combination with model checking provides
techniques to support the development of reliable protocol implementations.</p>
      <p>
        Coloured Petri Nets (CPNs) [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] is formal language combining Petri Nets
with a programming language to obtain a modelling language that scales to
large systems. In CPNs, Petri Nets provide the primitives for modelling
concurrency and synchronisation while the Standard ML programming language
provides the primitives for modelling data and data manipulation. CPNs have
been successfully applied for the modelling and verification of many protocols,
including Internet protocols such as the TCP, DCCP, and DYMO protocols [
        <xref ref-type="bibr" rid="ref1 ref4">1,
4</xref>
        ]. Formal modelling and verification have been useful in gaining insight into the
operation of the protocols considered and have resulted in improved protocol
specifications. However, earlier work has not fully leveraged the investment in
modelling by also taking the step to automated code generation as a way to
obtain an implementation of the protocol under consideration.
      </p>
      <p>
        In earlier work [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], we have proposed the PetriCode approach and a
supporting software tool [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] has been developed for automatically generating protocol
implementations based on CPN models. The basic idea of the approach is to
enforce particular modelling patterns and annotate the CPN models with code
generation pragmatics. The pragmatics are bound to code generation templates
and used to direct a template-based model-to-text transformation that generates
the protocol implementation. As part of earlier work, we have demonstrated the
use of the PetriCode approach on small protocols. In addition, it has been shown
that our approach supports code generation for multiple platforms, and that it
leads to code that is readable and also compatible with other software [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>PNSE’14 – Petri Nets and Software Engineering</p>
      <p>
        In the present work we consider the application of our code generation
approach as implemented in the PetriCode tool to obtain protocol software
implementing the IETF WebSocket protocol [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] protocol for the Groovy language
and platform. This demonstrates that our approach and tool scales to
industrialsized protocols. The WebSocket protocol is a relatively new protocol and makes
it possible to upgrade an HTTP connection to an efficient message-based
fullduplex connection. WebSocket has already become a popular protocol for several
web-based applications such as games and media streaming services where
bidirectional communication with low latency is needed.
      </p>
      <p>
        The contributions of our work include showing how we have been able to
model the WebSocket protocol following the PetriCode modelling conventions.
Furthermore, we perform formal verification of the CPN model prior to code
generation, and test the implementation for interoperability against the Autobahn
WebSocket test-suite [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] resulting in 97% and 99% success rate for the client and
server implementation, respectively. The tests show that the cause of test
failures were mostly due to local and trivial errors in newly written code-generation
templates, and not related to the overall logical operation of the protocol as
specified by the CPN model. Finally, we demonstrate in this paper that the
generated code is interoperable with other WebSocket implementations.
Acknowledgement. The results presented in this invited talk is based on joint
work with Kent I.F. Simonsen, Bergen University College and the Technical
University of Denmark, and Ekkart Kindler, the Technical University of Denmark.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>J.</given-names>
            <surname>Billington</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.E.</given-names>
            <surname>Gallasch</surname>
          </string-name>
          , and
          <string-name>
            <given-names>B.</given-names>
            <surname>Han</surname>
          </string-name>
          .
          <article-title>A Coloured Petri Net Approach to Protocol Verification</article-title>
          .
          <source>In Lectures on Concurrency and Petri Nets</source>
          , volume
          <volume>3098</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>210</fpage>
          -
          <lpage>290</lpage>
          . Springer,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>I.</given-names>
            <surname>Fette</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Melnikov</surname>
          </string-name>
          .
          <source>The websocket protocol</source>
          ,
          <year>2011</year>
          . http://tools.ietf.org/html/rfc6455.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>K.</given-names>
            <surname>Jensen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.M.</given-names>
            <surname>Kristensen</surname>
          </string-name>
          , and
          <string-name>
            <given-names>L.</given-names>
            <surname>Wells</surname>
          </string-name>
          .
          <article-title>Coloured Petri Nets and CPN Tools for modelling and validation of concurrent systems</article-title>
          .
          <source>International Journal on Software Tools for Technology Transfer</source>
          ,
          <volume>9</volume>
          (
          <issue>3</issue>
          -4):
          <fpage>213</fpage>
          -
          <lpage>254</lpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>L.M.</given-names>
            <surname>Kristensen</surname>
          </string-name>
          and
          <string-name>
            <given-names>K.I.F.</given-names>
            <surname>Simonsen</surname>
          </string-name>
          .
          <article-title>Applications of Coloured Petri Nets for Functional Validation of Protocol Designs</article-title>
          .
          <source>In Transactions on Petri Nets and Other Models of Concurrency VII</source>
          , volume
          <volume>7480</volume>
          <source>of LNCS</source>
          , pages
          <fpage>56</fpage>
          -
          <lpage>115</lpage>
          . Springer,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>K. I. F.</given-names>
            <surname>Simonsen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. M.</given-names>
            <surname>Kristensen</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E.</given-names>
            <surname>Kindler</surname>
          </string-name>
          .
          <article-title>Generating Protocol Software from CPN Models Annotated with Pragmatics</article-title>
          .
          <source>In Formal Methods: Foundations and Applications</source>
          , volume
          <volume>8195</volume>
          <source>of LNCS</source>
          , pages
          <fpage>227</fpage>
          -
          <lpage>242</lpage>
          . Springer,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>K.I.F.</given-names>
            <surname>Simonsen</surname>
          </string-name>
          .
          <article-title>An Evaluation of Automated Code Generation with the PetriCode Approach</article-title>
          . In To appear
          <source>in Proc. of PNSE'14</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>K.I.F.</given-names>
            <surname>Simonsen</surname>
          </string-name>
          .
          <article-title>PetriCode: A Tool for Template-based Code Generation from CPN Models</article-title>
          .
          <source>In SEFM 2013 Collocated Workshops: BEAT2</source>
          ,
          <article-title>WS-FMDS, FM-RAIL-Bok, MoKMaSD, and OpenCert</article-title>
          , volume
          <volume>8368</volume>
          <source>of LNCS</source>
          , pages
          <fpage>151</fpage>
          -
          <lpage>166</lpage>
          . Springer,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>Tavendo</given-names>
            <surname>GmbH</surname>
          </string-name>
          . Autobahn|Testsuite. http://autobahn.ws/testsuite/.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>