Documente Academic
Documente Profesional
Documente Cultură
WebRTC Applications
Sergej Alekseev
Marco Schindler
I. I NTRODUCTION
WebRTC (Web Real Time Communication) is a communication standard developed by the W3C [1] in close cooperation with the RTCWeb standard developed by the IETF
[2]. WebRTC offers developers the ability to create web
multimedia applications for real time communication without
plugins, downloads or installations. In this paper we present
an approach which allows to represent the state of a WebRTC
based application by collecting and analysing the state events.
The field of application could be e.g. error handling, collecting
statistics, detection of fraud attempts or analysis of user
behaviour.
The main idea of the proposed approach is to collect events
generated by WebRTC peers when a change of a state occurs.
For modelling the possible WebRTC states and flows we derive
the finite-state machines from the WebRTC specification [1].
The state change events are generated asynchronously by
WebRTC peers and this process does not have any influence on
the overlaying application. The collected events are validated
by the proposed algorithm to detect illegal state changes
according to the WebRTC specification [1]. The second algorithm recognizes the predefined sequences of event state
changes to create various statistics.
To evaluate our approach, the open source library WebRTCStateAnalyserhas been implemented and tested with various
WebRTC applications. The implemented library may be easily
integrated into any WebRTC application and is available as an
have-remote-pranswer
have-local-offer
!
g
a
b !
b
g
!
stable
closed
! g
g
e
d
d
!
!
have-remote-offer have-local-pranswer
e
f
(1)
Fig. 2.
Gathering states
new
gathering
complete
Fig. 4.
enum RTCIceConnectionState {
"new",
"checking",
"connected",
"completed",
"failed",
"disconnected",
"closed"
};
Fig. 5.
state machine C is presented in fig. 6. The state new represents the state in which a WebRTC peer waits until the
gathering process is completed and all connection candidates
are determined. The state new changes to state checking if the
Fig. 7.
a
c
d
b
!g
g
c
d
!
a a
closed
g!
g
g
failed
Fig. 6.
!
f disconnected !
(2)
(3)
A. Validation Algorithm
n
[
(4)
i=1
(5)
id
23
24
25
26
27
28
33
34
35
36
37
38
44
45
pid
0x01
0x02
0x01
0x02
0x02
0x01
0x01
0x02
0x01
0x02
0x01
0x02
0x01
0x02
sid
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
0x421ff0d
time stamp
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
03-19-2014
13:27:18.276
13:27:18.345
13:27:18.678
13:27:18.701
13:27:18.723
13:27:19.755
13:27:20.765
13:27:20.821
13:27:20.987
13:27:20.998
13:27:21.067
13:27:22.126
13:27:32.567
13:27:33.663
Fig. 8.
new
new
new
new
new
new
new
new
checking
checking
connected
connected
closed
closed
}
}
}
}
}
}
}
}
}
}
}
}
}
}
34, 36, 38, 45}. The validation is executed for each subset 1) or invalid (value = 0). The valid combination of states is
P the procedure V ALIDAT E EV EN T SEQU EN CE to ...
validate the sequence of signaling, gathering and connection [stable],
[new],
[new]
=1
=1
states. Additionally the combination of states for each event [have-local-offer], [gathering], [new]
[have-local-offer], [new],
[closed] =0
is validated by the combination validation algorithm.
[gathering], [new]
=0
1) Validating states for a single peer : The following [closed],
...
algorithm demonstrates the validation of events generated by a
Fig. 10. An excerpt from the combination matrix.
particular peer. The method otherend() returns the other state
connected to the given transition and state.
derived from the [1]. I.e. all the events from fig. 8 are valid.
Fig. 9.
The
runtime
complexity
of
the
procedure
V ALIDAT E EV EN T SEQU EN CE is O(|Q||E|),
where |Q| is the number of processed events and |E| the
number of edges (transitions) of the relevant finite state
machine. Since the number of transition in all machines
is constant, the runtime complexity is O(|Q|). I.e. the two
sequences P1 and P2 from fig. 8 are valid.
2) Validating combination of states: To validate the combination of states for single events, we created a static three
dimensional matrix (fig. 10) representing all combinations of
signaling, gathering and connection states. The values of the
matrix defines if the combination of states is valid (value =
Session failed:
Qs = { have-local-offer closed }
Qg = { new gathering }
Qc = { new checking failed closed }
1
profiling (fig. 11), is used. The path profiling algorithm works
1
1
ASSIGN LABELS( F SM )
V al(new EXIT )
=0
V al(new closed EXIT )
=1+0=1
1 for ( each vertex v V in reverse topological order ){
V al(new checking EXIT )
=2+0=2
2
if ( v is a leaf vertex ){
V al(new checking closed EXIT ) = 2 + 1 + 0 = 3
3
NumPaths(v) = 1;
V al(new checking f ailed EXIT ) = 2 + 2 + 0 = 4
...
4 } else {
V al(new checking connected . . .)
= 2 + 6 . . . = 15
5
NumPaths(v) = 0;
6
for( each edge e = v w) {
7
Val(e) = NumPaths(v);
number of possible paths (sequence patterns) is calculated as:
8
NumPaths(v) = NumPaths(v) + NumPaths(w);
16 3 17 = 816.
9 } } }
2) Calculating path value for an event sequence: The path
To evaluate the proposed algorithm we compared the runtime of the brute-force method (BFM) against the runtime
Fig. 12. Sequence Pattern Matching Algorithm
of the Event Sequence Pattern Matching (ESPM) algorithm.
The event sequence to be recognised is interpreted by the The input is an event sequence as defined in the equation
finite state machine. The path value is calculated as a sum 2 and a set of templates. A template is an event sequence
of the transition values (fig. 12: line 3) and the correspond- which is identified as a specific scenario for an use case (e.g.
ing pattern is determined from an index table by using the successful, failed or canceled session). The maximum possible
number of templates is 816 as calculated in section V-B. The
calculated integer value (fig. 12: line 4).
1) Representing event sequences with sums: The connec- realistic number of templates in a real application will be
tion finite state machine C (subsection III-C) is transformed approximately between 10 to 20. The algorithms have been
R and the tests have been executed on
into a DAG as presented in fig. 13. The transformation is done implemented in Java
R 3.4 GHz processor and 8GB of
by removing the back edges and adding the dummy edge EXIT a computer with an Intel
to derive correct paths for sequences that terminate before RAM.
We implemented two tests to evaluate the runtime. In the
reaching the end state.
The algorithm ASSIGN LABELS (fig. 11) calculates first test we executed the BFM and ESPM algorithms with
and assigns values, so each sequence path of 16 possible paths an event sequence including five events and various number
of templates as input. The table I reports the runtime results
is represented by an integer value as follows:
For the gathering finite state machine the algorithm and the diagram (fig. 14) represents the results graphically.
ASSIGN LABELS (fig. 11) calculates and assigns values To generate more representative results 1000 iterations per test
of three possible paths and for the signaling finite-state ma- have been executed. It is not surprisingly, that the runtime of
chine S the values of 17 possible paths. So the maximum the ESPM algorithms stays constant, because it depends on
TABLE I
RUNTIMES IN s DEPENDING ON THE NUMBER OF TEMPLATES .
# templates
BFM
s
ESPM
s
# templates
BFM
s
ESPM
s
5
20
50
620
1210
1815
364
391
368
150
400
816
2456
2896
4032
359
365
361
VII. C ONCLUSION
This paper describes a new approach for analysing the
behaviour of WebRTC-based applications. We presented an
algorithm for validating the collected events which may be
used e.g. to identify implementation errors in a WebRTC-based
application. We also presented an algorithm for recognition
the event sequences which can be used for generating various
monitoring records about a WebRTC session. Finally we presented some experimental results including the comparison of
the runtime of the new algorithm and the brute-force method.
The results show that the proposed approach and presented
algorithms are suitable to be implemented in all applications
related to the event based analysis.
Our further interests are focused for collecting statistics
from the real WebRTC-based applications, developing new
algorithms for identifying the event sequences containing
loops and creating a concept of a self learning system for
event sequence recognition.
time in s
4,000
3,000
2,000
1,000
0
5
20
50
150
400
816
# templates
BFM
ESPM
Fig. 14.
R EFERENCES
[1] Adam Bergkvist, Daniel C. Burnett, Cullen Jennings, Anant Narayanan,
WebRTC 1.0: Real-time Communication Between Browsers, Draft 30,
August 2013 http://dev.w3.org/2011/webrtc/editor/webrtc.html
[2] H. Alvestrand, Real Time Protocols for Brower-based Applications, IETF,
Draft 09, Feb. 2014 http://tools.ietf.org/html/draft-ietf-rtcweb-overview-09
[3] A. Danthine, Protocol Representation with Finite State Machines, IEEE
Transactions on Communications, Vol. 28, No. 4, 1980, pp. 632-643
[4] D. Brand, P. Zafiropulo, On Communicating Finite-State Machines, J.
ACM, Vol. 30, No. 2, April 1983, pp. 323-342
[5] Sunshine, C., Formal Modeling of Communication Protocols, in Proc.
Conference on Communication in Distributed Data Processing Systems,
Technical University Berlin, January 1981.
[6] T. S. Chow, Testing Design Modelled by Finite-State Machines, IEEE
Trans. S.E. 4, 3, 1978.
[7] S. Fujiwara, G.v. Bochmann, F. Khendek, M. Amalou, A. Ghedamsi,
Test selection based on finite state models, IEEE Trans. on Software
Engineering, Vol. 17, No. 6, June 1991, pp. 591-603.
[8] A. Ghedamsi, G.v. Bochmann, Test result analysis and diagnostics for
finite state machines, The 12-th international conference on distributed
systems, Yokohama, Japan, June 9-12, 1992
[9] B. Korel, PELAS-Program error-locating assistant system, IEEE Trans.
on Software Engineering, Vol. 14, No. 9, September 1988
[10] W. Grieskamp, Y. Gurevich, W. Schulte, M. Veanes, Generating finite
state machines from abstract state machines, Proceedings of the ACM
SIGSOFT Symposium on Software Testing and Analysis, 2002, pp. 112ff
[11] R. M. Hierons, Canonical finite state machines for distributed systems,
Theoretical Computer Science, 2010, pp. 566-580.
[12] H. Alvestrand, Google release of WebRTC source code, publicwebrtc@w3.org, 1. Juni 2011
[13] F. A. Scherschel, Google proposes VP8 and Opus for WebRTC standard,
The H Open, 31. Juli 2012
[14] J. Rosenberg, Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer
Protocols, RFC5245, April 2010 http://www.ietf.org/rfc/rfc5245.txt
[15] R. Berjon, S. Faulkner, T. Leithead, E. D. Navara, E. OConnor; S.
Pfeiffer, HTML5 - A vocabulary and associated APIs for HTML and
XHTML, W3C , 04 February 2014 http://www.w3.org/TR/html5
[16] M. Handley, V. Jacobson, SDP: Session Description Protocol, RFC2327,
April 1998 http://www.ietf.org/rfc/rfc2327.txt
[17] T. Ball, J. R. Larus, Efficient Path Profiling, Proceedings of the 29th
annual ACM/IEEE international symposium on Microarchitecture, 1996
[18] R. S. Boyer, J. S. Moore, A fast string searching algorithm, Communications of the ACM 20, 1977, pp. 762- 772
[19] D. Knuth, J. Morris, V. Pratt, Fast pattern matching in strings, SIAM
Journal on Computing, Vol 6(1), 1977, pp. 323-350
[20] R. N. Horspool, Practical fast searching in strings, Software-Practice
Experience , Vol 10(6), 1980, pp. 501-506.
time in s
TABLE II
RUNTIMES IN s DEPENDING ON THE LENGTH OF THE SEQUENCE .
# events
ESPM
s
PMA
s
# events
BFM
s
ESPM
s
1
3
5
998
1412
1834
181
356
611
7
9
11
2019
2102
2184
829
856
888
11
2,000
1,000
1
# events
BMF
ESPM
Fig. 15.