3.1 Time-constrained SDs
UML SDs may be annotated with time con-
straints (OMG, 2015). Although the UML standard
allows the specification of more complex constraints,
in this paper we restrict our attention to the types
of time constraints that are commonly addressed in
the literature of time-constrained distributed systems
(see Related Work) and are most relevant in practice:
constraints that specify the minimum and maximum
delays (time elapsed) between two events (message
sending or receiving) in the same lifeline, or between
the sending and receiving of a message between two
lifelines. We assume that the minimum and maximum
delays are constant values (or expressions that can be
evaluated before the scenario execution).
L2
m1
L1
e1
e2
e4
m2
{0..2}
{0..2}
{0..5}
e3
{0..2}
Figure 2: Example of a time-constrained SD.
Figure 2 presents a scenario with that type of
time constraints in UML. Each interval is denoted
{min..max}, where min or max can be omitted. De-
noting by ti the time instant of event ei, the only
valid execution trace defined by this SD is the time-
constrained trace [(e1, t1), (e2, t2), (e3, e3), (e4, t4)]
with t2 ∈ [t1, t1 + 2], t3 ∈ [t2, t2 + 2], t4 ∈ [t3, t3 +
2] and t4 ∈ [t1, t1 + 5]. An example of a valid
timed trace (with the time instant of each event) is
[(e1, 1), (e2, 3), (e3, 4), (e4, 5)]. An example of an in-
valid timed trace is [(e1, 1), (e2, 3), (e3, 5), (e4, 7)].
To check if an observed trace is valid, besides ver-
ifying if the observed events occurred by a certain or-
der, it is also necessary to verify if their time instants
satisfy the time constraints defined in the SD, as will
be formalized in the next two subsections. We start by
computing the valid time-constrained traces defined
by a SD.
In UML, an SD is a variant of an Interaction
(OMG, 2015). Figure 3 presents an excerpt of the
formalization of the structure of Interactions in VDM,
highlighting the elements added to support time con-
straints as compared to our previous work (Lima and
Faria, 2017). For simplicity, we omit the definition
of combined fragments (which can be found in our
previous work), integrity constraints, and some ba-
sic types. An Interaction comprises a set of lifelines
(representing in our case CUTs or actors), messages
(restricted in our case to asynchronous messages, al-
though synchronous messages could easily be han-
dled), combined fragments and time constraints. For
each message, we define the locations of the send and
receive events (sendEvent and receiveEvent), and
the (optional) variables that represent the instants of
time of occurrence of those events (sendTimestamp
and rcvTimestamp).
A TimeConstraint imposes minimum and max-
imum values on the time that can elapse between two
events (identified by the timestamp variables). Either
the minimum or the maximum may be omitted.
3.2 Valid Traces defined by a
Time-constrained SD
In general, the semantics of an Interaction is ex-
pressed in terms of two sets of valid and invalid traces
(OMG, 2015). In this paper, we don’t handle the
rarely used constructs for defining invalid traces (such
as the neg operator), so only the valid traces are rele-
vant here. A trace is a sequence of event occurrences
(OMG, 2015), corresponding, in this context, to the
emission or reception of messages at lifelines. Fig-
ure 3 shows the structure of traces in VDM with tim-
ing information, by means of an optional timestamp
associated with each event. Depending on the context,
the timestamp may be a variable (as in (e1, t1)) or a
concrete value (as in (e1, 1)). In this paper we assume
a discrete time scale (in an appropriate unit, such
as seconds or microseconds), but a continuous scale
would equally work. Hence, time instants (Time) and
elapsed time (Duration) are represented by natural
numbers.
Since we are dealing with distributed systems, we
assume there is no global clock, so time instants are
measured with the local clocks. Although it is impos-
sible to ensure perfect clock synchronization between
lifelines, in practice we can assume, like other authors
did (see Related Work), that there is a maximum dif-
ference (or skew) between the readings of any two
clocks (MaxClockSkew). For example, the Network
Time Protocol (NTP) (Mills, 1991), designed to syn-
chronize the clocks of computers over a network to a
common timebase (usually UTC), achieves synchro-
nization accuracies of 10 ms over Internet, and 1 ms
on LAN.
For computing the set of valid traces defined
by an Interaction with time constraints (see func-
tion validTraces in Figure 4), we first com-
pute the valid traces ignoring time constraints
(validTracesUntimed), following a procedure pre-
sented in our previous work for SDs without time con-
straints (Lima and Faria, 2017), and subsequently ex-
clude the traces for which the defined time constraints
Conformance Checking in Integration Testing of Time-constrained Distributed Systems based on UML Sequence Diagrams
461