=Paper= {{Paper |id=Vol-470/paper-5 |storemode=property |title=FREDDY: A Web Browser-friendly Lightweight Data-Interchange Method Suitable for Composing Continuous Data Streams |pdfUrl=https://ceur-ws.org/Vol-470/paper5.pdf |volume=Vol-470 }} ==FREDDY: A Web Browser-friendly Lightweight Data-Interchange Method Suitable for Composing Continuous Data Streams== https://ceur-ws.org/Vol-470/paper5.pdf
                                                                        ComposableWeb'09

FREDDY: A Web Browser-friendly Lightweight
   Data-Interchange Method Suitable for
   Composing Continuous Data Streams

             Shohei Yokoyama1 , Isao Kojima2 , and Hiroshi Ishikawa1
                             1
                               Shizuoka University, Japan
    2
        National Institute of Advanced Industrial Science and Technology, Japan



        Abstract. As a remarkable lightweight data-interchange format for use
        with web browsers, JSON is well known. Recently, web browsers have
        come to support rich applications called Software as a Service (SaaS) and
        Cloud Computing. Consequently, data interchange between web servers
        and web browsers is an important issue. A singleton, an array, or a nested
        object (tree) can be represented by JSON, which is based on a subset
        of the JavaScript Programming Language. It is valuable for SaaS appli-
        cations because JavaScript programs can parse JSON data without the
        need for special programs. However, web browsers and JSON are poorly
        designed to address large amounts of data and continuous data streams,
        e.g. sensing data and real time data. We propose here a novel data for-
        mat and a data-interchange mechanism named ”FREDDY” to address
        this deficiency. It is not merely a subset of the JavaScript; it can rep-
        resent semi-structured data, just as JSON does. Moreover, FREDDY is
        suitable for composing a continuous data stream on web browsers. Using
        the small JavaScript library of FREDDY, web applications can access
        streaming data via a SAX-style API; it works on all major browsers.
        Herein, we explain FREDDY and evaluate the throughput of our im-
        plementation. We loaded 400 MByte streaming data using our 5 kByte
        library of FREDDY.


1   Introduction
Once it was believed that web browsers were useful merely to display static
pages that web servers would provide one after another. However web pages are
no longer static, as exemplified by Google Maps, which uses dynamic HTML and
Asynchronous JavaScript + XML (Ajax)[15]. Using JavaScript, web pages can
access Web servers, download data, and update pages themselves. This technique
has laid the foundations for next-generation web applications such as SaaS[16],
Web2.0[13], and cloud computing. In this case, the main logic of applications
is partially located on a client side and partially located on a server side. We
will address implementations of web applications with the question of how data
that applications need can be accommodated. JavaScript applications on web
browsers always run inside a security sandbox. Consequently, all data must be
either on primary storage (main memory) of a local computer or on secondary

                                           39
ComposableWeb'09

storage (hard disks) of web servers, which is not of the local computer. That is
to say, data interchange between a web server and a web browser is an extremely
important issue for web applications.
    Ajax and JavaScript Object Notation (JSON: RFC4627)[5] are attractive so-
lutions for interchange of data between web servers and web browsers. However,
the combination of Ajax and JSON can download only a chunk of data simulta-
neously. They cannot handle continuous data streams, e.g. sensing data and real
time data. Numerous sensors are installed in devices from toilets to satellites,
but no lightweight integration method exists for handling sensing data on the
Web.
    The purpose of this paper is to propose a lightweight data stream interchange
mechanism named FREDDY. Our implementation provides a Simple API for
XML (SAX)[3] style programming. Therefore, FREDDY can accommodate not
only a continuous data stream, but also semi-structured data, equivalently to
XML. Using FREDDY, users can accommodate continuous data streams via a
SAX event handler, which is written in JavaScript.
    In this study, we also evaluate the throughput of our implementation of
FREDDY when the application loads a large SAX event stream. The results
of experiments show good throughput, about 1 MByte/s, of data interchange
between a web server and a web browser. However, we do not emphasize the
velocity of data interchange; also, FREDDY is a lightweight method in terms of
the security sandbox of web browsers. The remainder of this paper is organized
as follows. Section 2 expresses an overview of FREDDY. The data format and
our implementations of FREDDY are described in Section 3 and Section 4. In
Section 5, we present our experiments and evaluations. In Section 6, we describe
related works. Finally, Section 7 concludes the paper.


2    Overview of FREDDY

The main contributions (Fig. 1) of this paper are: (a) a lightweight data format
that is suitable for streaming data exchange using only JavaScript, (b) a stream-
ing delivery mechanism on the Web, (c) a lightweight library, whose size is about
5 kByte, to realize SAX-style programming for handling both semi-structured
data and continuous data streams.


                          FREDDY: lightweight data-interchange method

                              FREDDY       Streaming       SAX
                               data           data         Style
            Data Source       format        delivery        API         Web Browser




         Fig. 1. Software components and data flow of FREDDY and JSON.


                                              40
                                                                                   ComposableWeb'09

                                       Location, Speed, Vibration...
                                                                                     Factory
       Temperature, Motion...
                                           Logistics




                                                                     DY
                                     FR




                                                                   ED
                                       ED




                                                                 FR
                                          DY
          Office            FRE                                                     NOx, Fire alarm...
                               DDY                                  Continuous Data Stream

        Continuous Data Stream
                          FREDDY                 Web Browser                 Realtime Data
                                                  Mashup!            FR
           Dam                                                         ED
                                     FRE                                 DY       Home
                                        DD
                                             Y          SAX Event Stream
                                      Computation                                        Temperature,
                                                                                         illumination,
                                                 Emploee List
                                                          List,
                                      XML                                                Car security...
      Weather, Water level...                    Data Mining Result,
                                      Data       Output of Web Services...



                   Fig. 2. Our Goal, Stream Data Mashups using FREDDY.


    Figure 2 presents the goal of our research. FREDDY provides a lightweight
JavaScript API that is equivalent to the SAX API of XML document processing.
In fact, SAX API is the de-facto standard API. For that reason, we expect that
many users have sufficient knowledge of SAX. Using the proposed FREDDY,
users can easily develop Web mashups that compose web services to output
continuous data streams. Because space is limited, we have concentrated on data
interchange and have devoted scant attention to how to translate the output
signal of a sensor into our proposed data format.


3      Data model
3.1      Outline of Data Format
The data format for FREDDY, FREDDY Format, can represent both a flat
data stream and a semi-structured data stream. The FREDDY format is simple.
Figure 3 portrays instances of the FREDDY format as an XML tree and a data
stream representation. What the right of that figure readily clarifies is that the
FREDDY format uses function calls written in JavaScript. Each line of FREDDY
data expresses a type of SAX event and its property. We named each function
call event container a generic name.
    The main characteristic of the FREDDY Format, contrasted against that of
JSON, is that it is splittable because it is a simple repetition of event containers.
Actually, FREDDY realizes streaming between web servers and web browsers

                                                   41
ComposableWeb'09

   Semi-structured data                                sd();
                                                       s(”beer”);
                         beer                          s(”guinness”,{”label”:”Draught”});
                                                       c(”I like it!”);
      guinness                  guinness               e(”guinness”);
        @label:Draught            @label:Extra Stout   s(”guinness”,{”label”:”Extra Stout”});
                                                       e(”guinness”);
                                                       e(”beer”);
        I like it!                                     ed();                 FREDDY Format
                            thermometer                sd();                 FREDDY Format
                                                       s(”thermometer”);
                                                       s(”temperature”,{”unit”:”Celsius”});
                                temperature = 30       c(”30”);
                                  @unit:Celsius        e(”temperature”);
                                                       s(”temperature”,{”unit”:”Celsius”});
                                temperature = 28       c{”28”}
           Continuous             @unit:Celsius        e(”temperature”);
                                                       ...
           data stream      time t


Fig. 3. Examples of semi-structured data representation: the four expressions are mu-
tually equivalent.

                                    Table 1. Event containers

        SAX event          Usage             Event container
        XML Document start Data stream start ds();
        XML Document end Data stream end ed();
        XML Text Node      Property          c(value);
        XML Element start Tuple start        s(element-name , attr† );
        XML Element start‡ Tuple start‡      S(simplified-name, attr† );
        XML Element end    Tuple end         e(element-name† );
                                                      †: optional argument
                                           ‡: with simplified element name



by sending and receiving small fragments of all data one by one. Later in this
paper, a more precise account of the split FREDDY format is provided. We now
address the event container in detail.


3.2     Event container

Table 1 portrays a list of all event containers. The events of the XML Docu-
ment start and XML Document end are represented as ds() and de(). The
data stream must start with a ds() event container and end with a de() event
container. The two containers must appear only once.
    The second argument of c(...), which represents an XML Text node, is
optional. It is always omitted from the representation of XML Tree because the
XML Text Node has only a value.
    The events of an XML Element start and end are represented as s(...),
S(...), and e(...). The argument of e(...) is optional. The element name
is associated with an XML Element start event, which corresponds to that if
no argument is given. The reason is data size reduction. For the same reason,
the second argument of s(...) and S(...), which represents XML Element
Attributes, is optional.

                                                42
                                                                  ComposableWeb'09

3.3     Compression of verbose elements’ name
Actually, XML is known to be verbose by design[12], particularly in terms of ele-
ments that appear many times. The SAX event stream has the same problem. For
example, bibliographic information of Digital Bibliography and Library Project
(DBLP)[1] has about 2,300,000  tags, about 600,000 
tags, and about 350,000  tags.
    Efficient SAX event stream interchange must tackle that data verbosity. In
this context, XML compression is an important issue. In addition, XML compres-
sion is our concern: we proposed XML compression according to the simplified
element name[7, 17]. The FREDDY Format tackles XML verbosity using the
method of simplified element names. The reason that two event containers exist
for the XML Element start event is data size reduction.
    See Fig. 3. Two  tags and two  tags exist. If
the element name is  instead of  and  then
the amounts of data become small. This is the conceptual foundation of the
compression method.
    Algorithm 1 shows an algorithm for creation of an XML Element start event
container from the element name. Whenever the parser captures the element
start event, this procedure is called, where input T is a stack of visited element
names and argument name is an element name. The procedure then returns a
simplified element name derived from the original element name.

Algorithm 1: SimplifiedFREDDY(T, name)

 procedure GetSimpleName(idx)
  X ← [a, b. . .y, z, A, B. . .Y, Z, 0, 1. . .8, 9]
  len ← LengthOf(X)
  if len ≤ idx
             y ← X[idx%len]
          
          
          z ← idx/len
          
    then return (GetSimpleName(z) + y)
          
          comment: + means connection
          

      else return (X[idx])

 main
 if T [name].IsExist()
         
           evtContainer ← ”S(′ ” + sN ame + ”′ )”
   then
           return (T, evtContainer)
                     First appearance of the element
         
         comment:
         
         
         idx ← LengthOf(T )
         
         
         
   else sN ame ← GetSimpleName(idx)
         
         
         T [name] ← sN ame
                              ′            ′
         evtContainer ← ”s( ” + name + ” )”
         
         
         
          return (T, evtContainer)


                                         43
ComposableWeb'09

                                         Physical data
                                           np(1,10);                    page 1 (1)Request
                                           sd();
                    sd();                  s(”thermometer”);
                                           s(”temperature”,{”unit”:”Celsius”});
                    s(”temperature”);      c(”30”);
      Logial data   s(”temperature”,{”unit”:”Celsius”});
                                   ,{”uni
                                      unit”:
                                           e();
                    c(”30”);
                    e(”temperature”);
                                                                     (2)Response
                    s(”temperature”,{”unit”:”Celsius”});
                                   ,{”uni
                                      unit”:”Celsius”});             (3)Request     Web Browser
                    c{”28”}
                                           np(2,10);                    page 2
                    e(”temperature”);      S(”b”,{”unit”:”Celsius”});
                    ...                    c{”28”}
                                           e();
                                                                    (4)Response    (5)Request....


                                        Fig. 4. Split of FREDDY data.



    GetSimpleName(...) function generates the simple name for each new in-
coming element name. The original element name will be replaced with the sim-
ple name whenever this element re-appears later in this XML document. The
original element name itself is kept within the XML document by not replacing
the first entry of this element name.



3.4           Splitting data streams into small fragments


A salient difference between FREDDY and JSON is that FREDDY data can be
split by line into valid fragments, which maintains a subset of the JavaScript
programming language. All lines of FREDDY data are actually a subset of
JavaScript.
    Switching our attention to the continuous data stream, the data sources (e.g.
thermometer and NOx sensor, etc.) always output data continuously, but HTTP,
which enables any Web browser to communicate with any Web server, cannot
handle continuous data streams. Therefore, FREDDY can split continuous data
streams into small fragments, named Pages, as physical data.
    Figure 4 presents an example of split data. The function-call np(pointer,
sleep-time); in the first line of each Page is a pointer to the next Page.
FREDDY can start downloading the subsequent page when the function np is
called. The Pages are valid JavaScript code. For that reason, the web browsers
can download them dynamically using HTTP.
    Actually, FREDDY uses the dynamic