. The occurrence of σ0 σ1 . . . σMaxSeqNo in marking M0 leads to a marking Mm , where m = 5MaxSeqNo and
216
Jonathan Billington and Guy Edward Gallasch
Mm (sender ready)=1‘s Mm (seq no)=1‘0 Mm (ack channel)=∅ Mm (process mess)=∅ Mm (mess channel)=1‘0 + 1‘1
Mm (retrans counter)=1‘0 Mm (receiver ready)=1‘0 Mm (wait ack)=∅ + ... + 1‘MaxSeqNo
Mm covers marking M0 so that σ0 σ1 . . . σMaxSeqNo can repeat indefinitely from marking M0 , resulting in MaxSeqNo additional messages in the message channel for each repetition. Thus the message channel is unbounded. A similar theorem holds for the acknowledgement channel. Theorem 2. For the Stop-and-Wait CPN of Figs. 1 and 2 where MaxRetrans ≥ 1 and MaxSeqNo ≥ 1, the acknowledgement channel (place ack channel) is unbounded. Proof. The proof of this theorem is similar to that of Theorem 1, hence we just provide a sketch. A suitable transition sequence in this case is send mess, receive mess, send ack, timeout retrans, receive ack, receive mess and send ack. Transition occurrence sequences σ0 , σ1 , . . . σMaxSeqNo are defined in a similar way. The occurrence sequence σ0 , σ1 , . . . σMaxSeqNo can be repeated indefinitely from M0 , resulting in MaxSeqNo additional acknowledgements in the acknowledgement channel for each repetition. 3.2
Message Loss and Incorrect Acceptance of Duplicates
When the Stop-and-Wait protocol operates as required, one message will be received correctly at the receiver for every original message sent by the sender. It turns out that this is not the case for the Stop-and-Wait protocol operating over a medium that reorders messages. This demonstrates that the protocol does not satisfy the Stop-and-Wait service. Further we can show that sequences of sends and receives exist where there are more receives than sends, indicating that duplicates are accepted. Finally we can also demonstrate that there are sequences in which there are more sends than receives, indicating that messages can be lost. We summarise these results in the following three theorems, and prove them together in the one proof. Theorem 3. The Stop-and-Wait CPN of Figs. 1 and 2 where MaxRetrans ≥ 1 and MaxSeqNo ≥ 1, does not satisfy the Stop-and-Wait service. Theorem 4. For the Stop-and-Wait CPN of Figs. 1 and 2 where MaxRetrans ≥ 1 and MaxSeqNo ≥ 1, the receiver may incorrectly accept duplicate messages as new messages. Theorem 5. For the Stop-and-Wait CPN of Figs. 1 and 2 where MaxRetrans ≥ 1 and MaxSeqNo ≥ 1, messages can be lost without the sender or receiver being aware of it.
How Stop and Wait Protocols Can Fail over the Internet
0
send
217
1
receive Fig. 3. FSA for the SWP service.
Proof. We use language analysis [7, 20] to prove the above theorems. The first step is to define the service [17] provided by the Stop-and-Wait protocol. The service defines a set of service primitives and their global sequences as observed by the SWP users. Service primitives are abstract representations of the interactions between the service provider and a service user. For the SWP service, we define two primitives: a send at the sender entity interface; and a receive at the receiver entity interface. We can then define the service language as 0 or more repetitions of the sequence (send, receive). This can be represented by the regular expression (send receive)∗ or by the Finite State Automaton (FSA) shown in Fig. 3. The next step is to generate the protocol language from the protocol specification. The protocol language just contains service primitive events. This allows direct comparison of the service and protocol languages. Our protocol specification is the CPN model of Figs. 1 and 2. In this CPN we can consider that the send primitive occurs when the send mess transition occurs and similarly that the receive primitive occurs when receive mess occurs where the bindings of sn and rn are the same. (Otherwise the occurrence of receive mess represents the discarding of duplicates, which does not correspond to a receive primitive.) The protocol language can be obtained from the CPN’s reachability graph by treating it as a FSA. All non-service primitive transitions (i.e. those associated with sending and receiving acknowledgements, or with loss or retransmission) are replaced by empty () transitions and the resulting FSA minimised [6] to produce the minimum deterministic FSA. This FSA represents all possible sequences of service primitives, generated from the protocol, and is thus the protocol language. We use the suite of tools available in the FSM package [2] for FSA minimisation and comparison. Due to the unbounded communication channel in our original model shown in Fig. 1, the resulting reachability graph is infinite. However, to prove our theorems, we only need to demonstrate that it is possible for the system to malfunction. We therefore limit the capacity of the communication channels to two. The rationale behind this is that if the protocol operates incorrectly with a channel capacity of two messages, the same incorrect behaviour will also be present in a channel with capacity greater than two. Capacities of 0 and 1 are not appropriate, as a capacity of 0 results in no communication and a capacity of 1 prohibits overtaking. Thus a capacity of size two is the minimum needed to show interesting behaviour. To obtain the smallest reachability graph of interest, we also set MaxRetrans = 1 and MaxSeqNo = 1. We argue that if incorrect behaviour is evident when MaxRetrans = 1 then the same behaviour can occur for MaxRetrans ≥ 1 and similarly for MaxSeqNo.
218
Jonathan Billington and Guy Edward Gallasch
Channel capacity has been implemented as follows. The initial marking of the mess channel and ack channel places has been modified so that each place contains a certain number of empty tokens, in this case two each, representing empty buffers. Each time a message (data or acknowledgement) is placed in the channel, an empty token is removed from the corresponding channel place, and whenever a message is removed from the channel it is replaced by an empty token. The reachability graph of this CPN was generated using Design/CPN [25], with the configuration as shown in the CPN in Figs. 1 and 2 (noting the modifications above) and with the following additions: – Two Empty tokens in mess channel (Capacity of 2) – Two Empty tokens in ack channel (Capacity of 2) – No message loss on either channel The reachability graph contains 410 nodes and 848 arcs. After interpreting this as a FSA, the FSM package was used to obtain the equivalent minimum deterministic FSA as shown in Fig. 4. We have replaced send mess with s and receive mess with r in the figure due to size constraints. s
0
s
1
r
2
s
3
r
r
4 r
s
6 s
s 5
r
7
s
9
s
12
r
r
10
13 s r
r
11
s r
8
s
Fig. 4. FSA showing erroneous sequences of send and receive primitives.
This FSA shows that the SWP operating over a medium that reorders messages does not satisfy its service. There are incorrect sequences of send and receive primitives, indicating that the receiver can mistakenly accept duplicate s r s r r messages as new messages. For example, the cycle 7 → 10 → 13 → 6 → 4 → r 5 → 7 shows that it is possible for the system to enter a loop where the receiver accepts four messages as legitimate messages for every two sent by the sender. A s s s r second sequence 13 → 6 → 9 → 12 → 13 demonstrates that another cycle exists where for every 3 messages sent, only one is received, demonstrating message loss even though there is no loss in the medium! It is interesting to note that problems with acceptance of incorrect messages do not occur until the sequence numbers wrap, i.e. at node 4 in Fig. 4.
How Stop and Wait Protocols Can Fail over the Internet
219
We also generated results when the channel was lossy (in addition to reordering). The reachability graph contained 624 nodes and 2484 arcs. The reduced FSA showing the protocol language for this configuration contains 29 nodes and 47 arcs. There are many incorrect sequences in this language also. A figure has not been included due to size limitations.
4
Relevance to Practical Protocols
In order to understand the relevance of these results to the real world, let us consider the error recovery and flow control strategies implemented in TCP [32]. TCP uses retransmission on timeout to recover from packet loss and a sliding window mechanism for flow control, which includes dynamic window changes. TCP operates over IP (the Internet Protocol), which allows packets (known as segments) to be dropped or reordered. The correctness of TCP’s data transfer procedures can thus be related to the correctness of the Stop-and-Wait protocol operating over a medium that allows reordering. TCP uses a 32 bit sequence number, giving 232 = 4294967296 sequence numbers. Each sequence number is associated with 1 byte of data. The problems associated with the Stop-and-Wait protocol only arise after sequence numbers wrap, so that old duplicates can cause desynchronisation of the acknowledgement mechanism resulting in loss or acceptance of duplicates. This will only happen in TCP after 4Gbytes of data have been transmitted, and old duplicates still remain in the network. The threat posed by old duplicates was recognised by the designers of the Internet. They introduced the concept of a life-time for a packet in the IP layer, known as time-to-live. (This is implemented as a ‘hop count’ in practice.) The idea is that duplicate packets left floating around a network will be discarded once their time-to-live expires. RFC (Request for Comment) 793 [32], the protocol specification for TCP maintained by the Internet Engineering Task Force (IETF) [3], states that the maximum lifetime for a segment of data (MSL) is two minutes. Thus there will not be a problem with duplicate packets if they are destroyed before sequence numbers can wrap. Every byte is given a sequence number, thus for a transmission rate of 100 megabits/sec (12.5 megabytes/sec) we see that the sequence numbers will wrap after 232 /(1.25 ∗ 107 ) ≈ 5 minutes and 45 seconds. This is getting close to the maximum packet lifetime, but should not pose a problem unless the hop count mechanism takes longer than 2 minutes to quash packets. With the introduction of Gigabit networks [31] the sequence numbers of TCP could wrap after only 34 seconds of data transfer at 1 gigabit/second. Although the maximum throughput of a network rarely approaches the theoretical maximum, it would not be unreasonable to assume that with a very large window size and very large data transfers, wrapping of sequence numbers would occur after about one minute, allowing for the possibility of old duplicates being in the channel at the same time as new segments with the same sequence numbers.
220
Jonathan Billington and Guy Edward Gallasch
This is the condition necessary for loss and acceptance of the old duplicate (as a new segment) to occur. However, to get duplicates, there must be retransmissions caused by additional delay due to network congestion or lack of responsiveness in the receiver (e.g. an overloaded web server) which will reduce throughput. This delay, however, does not need to be very great to cause retransmissions, and hence the effect on throughput may not be significant. Another factor limiting throughput is TCP’s window size and the round trip delay (RTD). In standard TCP implementations, the maximum window size is 216 bytes, limiting the throughput to (216 /RTD) bytes/sec. The speed of light propagation delay contribution to RTD will then provide a limit irrespective of the transmission speed. However, to allow users to take advantage of high-speed networks, RFC 1323 [33] proposes to increase the maximum window size to 230 bytes or 1Gbyte, in which case the speed of light delays are no longer a limiting factor. It is unlikely that duplicates are a problem for TCP with the current speed of networks, however these problems may become more probable if network speed were to increase by another order of magnitude, i.e. 10 gigabit/second. There are additional ramifications to be considered if incorrect acceptance of duplicates or loss of data becomes a problem. For safety critical applications operating over the Internet the consequences could be catastrophic. There are a number of suggested ways in which this problem could be solved, or at least alleviated. RFC 1323 [33] specifies a number of TCP extensions for high performance. The extension for a larger window size has already been mentioned. Another extension is Protect Against Wrapped Sequence Numbers (PAWS) which proposes a solution to wrapping sequence numbers within a connection, by including a 32 bit time-stamp in every segment. Another solution involves extending the sequence number space, to 264 , i.e. 64 bit sequence numbers. Even at 10 gigabit/second, a 64 bit sequence number field would take 470 years to wrap. The procedure of sequence numbering may also be reviewed, as currently every byte is given a sequence number. Providing a sequence number for every segment would extend the usefulness of the existing 32-bit sequence numbers. How likely is it that unbounded growth of messages in the communication channels will actually occur? The unbounded growth is caused by retransmissions due to delayed acknowledgements. Given the variability of the round trip delay (due to the unpredictability of network congestion or overloaded servers) it is not uncommon for these delays to occur. This is countered to some extent by TCP measuring round trip delay and setting its retransmission timeout period accordingly. However, due to transients, unnecessary retransmissions will always occur. The unbounded growth, however, only occurs because the duplicates are not received by the receiver. This is highly unlikely. Also those that are delayed in the network will be expunged after their time-to-live limit has expired. Thus TCP already has mechanisms in place to prevent unbounded growth. TCP has also developed sophisticated techniques to cope with network congestion [31], so we don’t see that our unboundedness result for re-ordering media will cause
How Stop and Wait Protocols Can Fail over the Internet
221
major difficulties with protocols such as TCP. Nonetheless, as network speeds increase the problem will get worse, particularly if the time to live value is maintained at 2 minutes. In general we can say that the contribution to congestion over FIFO channels is well contained (determined by the maximum number of retransmissions allowed) whereas over channels that re-order messages, it requires other mechanisms to contain congestion.
5
Conclusions and Future Work
This paper is concerned with the class of Stop-and-Wait protocols (SWPs) that include retransmission on time-out procedures to recover from transmission errors or from dropped packets in a communication medium such as the Internet. These protocols were originally designed to operate over a physical wire where the sequence of packets is maintained. The recovery procedure requires packets to include a sequence number in order to detect duplicates. Duplicates are due to retransmissions that occur because packets (or their acknowledgements) are delayed or their acknowledgements are lost. It is well known that duplicates are successfully detected, so long as the sequence number space is greater than the number of packets sent without first receiving acknowledgement. For SWPs this allows the sequence numbers to be just two: {0,1} (the class of alternating bit protocols (ABPs)), but also allows a larger sequence number space to be used. It is not too difficult to show that ABPs work as expected over lossy FIFO channels and we have also shown [8] that the communication channels are bounded by one more than twice the maximum value of the retransmission counter. Protocols operating over the Internet Protocol (such as TCP) have to contend not only with loss due to transmission errors and packets dropped at routers, but also with the possibility that the order of packets is not maintained. Since TCP can behave as a Stop-and-Wait protocol under certain conditions it is interesting to investigate the behaviour of SWPs over a reordering medium. To do this we constructed a Coloured Petri Net model of the SWP, parameterised by the maximum number of retransmissions and the maximum sequence number. We analysed this model with respect to four properties and proved that: the communication channels are unbounded; messages can be lost, although the sender believes they have been confirmed by the receiver; duplicates can be accepted as new messages by the receiver; and that the SWP does not satisfy its service of alternating sends and receives. The last three results depend on sequence numbers wrapping before any problems occur. The first is independent of sequence number wrap. We discuss the relevance of these results to the ‘real world’ using TCP. We conclude that sequence number wrap is possible in Gigabit networks, particularly if the extended window size option is used. RFC 1323 discusses this problem and suggests a mechanism (PAWS) using 32 bit time stamps to reject old duplicates, which hopefully will eliminate the problems associated with sequence number wrap. The problem with unbounded channels is not serious, but could add to congestion problems as the speed of networks increases. Our discussion is at a
222
Jonathan Billington and Guy Edward Gallasch
high-level and does not investigate in detail TCP’s procedures for data transfer, nor the suggested PAWS scheme. This is a subject for future work. Acknowledgement We are indebted to our colleague, Mat Farrington, who pointed out the relevance of RFC 1323 to our investigations.
References 1. CCITT Recommendation Z.100 (2002). Functional Specification and Description Language (SDL). 2. FSM Library, AT&T Research Labs. http://www.research.att.com/sw/tools/fsm/. 3. Internet Engineering Task Force. http://www.ietf.org. 4. P. Aziz Abdulla and B. Jonsson. Verifying Programs with Unreliable Channels. Information and Computation, 127(2):91–101, June 1996. 5. Y. Afek and G.M. Brown. Self-Stabilization of the Alternating Bit Protocol. In Proceedings of the 8th Symposium on Reliable Distributed Systems, pages 80–83. IEEE Comput. Soc. Press, 1989. 6. W.A. Barrett and J.D. Couch. Compiler Construction: Theory and Practice. Science Research Associates, 1979. 7. J. Billington. Formal specification of protocols: Protocol Engineering. In Encyclopedia of Microcomputers, volume 7, pages pages 299–314. Marcel Dekker, New York, 1991. 8. J. Billington and G. E. Gallasch. An Investigation of the Properties of Stop-andWait Protocols over Channels which can Re-order messages. Technical Report 15, Computer Systems Engineering Centre, School of Electrical and Information Engineering, University of South Australia, Australia., 2003. 9. T. Bolognesi and E. Brinksma. Introduction to the ISO Specification Language LOTOS. Comput. Networks and ISDN Sys., 14(1):pages 25–59, 1987. 10. S. Budkowski and P. Dembinski. An Introduction to Estelle: A Specification Language for Distributed Systems. Comput. Networks and ISDN Sys., 14(1):pages 3–23, 1987. 11. C. A. Vissers and L. Logrippo. The Importance of the Service Concept in the Design of Data Communications Protocols. In Protocol Specification, Testing and Verification, V, pages pages 3–17. North Holland, Amsterdam, 1986. 12. CCITT. ISDN user-network interface data link layer specification. Technical report, Draft Recommendation Q.921, Working Party XI/6, Issue 7, Jan. 1984. 13. E.M. Clarke and J. M. Wing. Formal Methods: State of the Art and Future Directions. ACM Computing Surveys, 28(4):626–643, December 1996. 14. CPN ML: An Extension of Standard ML. http://www.daimi.au.dk/designCPN/sml/cpnml.html. 15. M. Diaz. Modelling and Analysis of Communication and Co-operation Protocols Using Petri Net Based Models. In Protocol Specification, Testing and Verification. North-Holland, 1982. 16. G.J. Holzmann. Design and Validation of Computer Protocols. Prentice-Hall International Editions, 1991.
How Stop and Wait Protocols Can Fail over the Internet
223
17. ITU-T. Recommendation X.210, Information Technology - Open Systems Interconnection - Basic Reference Model: Conventions for the Definition of OSI Services. Nov. 1993. 18. J. Billington, G.R. Wheeler and M.C. Wilbur-Ham. PROTEAN: A High-level Petri Net Tool for the Specification and Verification of Communication Protocols. In IEEE Transactions on Software Engineering, volume 14, pages 301–316. IEEE Press, 1988. 19. J. Billington, M. Diaz and G. Rozenberg (Eds.). Application of Petri Nets to Communication Networks, volume 1605 of Lecture Notes in Computer Science. Springer-Verlag, 1999. 20. J. Billington, M.C. Wilbur-Ham and M.Y. Bearman. Automated Protocol Verification. In Protocol Specification, Testing and Verification, V, pages 59–70. North Holland, Amsterdam, 1986. 21. K. Jensen. Coloured Petri Nets. Basic Concepts, Analysis Methods and Practical Use. Vol. 1, Basic Concepts. Springer-Verlag, 1992. 22. K.A. Bartlett, R.A. Scantlebury and P.T. Wilkinson. A Note on Reliable FullDuplex Transmission over Half-Duplex Links. Communications of the ACM, 12(5):260–261, May 1969. 23. L.M. Kristensen, S. Christensen and K. Jensen. The Practitioner’s Guide to Coloured Petri Nets. International Journal on Software Tools for Technology Transfer, 2(2):98–132, 1998. 24. Standard ML of New Jersey. http://cm.bell-labs.com/cm/cs/what/smlnj/. 25. Design/CPN Online. http://www.daimi.au.dk/designCPN/. 26. W. Reisig. Elements of Distributed Algorithms: Modelling and Analysis with Petri Nets, Volume 4. Springer-Verlag, 1998. 27. W. Stallings. Data and Computer Communications. Prentice Hall, 6th edition, 2000. 28. L.J. Steggles and P. Kosiuczenko. A Timed Rewriting Logic Semantics for SDL: a case study of the Alternating Bit Protocol. Electronic Notes in Theoretical Computer Science, 15, 1998. 29. I. Suzuki. Formal Analysis of the Alternating Bit Protocol by Temporal Petri Nets. IEEE Transactions on Software Engineering, 16(11):1273–1281, 1990. 30. I. Suzuki. Specification and Verification of the Alternating Bit Protocol by Temporal Petri Nets. In Proceedings of the 32nd Midwest Symposium on Circuits and Systems. IEEE Press, 1990. 31. A. Tanenbaum. Computer Networks. Prentice Hall, 4th edition, 2003. 32. The Internet Engineering Task Force. Transmission Control Protocol. RFC 793, 1981. 33. The Internet Engineering Task Force. TCP Extensions for High Performance. RFC 1323, 1992. 34. K. J. Turner (Ed.). Using Formal Description Techniques: An Introduction to Estelle, Lotos and SDL. John Wiley & Sons, 1993. 35. J. M. Wing. A Specifier’s Introduction to Formal Methods. IEEE Computer, 23(9):8–24, September 1990.
Introducing Commutative and Associative Operators in Cryptographic Protocol Analysis Ivan Cibario Bertolotti1 , Luca Durante1 , Riccardo Sisto2 , and Adriano Valenzano1 1
IEIIT – CNR Dipartimento di Automatica e Informatica, Politecnico di Torino, C.so Duca degli Abruzzi 24, I-10129 Torino, Italy, {luca.durante,ivan.cibrario,riccardo.sisto,adriano.valenzano}@polito.it 2
Abstract. Many formal techniques for the verification of cryptographic protocols rely on the abstract definition of cryptographic primitives, such as shared, private, and public key encryption. This approach prevents the analysis of those protocols that explicitly use commutative and associative algebraic operators to build their messages such as, for example, the Diffie-Hellman key-exchange protocol. This paper investigates the possibility of handling operators which exhibit special properties by considering a stand-alone extension to the way most known popular techniques handle messages exchanged during the protocol sessions. Such an extension makes the new operators tractable by automatic model checking techniques. The properties examined in this paper are commutativity and associativity.
1
Introduction
The formal verification of cryptographic protocols is being extensively studied by many researchers, in view of the ever increasing importance and popularity of secure, distributed applications. Most commonly adopted techniques, such as proof techniques [3, 19, 21] and state exploration [7, 11, 17] rely on abstract concepts of encryption and decryption. For instance, in a shared key cryptosystem, it is usually not allowed that encryption and decryption keys, computed autonomously by different agents, still represent the same key although they have different syntactical forms, as is the case of the Diffie-Hellman key exchange protocol [9]. Similar issues arise when using primitives like xor or exponentiation modulo different moduli as in the RSA cryptosystem. Such a limitation has the invaluable advantage that any syntactical difference between messages implies a semantical difference, i.e. there are not two or more different representations of the same message, but also hampers the ability to describe and formally verify any real-world cryptographic protocol that makes
This work was partially supported by the Italian National Research Council, grant number CNRC00FE45, and by the Center of Excellence on Multimedia Radiocommunications (CERCOM).
H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 224–239, 2003. c IFIP International Federation for Information Processing 2003
Commutative and Associative Operators in Cryptographic Protocol Analysis
225
use of more sophisticated operators, as pointed out in [2, 6, 12–14, 18, 20]; moreover, during peer review of this paper, the authors got to know that this problem was being addressed by other researchers, too [4, 8, 15, 16]. In this paper we present the theoretical framework needed to extend the intruder’s knowledge representation strategy presented in [5], to include associative and commutative operators. As most other researchers do, that method relies on the perfect encryption assumptions, and on the so-called Dolev-Yao intruder’s model, inspired by [10]; in addition, it guarantees that: – encryption and decryption keys are not restricted to be atomic, – public/private key cryptosystems, and related operators, are fully supported, – the intruder’s knowledge is always kept in a minimised form. In particular, we show that the intruder’s knowledge representation, as discussed in [5], can be updated to take into account the new operators by defining a canonical form for messages, i.e. any message built by means of the extended set of operators can always be syntactically transformed into its canonical form, preserving its semantic properties, so that the intruder’s knowledge representation can be based only on messages in such a canonical form. In fact the proposed extension preserves uniqueness, canonicity and minimality of the intruder’s knowledge representation. Section 2 recalls the term algebra of [5], while the formalism and the main results of [5], concerning the intruder’s knowledge representation, are briefly summarised in Sect. 3. Section 4 deals with commutative and associative operators, and the computation of the canonical form of messages containing them, while Sect. 5 shows how the intruder’s knowledge representation can be made able to handle these operators. Finally, Sect. 6 discusses the Diffie-Hellman key exchange protocol [9] in the light of the approach presented in Sections 4 and 5, and Sect. 7 draws some conclusions.
2
Basic Term Algebra
Many formal methods used to describe cryptographic protocols rely on a term algebra for the description of messages. In the spi calculus term grammar adopted in [5], terms can be either atomic elements, i.e. names, including the special name 0 representing the integer constant zero, or compound terms built using the term composition operators listed in Table 1. Names may represent communication channels, atomic keys and key pairs, nonces (also called fresh names) and any other unstructured data. If a term σ occurs as a sub-expression of another term ρ, then σ is called a sub-term of ρ; moreover, any term σ is a sub-term of itself. The informal meaning of the composition operators is as follows: – (σ, ρ) is the pairing of σ and ρ. It is a compound term whose components are σ and ρ. Pairs can always be freely split into their components. – suc(σ) is the successor of σ. This operator can also be used, more generally, as the abstract representation of an invertible function on terms.
226
Ivan Cibrario Bertolotti et al. Table 1. Basic term syntax σ, ρ a (σ, ρ) 0 suc(σ) x
terms name pair zero successor variable
H(σ) {σ}ρ σ+ , σ− {[σ]}ρ [{σ}]ρ
hashing shared-key encryption public/private part public-key encryption private-key signature
– H(σ) is the hashing of σ. H(σ) represents a function of σ that cannot be inverted. – {σ}ρ is the ciphertext obtained by encrypting σ under key ρ using a sharedkey cryptosystem. – σ + and σ − represent respectively the public and private half of a key pair σ. σ + cannot be deduced from σ − and vice versa. – {[σ]}ρ is the result of the public-key encryption of σ with ρ. – [{σ}]ρ is the result of the signature (private key encryption) of σ with ρ. Even though this algebra comes directly from spi calculus [1], it is general enough to cope with the needs of many formal techniques used to model cryptographic protocols.
3
Basic Intruder’s Knowledge Representation
In this section we recall some notation and results from [5], useful to understand how the intruder’s knowledge representation can be extended in order to manage also terms containing operators with special properties; it must be noted that here we do not take into account public and private key encryption, which is discussed in depth in [5]. Let A be the set of names, including the integer constant 0, and T the set of terms that can be built by combining the elements of A by means of the operators defined in Table 1. and is defined as the set The closure of a set of terms Σ ⊆ T is denoted Σ of all terms that can be built by combining the elements of Σ by means of the is the least set of operators defined in Table 1 and their inverses. Formally, Σ terms such that, for each σ, σ1 and σ2 ∈ T , the following closure rules hold: σ∈Σ σ∈Σ
⇒
σ∈Σ
⇒
∧ σ2 ∈ Σ σ1 ∈ Σ ∧ σ2 ∈ Σ σ1 ∈ Σ σ∈Σ
⇒
suc(σ) ∈ Σ (σ1 , σ2 ) ∈ Σ
suc(σ) ∈ Σ (σ1 , σ2 ) ∈ Σ
⇒ ⇒
{σ1 }σ2 ∈ Σ H(σ) ∈ Σ
(1) (successor)
(2)
(pairing)
(3)
(sh. key encryption)
(4)
(hashing) ⇒ σ∈Σ (prec) ⇒ σ1 ∈ Σ ∧ σ2 ∈ Σ (projection)
(5) (6) (7)
Commutative and Associative Operators in Cryptographic Protocol Analysis
∧ σ2 ∈ Σ {σ1 }σ2 ∈ Σ
⇒
σ1 ∈ Σ
(sh. key decryption)
227
(8)
In principle, if Σ is the set of messages the intruder has intercepted so far, is the set of all messages the intruder can generate at a given point. Since Σ neither A nor T contain variables, the intruder’s knowledge does not contain variables, too. We say that a set of terms is finite if it contains a finite number of finite length elements. Given a finite set of terms Σ, we define the minimal closure seed of that satisfies the following predicates for Σ, and denote it as Σ, the subset of Σ each a ∈ A, and for each σ, σ1 , σ2 ∈ T : a∈Σ⇔a∈Σ {σ1 }σ2 ∈ Σ ⇔ σ2 ∈ Σ H(σ) ∈ Σ ⇔ σ ∈ Σ
(9) (10)
suc(σ) ∈ Σ (σ1 , σ2 ) ∈ Σ
(12) (13)
(11)
Before discussing the basic properties of Σ, let us preliminarly define r(σ, Σ) as the boolean value obtained by executing the following algorithm: boolean r(σ, Σ) { if σ ∈ Σ else if σ = suc(σ1 ) else if σ = (σ1 , σ2 ) else if σ = {σ1 }σ2 else if σ = H(σ1 ) else (σ ∈ A \ Σ) }
then return TRUE; then return r(σ1 , then return r(σ1 , then return r(σ1 , then return r(σ1 , return FALSE;
Σ); Σ) ∧ r(σ2 , Σ); Σ) ∧ r(σ2 , Σ); Σ);
Informally, this algorithm recursively checks whether σ can be deduced from the set Σ using rules (2)-(5) only, i.e. by using rules that build a new term by introducing an operator between two or more simpler terms. The basic properties of Σ are then expressed by the following theorems: Theorem 1. (Finiteness) For each finite set of terms Σ ⊆ T , Σ is finite. Theorem 2. (Minimality) Let Σ ⊆ T be a finite set of terms, and σ ∈ Σ. Then (Σ \ {σ}) ⊂ Σ. Theorem 3. (Decidability) Let σ ∈ T be any finite term, Σ ⊆ T be a finite set is of terms, and let us assume that Σ is known. Then, determining if σ ∈ Σ decidable. Let us now define a reduction rule as a triple R = ΣI , C, ΣO , where ΣI and ΣO are sets of terms representing respectively premises and conclusions of closure rule C. Applying a reduction step R to a finite set of terms Σ means eliminating the premises from and adding the conclusions to Σ. This is written R Σ −→ Σ , where Σ = (Σ \ ΣI ) ∪ ΣO is the resulting set.
228
Ivan Cibrario Bertolotti et al.
Given a finite set of terms Σ, a reduction of Σ is a finite sequence of application of reduction rules Ri to finite sets of terms Σi , denoted: R
R
Rk−1
0 1 Σ0 −→ Σ1 −→ Σ2 · · · Σk−1 −→ Σk ,
such that Σ0 = Σ and Ri ∈ R(Σi ), where R(Σi ) is the set of reduction rules whose pre-conditions are satisfied by Σi . Below, the notation a → b means that if the pre-condition a is true, then the reduction rule b can be applied in Σi , that is, b ∈ R(Σi ). The set R(Σi ) is the least set such that the following relations hold: H(σ) ∈ Σi ∧ r(σ, Σi ) → {H(σ)}, (5), ∅ suc(σ) ∈ Σi → {suc(σ)}, (6), {σ} (σ1 , σ2 ) ∈ Σi → {(σ1 , σ2 )}, (7), {σ1 , σ2 } {σ1 }σ2 ∈ Σi ∧ r(σ2 , Σi ) → {{σ1 }σ2 }, (8), {σ1 }
(14) (15) (16) (17)
The definition of reduction allows to claim: Proposition 1. Given a finite set of terms Σ, there exists a finite reduction of Σ: Rk−1 R0 Σ = Σ0 −→ Σ1 · · · Σk−1 −→ Σk , i = Σ ∀ i ∈ [0, k]. such that Σk = Σ, and Σ Starting with proposition 1 the following results hold: = Σ. Theorem 4. (Closure preservation) For each finite set of terms Σ ⊆ T , Σ Theorem 5. (Computability) For each finite set of terms Σ ⊆ T , Σ can be computed in a finite number of steps. Since Σ can be computed from Σ, theorem 3 can now be used to check whether σ ∈ Σ. Theorems 1, 2 and 4 state that the closure seed representation of a finite set of terms Σ is finite and is the minimal set of terms having the same closure of Σ, where minimality means that any element cannot be built from the other ones by means of term composition operators only, i.e. there are no redundant elements. Theorems 4 and 5 entail that if a new term ρ is added to a minimal closure seed Σ, e.g. as a consequence of an output action, the new minimal closure seed Σ ∪ {ρ} can be incrementally computed by a reduction that starts from Σ ∪ {ρ}. Formal proofs of results depicted above are found in [5].
4
The Canonical Term Representation
The introduction of operators with special properties has several subtle implications in the intruder’s knowledge representation, where the necessary and sufficient condition for the equivalence of two terms simply relies on their syntactic
Commutative and Associative Operators in Cryptographic Protocol Analysis
229
identity. In fact, when a term algebra is extended with commutative and/or associative operators, two or more syntactic representations of the same term are allowed. For example, if is a commutative, binary operator, Σ1 = {σ ρ} and Σ2 = {ρ σ} express exactly the same knowledge and are both minimum and canonical according to the original definition of Σ presented in [5], but clearly they are not equal in a syntactical sense. In order to correctly handle such operators, we introduce the notion of canonical term representation and we assume that all algorithms that act on terms, such as Σ minimisation and r(·, ·) always act on canonical terms. The canonical term representation leverages on the concept of term equivalence class induced by the operators’ properties: two terms belong to the same equivalence class, induced by a given property, iff they can be made equal by applying that property. For example H(ab) and H(ba) are in the same equivalence class if is a commutative operator, because they can be made equal by applying the commutative property. The canonical term representation has the important role of selecting, for each term equivalence class induced by the operators’ properties, a unique element that will represent the class as a whole in all contexts. It can be proved, with ordinary effort, that this additional requirement is powerful enough to restore the uniqueness of Σ for all operators’ properties considered in this paper. From now on it is assumed that two terms that can be obtained from eachother by a suitable application of one or more operators’ properties are indistinguishable from the intruder’s point of view. For this reason, any additional observation the intruder can make on term generation besides the final value, such as timing or accuracy, is neglected. 4.1
Notational Conventions
Table 2 introduces the main notational conventions adopted in the following. Note also that: – When multiple atoms, terms, and operators are needed in the same context, a unique, numeric subscript is used to distinguish them. For example, a1 and a2 are two distinct, and possibly different, atoms. – When appropriate, the arity of the operator is explicitly denoted with a subscript, for example: n is an n-ary operator. When more than one operator is needed in the same context, the first subscript singles out the operator, and the second one gives its arity. For example, 1n and 2m are two distinct, and possibly different operators; the first one has arity n, the second has arity m. – This paper uses the infix and prefix operator notation interchangeably, that is, a b = (a, b). 4.2
Total Order Relation on Terms
We assume that there is a total order relation ≤P on the elements of P, as it is the case when P is finite or is a countable infinity; similarly, we assume that
230
Ivan Cibrario Bertolotti et al. Table 2. Notational conventions Symbol Meaning P is the set of term algebra operators; it contains both the standard term algebra operators of Table 1, and the additional operators described in Sections 4, 5 and 6. T is the set of all terms that can be built by combining the elements of A with operators of P. a is a generic, atomic term: a ∈ A. is a generic n-ary operator: ∈ P. σ is a generic term, either atomic or non-atomic: σ ∈ T . ≤A is a total order relation on A. ≤P is a total order relation on P. ≤T is a total order relation on T .
there is a total order relation ≤A on the elements of A, as it is the case when the total number of atomic terms ever used in a session of the protocol is finite or is a countable infinity. Then, we are able to define a relation ≤T on the elements of T , by means of the following implications: σ1 ∈ A ∧ σ2 ∈ A ∧ σ1 ≤A σ2 ⇒ σ1 ≤T σ2 σ1 ∈ A ∧ σ2 ∈ A ⇒ σ1 ≤T σ2
(18) (19)
σ1 = 1n (. . .) ∧ σ2 = 2m (. . .) ∧ n < m ⇒ σ1 ≤T σ2 σ1 = 1n (σ11 . . . σ1n ) ∧ σ2 = 2n (σ21 . . . σ2n ) ∧ ∃j | σ1j = σ2j ∧ σ1j ≤T σ2j ∧ σ1i = σ2i ∀i < j ⇒ σ1 ≤T σ2
(20)
σ1 = 1n (σ11 . . . σ1n ) ∧ σ2 = 2n (σ21 . . . σ2n ) ∧ σ1i = σ2i ∀i ∧ 1n ≤P 2n ⇒ σ1 ≤T σ2
(21) (22)
It is worth noting that implications (21) and (22) assume that the operands σ11 . . . σ1n and σ21 . . . σ2n of 1n and 2n , respectively, are already in canonical form. In turn, the algorithm to compute the canonical representation of a term, given in Sect. 4.3, will make use of ≤T . Correctness and computability are guaranteed, because: – The canonical representation algorithm always invokes ≤T on terms that are already canonical (correctness). – To compute the canonical representation mentioned above, the canonical representation algorithm is always invoked recursively on sub-terms that have one operator less than their parent, and it is trivially computable on atoms (computability by induction). Theorem 6. The relation ≤T is a total order relation on T . The proof of this theorem is based on proving that ≤T is reflexive, antisymmetric, transitive, and that: ∀σ1 , σ2 ∈ T , σ1 = σ2
σ1 ≤T σ2 ∨ σ2 ≤T σ1 .
Commutative and Associative Operators in Cryptographic Protocol Analysis
4.3
231
Term Canonicalisation
Term canonicalisation has the purpose of determining a unique, canonical form for each σ ∈ T ; the canonical form is used when inserting a term into the intruder’s knowledge, while checking whether the intruder is able to synthesise a term from a given knowledge. Term canonicalisation selects one representative element from each equivalence class induced on T by operator properties according to the following informal rules: – The canonical form of an atom is the atom itself (rule 23 below). – The canonical form of the invocation of an operator without special properties is the invocation of the same operator on the same operands, put into canonical form (rule 24). – The canonical form of the invocation of a commutative operator on a list of operands σ1 . . . σn is the invocation of the same operator on the operands put into canonical form and then sorted according to ≤T , to ensure the uniqueness of representation (rule 25). – The canonical form of the invocation of an associative operator on a list of operands σ1 . . . σn is the invocation of the same operator on the operands taken into canonical form. If, after canonicalisation, some operands have the same operator as their top-level operator, the hierarchy of invocations of is flattened (rule 26). Formally, the term canonicalisation function is the transitive closure C ∗ of function C : T → T , which can be defined according to the following set of rewrite rules, where PC is the set of commutative operators, and PA is the set of associative operators. The intersection of these sets may not be empty because operators may have multiple properties. should be read as: when the preIn the following, a rewrite rule like Cπ σ −→σ
requisite predicate π is true, then term σ can be rewritten as σ through a canonicalisation step. In σ , the notation C ∗ (σi ) entails the recursive application of the canonicalisation rewrite rules to sub-term σi . a∈A C
a −→ a ∈ (PC ∪ PA ) C
(σ1 . . . σn ) −→ (C ∗ (σ1 ) . . . C ∗ (σn )) ∈ PC ∧ (∃i | σi = C ∗ (σi ) ∨ ∃i, j | C ∗ (σi )≤T C ∗ (σj )) ∧ ∃k1 . . . kn , ki = kl ∀i, l | C ∗ (σki )≤T C ∗ (σki+1 ), i = 1 . . . n − 1 C
(σ1 . . . σn ) −→ (C ∗ (σk1 ) . . . C ∗ (σkn ))
(23)
(24)
(25)
∈ PA ∧ ∃i | C ∗ (σi ) = (σi1 . . . σim ) C
(σ1 . . . σn ) −→ (C ∗ (σ1 ) . . . C ∗ (σi−1 )C ∗ (σi1 ) . . . C ∗ (σim )C ∗ (σi+1 ) . . . C ∗ (σn ) (26)
232
Ivan Cibrario Bertolotti et al.
Moreover, it is assumed that, on each invocation of the C ∗ function on term σ, all rewrite rules whose prerequisite are satisfied on σ are applied in sequence, until the set of applicable rules is exhausted, or the only applicable rule is either the atom-preserving rule (23), or the trivial canonicalisation rule (24) for operators with no special properties. The order of rule application does not matter, because any order leads to the same canonical term. Theorem 7. The function C ∗ : T → T is computable for any finite-length σ∈T. The proof is based on the observation that, given a term σ, only a finite number of rewrite rules in the form (25-26) are applicable to each sub-term of σ, and no sequence of rule applications on a term can lead to the term itself. In addition, rules (23-24) can be applied at most once to each atom of σ and to each sub-term of σ, respectively, but those sub-terms are in finite number because σ is finite.
5
Extended Intruder’s Knowledge Representation
The intruder’s knowledge closure rules, the predicates defining Σ, the r(·, ·) algorithm, and the Σ minimisation rules presented in Sect. 3, have to be extended to take into account the operator’s properties and to ensure that all properties of Σ still hold: in fact, it can be proved that all properties mentioned in Sect. 3 (including incremental computability) still hold under the extensions proposed here. 5.1
Commutative Operators
Let us assume, without loss of generality, that is a binary, commutative operator. The ability to synthesise a compound term by means of operator can be captured by the following closure rule, to be added to rules (1-8): ∧ σ2 ∈ Σ ∧ σ1 ≤T σ2 ⇒ σ1 σ2 ∈ Σ . σ1 ∈ Σ
(27)
Accordingly, the following, additional Σ defining predicate must be added to (9-11): ∨ σ2 ∈ Σ) ∧ σ1 ≤T σ2 . (28) σ1 σ2 ∈ Σ ⇔ (σ1 ∈ Σ ∨ σ2 ∈ Σ prevents the presence of comInformally, the predicate σ1 ∈ Σ pound terms σ1 σ2 and σ2 σ1 in Σ if they can be synthesised from their operands; predicate σ1 ≤T σ2 is made true by term canonicalisation, performed before inserting any term in the intruder’s knowledge, and effectively prevents the presence of both σ1 σ2 and σ2 σ1 in Σ, by explicitly selecting which one has to be preferred. Similarly, closure rule (27) gives rise to the following additional Σ reduction rule to be added to (14-17): σ1 σ2 ∈ Σi ∧ r(σ1 , Σi ) ∧ r(σ2 , Σi ) → {σ1 σ2 }, (27), ∅
(29)
Commutative and Associative Operators in Cryptographic Protocol Analysis
233
Rule (29) has a premise term that can be generated using other elements of Σi , and simply removes its premises. Therefore, it cannot introduce loops, and ensures that Σi+1 only contains canonic terms if preserves the closure Σ the same is true for Σi . Closure rule (27) is also the starting point to extend the function r(·, ·) presented in Sect. 3: boolean r(σ, Σ) { ... else if σ = (σ1 , σ2 ) ∧ ∈ PC then return r(σ1 , Σ) ∧ ... } 5.2
r(σ2 , Σ) ;
Associative Operators
Let us assume, without loss of generality, that ∈ PA is a n-ary, associative operator, with n ≥ 2. In addition, let us assume that the (degenerate) invocation of operator with one operand is the operand itself: (σ) = σ. The ability to synthesise a compound term by means of operator , possibly leveraging the associative property, is captured by the following closure rule: ∧ (σ21 . . . σ2n ) ∈ Σ ⇒ (σ11 . . . σ1m , σ21 . . . σ2n ) ∈ Σ (σ11 . . . σ1m ) ∈ Σ (30) by the additional Σ defining predicate: ∨ (σi+1 . . . σn ) ∈ Σ (σ1 . . . σn ) ∈ Σ ⇔ ∀i ∈ [1, n − 1] (σ1 . . . σi ) ∈ Σ (31) by the additional Σ reduction rule: (σ1 . . . σn ) ∈ Σi ∧ ∃i ∈ [1, n − 1] | r((σ1 . . . σi ), Σi ) → {(σ1 . . . σn )}, (30), ∅ (32) ∧ r((σi+1 . . . σn ), Σi ) and by the following extension to the r(·, ·) function: boolean r(σ, Σ) { ... else if σ = (σ1 , . . . σn ) ∧ ∈ PA then return ∃i ∈ [1, n − 1] | r((σ1 , . . . σi ),Σ) ∧ r((σi+1 , . . . σn ),Σ) ; ... } If is both associative and commutative, the rules outlined above must be complemented because if the lists: (σ1 . . . σi ) and (σi+1 . . . σn ) are both sorted according to ≤T , this does not imply that their concatenation (σ1 . . . σi , σi+1 . . . σn ) is also sorted according to the same relation. even So, for example, assuming that σ1 ≤T σ2 ≤T σ3 it can be (σ1 , σ2 , σ3 ) ∈ Σ if σ1 ∈ Σ ∧ (σ2 , σ3 ) ∈ Σ ∧ (σ1 , σ2 ) ∈ Σ ∧ σ3 ∈ Σ and closure rule (30) ∧ (σ1 , σ3 ) ∈ Σ. cannot be applied. In fact, this happens when σ2 ∈ Σ
234
Ivan Cibrario Bertolotti et al.
On the other hand, the same closure rule can introduce non-canonical terms for the same reason. The refined closure rule for a commutative and assoin Σ, ciative operator therefore is: ∧ (σ21 . . . σ2n ) ∈ Σ ⇒ (σ11 . . . σ1m ) ∈ Σ , C ∗ ((σ11 . . . σ1m , σ21 . . . σ2n )) ∈ Σ
(33)
where the invocation of the canonicalisation operator C ∗ avoids non-canonical terms in Σ. On the other hand, when defining the Σ reduction rules on terms in the form (σ1 . . . σn ), all possible partitions of S = {σ1 . . . σn } into two subsets must be considered: (σ1 . . . σn ) ∈ Σi ∧ ∃S1 , S2 | S1 = ∅ ∧ S2 = ∅ ∧ S1 ∩ S2 = ∅ → {(σ1 . . . σn )}, (33), ∅ ∧ S1 ∪ S1 = {σ1 . . . σn } ∧ r((S1 ), Σi ) ∧ r((S2 ), Σi ) (34) In the above rule, with a little abuse of notation, we let (S) = (σ1 . . . σn ), where S = {σ1 . . . σn } is a set. In the same manner, the extension to the r(·, ·) function must be: boolean r(σ, Σ) { ... else if σ = (σ1 , . . . σn ) ∧ ∈ PA ∩ PC then return ∃ S1 , S2 | S1 = ∅ ∧ S2 = ∅ ∧ S1 ∩ S2 = ∅ ∧ S1 ∪ S2 = {σ1 , . . . σn } ∧ r((S1 ), Σ) ∧ r((S2 ), Σ) ; ... }
6
Diffie-Hellman Key Exchange Protocol
In the Diffie-Hellman protocol [9], depicted in Fig. 1, two numbers G and N are publicly agreed on by the communicating principals A and B. A chooses X = Gn1 mod N for some random n1 and sends the result to B as message (1). B chooses Y = Gn2 mod N for some random n2 and sends the result to A as message (2). A computes k = Y n1 mod N and B computes k = X n2 mod N . The result of these two calculations is the same and is equal to the new session key k. This provides a means for exchanging keys but gives no guarantees of authenticity. The last step (3) does not belong to the key-exchange protocol itself, but shows how the new key shared among agents can be used: A sends a message M encrypted by means of k = (Gn2 mod N )n1 mod N to B which in turn can decrypt it by means of the same key k = (Gn1 mod N )n2 mod N .
Commutative and Associative Operators in Cryptographic Protocol Analysis
235
(1) A → B : X = Gn1 mod N (2) B → A : Y = Gn2 mod N (3) A → B : {M }Y n1 mod N Fig. 1. The Diffie-Hellman key exchange protocol
6.1
Representation of the Diffie-Hellman Operator
Here we define a new operator which allows to model computations made in the Diffie-Hellman key exchange protocol. Let us define: σσN1 ...σn = σ σ1 ...σn mod N .
(35)
The new operator has the following properties: Π(σ1 ...σn )
σσN1 ...σn = σN
,
(36)
where Π(σ1 . . . σn ) is a permutation, which captures the commutative property of the exponent product, and: σσN11 ...σ1n σN21 ...σ2m = σσN11 ...σ1n σ21 ...σ2m ,
(37)
which reflects the ability to associate nested invocations of the operator in base position. The generic term canonicalisation rewrite rules outlined in Sect. 4.3 can be specialised for the Diffie-Hellman operator, taking into account its well-known operator’s algebraic properties recalled in (35-37). The specialised rewrite rules are: (∃i | σi = C ∗ (σi ) ∨ ∃i, j | C ∗ (σi )≤T C ∗ (σj )) ∧ ∃k1 . . . kn , ki = kl ∀i, l | C ∗ (σki )≤T C ∗ (σki+1 ), i = 1 . . . n − 1 (38) C ∗ (σ ),...C ∗ (σkn ) C σσN1 ,...σn −→ σN k1 σ = σ σN11 ,...σ1n C
σσN21 ,...σ2m −→ σ σN11 ,...σ1n ,σ21 ...σ2m
(39)
The intruder’s ability to compute the Diffie-Hellman operator can be expressed by the following closure rules: ∧ σ1 , . . . σn ∈ Σ ∧ σi ≤T σi+1 ∀i ∈ [1, n − 1] ⇒ σ σ1 ,...σn ∈ Σ σ ∈ Σ N (40) ∧ σ21 , . . . σ2m ∈ Σ ⇒ C ∗ ( σ σ11 ,...σ1n ,σ21 ,...σ2m ) ∈ Σ σ σN11 ,...σ1n ∈ Σ N (41) Rule (40) captures the commutative property of the Diffie-Hellman operator with respect to σ1 , . . . σn ; similarly, rule (41) captures the ability to flatten nested invocations of the Diffie-Hellman operator in base position by grouping exponents σ11 , . . . σ1n and σ21 , . . . σ2m together.
236
Ivan Cibrario Bertolotti et al.
In rule (41), the invocation of the canonicalisation operator C ∗ avoids the in rule (40), canonicalisation is unintroduction of non-canonical terms in Σ; necessary, because the rule’s prerequisites implicitly ensure that the right-hand term is canonic. closure rules above, we can introduce the following addiAccording to the Σ tional Σ defining predicates; below, S1 and S2 represent all possible partitions of S = {σ1 , . . . σn } and, with a little abuse of notation, we let σSN1 = σσN11 ,...σ1k ∨ ∃i | σi ∈ Σ) ∧ σj ≤T σj+1 ∀j ∈ [1, n−1] (42) σσN1 ,...σn ∈ Σ ⇔ (σ ∈ Σ S1 = {σ11 , . . . σ1k }, S2 = {σ21 , . . . σ2l }, S = ∅ ∧ S = ∅ ∧ S ∩ S = ∅ ∧ 1 2 1 2 σσN1 ,...σn ∈ Σ ⇔ ∀S1 , S2 | S1 ∪ S2 = {σ1 , . . . σn } ∧ ∨ ∃i | σ2i ∈ Σ) ( σSN1 ∈ Σ (43) Last, closure rules (40) and (41) induce the following Σ reduction rules: σσN1 ,...σn ∈ Σi ∧ r(σ, Σi ) ∧ r(σj , Σi ) ∀j ∈ [1, n] → { σσN1 ,...σn }, (40), ∅
(44)
σσN1 ,...σn ∈ Σi ∧ ∃S1 , S2 | S1 = {σ11 , . . . σ1k }, S2 = {σ21 , . . . σ2l }, S1 = ∅ ∧ S2 = ∅ ∧ S1 ∩ S2 = ∅ → ∧ S1 ∪ S2 = {σ1 , . . . σn } ∧ r( σSN1 , Σi ) ∧ r(σ2j , Σi ) ∀j ∈ [1, l]
{ σσN1 ,...σn }, (41), ∅ (45)
and the following extension to the r(·, ·) function: boolean r(σ, Σ) { ... else if σ = σ σN 1 ,...σn then return ( r(σ , Σ) ∧ r(σj , Σ) ∀j ) ∨ (∃S1 = {σ11 , . . . σ1n }, S2 = {σ21 , . . . σ2m } | S1 = ∅ ∧ S2 = ∅ ∧ S1 ∩ S2 = ∅ ∧ S1 ∪ S2 = {σ1 , . . . σn } ∧ r( σ SN1 , Σ) ∧ r(σ2j , Σ) ∀j); ... } 6.2
Example of Intruder’s Knowledge Management
Table 3 shows how the intruder’s knowledge grows up when the intruder intercepts the messages exchanged between A and B of Fig. 1: Σ is the minimised intruder’s knowledge, ρ is the eavesdropped message, and column C contains the number of the canonicalisation rules needed to put ρ in canonical form.
Commutative and Associative Operators in Cryptographic Protocol Analysis
237
Table 3. An example of canonicalisation Σ {c, G, N } 1 {c, G, N, Gn N } n1 2 {c, G, N, GN , Gn N }
n2 1 n n {c, G, N, Gn N , GN , {M }G 1 2 }
ρ C 1 Gn N 2 Gn N {M }Gn2 n1 (39) N N (38) {M }Gn2 n1 N n n {M }G 1 2 N
N
The first and second message of Fig. 1 are already in canonical form, thus no canonicalisation is needed. Moreover, they cannot be split into simpler submessages, thus the new minimal intruder’s knowledge is obtained simply by adding these messages to the initial one. The last message of Fig. 1 has been encrypted by a nested invocation of the new operator thus, by rule (39), the associative property is exploited and {M }Gn2 n1 is obtained. Last, rule (38) gives the canonical form {M }Gn1 n2 N N where each exponent precedes the next with respect to the total order relation among terms (we assume n1 ≤T n2 ). Table 4 shows what happens to the intruder’s knowledge when n1 belongs to the initial Σ, too. Since the canonicalisation details have already been analysed in the previous example, here we assume that each message the intruder intercepts is already in canonical form (C ∗ (ρ)), and we focus on the intruder’s knowledge minimisation steps, induced by the presence of n1 in the initial Σ. At each protocol step Σ (obtained from the previous step) and the intercepted message C ∗ (ρ) are listed in a row. Below, the sequence of reduction steps follows, Table 4. An example of reductions Σ = {c, G, N, n1 } i Σi 1 0 {c, G, N, n1 , Gn N } 1 {c, G, N, n1 } Σ = {c, G, N, n1 } i Σi 2 0 {c, G, N, n1 , Gn N }
1 C ∗ (ρ) = Gn N R ΣI ΣO 1 (44) { Gn ∅ N }
2 C ∗ (ρ) = Gn N R ΣI ΣO
C ∗ (ρ) = {M }Gn1 n2 N i Σi R ΣI ΣO 2 n1 n2 } (17) {{M } n1 n2 } {M } 0 {c, G, N, n1 , Gn , {M } N GN GN 2 1 {c, G, N, n1 , Gn N , M} 2 Σ = {c, G, N, n1 , Gn N }
2 Σ = {c, G, N, n1 , Gn N , M}
238
Ivan Cibrario Bertolotti et al.
starting from Σ0 = Σ ∪ {C ∗ (ρ)} and ending when a new minimised Σi has been obtained. For each step, the reduction rule used (R) and the corresponding ΣI and ΣO sets are shown. Starting from Σ = {c, G, N, n1 }, the intruder captures the first message GnN1 sent from A to B, thus Σ0 = {c, G, N, n1 , GnN1 } is obtained. GnN1 can be synthesised starting from G and n1 (N is embedded into the operator itself, but this is correct since N and G are publicly agreed between A and B), in fact rule (44) allows to remove it from Σ0 . The next intercepted message is GnN2 ; it is added to Σ without any reduction, since it can neither be synthesised from simpler messages, nor it allows to decode some message already in Σ. In fact, premises of both rules (44) and (45) fail. The last intercepted message is {M }Gn1 n2 . Since r(Σ0 , GnN1 n2 ) is N true, then rule (17) allows to remove {M }Gn1 n2 from, and add M to the N intruder’s knowledge. In fact r( GnN1 n2 , Σ0 ) corresponds to the last extension to r(·, ·) made before the examples. By defining S1 = {n2 } and S2 = {n1 }, we have that both r( GSN1 , Σ0 ) and r(n1 , Σ0 ) are true.
7
Conclusions
A compact and efficient intruder’s knowledge representation is a key point for all formal techniques that use model checking to verify cryptographic protocols. Current techniques rely on specification languages and intruder’s knowledge models that allow to deal only with abstract term composition operators, without any mathematical property. This prevents to model protocols that heavily use commutative and associative operators to build their messages. In this paper we have shown how to overcome such a limitation by enabling an existing intruder’s knowledge representation technique to successfully handle also messages built by means of associative and commutative operators. Then, theoretical results have been applied to build the set of rules needed to handle the knowledge of a Dolev-Yao intruder that eavesdrops on a session of the Diffie-Hellman key exchange protocol. As a further enhancement, we plan to extend this technique in order to enable it to manage operators with operand self-cancellation properties, such as the exclusive-or.
References 1. Mart´ın Abadi and Andrew D. Gordon. A calculus for cryptographic protocols. The spi calculus. Information and Computation, 148(1):1–70, January 1999. 2. Michele Boreale and Maria Grazia Buscemi. A framework for the analysis of security protocols. In Proceedings of CONCUR’01. Springer-Verlag, 2002. 3. Michele Boreale, Rocco De Nicola, and Rosario Pugliese. Proof techniques for cryptographic processes. In Proceedings of 14th IEEE LICS, pages 157–166. IEEE Computer Society Press, 1999.
Commutative and Associative Operators in Cryptographic Protocol Analysis
239
4. Yannick Chevalier, Ralf K¨ usters, Micha¨el Rusinowitch, and Mathieu Turuani. An NP decision procedure for protocol insecurity with XOR, 2003. To appear in Proc. of 18th IEEE LICS’2003. 5. Ivan Cibrario Bertolotti, Luca Durante, Riccardo Sisto, and Adriano Valenzano. A new knowledge representation strategy for cryptographic protocol analysis. In Proceedings of TACAS’03, volume 2619 of Lecture Notes in Computer Science, pages 284–298. Springer-Verlag, April 2003. 6. E. M. Clarke, S. Jha, and W. Marrero. Using state space exploration and a natural deduction style message derivation engine to verify security protocols. In Proceedings of IFIP PROCOMET, pages 87–106, London, 1998. Chapman & Hall. 7. E. M. Clarke, S. Jha, and W. Marrero. Verifying security protocols with Brutus. ACM Transactions on Software Engineering and Methodology, 9(4):443–487, October 2000. 8. H. Comon-Lundh and V. Shmatikov. Constraint solving and insecurity decision in presence of exclusive or, June 2003. To appear in Proc. of 18th IEEE LICS’2003. 9. W. Diffie and M. Hellman. New directions in cryptography. IEEE Transactions on Information Theory, 22(6):644–654, November 1976. 10. D. Dolev and A. Yao. On the security of public key protocols. IEEE Transactions on Information Theory, 29(2):198–208, 1983. 11. Gavin Lowe. Breaking and fixing the Needham-Schroeder public-key protocol using FDR. In T. Margaria and B. Steffen, editors, Proceedings of TACAS’96, volume 1055 of Lecture Notes in Computer Science, pages 147–166. SpringerVerlag, 1996. 12. Gavin Lowe. Casper: a compiler for the analysis of security protocols. In Proceedings of 10th IEEE CSFW, pages 18–30. IEEE Computer Society Press, June 1997. 13. Gavin Lowe. Towards a completeness result for model checking security protocols. Journal of Computer Security, 7(2–3):89–146, 1999. 14. W. Marrero, E. M. Clarke, and S. Jha. A model checker for authentication protocols. In DIMACS Workshop on Design and Formal Verification of Security Protocols, 1997. 15. Catherine Meadows and Paliath Narendran. A unification algorithm for the group Diffie-Hellman protocol. In Proceedings of WITS’02, 2002. 16. Jonathan Millen and Vitaly Shmatikov. Symbolic protocol analysis with products and Diffie-Hellman exponentiation, June 2003. To appear in Proc. of 16th IEEE CSFW. 17. Jonathan K. Millen, S. C. Clark, and S. B. Freedman. The Interrogator: Protocol security analysis. IEEE Transactions on Software Engineering, 13(2):274–288, February 1987. 18. David Monniaux. Abstracting cryptographic protocols with tree automata. In Sixth International Static Analysis Symposium (SAS’99), number 1694 in Lecture Notes in Computer Science, pages 149–163. Springer Verlag, 1999. 19. Lawrence C. Paulson. The inductive approach to verifying cryptographic protocols. Journal of Computer Security, 6:85–128, 1998. 20. Micha¨el Rusinowitch and Mathieu Turuani. Protocol insecurity with finite number of sessions is NP-complete. In Proceedings of 14th IEEE CSFW, pages 174–187. IEEE Computer Society Press, June 2001. 21. Steve Schneider. Verifying authentication protocols in CSP. IEEE Transactions on Software Engineering, 24(9):741–758, September 1998.
A Lightweight Formal Analysis of a Multicast Key Management Scheme Mana Taghdiri and Daniel Jackson MIT Laboratory for Computer Science, {taghdiri,dnj}@mit.edu
Abstract. This paper describes the analysis of Pull-Based Asynchronous Rekeying Framework (ARF), a recently proposed solution to the scalable group key management problem in secure multicast. A model of this protocol is constructed in Alloy, a lightweight relational modeling language, and analyzed using the Alloy Analyzer, a fully automatic simulation and checking tool for Alloy models. In this analysis, some critical correctness properties that should be satisfied by any secure multicast protocol are checked. Some flaws, previously unknown to the protocol’s designers are exposed, including one serious security breach. To eliminate the most serious flaw, some fixes are proposed and checked using the Alloy Analyzer. The case study also illustrates a novel modeling idiom that supports better modularity and is generally simpler and more intuitive than the conventional idiom used for modeling distributed systems. Keywords: Lightweight modeling, formal specification, Alloy, secure multicast, key management, asynchronous rekeying
1
Introduction
In this paper, we describe an application of a lightweight formal method[7] to the analysis of a recently proposed protocol[16] for key management in a multicast system. To our knowledge, this is the first formal analysis of such a system that exploits automated verification techniques. In modeling the protocol, we developed a new idiom of specification which allows a rather natural and succinct expression of the protocol and its expected properties. Our paper describes the idiom, presents the analysis of the protocol in full, and discusses the ramifications of the flaws that were identified. Our modeling language is Alloy[6]. Since Alloy is essentially just a syntax for a rather conventional first-order logic, we believe that our modeling ideas could be applied straightforwardly in other languages. The model is analyzed with the Alloy Analyzer[5], a fully automatic simulation and checking tool built on an underlying SAT engine. Although our specification closely models the behaviour of a particular protocol – pull based ARF[16] – it introduces a reusable structure to check the correctness properties for a class of multicast key management schemes. These properties are generic, and could be applied to any multicast key management H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 240–256, 2003. c IFIP International Federation for Information Processing 2003
A Lightweight Formal Analysis of a Multicast Key Management Scheme
241
protocol. Although the model of the protocol is abstract, we have been careful to remain faithful enough to the implementation to ensure that all counterexamples are in fact real, so that flaws detected by the Alloy Analyzer actually exist in this protocol. Our experience supports the contention that lightweight formal methods are feasible and economical. Our model is less than 100 lines of code in its entirety, and yet it exposed a kind of message loss in this asynchronous protocol that is non-existent in previous synchronous multicast key management protocols. More significantly, it has shown that the protocol violates one of the properties claimed by its own developers, resulting in a security breach that was not previously known to its designers. We suggest a way to fix this breach and reduce it to a less important kind of message loss. The organization of this paper is as follows: Section 2 compares our proposed modeling idiom with the conventional one. Section 3 gives an overview of the multicast key management problem in general and ARF as a particular solution to that. Section 4 describes our model of this protocol. Section 5 explains the distinguished features of this model. Section 6 describes the analysis of the model, counterexamples found and the evaluation of our suggested fixes. Section 7 explains the related work. Section 8 summarizes and concludes.
2
Tick-Based Modeling vs. Global State Modeling
In this section, we compare tick-based modeling, the idiom we shall use in the rest of the paper, to a more conventional idiom, which we will call global state modeling. Figure 1 shows a simple system modeled in the two idioms. The system is a simple distributed system based on message passing. A server sends some encrypted messages to all the agents in the system. To provide security, whenever the server sends a message it generates a fresh key and encrypts the message with it. This key is then sent to some of the agents authorized to decrypt the message. To simplify the example, we ignore the delay in receiving the key. In Alloy[6], a signature (sig) S introduces a set of atoms of type S. Fields declare relations, and the first column of the relation is always implicit. So, within a signature S, a field declared as r : T is a binary relation that maps each element of S to exactly one element of T, while a field r : set T is a binary relation that maps each element of S to a set of elements of type T. For example in Fig. 1-a, the genTime field in signature Key maps each element of Key to one element of Tick and in Fig. 1-b, the genKeys field in signature Tick maps each element of Tick to a set of elements of type Key. Furthermore, a field declared as r: T -> U in a signature S is actually a ternary relation r: S -> T -> U. A fact paragraph in Alloy is a formula that is always true; a fun paragraph is a formula that can be invoked elsewhere. An assertion (assert) is a conjecture to be checked: a formula claimed to follow from the facts. The check command instructs the Alloy Analyzer to check the validity of an assertion over all the assignments of values to signatures and relations within a given scope, i.e. a
242
Mana Taghdiri and Daniel Jackson
1 2 3
sig Tick {} sig Key { genTime : Tick }
4 5 6 7
sig Message { encKey : Key, sentTime : Tick } {encKey.genTime = sentTime}
8 sig Agent { 9 knows : Tick -> Key } 10 {all t : Tick | knows[t].genTime in OrdPrevs(t)+t} 11 assert NoReusedKey { all m : Message, t : Tick | m.sentTime in OrdNexts(t) => no a : Agent | m.encKey in a.knows[t]} 12 check NoReusedKey for 5
1 2 3 4 5 6 7 8 9
sig Tick { sentMsgs : set Message, genKeys : set Key, agentKnows : Agent -> Key } {all m : sentMsgs | m.encKey in genKeys all a : Agent | agentKnows[a] in (OrdPrevs(this)+this).Tick$genKeys} sig Key {} sig Message { encKey : Key } sig Agent {}
10 fact GeneratedOnce { all disj t, t’ : Tick | no t.genKeys & t’.genKeys} 11 assert NoReusedKey { all m : Message, t : Tick | m in OrdNexts(t).sentMsgs => no a : Agent | m.encKey in t.agentKnows[a]} 12 check NoReusedKey for 5
Fig. 1. Tick-based model (a) on left, and Global state model (b) on right, of a simple system
bound on the number of atoms in each signature. The Alloy Analyzer then finds a counterexample for that assertion if any exists in the specified scope. Alloy is a side-effect-free declarative language. Moreover, no notion of state, transition or even time is built-in. So we define an order over all time ticks in order to be able to talk about the order in which events happen. This total order can be defined by applying generic ordering functions from the Alloy library to signature Tick, as in both models above. Using these functions with any signature T introduces a fresh relation next : T -> T that implicitly defines a total order over all the atoms of type T. These ordering functions are: OrdPrev(t) that returns the atom immediately preceding t, OrdPrevs(t) that returns the set of atoms preceding t excluding t itself, and functions OrdNext(t) and OrdNexts(t) that return the next atom(s). In the tick-based model (Fig. 1-a), signature Tick is a notion of time; all dynamic parts of the system are modeled as relations involving Tick. Signature Key represents the keys generated by the server and the field genTime gives the time at which the key is generated. Signature Message represents sent messages. Each Message has an encrypting key (encKey) and a sent time (sentTime). Line 7 encodes the property that the time at which the encrypting key of a message is generated should be the same as the time at which the message is sent. (In Alloy, the formulas immediately following a signature are facts over all the atoms of that signature.) Signature Agent models the agents of the system and the field
A Lightweight Formal Analysis of a Multicast Key Management Scheme
243
knows gives the set of keys an agent knows at each time. Line 10 encodes the
fact that all keys an agent knows at each time t should be generated before or at time t. (Operator + is the union and in is the subset operator.) Then we claim the trivial property that if a message is sent at some time after t, then its encrypting key is not known to any of the agents at time t (Line 11). No counterexample is found by the Alloy Analyzer in the scope of 5. In the global state model (Fig. 1-b), the signature Tick is used to model a global state, i.e. a snapshot, of the whole system. All mutable components of the system are modeled as fields of this signature. So here the fields of Tick are sentMsgs, i.e. the messages sent in this state, genKeys, i.e. the keys generated in this state and agentKnows that gives the keys known to each agent in this state of the system. Lines 5 and 6 express the same properties as lines 7 and 10 in the previous model. The other signatures have the same semantics as in the previous case. The fact GeneratedOnce (Line 10) is implicit in the tick-based model. It says there is no key generated in two different ticks t and t (& is the set intersection operator and disj represents disjoint sets). While in the previous model the field genTime in Key implicitly encodes, in its declaration, that a key has a single generated time, here this explicit fact is necessary to outlaw false situations in which a key is generated more than once. Without this rule, the assertion would not hold. The key difference of the two idioms is that, in tick-based modeling, history is maintained local to objects, while in global state modeling, global state is associated with time ticks. In other words, in tick-based models we are able to maintain all the attributes of an entity in a single place, i.e. the declaration of that entity. Thus, the tick-based idiom exhibits better modularity. Furthermore, models based on global state may need more non-obvious rules (like GeneratedOnce here). This makes them more error-prone. So in general, tick-based models are simpler and more succinct.
3 3.1
Overview of the Asynchronous Rekeying Framework Secure Multicast and Key Management Problem
Multicast is appropriate when an identical message is to be sent to a group of authorized agents. It has become more important due to the growth of network applications such as teleconferencing, internet newscast, distributed games, and stock quotes. In sending a message to a large group, multicast is much more efficient than many point-to-point unicasts. However, multicast introduces new problems: the message should not be readable by unauthorized users, while it must be guaranteed that all authorized users are able to read it. One approach is to encrypt the message using a key only known to the members of the group, called the group key. However, in many applications group membership changes often, as members leave and join. In such groups, to provide communication security, we have to
244
Mana Taghdiri and Daniel Jackson
make sure that former members do not have access to the current messages and new members do not have access to the previous communications of the group. So after each join or leave, a new group key is generated and distributed to all current group members in order to send or receive the messages securely. Members who do not receive key updates may cause security breaches: – Receivers failing to receive group key updates will not be able to decrypt new messages, and may also accept messages from members that have been removed from the group. – Senders failing to receive group key updates will continue to encrypt messages with an outdated group key so that some of the current members of the group may be unable to decrypt the message and also some of the previous members of the group may be able to decrypt it. Handling group key changes efficiently is a problem in large dynamic groups. Many solutions have been proposed to solve this problem, known as group key management, addressing its different aspects of scalability and performance. 3.2
Asynchronous Rekeying – The ARF Protocol
The Asynchronous Rekeying Framework [13, 16], which we call ARF for short, is one of the recent proposed solutions to the key management problem. It tries to reduce the overhead caused by the synchronization of all members during rekeying in a large dynamic group, by distributing the group key to the members only on demand, i.e. asynchronously. To the best of our knowledge, ARF is the only proposed asynchronous rekeying protocol. This motivated us to verify some of its claims formally. The ARF designers argue that synchronizing all group members for agreement on rekeying after each change in the key, as in other protocols, is costly and unnecessary. Rather, it is sufficient to guarantee that each member is able to receive the key updates before sending or receiving group messages. Thus, they propose to distribute the group key updates on demand, just prior to use. ARF was designed in two phases. The first phase was pull-based ARF. However, since it was not scalable to large groups, it was combined with push-based ARF. In this paper we focus on analyzing the pull-based ARF[16]. In the ARF architecture, the group is partitioned into subgroups called domains. Each domain has a trusted Key Distribution Server (KDS) which has information about its domain membership and is responsible for processing the requests of the domain’s members. There is a distinct individual key shared between each member of a domain and the corresponding KDS. This key is used when it is needed to send a message not decryptable by others. It is assumed that the KDS’s communicate with each other via a Reliable and Totally Ordered Multicast Protocol (RTOMP). Reliable multicast protocols provide retransmissions and ordering of messages from a source. Totally ordered multicast protocols guarantee that all members receive messages in the same order, ensuring consistency of shared information.
A Lightweight Formal Analysis of a Multicast Key Management Scheme
245
When a group member wants to leave the group, it sends a leave request to the KDS of its domain and waits for confirmation. The KDS generates a new group key, distributes it to the other KDS’s and then sends back the confirmation. In some cases, a KDS may decide that a current member of its domain should leave and so initiates the leaving process itself. When a host wants to join the group, it sends a join request to one of the KDS’s and waits for confirmation. The KDS authenticates it and sends a confirmation if approved. The host then joins the corresponding domain. A new individual key is generated for the new member in this process. Whenever membership changes in a domain, the KDS of that domain creates a new valid group key and distributes it to other KDS’s using the RTOMP. The KDS also sends the new group key to the new members of the domain, if any, using their individual keys. Each group key carries a unique ID as well as the ID of the KDS which has generated it. All group keys are ordered by the RTOMP. Thus, although different KDS’s may create different new group keys simultaneously, there will not be any conflict in the order of key updates. When a member decides to send a message, it sends a sequence number request to the KDS of its domain to check the newness of the group key it owns. The member attaches the ID of its newest group key to this message. If the ID of the member’s key is older than the newest group key, the KDS sends back all the newer keys. The individual key of the member is used to encrypt this reply. Then, the member uses the newest key to encrypt its message and multicasts the encrypted message. When a member receives a message which is not encrypted by any of its valid keys, it sends a request to the KDS of its domain and asks for the newer keys. It attaches the ID of its newest key to this request. The corresponding KDS replies to this request with new keys, as for a sender. A KDS marks a group key as invalid if it is distributed to all the members of its domain. A member marks a key as invalid t units of time after it receives a message encrypted with a newer key, where t is the accepted delay of the network. To prevent members from keeping very outdated keys, a KDS must multicast a dummy message encrypted by the newest group key if there have been no messages for a while.
4
Alloy Model of the Asynchronous Rekeying Framework
We have made an abstract model of the pull-based ARF in Alloy. Since there is no notion of delay for the RTOMP in the original protocol, we assume that there is no delay in the communications via the RTOMP. Hence, if a KDS generates a new group key, all other KDS’s receive it instantly. Furthermore, we assume that a member marks a key as invalid when it receives a message encrypted with a newer key or, more precisely, when it receives a newer key from the KDS1 . 1
This will eliminate some trivial scenarios in which ARF does not work correctly only because of the notion of t units of delay time in invalidating keys.
246
Mana Taghdiri and Daniel Jackson
sig Tick {} sig Member { kds : KDS, ownedKeys : Tick -> Key, receivedMessages : Tick -> Message } sig KDS { keys : Tick -> Key, members : Tick -> Member } sig Message { sender : Member, sentTime : Tick, encryptingKey : Key } sig Key { creator : KDS } Fig. 2. Basic components of the model
Basic components of the model are shown in Fig. 2. – Member: This signature models all the members in the system. Field kds gives the KDS of the domain this member belongs to (or may join in the future). The model has no explicit notion of domain; all members with the same kds field belong to the same domain. The fields ownedKeys and receivedMessages give respectively all the keys and messages known to this member at a given time. Since, as mentioned before, Tick is an ordered type, these fields give the sequence of keys and messages and thus keep a history of them. – KDS: This signature models the key distribution servers in the system. The keys field in this signature indicates the keys known to this KDS at a time tick and members shows the members present in the corresponding domain at a time tick. – Message: This signature models only multicasted messages. Each message has a sender, a sent time and an encrypting key. – Key: This signature models only group keys. creator gives the KDS generating this key. The kds field of the Member signature is not based on time: once its value is determined, it does not change. So a member m can only join the domain indicated by m.kds whenever it wants to join the group. This relies on the fact that different domains are interchangeable. So there is no need to consider all combinations of domains for a member to join over time. With this observation, without loss of generality, many possible cases are pruned away, and analysis time decreases. To model the behavior of the RTOMP, the previously mentioned ordering functions of Alloy’s library are used on signature Key. Thus, all the generated keys are ordered. Furthermore, it is implicitly assumed that if key k2 follows key k1 in this ordering, then k2 is generated at some time not before k1 . With this assumption, there is no need to explicitly record the time at which a key is generated. This makes the model simpler and easier to analyze.
A Lightweight Formal Analysis of a Multicast Key Management Scheme
247
fun SendMessage(m : Member, t : Tick, msg : Message) { let t’ = OrdPrev(t) { m.ownedKeys[t] = m.ownedKeys[t’] + NewerKeys(m, m.kds, t, NewestKey(m.ownedKeys[t’])) m.receivedMessages[t] = m.receivedMessages[t’] + msg } msg.sender = m && msg.sentTime = t msg.encryptingKey = NewestKey(m.ownedKeys[t]) ConstantMembership(m, t) } fun ReceiveMessage(m : Member, t : Tick, msg : Message) { CanReceive(m, msg, t) let t’ = OrdPrev(t) { let newestKey = NewestKey(m.ownedKeys[t’]) | msg.encryptingKey = newestKey => m.ownedKeys[t] = m.ownedKeys[t’], m.ownedKeys[t] = m.ownedKeys[t’] + NewerKeys(m,m.kds,t,newestKey) m.receivedMessages[t] = m.receivedMessages[t’] + msg }} fun CanReceive(m : Member, msg : Message, t : Tick) { ConstantMembership(m, t) msg !in m.receivedMessages[OrdPrev(t)] msg.sentTime in OrdPrevs(t) let newestKey = NewestKey(m.ownedKeys[OrdPrev(t)]) | msg.encryptingKey in NewerKeys(m, m.kds, t, newestKey) + newestKey } Fig. 3. Main constraints - part one
In order to support delay in propagating messages, we let a message be sent at some time and received by other members at any later time. Thus, different members may receive the same message at different times. Figures 3 and 4 show the main operations in this model. The model also makes use of auxiliary functions defined in Appendix 8. Some of these are simple utilities (such as defining the newest key in a set of keys); others represent frame conditions which prevent undesired changes of values in the model. We use the following fact to constrain the initial values and the behavior of each member at each time. It constrains the histories associated with the tick-based relations to match the defined operations. fact MemberBehavior{ Init(Ord[Tick].first) all m: Member, t: Tick - Ord[Tick].first | (some msg: Message | SendMessage(m,t,msg) || ReceiveMessage(m,t,msg)) || (some k: KDS | Join(m,t,k)) || Leave(m,t) || MemberInactive(m,t)}
The function Init, presented in the appendix, describes the constraints on the initial state of the model: it makes an empty group in which no host owns any keys or messages. According to MemberBehavior, at each time after that, each member can choose what to do from the list of specified actions. (||, && and ! are respectively logical or, and and not operators in Alloy.) Following is a brief description of functions shown in Figures 3 and 4.
248
Mana Taghdiri and Daniel Jackson
fun Join(m : Member, t : Tick, k : KDS) { k = m.kds JoinRequest(m, k, t) NoChange(m.receivedMessages, t) } fun Leave(m : Member, t : Tick) { LeaveRequest(m, m.kds, t) NoChange(m.receivedMessages, t) } fun JoinRequest(m : Member, kds : KDS, t : Tick) { m !in kds.members[OrdPrev(t)] && m in kds.members[t] some k : GeneratedKey(kds, t) { m.ownedKeys[t] = m.ownedKeys[OrdPrev(t)] + k k in kds.keys[t] } } fun LeaveRequest(m : Member, kds : KDS, t : Tick) { m in kds.members[OrdPrev(t)] && m !in kds.members[t] GeneratedKey(kds, t) in kds.keys[t] NoChange(m.ownedKeys, t) } Fig. 4. Main constraints - part two
1. SendMessage(m, t, msg) Without loss of generality, we assume a member sends only one message at each time. To send a message, the member asks its KDS for newer keys. It sends its current newest key with this request. The KDS then checks (in function NewerKeys in the appendix) the newness of this key and sends back all the newer keys. Since according to ARF, each KDS knows about the memberships of its domain, the KDS returns an empty set of keys if it finds out that the member is not currently in the group. The member then adds this set of keys to its set of owned keys and sends the message encrypted with the newest key. This message is added to its set of known messages. 2. ReceiveMessage(m, t, msg) Without loss of generality, we assume a member can receive only one message at each time. A member m can receive a message msg at time t if CanReceive(m, msg, t) holds. The member checks if the message is encrypted with its newest owned key. If not, it asks the corresponding KDS for newer keys and adds them to its set of keys. Then, it accepts the message. (x => y, z used in this function is a syntax for if x then y else z.) 3. CanReceive(m, msg, t) A member m can receive message msg at time t only if its membership is not being changed at the same time, if the message was not received before, it was sent at some time in the past and the encrypting key is either the member’s newest key or a key newer than that. 4. Join(m, t, kds) To join a domain, the member sends a join request to its assigned KDS. In the JoinRequest function, the KDS makes sure that the member was not in
A Lightweight Formal Analysis of a Multicast Key Management Scheme
249
the group in the previous time tick. The KDS adds it to the set of current group members. A new key is generated and sent to this new member as well as all other KDS’s. 5. Leave(m, t) To leave a domain, the member sends a leave request to its KDS. In LeaveRequest, it is checked that the member was a group member in the last time tick. Then it is removed from the group. A new key is generated and sent to all other KDS’s. (In this case the new key is not sent to the leaving member.)
5
Distinguished Features of the Model
Although this model is specific to the pull-based ARF properties, it suggests a structure for modeling a class of multicast key management protocols. The signatures in Fig. 2 define aspects of any key management protocol. These signatures can be extended to include more features if needed, and the operations can be written in the same way as introduced here to describe the operations of the underlying protocol. In the first author’s masters thesis[15], the same structure is used to formally check Iolus[12], a totally different approach to the scalable multicast key management problem. Thus, the model is reusable in this sense. The structure of this model is based on local behaviour; a member decides what to do at each time, nondeterministically and independently from others. Thus, it allows different members to do different things simultaneously, despite the lack of an explicit modeling of any concurrency mechanism. Because of this flexibility in the model, the analyzer can generate unusual scenarios which are likely to be neglected in a manual review. On the other hand, the model is constrained enough (by preconditions inherent in the operations) to prevent a single member from doing several different things at the same time. To ensure that this is so, we formulate assertions of this form for each pair of operations: assert NotSimultaneous { no m : Member, msg : Message, t : Tick | Join(m, t, m.kds) && SendMessage(m, t, msg) }
No counterexample is found for any of them.
6
Analysis of the Model
The Alloy Analyzer has been used to automatically check some properties of the model, shown in Fig. 5. The first assertion is checked in a scope of 5 and no counterexample is found. The other ones are checked in a scope of 6. All of them are checked in less than three minutes on a 1.80 GHz Pentium 4 processor.
250
Mana Taghdiri and Daniel Jackson
assert OutsiderCantRead { no msg : Message, m : Member, t : Tick { IsMember(msg.sender, msg.sentTime) !IsMember(m, msg.sentTime) CanReceive(m, msg, t) } } assert OutsiderCantSend { no msg : Message, m : Member, t : Tick { !IsMember(msg.sender, msg.sentTime) IsMember(m, t) CanReceive(m, msg, t) } } assert InsiderCanRead { no msg : Message, m : Member, t : Tick { IsMember(msg.sender, msg.sentTime) IsMember(m, msg.sentTime) t in OrdNexts(msg.sentTime) msg !in m.receivedMessages[OrdPrevs(t)] && !CanReceive(m, msg, t)}} Fig. 5. Basic properties of any secure multicast scheme
6.1
Verified Properties of the Pull-Based ARF
The assertion OutsiderCantRead claims that all messages sent inside the group are secure from anyone outside. This is modeled by saying there is no message sent inside the group (IsMember(msg.sender, msg.sentTime)) that someone who was not present in the group at that time (!IsMember(m, msg.sentTime)) can receive it at some time (CanReceive(m, msg, t)). The Alloy Analyzer could not find any counterexample for this assertion. It should be noted that this assertion subsumes two different desirable properties of any secure multicast protocol: “A new member of the group does not have access to the previous communications” and “A former group member has no access to the current communications”. 6.2
Flaws Found
OutsiderCantSend: This assertion claims that no message is sent outside the group (!IsMember(msg.sender, msg.sentTime)) which can be received by some member at a time he is inside the group (IsMember(m, t) and CanReceive(m, msg, t)) and thus, interpreted as a valid group message.
For this assertion, the Alloy Analyzer found two different types of counterexamples shown in Tables 1 and 2. In both scenarios the group has only one domain. The first case is when member m1 joins the group when member m0 is already there. Thus, m1 receives a key (k4 ) newer than that of m0 (k3 ). Then, m1 leaves the group and decides to send a message. Since it is not in the group any more, the KDS denies to send it the newer keys. Thus, it encrypts its message with its own newest key, k4 . When m0 receives the message, since it is encrypted
A Lightweight Formal Analysis of a Multicast Key Management Scheme
251
Table 1. First counterexample for OutsiderCantSend Time, KDS Newest Key Member m0 , Newest Key Member m1 , Newest Key T1 , k 3 join, k3 T2 , k 4 - , k3 join, k4 T3 , k 5 - , k3 leave, k4 T4 , k 5 - , k3 send a message , k4 T5 , k 5 receive the message, k5 - , k4
Table 2. Second counterexample for OutsiderCantSend Time, KDS Newest Key Member m0 , Newest Key Member m1 , Newest Key T1 , k 1 join, k1 join, k1 T2 , k 2 - , k1 leave, k1 T3 , k 2 - , k1 send a message, k1 T4 , k 2 receive the message , k1 - , k1
with a key newer than its own, it asks the KDS for newer keys. The KDS sends it both k4 and k5 according to the ARF scheme and so m0 decrypts the message just like an ordinary group message. In the second scenario, two members m0 and m1 join the group at exactly the same time and thus, get the same group key (k1 ). Then m1 leaves the group and sends a message encrypted with its newest key (k1 ). When m0 receives this message, it does not contact the KDS for newer keys because the message is encrypted with its own newest key. So it accepts and decrypts the message without realizing that the message is sent from outside the group. These scenarios indicate a serious security breach. A message from a former group member can influence current communications of the group. We contacted the authors of the original paper [16] to ask about this problem. They were not previously aware of this bug and agreed that the protocol is flawed. To fix the bug, the model was changed so that in reply to the sequence number request, the KDS attaches only the newest key rather than a key vector. Function NewerKeys-modified in the appendix reflects this change. Also, the behavior of each member was modified so that before receiving any messages, it asks the KDS for the newest group key. If the message is not encrypted with the newest group key, it should not be accepted. The new functions are shown in Fig. 6. After making these changes no counterexample was found. It seems that these changes in the pull-based ARF eliminate this security breach. It should be noted that both of these modifications are necessary to have a working protocol. In other words, neither of these changes alone is enough. InsiderCanRead: This assertion claims that any current member of the group is able to decrypt messages sent inside the group. In order to take care of any possible delay in the network, the model asserts that any messages sent in the group can be decrypted by all present members at any time after that.
252
Mana Taghdiri and Daniel Jackson
fun ReceiveMessage(m : Member, t : Tick, msg : Message) { CanReceive(m, msg, t) m.ownedKeys[t] = m.ownedKeys[OrdPrev(t)] + NewerKeys(m, m.kds, t, NewestKey(m.ownedKeys[OrdPrev(t)])) m.receivedMessages[t] = m.receivedMessages[OrdPrev(t)] + msg } fun CanReceive(m : Member, msg : Message, t : Tick) { ConstantMembership(m, t) msg !in m.receivedMessages[OrdPrev(t)] msg.sentTime in OrdPrevs(t) let futureKeys = NewerKeys(m,m.kds,t,NewestKey(m.ownedKeys[OrdPrev(t)])) | (some futureKeys) => msg.encryptingKey in futureKeys, msg.encryptingKey = NewestKey(m.ownedKeys[OrdPrev(t)]) } Fig. 6. Changed Receiving Functions Table 3. First counterexample for InsiderCanRead Time, Newest KDS Key Member m0 , Newest Key Member m1 , Newest Key T1 , k2 join, k2 T2 , k3 join, k3 T3 , k3 send message by k3 T4 , k4 leave, k2 - , k3 Here, a message is sent by m0 while m1 is in the group. Then m0 leaves the group. From now on, m1 is not able to accept that message because the group key is changed to one newer than the encrypting key of the message.
This property does not hold in the pull-based ARF. The counterexample shown in Table 3 describes a scenario in which the group has only one domain. A message is sent by member m1 when both m0 and m1 are in the group, but only m1 has the latest key, which is used to encrypt the message. Then m0 leaves the group while it only has the outdated key. Thus, although it was in the group when the message was sent, it can never receive the message. This problem is caused because of the asynchronous nature of ARF. In a synchronous approach, all receivers have the same key as the sender of the message. So even if, because of some delay, a member leaves the group without being able to receive the message, sooner or later it receives the message and is able to decrypt it. But in the asynchronous approach, the member leaves without having the proper key. So it can not decrypt the message even if it receives it. To fix this kind of bug, the Leave function is changed so that each member updates his keys right before leaving the group. Here is the new function: fun LeaveRequest(m : Member, kds : KDS, t : Tick) { m in kds.members[OrdPrev(t)] && m !in kds.members[t] some k : GeneratedKey(kds, t) { all kds’ : KDS | k in kds’.keys[t] m.ownedKeys[t] = m.ownedKeys[OrdPrev(t)] + NewerKeys(m, kds, t, NewestKey(m.ownedKeys[OrdPrev(t)])) - k } }
A Lightweight Formal Analysis of a Multicast Key Management Scheme
253
Table 4. Second counterexample for InsiderCanRead Time, Newest KDS Key Member m0 , Newest Key Member m1 , Newest Key T1 , k 0 join, k0 T2 , k 2 send a message , k2 join, k2 T3 , k 4 leave , k2 - , k2 T4 , k 4 - , k2 - , k2
Even after this change, the counterexample shown in Table 4 was found. It can be seen that in the original model of pull-based ARF, this particular scenario did not exist because the member could receive any message encrypted with its newest key without having to contact the KDS first. In other words, the analysis shows that in this protocol a member can not distinguish between a message from outside the group and a late message. Thus, it seems that if we want to keep the asynchronous nature of the protocol, we should either allow this kind of message loss or the security breach mentioned before. This problem is not as significant as the previous ones. This kind of message loss is inevitable in most proposed secure key management schemes. If a message is sent at some time but received after the group key is changed because of any changes in the group memberships, the key encrypting the message will be considered invalid. Thus, the message can’t be accepted. This kind of message loss can occur with any amount of accepted delay in the network because membership changes might occur right after the message is sent. So although we have allowed any amount of delay in our model, which may seem unrealistic, the counterexamples show scenarios that are feasible in reality.
7
Related Work
Global state modeling is the idiom used in most specification languages such as Z[14], VDM [8], and Larch [3]. Compared to that, the tick-based idiom introduced here can be viewed as defining local states for each entity of the underlying system. It has more in common with the communicating process idiom used, e.g., in Promela, the input language of Spin[4]. However, unlike Promela, the Alloy language is a first-order logic which allows for declarative specification of a system. Note that, like Alloy, Z and Larch are flexible enough to support different idioms, and it should be straightforward to translate our specification into those languages. However, They do not currently have automatic analysis tools. Group key management schemes are important and useful but their design is error-prone. Although formal verification of security-based protocols is an old topic (e.g. [2, 9]), to our knowledge, none of the secure multicast key management protocols has ever been formally verified with a fully automatic tool. Meadows et. al.[11] have constructed a model of the GDOI Group Key Management Protocol[1] using the NPATRL language, i.e. a temporal requirement
254
Mana Taghdiri and Daniel Jackson
specification language to be used with the NRL Protocol Analyzer[10]. To our knowledge, this is the only attempt to formally verify a group key management protocol. However, the NRL Protocol Analyzer, which combines model checking and theorem-proving techniques, is not fully automatic and relies on the user’s interaction to terminate. Fully automatic checking of formal specifications is not a new concept. Model checkers (such as Spin) have been applied extensively for protocol analysis. Alloy offers the same automation, but in the context of a logic more suited to declarative specification, and the description of structured state in an arbitrary level of details. On the other hand, unlike Spin, Alloy is not tailored to the description of protocols, and does not scale well to long executions.
8
Conclusions and Future Work
The model presented in this paper exposed flaws in pull-based Asynchronous Rekeying Framework (ARF). It showed that ARF violates one of the properties which should be satisfied by any secure multicast protocol. Although some of these flaws might be obvious to those deeply familiar with security protocols, only a complete formal analysis could reveal the behavior of the system in details. In this model some assumptions were adopted to break the inherent symmetry of the instances without loss of generality, to help the Alloy Analyzer check the properties faster. The model abstracted away some details of ARF, but was constrained enough to prevent generating unreal instances while not eliminating real but subtle and easy to neglect scenarios. In this model, we exploited the fact that Alloy is a first-order logic without a built-in notion of time or state in a novel idiom in which operations are associated with the time at which their effects are seen. We proposed tick-based modeling as a method that supports better modularity for modeling distributed systems. Furthermore, the model presented to check the correctness properties of ARF introduced a structure reusable in checking a class of secure multicast key management protocols. A report on the use of the same structure to validate Iolus, a rather different multicast key management scheme, can be found elsewhere[15]. Group key management schemes are important because of their complexity yet increasing number of applications. This work might be further extended by constructing a domain-specific modeling library to make checking various properties of these schemes easier. Acknowledgement This research was funded by grant 0086154 from the ITR program of the National Science Foundation.
A Lightweight Formal Analysis of a Multicast Key Management Scheme
255
References 1. M. Baugher, T. Hardjono, H. Harney, and B. Weis. Group domain of interpretation for ISAKMP. http://search.ietf.org/internet-drafts/draft-irtf-smug-gdoi01.txt, 2001. 2. E. M. Clarke and W. Marrero. Using formal methods for analyzing security. Information Survivability Workshop (ISW), Oct. 1998. 3. J. Guttag, J. Horning, and A. Modet. Report on the Larch Shared Language: Version 2.3. Digital Equipment Corporation, Systems Research Center, report 58, 1990. 4. G. J. Holzmann. The model checker SPIN. IEEE Transactions on Software Engineering, 23(5), May 1997. 5. D. Jackson. Automating first-order relational logic. Proc. of the 8th ACM SIGSOFT Symposium on the Foundations of Software Engineering, 2000. 6. D. Jackson, I. Shlyakhter, and M. Sridharan. A micromodularity mechanism. Proc. of the joint 8th European Software Engineering Conference and 9th ACM SIGSOFT Symposium on the Foundations of Software Engineering, 2001. 7. D. Jackson and J. Wing. Lightweight formal methods. IEEE Computer, 1996. 8. C. B. Jones. Systematic Software Development using VDM. Prentice Hall International, 1990. 9. C. Meadows. A system for the specification and analysis of key management protocols. Proc. of 1991 IEEE Computer Society Symposium on Research in Security and Privacy, pages 182–195, 1991. 10. C. Meadows. The NRL protocol analyzer: An overview. Journal of Logic Programming, 26(2):113–131, 1996. 11. C. Meadows, P. Syverson, and I. Cervesato. Formalizing GDOI group key management requirements in NPATRL. Proc. of the 8th ACM Conference on Computer and Communications Security, pages 235–244, 2001. 12. S. Mittra. Iolus: A framework for scalable secure multicasting. Proc. of ACM SIGCOMM’97, pages 277 – 288, 1997. 13. F. Sato and S. Tanaka. A push-based key distribution and rekeying protocol for secure multicasting. Proc. of International Conference on Parallel and Distributed Systems, pages 214–219, 2001. 14. J. M. Spivey. The Z Notation: A Reference Manual. Prentice Hall, second edition, 1992. 15. M. Taghdiri. Lightweight modelling and automatic analysis of multicast key management schemes. Master’s thesis, MIT, EECS Department, Dec. 2002. 16. S. Tanaka and F. Sato. A key distribution and rekeying framework with totally ordered multicast protocols. Proc. of the 15th International Conf. on Information Networking, pages 831–838, 2001.
Appendix: Complementary Parts of the ARF Model sig KDS { keys : Tick -> Key, members : Tick -> Member } { all t : Tick | let t’ = OrdPrev(t) { keys[t’] in keys[t]
256
Mana Taghdiri and Daniel Jackson
all m : members[t]-members[t’] | Join(m, t, this) all m : members[t’]-members[t] | Leave(m, t) } all t : Tick-Ord[Tick].first | let t’ = OrdPrev(t) { all k : keys[t]-keys[t’] | some m : Member { Join(m, t, m.kds) || Leave(m, t) k = GeneratedKey(m.kds, t) } all disj k1, k2 : keys[t]-keys[t’] | k1.creator != k2.creator } } fact { all k1, k2 : KDS | k1.keys = k2.keys all m : Message | SendMessage(m.sender, m.sentTime, m) } fun Init(t : Tick) { no Member.receivedMessages[t] no Member.ownedKeys[t] no KDS.keys[t] no KDS.members[t] } fun MemberInactive(m : Member, t : Tick) { NoChange(m.receivedMessages, t) NoChange(m.ownedKeys, t) ConstantMembership(m, t) } det fun NewerKeys(m: Member, kds: KDS, t: Tick, lastKey: Key): set Key { m !in kds.members[t] => no result, result = kds.keys[t] & OrdNexts(lastKey) } det fun NewerKeys-modified(m : Member,kds : KDS,t : Tick,lastKey : Key): option Key { m !in kds.members[t] => no result, result = NewestKey(kds.keys[t] & OrdNexts(lastKey)) } det fun NewestKey(keys : set Key) : option Key { some keys <=> some result result in keys no OrdNexts(result) & keys } det fun GeneratedKey(kds : KDS, t : Tick) : Key { some kds.keys[OrdPrev(t)] => result in OrdNexts(NewestKey(kds.keys[OrdPrev(t)])), result in Key result.creator = kds } fun ConstantMembership(m : Member, t : Tick) { IsMember(m, t) <=> IsMember(m, OrdPrev(t)) } fun IsMember(m : Member, t : Tick) { some kds : KDS | m in kds.members[t] } fun NoChange[T](r : Tick -> T, t : Tick) { r[OrdPrev(t)] = r[t] }
Formal Security Policy Verification of Distributed Component-Structured Software Peter Herrmann University of Dortmund, Computer Science Department, 44221 Dortmund, Germany, [email protected]
Abstract. Component-structured software, which is coupled from independently developed software components, introduces new security problems. In particular, a component may attack components of its environment and, in consequence, spoil the application incorporating it. Therefore, to guard a system, we constrain the behavior of a component by ruling out the transmission of events between components which may cause harm. Security policies describing the behavior constraints are formally specified and, at runtime, so-called security wrappers monitor the interface traffic of components and check it for compliance with the specifications. Moreover, one can also use the specifications to prove formally that the combinations of the component security policies fulfill certain security properties of the complete component-structured application. A well-known method to express system security properties is access control which can be modelled by means of the popular Role Based Access Control (RBAC) method. Below, we will introduce a specification framework facilitating the formal proof that component security policy specifications fulfill RBAC-based application access control policies. The specification framework is based on the specification technique cTLA. The design of state-based security policy specifications and of RBAC-models is supported by framework libraries of specification patterns which may be instantiated and composed to a specification. Moreover, the framework contains already proven theorems facilitating the formal reasoning since a deduction proof can be reduced to proof steps which correspond directly to the theorems. In particular, we introduce the specification framework and clarify its application by means of an e-commerce example.
1
Introduction
More and more e-commerce applications are composed from cost-effective software components which are developed independently from each other and are separately offered on an open market (cf. [1]). The component-structured applications can be tailored to the particular needs of their customers by selecting, configuring, and customizing suitable components which may come from various sources. The architecture of the component-structured software and, in particular, the heterogeneity of the component interfaces, however, aggravates the composition process. The coupling of components therefore is facilitated by using H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 257–272, 2003. c IFIP International Federation for Information Processing 2003
258
Peter Herrmann
— ideally legally binding — component contracts describing all context dependencies of a component. According to [2], a component contract consists of four parts. In the first part the methods, events, and exceptions of the component interfaces and the corresponding arguments are listed. The second part describes constraints of the interface behavior to be fulfilled by the component resp. its environment. The third part models synchronization aspects while the forth part lists quality-of-service properties. The contracts are utilized by visual application builder tools which facilitate the composition process. Well-established platforms for component-structured software are Enterprise Java Beans (EJBs) which are based on Sun’s Java Beans and Microsoft’s COM/DCOM. Moreover, OMG’s middleware platform CORBA was extended by a component model. Component-structured software also faces new security risks since, compared with monolithic applications, a higher number of principals is involved in the system development and deployment (i.e., application owners and users, component designers and vendors, system builders, component service providers). On the one hand, each principal introduces his own security objectives which have to be fulfilled by the other principals. On the other hand, a principal is a potential threat to the other principals as well as to the component-structured application. Taxonomies of security risks for component-structured software are introduced in [3, 4]. Our work concentrates on a main security risk which cannot be dealt with traditional security mechanisms: A malicious component may distort other components and, in consequence, spoil the application incorporating it. This risk is addressed by so-called security wrappers which are introduced in [5, 6]. We expanded the component contracts by formal state-based models specifying that components always behave in a way that the security of their environment components is guaranteed. Moreover, a security wrapper is inserted at the interfaces of a component. It is a special software wrapper (cf. [7]) which temporarily blocks all events passing an interface and checks them for compliance with the component contract security policy specifications. To perform the compliance checks, the wrapper simulates the specifications and accepts an event only if the transitions modelling the event are enabled in the current states of all simulations. An accepted event is forwarded to its destination. If, however, an event is rejected, the wrapper seals the component by blocking its interface traffic and notifies the application administrator. The performance effort of the security wrappers is between 5 and 10 %, but can be significantly reduced by applying trust management (cf. [4, 8]). Similarly to us, Khan et al. [9] extend component contracts to describe security aspects in order to check requirement-assurance relationships between coupled components. The used description technique is relatively simple and does not represent behavioral properties used to model interface behavior. In this paper, we concentrate on another utilization of the component contract security models. Besides of runtime enforcement by the security wrappers, the specifications can also be used at design time to verify that the application incorporating the constrained components fulfill more general system-oriented security policies. These policies can be regarded as safeguards for a system which
Security Policy Verification of Distributed Component-Structured Software
259
make successful attacks more difficult. Well-known techniques to describe system security policies are access control and information flow models. The use of formal methods to prove that the component contract models realize system security policies is of great practical interest since the current standard for security analysis, the so-called Common Criteria (CC, [10]), demands a formal-based analysis for the certification of systems operating in a highly sensitive environment. As a description technique for the system security properties we use the popular Role-Based Access Control method (RBAC, [11]) which is well-suited to rule out attacks on the confidentiality and integrity of systems. To develop specifications of component contract security policies or system security policies and to perform refinement proofs, we consider the specification technique cTLA [12] suitable. cTLA facilitates the creation of state transition systems in a modular and process-oriented fashion. In particular, it enables the composition of system descriptions from implementation-oriented processes (e.g., contract models describing aspects of component interface behavior), constraintoriented processes (e.g., certain constraints of an RBAC model), and combinations (cf. [13]). Process composition in cTLA has the character of superposition (cf. [14]). Here, a relevant property of a process or a subsystem is also a property of the embedding system. Therefore structured verification is possible (i.e., a proof that a system fulfills a property can be reduced to the verification that an — often very small — subsystem fulfills this property). Moreover, structured verification facilitates the establishment of specification and verification frameworks which contain libraries of cTLA process types. System and subsystem specifications can easily be developed by instantiating and composing the process types from the framework libraries. In particular, a specification framework contains libraries of theorems which are proven by the framework designer. A theorem states that, if some side conditions hold, a subsystem consisting of more detailed processes fulfills a more coarse-grained process. Thus, in order to prove that a detailed system C fulfills a coarse-grained system S, one has to check only that for each process of S a theorem exists stating that a subsystem of C fulfills this process. Furthermore, one has to prove that the side conditions of the applied theorems hold and that the processes of C and S are consistently coupled. These checks, however, are usually simple and can be automated (cf. [15]). Therefore the specification frameworks make formal proofs of real-sized problems possible (e.g., service verification of transport communication protocols [16]). Below, we will introduce a specification framework for the verification that component contract security policy specifications fulfill RBAC-based system security policy models. The cTLA processes and theorems of this framework are depicted in the WWW (URL: ls4-www.cs.uni-dortmund.de/RVS/P-SACS/eReq).
2
cTLA
Leslie Lamport’s Temporal Logic of Actions (TLA, [17]) is a linear time temporal logic which describes safety and liveness properties (cf. [18]) of state transition systems by means of canonical formulas. cTLA (compositional TLA, [12]) is
260
Peter Herrmann
PROCESS IntegrityEnablingHistorySTS (ComponentIds : ANY; InterfaceIds : ANY; EventIds : ANY; Args : ANY; ConstrEv : EvDfType; States : ANY; InitState : States; ExecuteCond : SET[States → SUBSET(Args)]; Trans : SET[(States × EvDfType × Args) → States]) CONSTANTS ∆ EvDfType = (ComponentIds × ComponentIds × InterfaceIds × EventIds); BODY VARIABLES var : States; ∆ INIT = var = InitialState; ACTIONS Event (callee : ComponentIds; caller : ComponentIds; ∆ if : InterfaceIds; ev : EventIds; arg : Args) = ((callee, caller, if, ev) = ConstrEv ∨ arg ∈ ExecuteCond[var]) ∧ var = Trans[var, (callee, caller, if, ev), arg]; END Fig. 1. Process type IntegrityEnablingHistorySTS
based on TLA, but enables the suitable specification of systems in the notation of processes. A process acts as a modular specification component and a system can be specified by a set of coupled processes. A process has either the form of a simple process or of a process composition. Simple processes refer directly to state transition systems and can represent implementation parts as well as logical constraints. Fig. 1 depicts the simple cTLA process type IntegrityEnablingHistorySTS used to specify a pattern of a typical component contract specification. It is introduced to more detail in Sec. 5. In the header the process type name and generic module parameters (e.g., ComponentIds) are declared. The parameters facilitate the specification of a spectrum of similar but different processes by a single process type. In the sectionCONSTANTS constant and type definitions are listed. The body of the process type defines the state transition system modelling a process instance. The state space is specified by the state variable var which carries values of the data type defined by the process parameter States. The initial condition INIT refers to state variables and defines the set of initial states (i.e., var initially has the value expressed by the parameter InitState). The state transitions are specified by actions (i.e., Event). An action is a predicate on a pair of a current and a successor state modelling a set of state transitions. The state variables referring to the current state are described by ordinary variable identifiers (i.e., var) while variables referring to the successor state occur in the so-called primed form (i.e., var’). An action may be supplemented by action parameters (e.g., callee). The next state relation of the modelled state transition system corresponds to the disjunction of the actions. Systems and subsystems are described as compositions of concurrent processes. As in the ISO/OSI specification language LOTOS, a set of processes interact in a rendezvous-like way by performing actions jointly, and the data
Security Policy Verification of Distributed Component-Structured Software
261
parameters of the actions can model the communication of values between processes. Each process encapsulates its variables and changes its state by atomic execution of its actions. The system state is the vector of the process state variables. State transitions of the system correspond to simultaneously executed process actions or to so-called process stuttering steps (i.e., the process does not change its state). Since, moreover, a process participates in a system action either by exactly one process action or by a process stuttering step, one can define a system action by a conjunction of process actions and stuttering steps. In consequence, concurrency is modelled by interleaving while the coupling of processes corresponds to joint actions. The design of cTLA process types as well as the composition of processes to systems is supported by a compiler tool [19].
3
Global Formal Model
The component contract security policy descriptions and the RBAC-based system security models are specified by means of cTLA process types. In order to provide a common understanding of the interaction between process instances facilitating the composition of the processes to system specifications, we defined a simple global formal model. In a specification of a component-structured application, this model represents the components, the component interfaces, the events transferred between components, and the event arguments. The process instances describing the global model form the core of all component contract or system security specifications. In particular, the global model defines naming conventions for process parameters, action names, and action parameters guiding the instantiation and composition of the other process types to system specifications. Thus, by enforcing identical names for similar behavior aspects in the component contract specifications and in the descriptions of the system security properties, refinement proofs are made easier. To keep the global model simple, only static component-structured systems (i.e., systems without adding or removing components during runtime) are currently supported1 . Moreover, we use events as the only means to describe cooperation between components since other interaction constructs like method calls or exceptions can also be realized by events (e.g., a method call is the combination of a calling and a return event). The main cTLA process type is GlobalSystem (cf. Fig. 2). By means of the generic process parameters ComponentIds, InterfaceIds, and EventIds one can define identifiers for the components, interfaces, and events of a componentstructured application while the arguments of the events are defined by the process parameter Args. Identical parameters occur in other cTLA process types where they should be instantiated with the same sets as in GlobalSystem. The parameter Interfaces of the type InterfaceType, which is defined in the sectionCONSTANTS, specifies the component interfaces. An interface consists of an identifier iId, a set iEvents of events passing the interface, and a function 1
Dynamic changes of the component structure can be modelled by means of special life cycle variables (cf. [20]).
262
Peter Herrmann
PROCESS GlobalSystem (ComponentIds : ANY; InterfaceIds : ANY; EventIds : ANY; Args : ANY; Interfaces : SUBSET(InterfaceType); CompIfs : SET[ComponentIds → SUBSET(Interfaces)]) CONSTANTS ∆ InterfaceType = [[ iId : InterfaceIds; iEvents : SUBSET(EventIds); iEvArgs : SET[EventIds → Args] ]] ; BODY ∆ INIT = True; ACTIONS Event (callee : ComponentIds; caller : ComponentIds; ∆ if : InterfaceIds; ev : EventIds; arg : Args) = ∃ i ∈ InterfaceType :: i ∈ CompIfs[callee] ∧ i.iId = if ∧ ev ∈ iEvents ∧ arg = i.iEvArgs[ev]; END Fig. 2. Process type GlobalSystem
iEvArgs assigning a set of arguments to each event. Finally, the parameter CompIfs maps component identifiers to interfaces and specifies which interfaces belong to a component. Since the process type is stateless, the process body does not contain variables and the initial condition is always true. Event is the only action used in this or in other process types. It models that an event with the identifier ev and the argument arg is sent from the component caller to the interface if of the component callee. Besides of GlobalSystem, the global formal model consists of the process type ComponentCoupling describing which components are enabled to send events to an interface of a particular component. This process is listed in the WWW (URL: ls4-www.cs.uni-dortmund.de/RVS/P-SACS/eReq). The complete global model is specified by means of an instance of process type GlobalSystem and a separate instance of ComponentCoupling for each component being coupled to the modelled component-structured application.
4
RBAC System Models
A malicious component may attack its environment in many different ways violating the confidentiality, integrity, availability, or non-repudiation of the embedding application. In the following, we sketch some threats relevant for the confidentiality and integrity of a component-structured system while availability and non-repudiation threats are listed in [6]. Confidentiality attacks are particularly significant for distributed component-based systems where the components reside in different security domains with varying user-access policies. Here, the information flow between components may be maliciously altered in a way that data is forwarded to system parts controlled by principals who are not allowed to read the data. Moreover, hidden channels may be used where certain information is illegally concealed in transferred data — so-called steganography — or
Security Policy Verification of Distributed Component-Structured Software
263
(RH) Role Hierarchy
USERS
(UA) User Assignment
ROLES
(PA) Permission Assignment
OPS
OBS PRMS
user_ sessions
session_roles
SESSIONS
Fig. 3. RBAC model (taken from [11])
by defining secret agreements in the order, the number, or the execution time of events. A component may attack the integrity of its environment by triggering incorrect events, by modifying the event parameters, or by manipulating the system configuration parameters. Due to these attacks the application may deviate from the specified system behavior harming the system owners and users. A well-known technique to protect systems against confidentiality or integrity attacks is access control in which the read or write access on various system resources is limited to certain users. A popular access control technology is RoleBased Access Control (RBAC, [11, 21]) which allows to express a wide range of security policies (cf. [22]). Fig. 3 outlines the major structure of RBAC. It uses roles (ROLES) as main construct to assign access permissions to users. The roles model certain positions in an application domain (e.g., in a hotel environment guest, general manager, housekeeping manager, and housekeeping staff member are examples of roles). The roles may be hierarchically organized. In this case the rights of a lower level role are inherited by a higher level role (e.g., the general manager has also the rights of a housekeeping manager). Access permissions (PRMS) describe the right to perform certain operations (OPS) on objects (OBS). The RBAC model defines a many-to-many relation between roles and permissions (e.g., a general manager may give reductions to the room prizes). Another many-to-many relation is defined between roles and users (USERS, e.g., Alice is a general manager while Bob and Charlotte are both a housekeeping manager). A user has the permission to access a resource if at least one role is assigned to both himself and the desired permission (e.g., Alice may decide about room prize reductions but not Bob). Moreover, to use a permission, the corresponding role must be active for the user requesting access. Therefore, the RBAC model includes so-called sessions (SESSIONS). Each session models the set of active roles by mapping a user to a subset of the roles assigned to him. Furthermore, one can define certain constraints limiting the assignment of roles or the number of active roles (cf. [11]). A constraint type is static separation of duty. Here, a user may not be assigned to two different roles in order to avoid conflicts of interest (e.g., the general manager may never be a guest in her
264
Peter Herrmann
PROCESS ActiveRoles (ComponentIds : ANY; InterfaceIds : ANY; EventIds : ANY; Args : ANY; Roles : ANY; ConstrCallers : SUBSET(ComponentIds); ConstrRoles : SUBSET(Roles); InitRoles : SUBSET(Roles); ActivateRoles : SET[(EvDfType × Args) → SUBSET(Roles)]; DeactivateRoles : SET[(EvDfType × Args) → SUBSET(Roles)]) CONSTANTS ∆ EvDfType = (ComponentIds × ComponentIds × InterfaceIds × EventIds); BODY VARIABLES act : SUBSET(Roles); ∆ INIT = act = InitRoles ∩ ConstrRoles; ACTIONS Event (callee : ComponentIds; caller : ComponentIds; if : InterfaceIds; ev : EventIds; arg : Args; ∆ actRoles : SUBSET(Roles)) = (caller ∈ / ConstrCallers ∨ act = (actRoles ∩ ConstrRoles)) ∧ act = ((act ∪ ActivateRoles[((callee,caller,if,ev),arg)]) \ DeactivateRoles[((callee,caller,if,ev),arg)]) ∩ ConstrRoles; END
Fig. 4. Process type ActiveRoles
hotel in order to prevent making room prize reductions to herself). In contrast, in dynamic separation of duty a user may be assigned to two conflicting roles which, however, must not be active at the same time (e.g., Bob and Charlotte who are also housekeeping staff members are not allowed to act as manager and staff member simultaneously). Finally, the number of users for which a role is currently active may be limited (e.g., only one person at a time may act as a housekeeping manager). In the domain of component-structured software, the components linked to an application form the group of users. A permission corresponds to the right to send a particular event to a certain interface of another component. The definition of the roles is guided by the tasks performed by the software-based application. Fig. 4 depicts the cTLA process type ActiveRoles specifying which roles are currently active for a particular component. Besides of the basic process parameters ComponentIds, InterfaceIds, EventIds, and Args, the process type contains the parameter Roles describing the roles in the modelled RBAC model. In order to allow modular system specifications consisting of a large number of simple process instances, the components and roles constrained by a process can be limited. The parameters ConstrCallers and ConstrRoles describe the identifiers of the constrained callers resp. roles. The parameter InitRoles specifies which roles are initially active. Finally, ActivateRoles and DeactivateRoles define which roles get active resp. inactive. These two parameters are mappings from event references which are modelled by the data type EvDfType to sets of roles. The state variable act specifies which constrained roles are currently active. The action Event contains an additional action parameter actRoles spec-
Security Policy Verification of Distributed Component-Structured Software
265
ifying the set of roles which are active for the event caller. Thus, this set can also be accessed by other process instances in the RBAC specification. Event is always enabled if the caller is not constrained by the process instance. Otherwise, each role constrained by the process has to be included in both sets defined by the variable act and the process parameter actRoles or in neither of them. Besides of ActiveRoles, we defined cTLA process types modelling the relations between roles and users resp. permissions as well as RBAC constraints.
5
Component Contract Security Specifications
To facilitate the design of specifications constraining the interface behavior of a component in order to guarantee security properties, we defined a group of cTLA process types, too. Each process type models a pattern for a component contract security policy. Component developers define contract security policies based on the patterns by instantiating the cTLA process types and by adding the process instances to the component contract. Reflecting that one can only consider the component interface behavior but not the internal attribute settings and internal events of a component, the component contract security policy patterns address the attack scenarios outlined in the beginning of Sec. 4 directly. Confidentiality attacks can be avoided by restricting the flow of data between components. A data unit must only be send to components which deny readaccess to principals unauthorized to read it. Moreover, one can impede hidden channels by preventing non-deterministic interface behavior (cf. [23]). Therefore, to prevent steganography, corresponding security policies define deterministic functional dependencies between data units and preceding events and restrict the order, number, and execution time of the events. The confidentiality policies are realized by the following policy patterns: – Data flow access: A data unit may only be forwarded to a component if its read access permissions are preserved. – Data flow history: A data unit may only be forwarded in the context of certain preceding interface events. – Hidden channel functional dependency: A forwarded data unit depends on previously transferred data according to a data dependency function. – Hidden channel enabling history: The enabling condition of an interface event and its arguments depend on the context of preceding events according to a occurrence dependency function. – Hidden channel execution time: An interface event has to be executed after a preceding interface event within a certain time period. Integrity attacks are addressed by security policies restricting the execution of interface events and the selection of event arguments. Moreover, the policies can be used to check if events are plausible with respect to the context of preceding events. The policies are specified by the patterns listed below: – Integrity enabling condition: The enabling conditions of interface events and their arguments are constrained in order to guarantee plausible component interaction.
266
Peter Herrmann
– Integrity enabling history: The enabling conditions of interface events and their arguments depend on the context of preceding interface events in order to guarantee plausible component interaction. Other policy patterns to prevent availability and non-repudiation attacks are introduced in [6]. An example of a cTLA process type specifying a specific component contract security pattern is IntegrityHistorySTS which is depicted in Fig. 1. It realizes the specific pattern integrity enabling history by modelling that a certain event (defined by the generic process parameter ConstrEv) with a corresponding argument setting must only be triggered if a particular history of events occurred before. To describe the history, in the process type a state transition system is explicitly modelled. Here, the generic process parameter States describes the state space, InitState the initial state, and Trans the next step relation which depends on executed events. Finally, the process parameter ExecuteCond defines for which event arguments the event ConstrEv may be executed in a certain state. The state variable var models the current state of the state transition system.
6
Verification
In order to verify that component contract policy patterns fulfill an RBACbased system security model, the owner of the component-structured application develops two cTLA specifications S and C. S models the RBAC model which is created by instantiating the RBAC-oriented cTLA process types introduced in Sec. 4 and composing them with the process instances defining the global formal model (cf. Sec. 3). Likewise, a specification C describing component contract policies is designed by coupling the processes of the global model with instances of the security policy patterns (cf. Sec. 5). The verification is performed by means of a TLA deduction proof of the implication C ⇒ S (cf. [17]). We can reduce this proof into a series of simpler proof steps. In each proof step, we prove that a cTLA process instance of S is fulfilled by a subsystem of C which usually consists of a relatively small number of process instances. If all instances of S are realized by subsystems of C and the processes of C and S are consistently coupled with each other, C ⇒ S holds due to the compositionality of cTLA2 . The consistency of the process couplings in C and S is trivially true since in both specifications the process actions Event are coupled with each other to the system actions Event. The proof steps describing that subsystems of C realize process instances of S correspond directly to the already proven framework theorems. Thus, we can reduce the verification of C ⇒ S to the selection of suitable framework theorems and to some consistency checks of process parameter instantiations. A tool supporting the theorem selection and performing most of the checks is introduced in [15]. An example theorem is depicted in Fig. 5. It states that a subsystem consisting only of an instance of the cTLA process type IntegrityEnablingHistorySTS 2
The corresponding proof is included in [12].
Security Policy Verification of Distributed Component-Structured Software
267
LET ∆ Pars = ∃ rm ∈ SET[States → SUBSET(ConstrRoles)] :: (rm[InitState] = InitRoles ∧ ∀ s ∈ States ∀ edt ∈ EvDfType ∀ a ∈ Args :: rm[Trans[(s,edt,a)]] = (rm[s] ∪ ActivateRoles[(edt,a)]) \ DeactivateRoles[(edt,a)]); ∆ Sys = IntegrityEnablingHistorySTS (ComponentIds,InterfaceIds,EventIds,Args,ConstrEv,States, InitState,ExecuteCond,Trans); IN Pars ∧ Sys ⇒ ActiveRoles (ComponentIds,InterfaceIds,EventIds,Args, Roles,ConstrCallers,ConstrRoles,InitRoles, ActivateRoles, DeactivateRoles); Fig. 5. Theorem to prove ActiveRoles based on IntegrityEnablingHistorySTS
(cf. Fig. 1) fulfills an instance of the process type ActiveRoles (cf. Fig. 4) if the theorem condition Pars holds. Thus, the theorem proves that an instance of the specific security policy pattern integrity enabling history realizes the activation mechanism for certain roles in an RBAC model. To apply this theorem, we have to prove the condition Pars stating that we must find a mapping rm between the state variable var of IntegrityEnablingHistorySTS and the variable act of ActiveRoles. The mapping has to guarantee that the initial state of var maps to the initial set of active roles in act and that a state change of var leads to a corresponding change of act. Thus, rm is a so-called refinement mapping (cf. [17]) which was used to prove the theorem. In our experience, it is relatively easy to detect suitable refinement mappings due to the use of small subsystems in cTLA (cf. [16]).
7
Proof Example
In [6] we presented a component-structured application example performing the commodity management of fast-food franchise restaurants. The core of this system was developed on the basis of the SalesPoint-Framework [24], a Java-based framework of shop administration functions. Based on these functions we created three components which realize the restaurant sales functions, the counting stock management, and the product catalog. Moreover, we added four selfprogrammed components in order to adapt the commodity management of our shop to the Open Buying on the Internet (OBI) standard [25]. In this standard an architecture for electronic procurement of goods and a corresponding business-to-business model are defined. The architecture introduces a buying organization, selling organizations, a payment authority, and a requisitioner. In behalf of the buying organization the requisitioner carries out orders at the selling organizations and the orders are paid by means of the payment authority. In particular, in intervals, the requisitioner checks the counting stock for shortages of goods. If a shortage was detected, the requisitioner requests seller addresses from the buying organization, sends requests for tenders to the sellers, receives
268
Peter Herrmann
tenders, decides about a winning seller based on the tenders, and sends an order to the winning seller. Thereafter the order is fulfilled and paid by means of the paying authority. We changed the OBI standard in one respect: The procurements are not performed by a human but are automatically carried out by a so-called e-requisitioner component. Furthermore, we added a directory-of-sellers component storing the seller addresses and the range of goods offered by a seller. An adapter component manages the communication with the sellers which is realized by standardized tender requests, tenders, and orders. Moreover, we use remote seller components which are also based on the SalesPoint-Framework and a notary logging service in order to support non-repudiation of the relevant transactions. With respect to system security, we have to guarantee that the buying organization is not cheated to the advantage of certain sellers. This is of relevance, since we presume that the e-requisitioner is obtained from a non-trusted source and its code may be manipulated in order to favor certain sellers. We assume, however, that the contract of the e-requisitioner component contains security contract models which can be enforced by a security wrapper. The models are listed in [6] and the corresponding cTLA process instances can be obtained from the WWW (URL: ls4-www.informatik.uni-dortmund.de/RVS/P-SACS/eReq). As a system user, we have to specify the desired system security policies and prove that they are fulfilled by the component contract policy descriptions. An RBACbased model is used to specify various system security objectives (e.g., a seller is selected which delivered one of the least expensive tenders). In the following, we concentrate on an integrity security policy defining that a procurement may only be started if the e-requisitioner detected a shortage of a good in the counting stock. In the RBAC model this is modelled by roles which have to be active for the e-requisitioner in order to perform procurements. Since we assume, that procurements of food and beverages are carried out separately, we use the two roles "foodReq" and ‘‘beverageReq". The roles are activated if the e-requisitioner detects a shortage of food resp. beverages. They are deactivated if corresponding orders are carried out. The activation and deactivation mechanism for the two roles is modelled by the cTLA process ActiveBuyingRoles (cf. Fig. 6) which is instantiated from ActiveRoles. The process is modelled as a cTLA process composition and, in order to facilitate the understanding of the process parameter instantiations, we instantiate the generic parameters of ActiveRoles with constants carrying the same names as the parameters. The setting of the parameter ConstrRoles describes that the process constrains only the two roles ‘‘foodReq" and ‘‘beverageReq". The instantiations of the parameters InitRoles, ActivateRoles, and DeactivateRoles model that the two roles are initially inactive, that they are activated by ‘‘RecvGetStock" events if the counting stock for a certain good is below a threshold, and that they are deactivated by ‘‘CallSendOrder" events. To prove that the specification C consisting of component policy contract models fulfills the process ActiveBuyingRoles, we apply the component contract specification AskDoSIfBuyerOnly of the type IntegrityEnablingHistory
Security Policy Verification of Distributed Component-Structured Software
269
PROCESS ActiveBuyingRoles CONSTANTS ... ∆ ConstrRoles = {"foodReq","beverageReq"}; ∆ InitRoles = {}; ∆ ActivateRoles = [ (edt,a) → IF (edt = ("eReq","stock","main","RecvGetStock") ∧ a.no < threshold[a.good]) THEN IF (a.type = "food") THEN {"foodReq"} ELSE {"beverageReq"} ELSE {} ]; ∆ DeactivateRoles = [ (edt,a) → IF (edt = ("adap","eReq","main","CallSendOrder")) THEN IF (a.type = "food") THEN {"foodReq"} ELSE IF (a.type = "beverage") THEN {"beverageReq"} ELSE {"foodReq","beverageReq"} ELSE {} ]; PROCESSES p : ActiveRoles (ComponentIds,InterfaceIds,EventIds,Args,Roles,ConstrCallers, ConstrRoles,InitRoles,ActivateRoles,DeactivateRoles); ACTIONS Event (callee : ComponentIds; caller : ComponentIds; if : InterfaceIds; ev : EventIds; ∆ arg : Args; activeRoles : SUBSET(Roles)) = p.Event(callee,caller,if,ev,arg,activeRoles); END Fig. 6. Process instance ActiveBuyingRoles
(cf. Fig. 7). This process defines a state transition system modelling that the erequisitioner may only call the directory-of-sellers for seller addresses if some goods in the counting stock are short. The state transition system has the four states ‘‘no", ‘‘food", ‘‘beverage", ‘‘foodAndBeverage" modelling which types of goods are short. The proof is performed by means of the theorem listed in Fig. 5. Thus, we can reduce the proof to the recognition of a suitable refinement mapping which fulfills the two side conditions specified by the conjuncts in the theorem condition Pars. A straightforward refinement mapping is ∆
rm = [ s → IF (s = "food") THEN {"foodReq"} ELSE IF (s = "beverage") THEN {"beverageReq"} ELSE IF (s = "foodAndBeverage") THEN {"foodReq", "beverageReq"} ELSE {} ]
The first conjunct of Pars is true for this refinement mapping since the equation chain rm[InitState] = rm["no"] = {} = InitRoles holds. To verify the second conjunct, we reduce the proof to cases guided by the conditions of the IF THEN ELSE-constructs in the parameter Trans of AskDoSIfBuyerOnly. For
270
Peter Herrmann
PROCESS AskDOSIfBuyerOnly CONSTANTS ... ∆ States = {"no","food","beverage","foodAndBeverage"}; ∆ InitState = "no"; ∆ Trans = [(s,edt,a) → IF (edt = ("eReq","stock","main","RecvGetStock") ∧ a.no < threshold[a.good]) THEN IF (a.type = "food") THEN IF (s ∈ {"no","food"}) THEN "food" ELSE "foodAndBeverage" ELSE IF (s ∈ {"no","beverage"}) THEN "beverage" ELSE "foodAndBeverage" ELSE IF (edt = ("adap","eReq","main","CallSendOrder")) THEN IF (a.type = "food") THEN IF (s ∈ {"no","food"}) THEN "no" ELSE "beverage" ELSE IF (a.type = "beverage") THEN IF (s ∈ {"no","beverage"}) THEN "no" ELSE "food" ELSE "no" ELSE s]; ... END Fig. 7. Process AskDoSIfBuyerOnly
instance, in the case that the state transition system is in the state ‘‘no" or ‘‘food" and the e-requisitioner receives an event from the counting stock indicating a shortage of food, we can prove the conjunct by means of the two equation chains rm[Trans[(s,edt,a)]] = rm["food"] = {‘‘foodReq"} and (rm[s] ∪ ActivateRoles[(edt,a)]) \ DeactivateRoles[(edt,a)] = {‘‘foodReq"}\{} = { ‘‘foodReq"}. By applying similar framework theorems, we prove that C fulfills the other processes of the RBAC-based system security specification S, too.
8
Concluding Remarks
We reported on an approach making formal verifications possible that software components fulfill RBAC-based system security properties. The corresponding cTLA framework facilitates the specification of component contract-based descriptions and of RBAC models while the framework theorems make the refinement proofs easier. Due to the compositionality of cTLA, however, not only the application but also the creation of the framework is supported. The cTLA process types of the component contract patterns and RBAC models were developed by a person within four weeks, while the theorems were set up and proven within two weeks. We intend to enhance the framework-based approach in order to support also other system security policy models. In particular, information
Security Policy Verification of Distributed Component-Structured Software
271
flow systems are of interest since they enable the detection of confidentiality attacks due to flaws in the — often complex — flow of data between components (cf. [26, 27]). This work will complement a less formal but highly automated approach [28] which is based on object-oriented modelling and on the application of graph rewrite rules on object models. Moreover, we plan to extend the global formal model, the specification patterns, and the theorems in order to facilitate also the specification and verification of flexible component-structured systems where components are added to or removed from an application during runtime.
References 1. Szyperski, C.: Component Software — Beyond Object Oriented Programming. Addison-Wesley Longman (1997) 2. Beugnard, A., J´ez´equel, J.M., Plouzeau, N., Watkins, D.: Making Components Contract Aware. IEEE Computer 32 (1999) 38–45 3. Lindqvist, U., Jonsson, E.: A Map of Security Risks Associated with Using COTS. IEEE Computer 31 (1998) 60–66 4. Herrmann, P.: Trust-Based Procurement Support for Software Components. In: Proceedings of the 4th International Conference on Electronic Commerce Research (ICECR-4), Dallas, ATSMA, IFIP (2001) 505–514 5. Herrmann, P., Krumm, H.: Trust-adapted enforcement of security policies in distributed component-structured applications. In: Proceedings of the 6th IEEE Symposium on Computers and Communications, Hammamet, IEEE Computer Society Press (2001) 2–8 6. Herrmann, P., Wiebusch, L., Krumm, H.: State-Based Security Policy Enforcement in Component-Based E-Commerce Applications. In: Proceedings of the 2nd IFIP Conference on E-Commerce, E-Business & E-Government (I3E), Lisbon, Kluwer Academic Publisher (2002) 195–209 7. Fraser, T., Badger, L., Feldman, M.: Hardening COTS Software with Generic Software Wrappers. In: Proceedings of the 1999 IEEE Symposium on Security and Privacy, IEEE Computer Society Press (1999) 2–16 8. Herrmann, P.: Trust-Based Protection of Software Component Users and Designers. In Nixon, P., Terzis, S., eds.: Proceedings of the 1st International Conference on Trust Management. LNCS 2692, Heraklion, Springer-Verlag (2003) 75–90 9. Khan, K., Han, J., Zheng, Y.: A Framework for an Active Interface to Characterise Compositional Security Contracts of Software Components. In: Proceedings of the Australian Software Engineering Conference (ASWEC’01), Canberra, IEEE Computer Society Press (2001) 117–126 10. ISO/IEC: Common Criteria for Information Technology Security Evaluation. (1998) International Standard ISO/IEC 15408. 11. Ferraiolo, D.F., Sandhu, R., Gavrila, S., Kuhn, D.R., Chandramouli, R.: Proposed NIST Standard for Role-Based Access Control. ACM Transactions on Information and System Security 4 (2001) 224–274 12. Herrmann, P., Krumm, H.: A Framework for Modeling Transfer Protocols. Computer Networks 34 (2000) 317–337 13. Vissers, C.A., Scollo, G., van Sinderen, M.: Architecture and specification style in formal descriptions of distributed systems. In Agarwal, S., Sabnani, K., eds.: Protocol Specification, Testing and Verification. Volume VIII., Elsevier, IFIP (1988) 189–204
272
Peter Herrmann
14. Back, R.J.R., Kurkio-Suonio, R.: Decentralization of process nets with a centralized control. Distributed Computing (1989) 73–87 15. Herrmann, P., Krumm, H., Dr¨ ogehorn, O., Geisselhardt, W.: Framework and Tool Support for Formal Verification of High Speed Transfer Protocol Designs. Telecommunication Systems 20 (2002) 291–310 16. Herrmann, P., Krumm, H.: Modular Specification and Verification of XTP. Telecommunication Systems 9 (1998) 207–221 17. Lamport, L.: The Temporal Logic of Actions. ACM Transactions on Programming Languages and Systems 16 (1994) 872–923 18. Alpern, B., Schneider, F.B.: Defining liveness. Information Processing Letters 21 (1985) 181–185 19. Heyl, C., Mester, A., Krumm, H.: ctc — A Tool Supporting the Construction of cTLA-Specifications. In Margaria, T., Steffen, B., eds.: Tools and Algorithms for the Construction and Analysis of Systems. Number 1055 in Lecture Notes in Computer Science, Springer-Verlag (1996) 407–411 20. Graw, G., Herrmann, P., Krumm, H.: Constraint-Oriented Formal Modelling of OO-Systems. In: Second IFIP WG 6.1 International Working Conference on Distributed Applications and Interoperable Systems (DAIS 99), Helsinki, Kluwer Academic Publisher (1999) 345–358 21. Ferraiolo, D.F., Barkley, J.F., Kuhn, D.R.: A Role Based Access Control Model and Reference Implementation within a Corporate Intranet. ACM Transactions on Information Systems Security 1 (1999) 34–64 22. Osborn, S.L., Sandhu, R.S., Munawer, Q.: Configuring Role-Based Access Control to Enforce Mandatory and Discretionary Access Control Policies. ACM Transactions on Information and System Security 3 (2000) 85–106 23. Z¨ ollner, J., Federrath, H., Klimant, H., Pfitzmann, A., Piotraschke, R., Westfeld, A., Wicke, G., Wolf, G.: Modeling the security of steganographic systems. In: Proceedings of the 2nd Workshop of Information Hiding. LNCS 1525, Portland, Springer-Verlag (1998) 345–355 24. Schmitz, L.: The SalesPoint Framework — Technical Overview. Available via WWW: ist.unibw-muenchen.de/Lectures/SalesPoint/overview/english/ TechDoc.htm (1999) 25. OBI Consortium: OBI Technical Specifications — Open Buying on the Internet. Draft release v2.1 edn. (1999) 26. Ferrari, E., Samarati, P., Bertino, E., Jajodia, S.: Providing flexibility in information flow control for object-oriented systems. In: Proceedings of the IEEE Symposium on Security and Privacy, Oakland (1997) 130–140 27. Myers, A.C., Liskov, B.: Complete, Safe Information with Decentralized Labels. In: Proceedings of the IEEE Symposium on Security and Privacy, Oakland (1998) 186–197 28. Herrmann, P.: Information Flow Analysis of Component-Structured Applications. In: Proceedings of the 17th Annual Computer Security Applications Conference (ACSAC’2001), New Orleans, ACM SIGSAC, IEEE Computer Society Press (2001) 45–54
Towards Testing SDL Specifications: Models and Fault Coverage for Concurrent Timers ¨ Mariusz A. Fecko1 , M. Umit Uyar2 , and Ali Y. Duale3 1 2
Applied Research Area, Telcordia Technologies, Inc., Piscataway, NJ, USA, [email protected] Electrical Engineering Dept., CCNY, The City University of New York, USA, [email protected] 3 System Architecture Compliance, IBM Corp., Poughkeepsie, NY, USA, [email protected]
Abstract. A recent model for testing systems with multiple timers is extended to compute proper input delays and timeout settings, and is applied to several types of timers required in a testing procedure. In the model, any transition in the specification can be made conditional on a set of running timers. Depending on the path taken to reach an edge, the values of the timer variables may render the traversal of the edge infeasible. The presented modeling technique, combined with the INconsistencies DEtection and ELimination (INDEEL) algorithms, allows the generation of feasible test sequences. The model also offers the flexibility to define timer lengths as variables, and have the INDEEL find the appropriate timer ranges. An approach to apply this new methodology to SDL timed extensions (guarding and delaying timers) is presented. Keywords: conformance testing; timed EFSM; timed extensions; SDL
1
Introduction
Proper handling of timers is of special concern for computer-aided test generation from formal specifications [4, 8, 12, 13, 19, 22]. Consider sending a message that requires an acknowledgment, which implies that two timers may be started with different expiry times. If no acknowledgment is received before the first timer expires, the message is retransmitted and the timer restarted. When the second timer expires, the transmission attempts are abandoned. A feasible test sequence cannot proceed directly to the expiry of the second timer, bypassing that of the first timer. Such dependencies must be incorporated in the flow graph of the specification and resolved during test sequence generation [22].
M.A. Fecko initiated the timed EFSM model [9] at U Delaware. A.Y. Duale codesigned the indeel [6] at CUNY. They were then funded by the ATIRP Consortium sponsored by U.S. Army Research Lab (ARL) under the FedLab Program, Cooperative Agreement DAAL01-96-2-0002.
H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 273–288, 2003. c IFIP International Federation for Information Processing 2003
274
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
To address the above challenge, a new methodology has been introduced for test generation for timed systems modeled as Extended Finite State Machines (EFSMs) [14] with time-related variables [9, 10]. The methodology includes a novel model that uses simple linear expressions of time-related variables to represent complex timing dependencies. To ensure feasibility of test sequences, Duale and Uyar [6] designed INconsistencies DEtection and ELimination (indeel) algorithms to resolve inconsistencies among the condition or action variables of an EFSM. After these algorithms are applied to eliminate any time-related variable conflicts, all paths of the resulting EFSM are feasible. This paper generalizes and extends the timing model introduced in Ref. [9], and shows a range of its capabilities: • Testing various classes of timers: We illustrate a range of modeling that can be accomplished with our technique, including general models of various types of timers required during the testing procedure (i.e., global, guarding, delaying, and functional timers) (Section 2). • Fault models: As a formal analysis of timing faults, we show that a test sequence, if it covers every feasible edge at least once [10], can detect 1- and n-clock timing faults [8] and incorrect timer settings (Section 3). • Application to SDL: We illustrate how the above classes of timers can be defined and tested in SDL [4, 22]. Once the FSM is extracted [3], the time extensions for SDL [12] have a natural representation in our model (Section 4). • Delaying transitions: We present a formal approach to identify transitions that have to be delayed. A step-by-step test-sequence derivation shows how delays are algorithmically computed by the augmented indeel (Section 4.3). • Flexible timeout and transition-execution settings: We show how a tester can define a timer length as a constant or variable to automatically find proper timeout settings. This way, a test suite can cover service delivery and controllability features with multi-timer dependencies (Section 4.4).
2
Timing Model
The timed EFSM model for testing protocols with timers was introduced and formally described in Refs. [9, 10]. The model uses exclusively the paradigm of EFSM, which makes it easily applicable to the languages such as SDL [4, 22], VHDL [6], and Estelle [5], and thus enables testing timed systems with the numerous (E)FSM-based test generation methodologies [6, 14, 22]. To model concurrent timers, the original system along with its time-related behavior can be represented by an EFSM consisting of an FSM (the untimed model of the system) and a set of time-related variables. These variables represent features such as (1) a timer being on or off, (2) the amount of time elapsed since the last timeout, (3) the amount of time remaining until the next timeout, (4) the set of timers that must be on or off for a given transition to execute. There are several classes of timers used in test sequences [12]: • global timers to assure that the execution of a test case stops even if it is blocked due to unexpected behavior of the SUT;
Towards Testing SDL Specifications
275
• guarding timers to check constraints on the SUT response time; • delaying timers to delay the sending of messages to the SUT in order to allow the SUT to get into a desired state. The delaying timers help the SUT reach a state where it can receive the next signal when a tester is too fast. They also help check the reaction of the SUT if a signal is delayed too long to test invalid behavior, e.g., to check that the SUT does not send any signal for a given amount of time [12]. We also consider another type of delaying timers, whose purpose is to help the SUT reach certain states that otherwise would become unreachable (Sections 4.3 and 4.4). Let us refer to these classes of timers, which focus on an SUT’s behavior during testing, as test-execution timers. In addition, a protocol’s specification may contain functional timers, such as retransmission and acknowledgement timers. The timed EFSM model [9] is capable of modeling each type of timers. 2.1
Model Overview
For an FSM represented by graph G(V, E), consider a set of timers K = {tm1 , . . . , tm|K| } that may be arbitrarily started and stopped. Each tmj is associated with a boolean Tj whose value is true if tmj is running, and false otherwise. Each transition can be guarded by φ—a time formula obtained from variables T1 , . . . , Tk by using logical operands ∧, ∨, and ¬. We further define the following parameters [9, 10]: • Tj ∈ {0, 1}—Tj = 1 if tmj is running; Tj = 0 otherwise; • Dj ∈ R+ —tmj ’s timeout value (i.e., timer length); • fj ∈ R+ —time-keeping variable denoting the current time of tmj ; • ci ∈ R+ —time needed to traverse transition ei ∈ E, which is obtained from ei ’s definition in the specification or assessed by a domain expert; • time condition for ei : φi —ei can trigger only if its φi is satisfied; • action list for ei : {ϕi,1 , ϕi,2 , . . .}—each one updates a variable’s value; • csp ∈ R+ —time needed to traverse a self-loop of node vp ∈ V ; Based on the time-related variables described above, the model first defines a set of conditions and actions for four different types of transitions. The original G is then augmented as G , to which the indeel algorithms [6, 7] are applied. The algorithms, by analyzing the conflicts in a class of EFSMs, prevent inclusion of two or more conflicting edges in the same path in a test sequence. In the case of timed EFSMs, the time variables are treated as context variables. The conflicts are resolved by splitting the graph edges and nodes such that each conflicting pair of edges is placed in a different sub-graph. The resulting EFSM graph (represented by G ) does not contain any infeasible paths, and hence can be used as an input to the FSM-based test generation methods [14]. The algorithms avoid unnecessary state explosion during the conflict resolution by creating the new sub-graphs only when needed. By augmenting the original indeel, we significantly reduce the number of tests, while preserving all feasible transitions of G in G after the indeel applied to eliminate inconsistencies (converting G to G ). As a result, our method achieves the goal to cover every state transition at least once [10].
276
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
Eqs. 1 and 2 show the conditions (enclosed in angled brackets ) and actions (enclosed in curly braces {}) for transitions of Types 1 and 2. To reduce the test sequence length, additional two types of transitions merge non-timeout self-loops of vp sharing the same time condition φp,l . An in-depth interpretation of these transition types is presented in Refs. [9, 10]. Type 1 timeout transition eji = (vp , vq ), defined for each timer tmj (eji may be a self-loop, i.e., p = q) Tj ∧ (Dj − fj < Dk − fk )
(1)
{Tj = 0; fk = fk + max(0, ci + Dj − fj ); fj = −∞} Type 2 non-timeout transition ei = (vp , vq ), which may be a self-loop that starts/stops a timer or a non-self-loop fk < Dk {fk = fk + ci }
3
(2)
Fault Analysis
In our analysis, several well known assumptions [8, 14] on the specification and the IUT are valid: (1) the specification is strongly-connected, reduced, and deterministic; (2) the IUT has the same input alphabet as the specification; and (3) the faults do not increase the number of states in the IUT. The detection of transfer/output faults [16] depends on the state verification method [1, 15, 18], and is not part of the timing-fault analysis. If a timing fault results in a transfer/output fault, we assume that it is detected with high probability. This paper utilizes the classification of timing faults from Refs. [8, 13]. We prove that under the above assumptions, all single 1-clock and n-clock timing faults [8] are detected when applicable. We also prove that certain faults due to incorrect settings for timer lengths are covered. Fault coverage for multiple simultaneous timing faults is an open problem regardless of the testing model. At the testing of ei : (ai /oi ), output oi is expected no later than θ after applying ai . This behavior is controlled by a special-purpose timer in a test harness (outside the IUT), with the length θ: 0 < θ < ci + for a non-timeout ei , and max(0, Dj − fj ) < θ < ci + max(0, Dj − fj ) + for a timeout eij . 3.1
1-Clock, Interval Fault
• Timing requirement: For transitions ei = (vp , vq ; ai /oi ) and hk , transition ei can trigger only after applying ai within time boundaries [b1 , b2 ] measured from the execution of hk . • Timing fault I: ai is applied at bai ∈ [b1 , b2 ]; oi is observed and vq verified in less than bai + θ. • Timing fault II: ai is applied at bai ∈ [b1 , b2 ]; oi is not observed or vq not verified in less than bai + θ.
Towards Testing SDL Specifications
vk1
b2
ck
hk
b1
vk2
<1> {T1=1;T2=1;f1=0; f2=0}
277
θ ai
θ oi observed; fault Ι
ai
no output; fault ΙΙ
Fig. 1. Modeling 1-clock interval timing fault.
The 1-clock, interval timing requirement can be modeled as shown in Fig. 1. First, tm1 (with D1 = b1 ) and tm2 (with D2 = b2 ) are started in hk : 1{T1 = 1; f1 = 0; T2 = 1; f2 = 0}. As a result of the timing requirement, ei triggers after tm1 and before tm2 expire, and in its actions stops tm2 with output oi , i.e., ei : ¬T1 ∧ T2 {T2 = 0}. Let us consider the state and transition spaces (UG , RG ), defined for V and variables V = {T1 , f1 , . . . , T|K| , f|K| }. UG = {(vp , T1 , f1 , . . . , T|K| , f|K| ) : vp ∈ V, Tk , fk ∈ V}
(3)
be denoted as RG Let the sets of transitions between states in UG and UG and RG , respectively. Let each ui ∈ UG be represented by (vi , T1 , f1 , T2 , f2 ). Transition ei is represented in RG by gi = (up , uq ), where up = (vp , 0, −∞, 1, f2 ∈ [b1 , b2 ]) and uq = (vq , 0, −∞, 0, −∞). The time condition of ei and the definition of up indicate that gi is included (and can trigger) in a conflict-free graph only at a point in time f2 within the boundaries of [b1 , b2 ]. Transition ei will not be included in a test sequence as originating from any up with f2 ∈ [b1 , b2 ]. Timing fault I is detected in three steps: (1) verifying state vp , (2) observing oi , and (3) verifying state vq . These steps correspond to the execution of infeasible transition gi , which is present in neither a conflict-free graph nor a test sequence. Timing fault II is detected in two steps: (1) verifying state vp , and (2) observing ok =oi or verifying state vk =vq . These steps are not expected as a result of executing transition gi , which is included in a conflict-free graph and a test sequence. Therefore, all single 1-clock interval faults are detected. The above analysis can be easily extended for two interval faults such as timeconstraint restriction and time-constraint widening faults, which occur when the IUT changes either the upper or lower bound of a time constraint [8].
3.2
n-Clock Fault
• Timing requirement: For transitions ei = (vp , vq ; ai /oi ) and h1 , . . . , hn , transition ei can trigger after applying input ai only when, for any k < n, hk was executed before hk+1 . • Timing fault III: ai is applied, oi is observed and vq verified in less than bai +θ time when, for at least one k: 2 ≤ k ≤ n, hk is executed before hk−1 . For the n-clock timing requirement, timers tm1 , . . . , tmn with the infinite lengths are introduced (Fig. 2). Transition h1 starts tm1 , i.e., h1 : 1{T1 = 1; f1 = 0}. Each hk (2 ≤ k ≤ n) is split into h1k and h2k : the former triggers
278
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
vk1
v 11 h1
v 12
hk
vk1
vk1 hk1 hk2
vk2
vk1
vk-12
hk2
v n1
vk-11 hk-11
hk1
hk-12
hn1
v n2
vk2
vp hn
2
ei
vq
Fig. 2. Modeling n-clock timing fault. Transitions executed when the fault occurs appear in bold.
before tmk−1 expires, and starts tmk , i.e., hk : Tk−1 {Tk = 1; fk = 0}; the latter triggers when tmk−1 is not running, and in its actions stops tmk , i.e., hk : ¬Tk−1 {Tk = 0}. Finally, ei triggers only when tmn is running. The indeel allow only feasible test sequences to be generated. Consider two such sequences: • (h11 , . . ., h2k , h1k−1 , h2k+1 , . . ., h2n , hn+1 = ei ), with the outputs of (oh1 , . . ., ohk , ohk−1 , ohk+1 , . . ., ohn , ohn+1 ), where ohn+1 = oi or vq = tail(hn+1 ). Since hk precedes hk−1 , h1k ’s condition of Tk−1 cannot be satisfied because only h1k−1 can start tmk−1 . Transition ei : Tn is infeasible, since h2n does not start tmn ; • (h11 , . . ., h1k−1 , h1k , . . ., h1n , ei ), with the outputs of (oh1 , . . ., ohk−1 , ohk , . . ., ohn , oi ). The outputs observed when the timing fault III occurs are as follows: (oh1 , . . ., ohk , ohk−1 , ohk+1 , . . ., ohn , oi ). The above multi-clock fault is detected by the first valid test sequence, either by observing oi =ohn+1 , or by verifying state vq = tail(hn+1 ) when ohn+1 =oi . Therefore, all single n-clock faults are detected. 3.3
Incorrect Timer-Setting Fault
• Timing requirement: For timer tmj of length Dj , timeout transition eji = (vp , vq , −/oji ) will trigger exactly in Dj time units after tmj is started in transition hk . • Timing fault IV: After hk triggers, oji is observed and vq verified in less than Dj time. • Timing fault V: After hk triggers, oji is observed and vq verified in more than Dj + ci time. There are several ways in which this type of timing faults can be detected. The first way is to take advantage of the special-purpose timer with the length of θ. Suppose that transition eji triggers after Dj < Dj (timing fault IV). If Dj <= fj , then θ > 0 and the fault is not detected through the special-purpose timer. (It may, however, be detected by observing incorrect outputs.) If Dj > fj , then θ > Dj − fj , and the fault is detected by observing oji in less than θ time. Suppose that transition eji triggers after Dj > Dj (timing fault V). If Dj <= fj ,
Towards Testing SDL Specifications
279
then θ < ci + and the fault is detected for Dj − Dj > θ by observing oji in more than θ time. When the fault cannot be detected by using the special-purpose timer, in many cases it may be detected by observing expected outputs from other transitions affected by the fault. Suppose that, for the timing fault IV, the specification allows the following test sequence: (. . ., hk , . . ., hn , . . ., eji , . . .). Consider two cases of timing fault IV: (1) tmj expires in eji before the implementation is able to execute hn , and (2) the implementation executes the above test sequence in order. In the first case, eji triggers instead of hn . This error is detected by observing oji =ohn or verifying vq =tail(hn ). In the second case, whether the fault is detected depends on the state of the running timers at the time of error occurrence. If there are no running timers after tmj expires prematurely, timing fault IV is not detected other than by the special-purpose timer. Figure 3 shows a different case where there are running timers when the fault occurs. Timer tma with output oa is started by hk (which also starts tmj ), and timer tmb with output ob = oa is started by eji . The outputs in a test sequence for this case are as follows: (. . . , ok , . . . , on , . . . , oji , . . . , oa , ob , . . .). When timing fault IV occurs and Dj > Da − ci − Db (Case 2.1), the order of outputs in the test sequence is preserved by the implementation, and the discrepancy between Dj and Dj is not large enough to be detected in this way. If Dj < Da − ci − Db (Case 2.2), the difference Dj − Dj is large enough to cause ob appear before oa , which is detected by the above test sequence. The analysis for the timing fault V is analogous. Therefore, many single incorrect timer setting faults are detected. Example 1 (Fault detection) Let us consider a system where 3 timeouts are required to occur in a specific order: timeouts for tm1 followed by tm2 and tm3 . A violation of this requirement results in a 3-clock timing fault. Our method can detect this 3-clock fault, which can occur due to several faulty timers as follows: (1) tm3 expires then tm1 then tm2 , (2) tm2 expires then tm1 then tm3 , or (3) tm2 expires then tm3 then tm1 , etc. In this example, the timer lengths are correct, but they are started incorrectly (too early or too late). Otherwise, the errors correspond to incorrect timer-setting faults. As proven in this section, any single n-clock faults are detected by our method. We do not guarantee detection of all multiple n-clock or multiple incorrect timer-setting faults (or their combination). Consider the above error case tm3 expires followed by tm1 and then tm2 . Suppose also that there are incorrect timer settings: tm1 and tm2 are set to much shorter lengths than specified. In this case, the timers will all expire incorrectly (i.e., too early), but in the correct order.
Fig. 3. Incorrect timer-setting fault IV: not detected (2.1); detected (2.2).
280
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
Such multiple faults cannot be detected in our model unless special external timers are present in the test harness to monitor timers’ expiration times.
4
Application to SDL
The timer mechanism in SDL is used to express timing behavior of a system with only one variable (Timer ) and three operations (Set, Stop and Expire) [12]. The passage of time is implicit and various background procedures handle timer set, stop, and expiry. As a result, by inspecting an SDL specification, one cannot tell whether or not a timer will expire after the SUT arrives at a certain state. Therefore, infeasible test sequences can easily be generated unless time passage is being completely described by the timer variables. However, in our model, these three operations are represented by actions, with a major distinction that the passage of time is described by explicitly changing the variables’ values. This important feature allows detection and elimination of infeasible tests. Given an SDL specification, there are several steps involved in building a model from which a timed test sequence can be derived: • extracting partial behavior of an SDL system as an FSM, which is represented by graph G(V, E) (Section 4.1); • extending thus obtained FSM with time-related variables T1 , f1 , . . . , T|K| , f|K| , L1 , . . . , L|V | , ts1,1 , . . . , ts|V |,M|V | . The resulting timed EFSM models the original system along with its time-related behavior, and is represented by graph G (V , E ); • augmenting G algorithmically with the time conditions and actions. 4.1
FSM Derivation from SDL Specification
Extracting an FSM that represents partial behavior of an SDL system is beyond the scope of this paper. Instead, we adopt the techniques reported in the literature [3, 22]. One such technique [22] uses a special procedure to construct a single-entry multiple-exit graph for an EFSM modeling an SDL process. In the second stage, the extracted EFSM is converted to an FSM, which can be accomplished by using one of several known approaches [6, 14]. One can also use an FSM extractor called the FEX tool [3]. In general, transitions’ predicates in an SDL specification depend on both internal (context) variables and input parameters. The approach behind FEX is to extract an FSM by the partial unfolding of variables of enumerated types, while using the predicates as part of the corresponding FSM inputs. The behavior of the SDL specification is thus approximated by an FSM (called an approximating machine), where the FSM’s input is defined as a pair , and most states correspond to the control states of the SDL specification. The FEX tool constructs such an approximating machine from a given SDL specification with the help of a normalization algorithm. The procedure is especially effective for the specifications with relatively simple predicates, which is the case for most protocols.
Towards Testing SDL Specifications
281
Assuming an efficient procedure for the FSM extraction (like the ones described above), we will now illustrate test derivation for SDL specifications, where guarding (Section 4.2) and delaying (Section 4.3) timers are taken into account. Test derivation for the functional timers appears in Ref. [11]. 4.2
Guarding Timers
Let us consider the benchmark time-constraint specification in Fig. 4, given in TTCN-3 notation (taken from Ref. [12]), which uses two guarding timers. The SUT has two Points of Control and Observation (PCOs), called A and B, through which a tester entity can send and receive messages to and from the SUT. A tester handling PCO A sends input a to the SUT, and sets two guarding timers, T Guard Min and T Guard Max, to 2 and 5 seconds, respectively. The expected behavior of the SUT is to wait for T Guard Min timeout (line 5), and then receive the output d before T Guard Max timeout (lines 13 and 14). If the SUT’s reply d is too quick (i.e., before T Guard Min timeout in lines 6-10) or too slow (i.e., after T Guard Max in lines 15-19), the SUT fails the test. The above functional requirement of the system can be formulated as a special case of the 1-clock, interval timing requirement [8]. Let us use the fault analysis from Section 3.1 as the basis for modeling the violation of the timing requirement. First, transition h is introduced as h = (vp , vq , a/d) with the execution time of ch (vp is the initial state). Next, h is split into h1 = (vp , vq ) with execution time of ch and h2 = (vq , vq ) with execution time of 0, as shown in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
timer T Guard Min; timer T Guard Max; A.send (a); T Guard Min.start (2); T Guard Max.start (5); alt { [ ] T Guard Min.timeout; [ ] A.receive (d); { verdict.set (fail); MyComponent.stop; } } alt { [ ] A.receive (d); { T Guard Max.stop; } [ ] T Guard max.timeout; { verdict.set (fail); MyComponent.stop; } }
Fig. 4. Example SDL spec with two guarding timers (in TTCN-3 format).
282
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
vt
eb: (b/c)
vp
h: (a/d)
eon
vq
eb: (b/c)
eoff
vp
h1: (a/ε)
vq’
e1 e2
h2: (ε/d) e1 e2
vq
e1 e2
Fig. 5. Modeling 1-clock timing faults.
Figure 5. Then, the timing requirement can be reformulated as follows (ε denotes a null input or output): • Timing requirement: For transitions h1 = (vp , vq ; a/ε) and h2 = (vq , vq , ε/d), transition h2 can trigger only within time boundaries [b1 , b2 ] measured from the execution of h1 . • Timing fault I: d is observed in less than b1 seconds after application of a. • Timing fault II: d is observed in more than b2 seconds after application of a. • Timing fault III: d is not observed at all after application of a. These timing faults can be modeled as transfer/output faults [16] for the graph in Figure 5. First, timers tm1 and tm2 are introduced with the lengths of D1 =b1 and D2 =b2 , respectively. The timers are started in h1 : ¬T1 ∧ ¬T2 {T1 = 1; f1 = 0; T2 = 1; f2 = 0}. Because of the timing requirement, h2 can trigger only after tm1 and before tm2 expire, i.e., h2 : ¬T1 ∧ T2 {}. The timeout transitions for tm1 and tm2 are e1 : T1 {. . .} and e2 : T2 {. . .}, respectively. An expiry of tm1 and tm2 generates outputs o1 (tm1 ’s timeout) and o2 (tm2 ’s timeout). State vt is introduced as the initialization state, where a test sequence originates and terminates. A test sequence starts in state vt with edge eon : 1 {T1 = 0; T2 = 0; f1 = −∞; f2 = −∞}, which initializes all timers. It terminates when traversing edge eoff : ¬T1 ∧ ¬T2 {}, bringing the IUT from v0 back to state vt . The time condition of eoff ensures that at this point all timers are inactive. The above transitions also have the following appended conditions and actions [9]. For simplicity, we only show the appended conditions and actions for transitions h1 and h2 : h1 : f1 < 2 ∧ f2 < 5 ∧ ¬T1 ∧ ¬T2 {f1 = f1 + ch ; f2 = f2 + ch ; T1 = 1; f1 = 0; T2 = 1; f2 = 0} h2 : f1 < 2 ∧ f2 < 5 ∧ ¬T1 ∧ T2 {}
(4) (5)
Once G is built, the infeasible transitions are removed from it by the indeel [6], which produces a conflict-free EFSM. Then, any FSM test-generation method [14] can be applied to obtain an efficient test sequence. Consider a feasible test sequence and the associated I/O pairs: (eon , h1 , e1 , h2 , e2 , eb , eoff )
(6)
(oon , a/ε, ε/o1 , ε/d, ε/o2 , b/c, ooff )
(7)
Note that, while the presented framework does not distinguish input/output sequences (a/ε, ε/o1 ) and (a/o1 ), no timing fault is undetected due to this prop-
Towards Testing SDL Specifications
283
erty. On the other hand, when timing fault I occurs, the SUT traverses an infeasible path (eon , . . . , h1 , h2 , . . .), with the corresponding sequence of I/O pairs (oon , . . . , a/ε, ε/d, . . .). Similarly, the SUT traverses infeasible path (eon , . . . , h1 , . . . , h2 , . . .), with the corresponding sequence of I/O pairs (oon , . . . , a/ε, . . . , ε/o2 , ε/d, . . .), when timing fault II occurs. In the case of timing fault III, the SUT traverses another infeasible path (eon , . . . , h1 , e1 , e2 , . . . , eoff ), with the I/O pairs of (. . . , a/ε, ε/o1 , ε/o2 , . . . , ooff ). All these infeasible paths are eliminated by the indeel from a conflict-free graph and valid test sequences. An observation of the infeasible I/O pairs is thus detected by test sequence (6) by comparing them with outputs in (7). Specifically, observing d after applying a detects timing fault I; observing o2 after applying a detects timing fault II; and observing a pair o1 , o2 after applying a detects timing fault III. None of these observations correspond to those required by (7). 4.3
Delaying Timers
To prevent feasible transitions from becoming unreachable during testing, the transitions that start a guarding or functional timer may need to be delayed by certain amount of time [9]. The following rule is applied to graph G ’s traversal: • If ei starts a timer and at least one other timer is running when ei is to be traversed, delay ei ’s traversal by the amount of time less than the time remaining until the earliest timeout. The action of delaying such transitions allows us to explore various orderings of timers’ expirations by causing certain timers to expire before others. The length of delaying timers is found algorithmically. Example 2 (Delaying timers) The FSM in Figure 6 consists of three states v0 (the initial state), v1 , and v2 , and five transitions e1 through e5 . Suppose that all transitions take 1sec to traverse and each has the time condition 1 (i.e., true). There are two functional timers defined for the FSM: tm1 (started by e1 ) with the length of D1 = 4 and the timeout transition e3 , and tm2 (started by e2 ) with the length of D2 = 2 and the timeout transition e4 . Transitions e3 and e4 also explicitly stop timers tm2 and tm1 , respectively. Let us illustrate that e3 may not be traversed if no delaying timers are used. When the IUT is in its initial state v0 with all timers inactive, there is no need to delay e1 , since a delay cannot affect the time-related behavior of the system. Suppose that a tester does not delay e2 either. In this case, when v2 is visited, tm1 and tm2 have 3sec and 2sec left until expiration, respectively. Timer tm2 expires first in the timeout transition e4 that also stops tm1 . The system returns to v0 with all timers stopped and e3 never traversed. On the other hand, when e2 is delayed by more than 1sec, tm1 and tm2 have less than 2sec and exactly 2sec left until expiration, respectively. In this case, timer tm1 expires first in the timeout transition e3 , which also stops tm2 . Thus by choosing the length of the delaying timer in e2 as 0, a tester can traverse e4 . At another visit to v1 , the length greater than 1 will make e3 feasible.
284
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale procedure delaying
1(1)
* v1 or v2
vt
v0
on
off
T1=0; f1=−inf; T2=0; f2=−inf;
transition e_on *
Timeout T1
Timeout T2
v0
v1
start T1
start T2
T1=1; f1=0;
T2=1; f2=0;
start T1
start T2
T1 & T2 off
T1=0; f1=−inf; T2=0; f2=−inf
T2=0; f2=−inf; T1=0; f1=−inf
v0
v0
v1
v2
vt
v0
transition e3
transition e4
transition e1
transition e2
transition e_off
transition e5
yes
no
Fig. 6. Delaying affects reachability.
To generalize our previous results [9], let us consider the following state space defined for states in V and variables V = {T1 , f1 , . . . , T|K| , f|K| }: W = {(vp , (τj1 , yj1 ), . . . , (τjn , yjn )) : vp ∈ V, Tjk ∈ V} where τj1 , . . . , τjn are indices of running timers in the order of expiration. Each yjk=1 is defined as the time between tmjk−1 ’s and tmjk ’s timeouts; yj1 is set to 0. Let WG be the subset of W reachable in G , with the set of transitions among states in WG denoted as XG . Each xi ∈ XG is derived [14] from the original G ’s 1 2 transition ei = (vi , vi ) and labeled with the following parameters: • ei —original transition in E • wi1 , wi2 ∈ WG —xi ’s start and end states in WG , respectively, where wi1 = (vi1 , . . .) and wi1 = (vi2 , . . .) is to be traversed. It is clear that the timeSuppose that transition xi ∈ XG related components (i.e., variables of Ti and yi ) of wi1 and wi2 are identical unless xi is derived from a timeout transition or a transition that starts/stops a timer. Other transitions alter neither the order nor the time between timer expirations, which makes it unnecessary for a tester to delay their inputs.
Towards Testing SDL Specifications
285
Fig. 7. Delaying transition xi .
If xi is a timeout transition for tmj , the amount of time a tester can delay xi is independent of the tester’s action and equal to Dj − fj . If xi is not a timeout transition, one of the timers—say tma —is to expire first. Let dm i be the amount of time by which xi is delayed in this case. It can be observed that if xi is to be traversed instead of tma ’s timeout, dm i must be less than Da − fa (Figure 7 (b)). In the case where none of the timers are running before traversing xi (Figure 7 (a)), dm i will be set to 0 because time passage does not affect system behavior if all timers are inactive. (A delay greater than Da − fa cannot be applied, as shown in Figure 7 (c)). If xi stops a timer, delaying xi by any 0 < dm i < Da − fa does not result in the end state wi2 different from the end state for a zero delay. Therefore, dm i will be set to 0 as for a timeout transition. If xi starts a timer, delaying xi by 2 any 0 ≤ dm i < Da − fa is likely to result in multiple end states wi depending on m 2 the value of di . These multiple copies of wi need to be considered in G , since certain transitions in G may be feasible only for a specific copy. To satisfy the above requirement, each xi will be replaced by a set of transi(0) tions Xi . Transition xi ∈ Xi handles the case with dm i set to 0 where all timers (0) are inactive before traversing xi . Transition xi has the following appended condition: (∀k) timer tmk not running. Formally, this condition is ¬Tk . The case where dm i is upper bounded by a running timer tma with the shortest (a) time to expire is handled by transitions xi ∈ Xi , defined for each a: 1 ≤ a < |K|. In the above conversion, xi is replaced with |K| + 1 transitions in Xi , out (0) of which only one has a consistent condition, i.e., xi if no timer is running, (a) (a) or xi for a particular tma that is to expire first. Each xi has the following appended condition and actions: • condition: for each timer tmk =a : timer tma running AND timer tma is to expire before tmk . Formally, this condition is Ta ∧ (Da − fa < Dk − fk ); • action: for each k, increment tmk ’s current time by the introduced delay: m fk = fk + dm i , where 0 ≤ di < Da − fa . m During an application of the indeel, the two inequalities of dm i ≥ 0 and di < Da − fa must be included in the consistency check of conditions involving dm i . The actual instantiation of parameter dm , i.e., assigning a particular value from i between dm i ’s bounds, takes place after generating a test sequence. In addition, if xi stops or starts timer tmj , the actions {Tj = 0; fj = −∞} or {Tj = 1; fj = 0} must be appended to xi ’s action list, respectively. Let us now define a trace in state space WG , which will be instantiated as a test sequence in E [10].
286
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
Definition 1 A trace of G in state space WG is defined as a feasible sequence of tuples tG = (d1 , x1 ), . . . , (dm , xm ), where, for each xk , tester delays applying ak to an IUT by dk . For a non-timeout xk that starts a timer, dk ∈ R+ ; for a timeout xi = xji , dk = max(0, Dj − fj ), for the remaining transitions, dk is 0. Example 2 (cont’d) For the FSM of Fig. 6, consider state space WG and its transition set XG . The IUT traverses x1 to enter w1 . In w1 , if no delay is applied before traversing x2 , the IUT will move to state w2 (0) = (v2 , (2, 0), (1, 1)) regardless of a possible delay applied for x1 . If, however, delay dm 2 is applied before x2 is triggered, the IUT may be in multiple states distinguished by the 1 value of dm 2 . For the delay 1 < d2 < 3, x3 is feasible and x4 is not feasible in the 1 states defined by w2 (d2 ) = (v2 , (1, 0), (2, 2)). For 0 ≤ d22 < 1, in any state w2 (d22 ) = (v2 , (2, 0), (1, 1 − d22 )), x4 is feasible and x3 is not feasible. as the following paA test sequence can be algorithmically derived in XG rameterized trace: tG (d12 , d22 )
=
(0, x1 ), (d22 , x2 ), (2, x4 ), (0, x1 ), (d12 , x2 ), (3 − d12 , x3 )
(8)
(1)
where x2 = x2 ∈ X2 , 0 ≤ d12 , d22 < 3, and the accumulated conditions are x3 : (D1 − f1 < D2 − f2 ) ∧ . . . ≡ (d12 > 1) ∧ . . . x4 : (D2 − f2 < D1 − f1 ) ∧ . . . ≡ (d22 < 1) ∧ . . . The corresponding trace (test sequence) in E with the instantiated values of parameters d12 = 2 and d22 = 0 is as follows: tG (2, 0)
=
(0, e1 ), (0, e2 ), (2, e4 ), (0, e1 ), (2, e2 ), (1, e3 )
(9)
Eq. (9) indicates that, when e2 is traversed the first and second times, the length of its delaying timer is set to 2 and 0, respectively.
4.4
Flexible Timeout Settings
Let us now illustrate the advantages of our approach with respect to flexible modeling of timeout settings. If the timer lengths are fixed in advance (as they are, e.g., in Timed Automata (TA) [2]) certain portions of the system may become unreachable. In particular, in a complex system or protocol it is difficult to predict and manually assign the correct lengths for functional timers. Our model offers the flexibility to define timer lengths as variables, and have the indeel find the appropriate timer ranges, as shown below. Example 2 (cont’d) Suppose the timeout settings for the FSM of Fig. 6 are D1 =4 and D2 =5. For transitions x3 and x4 , the accumulated conditions are x3 : (d12 < 3) ∧ . . .,
x4 : (d22 < −2) ∧ . . .
(10)
The only possible sequence of delay/edge pairs through the FSM of Fig. 6 is trace tG (d12 , d22 ) = (0, x1 ), (d12 , x2 ), (3 − d12 , x3 ) containing x3 with feasible condition
Towards Testing SDL Specifications
287
in (10). During test generation, path (0, x1 ), (d22 , x2 ), (5, x4 ) that contains x4 is also considered, but pruned because its condition in (10) is always false for the initial timeout settings. As a result, x4 is always infeasible, and hence those portions of the graph reachable only through x4 are untestable. In our model, to find the timeout settings that make x4 feasible, D2 is a variable rather than a constant. In this case, the following parameterized trace will be obtained: tG (d12 , d22 , D2 ) = (0, x1 ), (d22 , x2 ), (D2 , x4 )(0, x1 ), (d12 , x2 ), (3 − d12 , x3 ) (11) (1)
where x2 = x2 ∈ X2 , with the following accumulated conditions: x3 : (d12 > 3 − D2 ) ∧ . . .,
x4 : (d22 < 3 − D2 ) ∧ . . .
(12)
A linear programming algorithm, which is used here to determine path feasibility, will find a feasible solution for (12) to instantiate (11). For example, trace (11) can be instantiated as the following test sequence in E: tG (2.5, 0, 1) = (0, e1 ), (0, e2 ), (1, e4 ), (0, e1 ), (2.5, e2 ), (0.5, e3 ) for d12 =2.5, d22 =0, and D2 =1. The methodology not only finds D2 =1, but also computes the appropriate lengths 2.5 and 0 for e2 ’s delaying timer.
5
Conclusion
A recent model for testing systems with multiple timers is extended to compute proper input delays and timeout settings, and is applied to several types of timers required in a testing procedure. This model, combined with the indeel algorithms, allows the generation of feasible test sequences. It can be used to specify timers defined as timed extensions to SDL such as guarding and delaying timers. In cases where it is difficult to predict and manually assign correct timer lengths, the model also offers the flexibility to define timer lengths as variables, and have the indeel find the appropriate timer ranges.
References 1. A.V. Aho, A.T. Dahbura, D. Lee, and M.U. Uyar. An optimization technique for protocol conformance test generation based on UIO sequences and rural Chinese postman tours. IEEE Trans. Commun., 39(11):1604–1615, 1991. 2. R. Alur and D.L. Dill. A theory of timed automata. Elsevier J. Theoret. Comput. Sci., 126:183–235, 1994. 3. G.v. Bochmann, A.F. Petrenko, O. Bellal, and S. Maguiraga. Automating the process of test derivation from SDL specifications. In Proc. SDL-Forum Symp., pp. 261–276, Evry, France, 1997. 4. M. Bozga, S. Graf, L. Mounier, I. Ober, J.-L. Roux, and D. Vincent. Timed extensions for SDL. In SDL’01 [17].
288
¨ Mariusz A. Fecko, M. Umit Uyar, and Ali Y. Duale
5. S. Budkowski and P. Dembi´ nski. An introduction to Estelle: A specification language for distributed systems. Elsevier J. Comput. Networks ISDN Syst., 14(1):3– 24, 1991. 6. A.Y. Duale and M.U. Uyar. Generation of feasible test sequences for EFSM models. In TestCom’00 [21], pp. 91–109. 7. A.Y. Duale and M.U. Uyar. INDEEL: A software system for inconsistency detection and elimination. In ATIRP’01 [20], pp. 3.29–34. 8. A. En-Nouaary, R. Dssouli, and F. Khendek. Timed Wp-method: Testing real-time systems. IEEE Trans. Softw. Eng., 28(11):1023–1038, 2002. 9. M.A. Fecko, P.D. Amer, M.U. Uyar, and A.Y. Duale. Test generation in the presence of conflicting timers. In TestCom’00 [21], pp. 301–320. 10. M.A. Fecko, M.U. Uyar, A.Y. Duale, and P.D. Amer. A technique to generate feasible tests for communications systems with multiple timers. IEEE/ACM Trans. Network. (to appear). 11. M.A. Fecko, M.U. Uyar, A.Y. Duale, and P.D. Amer. Efficient test generation for Army network protocols with conflicting timers. In ATIRP’01 [20], pp. 3.47–52. 12. D. Hogrefe, B. Koch, and H. Neukirchen. Some implications of MSC, SDL and TTCN time extensions for computer-aided test generation. In SDL’01 [17]. 13. A. Khoumsi, A. En-Nouaary, R. Dssouli, and M. Akalay. A new method for testing real-time systems. In Proc. IEEE RTCSA: Int’l Conf. Real-Time Comput. Syst. Appl., pp. 441–450, Cheju Island, S. Korea, 2000. 14. R. Lai. A survey of communication protocol testing. Elsevier J. Syst. Softw., 62:21–46, 2002. 15. G. Luo, G.v. Bochmann, and A.F. Petrenko. Test selection based on communicating nondeterministic finite state machines using a generalized Wp-method. IEEE Trans. Softw. Eng., 20(2):149–162, 1994. 16. A.F. Petrenko and G.v. Bochmann. On fault coverage of tests for finite state specifications. Elsevier J. Comput. Networks ISDN Syst., 29(1):81–106, 1996. 17. R. Reed and J. Reed, eds. Proc. SDL-Forum Symp., vol. 2078 of Springer LNCS, Copenhagen, Denmark, 2001. 18. A. Rezaki and H. Ural. Construction of checking sequences based on characterization sets. Elsevier J. Comput. Commun., 18(12):911–920, 1995. 19. J. Springintveld, F. Vaandrager, and P.R. D’Argenio. Testing timed automata. Elsevier J. Theoret. Comput. Sci., 254(1-2):225–257, 2001. 20. A.J. Tardif and J.W. Gowens, eds. ARL Advanced Telecommun./Information Distribution Research Program (ATIRP). UMD Printing, 2001. 21. H. Ural, R.L. Probert, and G.v. Bochmann, eds. Proc. IFIP TestCom: Int’l Conf. Test. Communicat. Syst., Ottawa, ON, 2000. 22. H. Ural, K. Saleh, and A. Williams. Test generation based on control and data dependencies within system specifications in SDL. Elsevier J. Comput. Commun., 23(7):609–627, 2000.
Concerning the Ordering of Adaptive Test Sequences Robert M. Hierons1 and Hasan Ural2 1
Department of Information Systems and Computing, Brunel University, Uxbridge, Middlesex, UB8 3PH, UK 2 School of Information Technology and Engineering, Faculty of Engineering, University of Ottawa, 800 King Edward Avenue, Ottawa, Ontario, K1N 6N5, Canada
Abstract. The testing of a state-based system may involve the application of a number of adaptive test sequences. Where the implementation under test (IUT) is deterministic, the response of the IUT to some adaptive test sequence γ1 may be capable of determining the response of the IUT to some other adaptive test sequence γ2 . Thus, the expected cost of applying a set of adaptive test sequences depends upon the order in which they are applied. This paper explores properties of adaptive test sequences and the problem of finding an order of application, of the elements from some set of adaptive test sequences, that minimises the expected cost of testing.
1
Introduction
Where a system is state-based, testing involves the application of sequences of input values. Such sequences are called test sequences. A test sequence, or a set of test sequences, may represent some test purpose or test objective. An adaptive test sequence is applied in an adaptive experiment which is a process in which at each stage the input applied depends upon the output that has been produced. An adaptive test typically consists of a number of adaptive test sequences. The use of adaptive tests has been proposed within the area of testing from a (possibly non-deterministic) finite state machine (see, for example, [1, 4, 7, 9, 10]), and generally in protocol conformance testing [6]. Further, algorithms for generating tests from a specification written in a Process Algebra such as LOTOS typically produce adaptive test sequences with verdicts (see, for example, [2, 8]). Adaptivity is thus a core element of the test description language TTCN (see, for example, [3]). Adaptivity may lead to more efficient tests. For example, when testing against a non-deterministic finite state machine there may be no single preset input sequence that reaches a given state s and thus a set of input sequences might be used to reach s. Instead, it may be possible to apply a single adaptive test sequence to reach s. When the implementation under test (IUT) is deterministic, the response to one adaptive test sequence γ1 may be capable of fully deciding the response of the IUT to some other adaptive test sequence γ2 . Where this is the case, using γ1 before γ2 may reduce the expected test execution effort. However, relationships H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 289–302, 2003. c IFIP International Federation for Information Processing 2003
290
Robert M. Hierons and Hasan Ural
involving other adaptive test sequences may affect the best relative ordering of γ1 and γ2 . This paper considers the problem of finding an order of execution, of a set of adaptive test sequences, that maximises the expected saving where the IUT is known to be deterministic. Such an ordering is said to be an optimal ordering. This paper makes a number of contributions. First, we make the observation that the order in which adaptive test sequences are applied may affect the expected cost of testing. We formalise this notion and define a function that determines whether the execution of one adaptive test sequence γ1 is capable of removing the necessity to apply another adaptive test sequence γ2 . We then show how the scale of the optimisation problem may be reduced. Finally, we introduce an algorithm that produces the optimal ordering where the problem has particular properties. Future work will consider how this algorithm may be generalised. This paper is structured as follows. Section 2 describes test sequences, directed graphs, and adaptive test sequences. Section 3 then considers conditions under which the relative ordering of adaptive test sequences may be significant. Section 4 considers two ways in which the optimisation problem may be simplified. Section 5 introduces a polynomial time algorithm that generates the optimal ordering under a well-defined condition. Section 6 describes potential future work and finally, in Section 7 conclusions are drawn.
2 2.1
Preliminaries Sequences
Throughout this paper X and Y will denote the input and output domains of the IUT. Given a set A, A∗ will denote the set of sequences of elements from A, including the empty sequence . It will be assumed that the IUT is a state-based system and thus that testing leads to the observation of input/output sequences of the form x1 /y1 , . . . , xk /yk ∈ (X/Y )∗ where x1 , . . . , xk ∈ X and y1 , . . . , yk ∈ Y . A preset input sequence is some element of X ∗ . Given sequences c and d, cd will denote the result of concatenating c and d. For example, a/0 a/1, b/0 = a/0, a/1, b/0. Given sets C and D of sequences, CD will denote the set formed by concatenating the elements of C with the elements of D. Thus CD = {cd|c ∈ C ∧ d ∈ D}. Given a sequence b ∈ A∗ , pre(b) will denote the set of prefixes of b. Given a set B of sequences P re(B) will denote the set of prefixes of sequences from B. These are defined more formally by the following. Definition 1. Given sequence b ∈ A∗ and set B ⊆ A∗ : pre(b) = {b ∈ A∗ |∃b ∈ A∗ .b = b b } pre(b) P re(B) = b∈B
Concerning the Ordering of Adaptive Test Sequences
291
If a set of adaptive test sequences is applied then the IUT is returned to its initial state after each test using a test postamble [5]. This ensures that each test is applied in the same state of the IUT. The postamble might involve some sequence of inputs or a single action such as a disconnect or reset, for a connection-oriented communications protocol, or the system being switched off and then on again. 2.2
Directed Graphs
A directed graph is a set of vertices with arcs between them. The following is a more formal definition. Definition 2. A directed graph (digraph) G is defined by a pair (V, E) in which V = {v1 , . . . , vn } is a finite set of vertices and E ⊆ V × V is a set of directed edges between the vertices of G. An element e = (vi , vj ) ∈ E represents an edge from vi to vj . Given edge e = (vi , vj ), start(e) denotes vi and end(e) denotes vj . Definition 3. Given digraph G = (V, E) and vertex v ∈ V , indegreeE (v) denotes the number of edges from E that end at v and outdegreeE (v) denotes the number of edges from E that start at v. Given a digraph G = (V, E), a sequence e1 , . . . , em of edges from E, in which for all 1 ≤ k < m end(ek ) = start(ek+1 ), is a path from start(e1 ) to end(em ) in G. A path is a cycle if its initial and final vertices are the same and no other vertex is repeated. A digraph is said to be acyclic if it has no cycles. Given a digraph G, the following defines the result of removing one or more vertices from G. Definition 4. Let G = (V, E) denote a digraph and V ⊆ V . Then G \ V denotes the digraph formed by removing every vertex contained in V , and the associated edges, from G. This is formally defined by the following. G \ V = (V \ V , {(vi , vj ) ∈ E|vj ∈ V ∧ vi ∈ V }) 2.3
Adaptive Test Sequences
Testing typically involves applying input sequences to the IUT and observing the output produced. Sometimes the input sequences used are preset: each is fully determined before it is applied. However, a test may be adaptive: the next input provided in a sequence may depend on the outputs produced in response to the previous input values. Such a test is called an adaptive test sequence. The use of adaptive test sequences has been proposed in a number of areas including protocol conformance testing (see, for example, [1, 6, 9]). In this paper T will denote the set of all adaptive test sequences that use inputs from X and refer to outputs from Y . The set T may be defined recursively in the following manner.
292
Robert M. Hierons and Hasan Ural
Definition 5. Each element γ ∈ T is one of: – null – a pair (x, f ) in which x ∈ X and f is a function from Y to T . An adaptive test sequence γ is applied in the following manner. If γ = null then the adaptive test sequence ends. If γ = (x, f ) then x is applied and the output y is observed. The adaptive test sequence f (y) is then applied. We will assume that the adaptive test sequences are finite. An adaptive test sequence may be represented by a tree. For example, the tree in Figure 1 represents an adaptive test sequence in which the first input is a, no further input is provided if the output is 0, and the input b is provided if the output is 1. Whatever the response to b after a, the test then terminates. The adaptive test sequence γ given in Figure 1 may be defined in the following way: γ = (a, f ), f (0) = null, f (1) = (b, f ), f (0) = null, and f (1) = null.
0
a
1 0
b
1
Fig. 1. An adaptive test sequence
Given γ ∈ T it is possible to define the set IO(γ) of input/output sequences that may be observed using γ. Definition 6. Given γ ∈ T , {} IO(γ) =
y∈Y
if γ = null {x/y}IO(f (y)) if γ = (x, f )
The first rule states that if γ = null then no input/output behaviour is seen and thus the empty sequence is observed. The second rule is recursive, stating that given y ∈ Y , γ may lead to an input/output behaviour in the form of x/y followed by some input/output behaviour formed by then applying f (y). For example, the adaptive test sequence γ given in Figure 1 has: IO(γ) = {a/0 , a/1, b/0 , a/1, b/1}. Since every adaptive test sequence has finite length, it follows that IO(γ) is finite and every element of IO(γ) is finite. Definition 7. The length of γ ∈ T is defined by: 0 if γ = null length(γ) = 1 + maxy∈Y length(f (y)) if γ = (x, f ) The length of an adaptive test sequence γ is thus the length of the longest input/output sequence that may occur through the application of γ.
Concerning the Ordering of Adaptive Test Sequences a
a
a 0
0
0
1
1
0 a
b 1
a 1
0
1
0
293
b 1
0
a 1
0
1
Fig. 2. Adaptive test sequences γ1 , γ2 , and γ3
3
Conditions under Which Savings Occur
This section will explore conditions under which it may not be necessary to use γ2 ∈ T if we first apply γ1 ∈ T . Consider adaptive test sequences γ1 and γ2 in Figure 2. Suppose the use of γ1 leads to the input/output sequence a/0, a/1. Then, since the IUT is deterministic we know that the response of the IUT to γ2 will be a/0. Thus there is no need to apply γ2 . Suppose we intend to execute some adaptive test sequence γ2 after some adaptive test sequence γ1 , γ1 being followed by a postamble that returns the system to its initial state. Then the response of the IUT to γ1 might determine the response of the IUT to γ2 if one of the possible responses to γ2 is a prefix of some possible response to γ1 . The condition under which this may happen will now be defined. Proposition 1. The response of the IUT to γ1 ∈ T may determine the response of the IUT to γ2 ∈ T if there is some x1 /y1 ∈ IO(γ1 ) and x2 /y2 ∈ IO(γ2 ) such that x2 /y2 ∈ pre(x1 /y1 ). Definition 8. If there is some x1 /y1 ∈ IO(γ1 ) and x2 /y2 ∈ IO(γ2 ), γ1 , γ2 ∈ T , such that x2 /y2 ∈ pre(x1 /y1 ) then we write γ2 ≤ γ1 . Note that ≤ is not an ordering: there are distinct adaptive test sequences γ1 and γ2 such that γ2 ≤ γ1 and γ1 ≤ γ2 . Such a case is illustrated in Figure 3.
a
a 0
1
subtree
0
1
subtree
Fig. 3. Related adaptive test sequences
294
Robert M. Hierons and Hasan Ural
Proposition 2. The relation ≤ is reflexive but in general it is not symmetric and is not transitive. Proof The fact that ≤ is reflexive is an immediate consequence of the definition. γ1 and γ2 in Figure 2 demonstrate that ≤ is not symmetric. In order to see that ≤ is not transitive consider the example in Figure 2. It is straightforward to show that γ2 ≤ γ1 , γ3 ≤ γ2 but γ3 ≤ γ1 . 2 Clearly, if γ2 ≤ γ1 but γ1 ≤ γ2 it may make sense to use γ1 before γ2 . The function sav, defined below, may be used to decide whether γ1 ≤ γ2 . Definition 9. sav(γ, null) = true sav(null, (x, f )) = f alse sav((x1 , f1 ), (x2 , f2 )) = (x1 = x2 ) ∧ ∃y ∈ Y.sav(f1 (y), f2 (y)) The following result is clear. Proposition 3. Given γ1 , γ2 ∈ T , γ2 ≤ γ1 if and only if sav(γ1 , γ2 ). Based on the relation ≤ it is possible to define a digraph. Definition 10. Given some set Γ = {γ1 , . . . , γn } of adaptive test sequences, the dependence digraph is the digraph G = (V, E) in which V = {v1 , . . . , vn } and there is an edge (vi , vj ) in E if and only if γj ≤ γi and γj = γi .
4
Simplifying the Optimisation Problem
This section describes two ways of reducing the scale of the optimisation problem and proves that these approaches do not conflict: by applying one approach we do not reduce the scope for applying the other approach. 4.1
Merging Adaptive Test Sequences
Given γ1 , γ2 ∈ T , it may be possible to combine γ1 and γ2 to form one adaptive test sequence. This may reduce the size of the optimisation problem. This section considers conditions under which this may be done and defines an algorithm that merges adaptive test sequences. Consider, for example, the adaptive test sequences given in Figure 4. Here γ3 is the result of merging γ1 and γ2 . By applying γ3 to a deterministic implementation we get exactly the same information as if we had separately applied γ1 and γ2 to some implementation since: 1. Each possible response to γ3 is a possible response to one of γ1 and γ2 ; and 2. Each possible response to one of γ1 and γ2 is a prefix of some possible response to γ3 .
Concerning the Ordering of Adaptive Test Sequences a
a 1
0
a 1
0
1
0
1
0 a
b 0
295
b 1
0
a 1
0
1
Fig. 4. Merging γ1 and γ2 to form γ3
Before considering how adaptive test sequences may be merged we will define what it means for one adaptive test sequence to be smaller than or equal to another. Definition 11. γ1 ∈ T is smaller than or equal to γ2 ∈ T if and only if IO(γ1 ) ⊆ P re(IO(γ2 )). This says that all behaviours observable under γ1 are also observable under γ2 . Definition 12. γ3 ∈ T is the result of merging γ1 ∈ T and γ2 ∈ T if and only if the following hold: 1. IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(IO(γ3 )) and 2. for every γ4 ∈ T , if IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(IO(γ4 )) then γ3 is smaller than or equal to γ4 . The first element of this definition insists that all behaviours observable under γ1 and all behaviours observable under γ2 are also observable under γ3 . The second element says that γ3 is the smallest adaptive test sequence that has this property. Sufficient and necessary conditions, for it to be possible to merge two adaptive test sequences, will be defined in terms of the notion of two adaptive test sequences being compatible. Definition 13. γ1 , γ2 ∈ T are said to be compatible if and only if there are no pairs of sequences x1 /y1 , x2 /y2 , . . . , xk−1 /yk−1 , xk /yk ∈ P re(IO(γ1 )) and x1 /y1 , x2 /y2 , . . . , xk−1 /yk−1 , xk /yk ∈ P re(IO(γ2 )) with xk = xk (k ≥ 1). Thus, γ1 and γ2 are compatible if there does not exist an input/output sequence x/y that might result from both γ1 and γ2 such that γ1 and γ2 apply different input values after x/y. It should be clear that in order to be able to merge two adaptive test sequences γ1 and γ2 it is necessary for them to be compatible: otherwise the resultant adaptive test sequence γ3 must be able to provide two different input values after some input/output sequence x/y. This is not allowed by the definition of an adaptive test sequence. The function compatible, defined below, decides whether two adaptive test sequences are compatible.
296
Robert M. Hierons and Hasan Ural
Definition 14. compatible(γ, null) = true compatible(null, γ) = true compatible((x1 , f1 ), (x2 , f2 )) = (x1 = x2 ) ∧ ∀y ∈ Y. compatible(f1 (y), f2 (y)) Proposition 4. γ1 , γ2 ∈ T are compatible if and only if compatible(γ1 , γ2 ) = true. Given compatible γ1 and γ2 , the following algorithm merges γ1 and γ2 . Definition 15. merge(γ, null) = γ merge(null, γ) = γ merge((x, f1 ), (x, f2 )) = (x, {y → merge(f1 (y), f2 (y)) |y ∈ Y }) Proposition 5. If γ1 ∈ T and γ2 ∈ T are compatible then merge(γ1 , γ2 ) is the result of merging γ1 and γ2 . Proof First observe that, by definition, if γ1 and γ2 are compatible then merge(γ1 ,γ2 ) is defined. Let γ3 = merge(γ1 , γ2 ). Clearly every sequence in IO(γ1 ) ∪ IO(γ2 ) is a prefix of some sequence in IO(γ3 ). It thus suffices to prove that γ3 is the smallest adaptive test sequence with this property. Proof by induction on the length of γ3 will be applied. The base case, where γ3 = null, is clear since null is smaller than or equal to every other adaptive test sequence. Inductive hypothesis: if γ3 = merge(γ1 , γ2 ) has length less than k and γ4 has the property that IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(γ4 ) then γ3 is smaller than or equal to γ4 . Suppose γ3 = merge(γ1 , γ2 ) has length k and γ4 has the property that IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(IO(γ4 )). It now suffices to prove that γ3 is smaller than or equal to γ4 . Note that γ1 and γ2 are smaller than or equal to γ4 . Thus the result is clear if either γ1 = null (so γ3 = γ2 ) or γ2 = null (and so γ3 = γ1 ). Suppose γ1 = null and γ2 = null. Then there exists x1 ∈ X such that γ1 = (x1 , f1 ), γ2 = (x1 , f2 ), γ3 = (x1 , f3 ), and γ4 = (x1 , f4 ). It is now sufficient to prove that the set IO(γ3 )\P re(IO(γ4 )) is empty. Proof by contradiction: suppose x1 /y1 , . . . , xm /ym ∈ IO(γ3 ) \ P re(IO(γ4 )). Let γ1 = f1 (y1 ), γ2 = f2 (y1 ), γ3 = f3 (y1 ), and γ4 = f4 (y1 ). Now consider the relationships between γ1 , γ2 , γ3 , and γ4 . By the definition of merge, γ3 = merge(γ1 , γ2 ). Further, IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(γ4 ) and x2 /y2 , . . . , xm /ym ∈ IO(γ3 ) \ P re(IO(γ4 )). Since γ3 has length at most k − 1, this contradicts the inductive hypothesis. The result thus follows. 2
Concerning the Ordering of Adaptive Test Sequences
297
Proposition 6. It is possible to merge adaptive test sequences if and only if they are compatible. Proof By Proposition 5, it is possible to merge γ1 and γ2 if they are compatible. It thus suffices to prove that if γ1 and γ2 can be merged then they are compatible. Proof by contradiction: suppose that γ1 and γ2 can be merged but they are not compatible. Let γ3 denote the result of merging γ1 and γ2 . Since γ1 and γ2 are not compatible there exists v = x1 /y1 , . . . , xm−1 /ym−1 , v xm /ym ∈ P re(IO(γ1 )), and v xm /ym ∈ P re(IO(γ2 )) with xm = xm . By ∈ P re(IO(γ3 )). This contradefinition, vxm /ym ∈ P re(IO(γ3 )) and vxm /ym dicts the definition of an adaptive test sequence, since γ3 must allow two different input values after the input/output sequence v. The result thus follows. 2 The following result is an immediate consequence of the definitions. Proposition 7. If γ1 ∈ T and γ2 ∈ T are compatible then γ1 ≤ merge(γ1 , γ2 ) and γ2 ≤ merge(γ1 , γ2 ). By merging compatible adaptive test sequences it is possible to reduce the number of sequences considered. Definition 16. A set Γ of adaptive test sequences is irreducible if no two elements of Γ are compatible. Otherwise Γ is reducible. It will be assumed that any set of adaptive test sequences considered is irreducible: where there are compatible adaptive test sequences these are merged before the order of application is decided. Observe that given a reducible set Γ of adaptive test sequences, there may be more than one way in which to merge the elements of Γ in order to produce an irreducible set. Future work will consider the problem of choosing an optimal irreducible set. 4.2
Independent Adaptive Test Sequences
We have seen that the order of the application of adaptive test sequences may be important. However, there may be adaptive test sequences in the test whose relative order is irrelevant. Where this is identified, the problem of determining the optimal ordering may be reduced to that of determining the optimal ordering amongst the elements within a number of sets of adaptive test sequences. Suppose that γ1 , γ2 ∈ T , γ1 ≤ γ2 and γ2 ≤ γ1 . Then it may appear that the relative order of γ1 and γ2 is irrelevant. However, since ≤ is not transitive, there may be some γ3 such that γ1 ≤ γ3 and γ3 ≤ γ2 . Thus, in order to define some notion of independence we form an equivalence relation from ≤. Definition 17. γ1 and γ2 are dependent in a set Γ of adaptive test sequences if and only if there exist γ 1 , . . . , γ k ∈ Γ with γ1 = γ 1 , γ2 = γ k and for all 1 ≤ i < k, γ i ≤ γ i+1 or γ i+1 ≤ γ i . If γ1 and γ2 are dependent we write γ1 ∼ γ2 ; otherwise we say they are independent and write γ1 ∼ γ2 .
298
Robert M. Hierons and Hasan Ural
In Lemma 4 we will prove that if two adaptive test sequences are compatible then they are dependent. The relation ∼ is the symmetric, transitive closure of the reflexive relation ≤. Thus ∼ is an equivalence relation. Given two equivalence classes Q1 and Q2 if Q1 = Q2 , γ1 ∈ Q1 , and γ2 ∈ Q2 , γ1 and γ2 must be independent. Thus it is possible to split the set of adaptive test sequences used into these equivalence classes and determine an order of application for the elements of each equivalence class. This observation may simplify the problem of choosing the optimal ordering. We have seen two different approaches to simplifying the problem: dividing the set of adaptive test sequences into a set of equivalence classes and merging adaptive test sequences where possible. In Theorem 1 we will prove that these approaches do not conflict: by merging two adaptive test sequences we cannot combine two equivalence classes. Definition 18. Given γ ∈ T and v ∈ IO(γ), prune(v, γ) is the adaptive test sequence formed by taking γ and replacing the node reached by input/output sequence v by null. prune(, (x, f )) = null prune(x1 /y1 v, (x1 , f )) = (x1 , {y → f (y)|y ∈ Y \ {y1 }} ∪{y1 → prune(v, f (y1 ))}) Thus, prune(v, γ) removes all extensions of v from IO(γ). The following is clear. Lemma 1. Given v x/y ∈ IO(γ), γ ∈ T and γ = prune(v, γ), we have that IO(γ ) = (IO(γ) ∪ {v}) \ {v x/y |y ∈ Y } We have seen two different approaches to simplifying the problem: dividing the set of adaptive test sequences into a set of equivalence classes and merging adaptive test sequences where possible. In Theorem 1 we will prove that these approaches do not conflict: by merging two adaptive test sequences we cannot combine two equivalence classes. Lemma 2. If γ=merge(γ1 , γ2 ), γ, γ1 , γ2 ∈ T then P re(IO(γ))=P re(IO(γ1 )) ∪ P re(IO(γ2 )). Proof By definition, P re(IO(γ1 )) ∪ P re(IO(γ2 )) ⊆ P re(IO(γ)). It thus suffices to prove that P re(IO(γ)) ⊆ P re(IO(γ1 )) ∪ P re(IO(γ2 )). This holds if IO(γ) ⊆ P re(IO(γ1 )) ∪ P re(IO(γ2 )). Proof by contradiction will be applied: suppose there exists some input/output sequence v x/y ∈ IO(γ) \ (P re(IO(γ1 )) ∪ P re(IO(γ2 ))). Then we may create a new adaptive test sequence γ = prune(v, γ). From Definition 15 we know that IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(IO(γ)). Since v x/y ∈ P re(IO(γ1 )) ∪ P re(IO(γ2 )), for all y ∈ Y we have that v x/y ∈ P re(IO(γ1 )) ∪ P re(IO(γ2 )). Thus, by Lemma 1, we have that IO(γ1 ) ∪ IO(γ2 ) ⊆ P re(IO(γ )). But γ is not smaller than or equal to γ , contradicting γ being the result of merging γ1 and γ2 . The result thus follows. 2
Concerning the Ordering of Adaptive Test Sequences
299
We thus get the following result. Lemma 3. Given γ, γ1 , γ2 ∈ T , if γ = merge(γ1 , γ2 ) and v ∈ IO(γ) then either v ∈ IO(γ1 ) or v ∈ IO(γ2 ). Lemma 4. If γ1 ∼ γ2 , γ1 , γ2 ∈ T , then we cannot merge γ1 and γ2 . Proof It is sufficient to prove that if we can merge γ1 and γ2 then γ1 ∼ γ2 . Suppose that we can merge γ1 and γ2 and let γ = merge(γ1 , γ2 ). Let v = x1 /y1 , . . . , xm /ym ∈ IO(γ). By Lemma 3, v ∈ IO(γ1 ) ∪ IO(γ2 ). Without loss of generality, v ∈ IO(γ1 ). If v ∈ P re(IO(γ2 )) then γ1 ≤ γ2 , and so γ1 ∼ γ2 as required. It will thus be assumed that v ∈ P re(IO(γ2 )). Let v denote the longest prefix of v contained in P re(IO(γ2 )). Thus v = x1 /y1 , . . . , xk /yk for some k < m. Suppose there is some extension, v x/y of v in P re(IO(γ2 )). Observe that, since γ1 and γ2 may be merged, by Proposition 6, γ1 and γ2 are compatible. Thus x = xk+1 , contradicting the maximality of v . Thus v ∈ IO(γ2 ) and so γ2 ∼ γ1 as required. 2 Lemma 5. If γ1 ∼ γ, γ2 ∼ γ and γ3 = merge(γ1 , γ2 ), γ1 , γ1 , γ3 ∈ T , then γ ≤ γ3 and γ3 ≤ γ. Proof Assume that γ1 ∼ γ, γ2 ∼ γ, and γ3 = merge(γ1 , γ2 ). Proof by contradiction will be applied. There are two cases to consider. Case 1: γ3 ≤ γ. Thus there exists input/output sequences v ∈ IO(γ3 ) and v ∈ IO(γ) such that v ∈ pre(v ). By Lemma 3, v ∈ IO(γ1 ) ∪ IO(γ2 ). Without loss of generality, v ∈ IO(γ1 ). Thus, γ1 ≤ γ, providing a contradiction as required. Case 2: γ ≤ γ3 . Thus there exists input/output sequences v ∈ IO(γ) and v ∈ IO(γ3 ) such that v ∈ pre(v ). By Lemma 3, v ∈ IO(γ1 ) ∪ IO(γ2 ). Without loss of generality, v ∈ IO(γ1 ). Thus, γ ≤ γ1 , providing a contradiction as required. 2 Theorem 1. We cannot combine two equivalence classes of ∼ by merging two adaptive test sequences. Proof Observe that the merging of adaptive test sequences γ1 and γ2 can only lead to equivalence classes being merged if one of the following happens: 1. γ1 and γ2 are in different equivalence classes. 2. γ1 and γ2 are in the same equivalence class Q of ∼ but there is some γ in an equivalence class Q = Q such that γ ≤ merge(γ1 , γ2 ) or merge(γ1 , γ2 ) ≤ γ. The result thus follows from Lemmas 4 and 5. 2
5
Ordering Based on the Dependence Digraph
This section will consider the problem of finding an ordering based on the dependence digraph where the dependence digraph G is acyclic. It transpires that
300
Robert M. Hierons and Hasan Ural
in this case an exact solution may be found in polynomial time. Future work will consider general algorithms. The following is a useful property of acyclic digraphs. Proposition 8. If digraph G = (V, E) is acyclic and |V | > 0 then there exists some v ∈ V such that indegreeE (v) = 0. Thus, if the dependence digraph G for Γ is acyclic, it is possible to choose some γ ∈ Γ such that the application of another element of Γ cannot lead to γ not being required. Thus, in choosing an order in which to apply the elements of Γ it is acceptable to start with γ. Proposition 9. Suppose digraph G = (V, E) is acyclic and v ∈ V . Then the digraph G \ {v} is acyclic. From this it is clear that if the dependence digraph G is acyclic, then having chosen some γ ∈ Γ as described above, when γ is removed from Γ the resultant digraph is acyclic. Based on these results, we get the following algorithm for the case when ≤ defines an acyclic dependency digraph. This algorithm essentially chooses some ordering based on a directed acyclic graph (DAG). Algorithm 1 1. Input the dependence digraph G = (V, E) (|V | = n), where vi ∈ V represents adaptive test sequence γi . 2. Set T = , G0 = (V0 , E0 ) = (V, E), k = 0. 3. While (Vk = ∅) do 4. Choose some vi ∈ Vk such that indegreeEk (vi ) = 0. 5. Set T = T γi , k = k + 1, Gk = (Vk , Ek ) = Gk−1 \ {vi }. 6. od 7. Output T The following result is clear. Proposition 10. Algorithm 1 has computational complexity O(n2 ) where n denotes the number of adaptive test sequences in Γ . Thus, where the dependency digraph is acyclic the problem of finding an optimal ordering for the adaptive test sequences may be solved in polynomial time.
6
Future Work
This paper has formalised properties of adaptive test sequences that may be utilised in order to reduce the expected cost of testing. However, a number of problems remain. Where there are cycles in the dependence digraph, any ordering chosen will allow some possible savings while precluding others. This leads to a more complex optimisation problem which will form an important element of future work.
Concerning the Ordering of Adaptive Test Sequences
301
We have shown that, given a set of adaptive test sequences, it may be possible to merge some of these sequences to produce an irreducible set. However, there may be a number of possible orders in which the merging may occur and a number of irreducible sets that may result from this process. Future work will consider algorithms that determine the order in which adaptive test sequences should be merged. This paper has focussed on the case where the IUT is known to be deterministic and thus will always respond to an input sequence with the same output sequence. Where the IUT is non-deterministic, it is sometimes possible to make a fairness assumption: it is assumed that there is some k such that the use of an adaptive test sequence k times will lead to all possible responses being observed. Where such an assumption is made it is possible for the responses of the IUT to one adaptive test sequence to be capable of determining the response to another adaptive test sequence. Future work will consider the problem of finding an optimal ordering of a set of adaptive test sequences where a fairness assumption can be made.
7
Conclusion
Adaptive test sequences may be used when testing a state-based system. Where the implementation under test I is known to be deterministic, the response of I to one adaptive test sequence γ1 may fully determine the response of I to another adaptive test sequence γ2 . Thus, the order in which the adaptive test sequences are applied may affect the expected cost of testing. This paper has considered the problem of finding an ordering that minimises the expected cost of testing. This paper has introduced two ways of reducing the size of the optimisation problem: by merging adaptive test sequences and by splitting the set of adaptive test sequences into a set of equivalence classes that may be considered separately. We have proved that they do not affect one another: merging adaptive test sequences cannot lead to equivalence classes being combined. The relation, that states when the use of one adaptive test sequence may lead to another not being used, has been represented as the dependence digraph. This paper has given a low-order polynomial time algorithm that produces the optimal ordering where the dependence digraph is acyclic. Future work will consider how the optimal ordering may be produced where the dependence digraph contains cycles.
References 1. H. AboElFotoh, O. Abou-Rabia, and H. Ural. A test generation algorithm for protocols modeled as non-deterministic FSMs. The Software Engineering Journal, 8:184–188, 1993. 2. E. Brinksma. A theory for the derivation of tests. In Proceedings of Protocol Specification, Testing, and Verification VIII, pages 63–74, Atlantic City, 1988. North-Holland.
302
Robert M. Hierons and Hasan Ural
3. J. Grabowski, A. Wiles, C. Willcock, and D. Hogrefe. On the design of the new testing language TTCN-3. In Testing of Communicating Systems, pages 161–176, Ottawa, August 29 - September 1 2000. Kluwer Academic Publishers. 4. R. M. Hierons. Generating candidates when testing a deterministic implementation against a non-deterministic finite state machine. The Computer Journal, 46:307– 318, 2003. 5. Joint Technical Committee ISO/IEC JTC 1. International Standard ISO/IEC 9646-1. Information Technology - Open Systems Interconnection - Conformance testing methodology and framework - Part 1: General concepts. ISO/IEC, 1994. 6. ITU-T. Recommendation Z.500 Framework on formal methods in conformance testing. International Telecommunications Union, Geneva, Switzerland, 1997. 7. D. Lee and M. Yannakakis. Principles and methods of testing finite-state machines - a survey. Proceedings of the IEEE, 84:1089–1123, 1996. 8. J. Tretmans. Conformance testing with labelled transitions systems: Implementation relations and test generation. Computer Networks and ISDN Systems, 29:49– 79, 1996. 9. P. Tripathy and K. Naik. Generation of adaptive test cases from non-deterministic finite state models. In Proceedings of the 5th International Workshop on Protocol Test Systems, pages 309–320, Montreal, September 1992. 10. S. Yoo, M. Kim, and D. Kang. An approach to dynamic protocol testing. In IFIP TC6 10th International Workshop on Testing of Communicating Systems, pages 183–199, Cheju Island, Korea, September 1997. Chapman and Hall, London.
Correct Passive Testing Algorithms and Complete Fault Coverage Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan Bell Laboratories, 101 Crawfords Corner Road, Holmdel, NJ 07733, {ann,kks,rv}@bell-labs.com
Abstract. The aim of passive testing is to detect faults in a system while observing the system during normal operation, that is, without forcing the system to specialized inputs explicitly for the purposes of testing. We formulate some general correctness requirements on any passive-testing algorithm which we term soundness and completeness. With respect to these definitions, we show that the homing algorithm, first proposed in [4], and subsequently used in [6–8], is sound and complete for passively testing the conformance of an implementation for several distinct conformance notions ranging from trace-containment to observational equivalence to even exact identity. This implies that, for some notions of conformance, there are faulty implementations that would not be detectable by any sound passive testing algorithm. We define a property to be passively testable as one admitting complete fault coverage under passive testing, i.e., one for which any faulty execution can be detected through passive testing. We provide an exact characterization of passively testable properties as being a natural subclass of safety properties, namely, those that are trace-contained in sets that are prefix- and suffix-closed. For such properties, we derive efficient complete passive testing algorithms that take constant time. We demonstrate the applicability of these results to networks and network devices by considering the problem of passively testing an implementation for conformance to the TCP protocol.
1
Introduction
Today’s networks are becoming larger, more heterogeneous, and are assembled by integrating equipment from multiple vendors. Consequently, managing networks and network devices is becoming increasingly difficult, making the development of automated network management tools and techniques more important. A key requirement of network management systems is detecting faults (c.f. [14, 18]), where a fault identifies abnormal behavior in a network or network device. Faults are detected by analyzing monitored network traffic or device state, the observed data is mid-stream in that the network may already have been in operation for some time, and the fault detection process is passive in that it cannot affect the normal operation of the network or network device, such as by injecting arbitrary traffic for the purposes of testing. Passive testing is weaker than other H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 303–318, 2003. c IFIP International Federation for Information Processing 2003
304
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
well-known validation methods such as verification and active testing in that system implementation details are unknown, inputs are not controllable, and the system need not be in its initial state when testing begins. While several practical monitoring tools have been described [9–11, 13], both for network management and for detecting security intrusions, the first formal and systematic treatment of passive testing [4] modeled a network as a (possibly non-deterministic) finite state machine and gave algorithms for detecting if an implementation machine conforms to a given specification machine. The fundamental idea underlying these algorithms is to perform a “homing” process which seeks to infer the current state of the network. In [6], this homing algorithm is considered for communicating finite state machines, thus providing a formal setting in which the problems of fault identification [8] and fault location [7] are addressed by adapting the homing algorithm suitably. However, this previous work does not explicitly address the precise notion of conformance for which the presented homing algorithms are correct. The algorithm in [4] is stated to be applicable for checking observational equivalence, though this is not formally established. On the other hand, the results of [7, 8] seem to be most directly applicable under the assumption that an implementation machine is faulty if it is not isomorphic to the specification machine. In this paper, we precisely analyze the conformance relation passively tested by the homing algorithm. We first formulate general correctness conditions on any algorithm which seeks to passively test an implementation for some particular property P. We call an algorithm sound (for testing property P) if, whenever it rejects an implementation, the implementation is indeed faulty. We term the algorithm complete if, in addition to being sound, it rejects a faulty implementation whenever observations are made that could not have been generated by a correct implementation. Using a formalization of these correctness requirements, we prove that the homing algorithm is sound and complete for testing whether an implementation is observationally equivalent to a specification (assumed in [4]), isomorphic to a specification (assumed in [7, 8]), or conformant according to trace-containment, trace-equivalence, simulability, and even exact identity. Given that these conformance relations are strictly distinct, it is somewhat counter-intuitive that the same homing algorithm could be complete for passively testing all of these different conformance relations. For example, there are implementations that are trace-contained in a specification machine but not observationally equivalent to it. By the soundness of the homing algorithm for trace-containment, it accepts such implementations that are faulty with respect to observational equivalence. However, the completeness of the homing algorithm with respect to observational equivalence establishes that no other sound passive-testing algorithm could detect such implementations as faulty, either. Thus, the homing algorithm’s failure to reject these faulty implementations is not as much a reflection on the homing algorithm per se, as an intrinsic inability of the passive testing methodology to completely detect non-conformance according to observational equivalence.
Correct Passive Testing Algorithms and Complete Fault Coverage
305
We thus consider the general question of which fault notions can be completely detected using passive testing. We consider the fault coverage of an algorithm to be the set of implementations it can successfully reject, and deem a property to be passively testable if it admits a sound passive testing algorithm whose fault coverage includes all faulty implementations. We show that a passively testable property must be a safety property. This yields an alternate, more direct, proof that observational equivalence and trace equivalence are not passively testable conformance relations. However, we exhibit an example of a safety property that is not passively testable which shows that safety is a necessary but not sufficient condition. We develop an exact characterization of passively testable properties as being validity conditions on traces that are prefix and suffix closed. Intuitively, this means that any sub-trace of a valid trace should also be a valid trace. Applying these general results to the case of conformance testing, we obtain that conformance is passively testable exactly when: (a) the conformance relation is trace containment, and (b) the set of traces of the specification machine is suffix-closed. Using this characterization of passively testable properties, we show that while a passive-testing algorithm for an arbitrary property must account for the unobserved initial behavior of the system, a passive-testing algorithm for a passively testable property can “pretend” as if the system is being observed from its initial state without sacrificing soundness. This allows us to derive complete passive testing algorithms for such properties that have O(1) running time, in contrast to the homing algorithm which has a running time of O(n) for each observation made, where n is the number of states in the specification machine. We apply our results to passive testing of the transmission control protocol (TCP) [17], one of the most widely-deployed network protocols. We show that, except for requirements on initial conditions for establishing a TCP session, all other parts of the TCP specification can be cast as prefix and suffix-closed properties. In particular, the more complex and intricate core of the TCP protocol that is concerned with congestion control and adaptive retransmissions is well amenable to passive testing. The remainder of the paper is organized as follows. Section 2 develops the notions of soundness and completeness for a passive testing algorithm and Section 3 analyses the homing algorithm for these properties. Section 4 investigates properties admitting complete fault coverage, identifying necessary and sufficient conditions and deriving more efficient testing algorithms for such properties. In Section 5, we apply these results to the problem of monitoring TCP implementations. We conclude in Section 6 with a summary of our contributions, comparison to other related work, and an outline of further directions.
2 2.1
Correctness of Passive Testing Algorithms Formal Framework
In this section, we describe our formal setting for studying passive testing. There are several choices for formally modeling the system implementation under test.
306
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
The results in this paper depend on relatively few assumptions and are applicable to a broad range of these formalisms. Rather than committing to a particular formalism or demonstrating our results for each choice of a formal model separately, we develop a general axiomatization of implementation models for which our results will hold. This axiomatization provides a distillation of the key characteristics of an implementation model that enable our results and make them easily applicable to a wide class of model formalisms. We use the following notations. For sets A, B, the set A × B denotes their cartesian product consisting of all tuples a, b with a ∈ A, b ∈ B, and An denotes the n-fold product A × · · · × A. For a set A, the Kleene-closure A∗ is the set of all finite sequences over the set A. The empty sequence is denoted and σ · σ denotes the concatentation of the sequences σ, σ . Our assumptions on the formal model used are captured in the following definition of expressively sufficient models. Definition 1 (Implementation Model). A formalism for modeling implementations is expressively sufficient if we can define functions O(·) and [[·]] on the class of all formal models with O(I) a set, and [[I]] ⊆ (O(I))∗ , for any model I. Further, the following two axioms must be satisfied: (Axiom I) For any σ, σ ∈ (O(I))∗ , if σ · σ ∈ [[I]] then σ ∈ [[I]] (Axiom II) For any set Σ and finite sequence σ ∈ Σ ∗ there is a model Iσ with O(Iσ ) = Σ such that [[Iσ ]] = {σ ∈ Σ ∗ | σ · σ = σ for some σ ∈ Σ ∗ }. Intuitively, for an implementation model I, the set O(I) corresponds to the atomic observations that I can exhibit at any particular instant, such as an ack message being sent, or an input operation i being received, or an output operation o performed. These atomic observations are extended over time to yield trace sequences with [[I]] the set of all the traces that can be observed from I upto any time instant. (Axiom I) then captures the intuitive requirement that if an implementation can exhibit the observed sequence σ · σ , then it can also exhibit the prefix σ (namely, earlier in the same execution trace). (Axiom II) requires that the class of formal models be expressive enough so that for any trace σ there is an implementation Iσ that exhibits exactly σ and no other observations subsequently. The importance of the technical requirement of (Axiom II) will become more apparent in the development of the results of Section 4. Popular choices for implementation models are finite automata that can be used to express the control plane of network protocols and extended finite automata that capture the data plane as well. We show that both these models are expressively sufficient and our results on passive testing will therefore apply to them as specific instances. Example 1 (Finite Automata). A finite automaton M is a quadruple Σ, S, s0 , δ, where Σ is a set, S is a finite set of states, s0 ∈ S is the initial state, and the transition relation δ ⊆ S × Σ × S. The automaton is deterministic if for any s ∈ S, a ∈ Σ, there is at most one s such that s, a, s ∈ δ. A sequence s0 a1 s1 . . . an sn , where si ∈ S, ai ∈ Σ, n ≥ 0, 1 ≤ i ≤ n, is a run of the automaton M if si−1 , ai , si ∈ δ for 1 ≤ i ≤ n. We can see that finite automata satisfy
Correct Passive Testing Algorithms and Complete Fault Coverage
307
the conditions of Definition 1 as follows. For an automaton M = Σ, S, s0 , δ, we take O(M ) to be Σ and [[M ]] to be the set of all sequences a1 . . . an ∈ Σ ∗ , n ≥ 0 such that for some s1 , . . . , sn ∈ S, we have that s0 a1 s1 . . . an sn is a run of M . Clearly, (Axiom I) is satisfied by this definition. For (Axiom II), consider any sequence σ = a1 . . . an , where ai ∈ Σ for some set Σ. We define the implementation Iσ to be the automaton Σ, S, s0 , δ where S = {s0 , . . . , sn } and δ = {si , ai+1 , si+1 | 0 ≤ i < n} which can be seen to satisfy the requirements of (Axiom II). Note that the automaton Iσ is deterministic and therefore the smaller class of deterministic finite automata is expressively sufficient, as well. Along similar lines, variants of finite automata such as those with explicit separation between input and output symbols [4], Mealy and Moore automata, Extended Finite Automata [3], and Kripke Structures can be easily seen to also satisfy the requirement of being expressively sufficient. For the rest of the paper, we assume any ambient modeling formalism that is expressively sufficient, and refer to any models in this ambient formalism as implementations. 2.2
Acceptable Traces for Passive Testing
Given an implementation I, we are interested in checking whether I satisfies some desired correctness property, e.g., that I is a faithful implementation of some protocol standard. Just as for implementation models, there is a plethora of available specification mechanisms. Since our results do not depend on the details of the particular specification method used, we abstractly view any correctness property as a collection of implementations, namely those that satisfy the property. Definition 2. A property, P, is a collection of implementations. An implementation I satisfies a property P, denoted I |= P, if I ∈ P. We now consider the question of how to passively test a black-box implementation for some property P. In passive testing, we do not have access to the implementation itself, nor can we assume that the implementation is in its initial state of execution. Instead, we observe its execution starting from some intermediate point after which we see a trace of externally observable actions. We now define when the implementation cannot be rejected as faulty on the basis of an observed trace, σ. Since the observation was begun mid-stream, we have to assume that some unknown trace σ preceded the observed sequence σ. Thus, the implementation cannot be deemed faulty if σ ·σ is a possible trace of a correct implementation, i.e., an implementation I satisfying P. We consider such traces σ to be acceptable when passively testing the property P, and formally define PT (P) to be the set of all such acceptable traces. Definition 3 (Acceptable Traces under Passive Testing). For a property P, the set PT (P) of acceptable traces is defined as σ ∈ PT (P) if and only if there is some implementation I|=P and trace σ with σ · σ ∈ [[I]]. Conversely, if we observe a trace σ ∈ PT (P) at any point midstream, then we can conclude that the implementation is faulty; such traces can therefore be considered fault-symptomatic.
308
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
Proposition 1 (Fault Symptomatic Traces). Let P be a property. For any implementation I, if we have σ · σ ∈ [[I]] with σ ∈ PT (P) then I ∈ P. Note that the definition of PT (P) is based only on the property and is not dependent on any particular algorithm used to passively test the property. It can therefore be used to provide correctness criteria on algorithms for passively testing property P. A passive testing algorithm, A, determines an implementation to be correct or faulty on the basis of observed trace σ, which we write as A accepting or rejecting the trace σ, respectively. A passive testing algorithm is sound, if whenever it rejects an observed trace, the implementation is definitely faulty. A passive testing algorithm is adequate if whenever an implementation can be determined to be faulty on the basis of its observed trace, the algorithm rejects the implementation. The algorithm is complete if it is both sound and adequate. Definition 4 (Passive Testing Algorithm Properties). Let A be a passive testing algorithm for the property P. Then Soundness: The algorithm A is sound if whenever σ ∈ PT (P) we have that A accepts the trace σ. Adequacy: The algorithm A is adequate if whenever the algorithm A accepts the trace σ we have that σ ∈ PT (P). Completeness: The algorithm A is a complete passive testing algorithm for the property P if it is both sound and adequate, i.e., the set of traces it accepts is exactly the same as PT (P).
3
Homing Algorithm for Passive Testing
Most previous work on passive testing is based on the homing algorithm, given in [4], for testing for conformance to a specification given as a Mealy automaton. In this section, we analyze this algorithm for the precise conformance notion with respect to which it is complete, in the sense of Definition 4. The homing algorithm is as follows. Because we observe the network “midstream” in its deployment, the algorithm begins by assuming that the network could be in any one of the states (as opposed to the initial state) of the specification machine. With each observation, the set of states that the network could be in is updated to include only those that are consistent with the observation just made. If we ever reach the point of not being able to find any state consistent with the observation just made, the algorithm pronounces the implementation to be faulty. We formally state the homing algorithm in the more general context of finite automata that are not necessarily complete or connected (defined in Example 1). For a specification automaton M = Σ, S, s0 , δ, the homing algorithm HM , defined below, tests for conformance to the automaton M . Definition 5 (Homing Algorithm). Let M = Σ, S, s0 , δ be a finite automaton. Define the relation R ⊆ S × S by s, s ∈ R iff there is some a ∈ Σ with
Correct Passive Testing Algorithms and Complete Fault Coverage
309
s, a, s ∈ δ. For any trace σ ∈ Σ ∗ , the set HM (σ) ⊆ S is defined by induction on the length of σ as follows: HM () = {s | s0 R∗ s} HM (σ · a) = FM (HM (σ), a) where R∗ is the reflexive transitive closure of R, and the function FM is defined by FM (S , a) = {s | there is an s ∈ S with s , a, s ∈ δ}. The algorithm HM accepts a trace σ if and only if the set HM (σ) is non-empty. The running-time of HM is O(nm) where n is the size of the trace σ and m is the size of M (even if M is deterministic). The algorithm HM initially assumes that we could be in any of the states of S that are reachable from the starting state s0 , and then uses the function FM to refine the knowledge of the current state. Intuitively, the function FM “homes” in to the current state: if we know that the current state belongs to a set S and we make the observation a, then FM (S, a) computes the set of states we can be in after having made the observation a. We now analyze the precise conformance relation to the specification M that the algorithm HM tests. We use I ≡ M to denote that I is isomorphic to M , and use the standard definitions of simulation, denoted s , bisimilarity denoted ≈s , trace-containment denoted tr , and trace-equivalence denoted ≈tr . Somewhat surprisingly, we can show that the algorithm HM is complete for passively testing an implementation with respect to any conformance notion that is not weaker than trace-containment and that admits the specification as a conformant implementation. Theorem 1 (Completeness of Homing Algorithm). For any finite auM tomaton M = Σ, S, s0 , δ, define the property P = {I | I tr M }. Then tr the algorithm HM is complete for passively testing any property P with {M } ⊆ M P ⊆ P . tr As an immediate corollary, we have that the algorithm HM is complete for passively testing an implementation with respect to trace-containment, traceequivalence, simulation, bisimulation and even isomorphism. Corollary 1. Let M be a finite automaton. The algorithm HM is complete for M M passively testing each of the following properties: P = {I | I tr M }, P≈ = tr tr M M M {I | I ≈tr M }, Ps = {I | I s M }, P≈s = {I | I ≈s M }, P≡ = {I | I ≡ M }. In [4], the passive testing algorithm was developed to check bisimilarity (although not proven), and [7], [8] work with the implicit assumption that the homing algorithm checks for isomorphism. Corollary 1 shows that the homing algorithm is the best any passive testing algorithm can do for the conformance relations that these works respectively consider. On the other hand, of these five properties, the relation that an implementation I is not trace-contained in M is the strongest fault notion. Hence, Theorem 1 shows that if algorithm HM rejects some implementation then the strongest statement we can make about the faultiness of the implementation is that it is not trace-contained in M .
310
4
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
Fault Coverage under Passive Testing
The results of Section 3 show that the homing algorithm HM is a complete algorithm for passively testing the properties of trace-containment, trace-equivalence, similarity, bisimilarity, and even isomorphism or exact identity. As detailed in Section 1, this implies that, for some of these conformance relations, e.g., bisimilarity, there are faulty implementations that would not be rejected by the homing algorithm. Thus, even a complete passive testing algorithm only provides a limited guarantee of the correctness of an implementation. More specifically, every rejected implementation is faulty but an accepted implementation is not necessarily correct; completeness of the algorithm only guarantees that no other sound passive testing algorithm could have rejected that implementation either. In this section, we explore the class of properties for which we can design passive testing algorithms that, in addition to guaranteeing the faultiness of rejected implementations, also guarantee the correctness of accepted ones. In the context of passive testing, this guarantee cannot be obtained unconditionally. In particular, two aspects inherent to passive testing that we have no control over are the particular run that is exercised and observed, and the point in the trace when we begin to observe it. We factor these two uncontrollable aspects by requiring that if observations from every point of every trace of an implementation never cause it to be rejected by passive testing then it is guaranteed to be correct. A property with this characteristic admits complete coverage under passive testing or, more tersely, is passively testable. Definition 6 (Admissibility of Complete Coverage). A property P admits complete coverage under passive testing or is passively testable if and only if it has the following closure property: Suppose that I is an implementation such that for all traces σ , σ with σ · σ ∈ [[I]], we have that σ ∈ PT (P). Then I |= P. Definition 6 can be read, contrapositively, as stating that a passively testable property is one for which any faulty implementation I ∈ P manifests a faultsymptomatic trace, i.e., a trace σ · σ ∈ [[I]] with σ ∈ PT (P). We are interested in characterizing the class of properties that are passively testable. We begin by deriving an immediate consequence of Definition 6. Suppose that P is a passively testable property. Then any implementation I each of whose traces is a trace of some correct implementation I |= P, must also be correct, i.e., included in P. Lemma 1. Suppose that P is a passively testable property and P ⊆ P. If [[I]] ⊆ I ∈P [[I ]] then I |= P. Lemma 1 yields a necessary condition for a property to be passively testable which can be used to establish that similarity, bisimilarity, and trace-equivalence are not passively testable conformance relations. Example 2 (Simulation, Bisimulation not Passively Testable). Consider the finite automaton M = Σ, S, s0 , δ with Σ = {a, b, c}, S = {s0 , s1 , s2 , s3 , s4 }, and the transition relation δ = {s0 , a, s1 , s0 , a, s2 , s1 , b, s3 , s2 , c, s4 }. Then the property of being simulated by M is not passively testable. To see this, consider
Correct Passive Testing Algorithms and Complete Fault Coverage
311
I = Σ, S , s0 , δ with S = {s0 , s1 , s2 , s3 }, S0 = {s0 }, Σ = {a, b, c}, and δ = {s0 , a, s1 , s1 , b, s2 , s1 , c, s3 }. For P = {M }, we have that [[I]] ⊆ I ∈P [[I ]], but I is not simulated by M which would contradict Lemma 1 if the property of being simulated by M were passively testable. Since I is not bisimilar to M either, this example also shows that the property of being bisimilar is not passively testable also.
Example 3 (Trace Equivalence not Passively Testable). Consider the automaton M = Σ, S, s0 , δ with Σ = {a}, S = {s0 }, and δ = {s0 , a, s0 }. Then the property of being trace-equivalent to M is not passively testable. To see this, consider the automaton I = Σ, S, s0 , δ with δ = ∅. For P = {M }, we have that [[I]] ⊆ I ∈P [[I ]], but I is not trace-equivalent to M which would contradict Lemma 1 if the property of being trace-equivalent to K were passively testable. For any property P, define the language LP of traces as LP = I∈P [[I]]. An immediate consequence of Lemma 1 is the following corollary. Corollary 2. Suppose that P is a passively testable property. Then I ∈ P iff [[I]] ⊆ LP . Corollary 2 can be restated in terms of the classical notion of being a safety property. Definition 7 (Safety Property). Let L be a language (set) of traces. Then L is prefix-closed if and only if for any traces σ, σ , if σ · σ ∈ L then σ ∈ L. A property P is a safety property if there exists a prefix-closed language L of traces such that I ∈ P iff [[I]] ⊆ L. Corollary 3. Suppose that P is a passively testable property. Then P is a safety property. Corollary 3 shows that the only passively testable properties are safety properties. However, the following example shows that not all safety properties are passively testable. Example 4. Let Σ = {a, b} and language L = {} ∪ {a · σ | σ ∈ Σ ∗ }, i.e., L is the set of traces where the first action or observation is always a. Then L is prefix-closed and hence P = {I | [[I]] ⊆ L} is a safety property. Consider I = Σ, {s0 }, s0 , {s0 , b, s0 }. Then I does not satisfy P (since a is not the first observation in any of its traces). However, it can be easily seen that any trace σ ∈ PT (P), i.e., PT (P) = Σ ∗ and therefore for any σ , σ with σ · σ ∈ [[I]] we have that σ ∈ PT (P). Thus P does not satisfy the closure condition of passive testability for I. Example 4 shows that while safety is a necessary condition for passive testability, it is not a sufficient condition. We next identify the set of necessary and sufficient conditions under which a property is passively testable. The proof of Theorem 2 pivotally uses the requirement of (Axiom II) of Definition 1. Definition 8 (Suffix Closure). Let L be a language (set) of traces. Then L is suffix-closed if and only if for any traces σ, σ , if σ · σ ∈ L then σ ∈ L.
312
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
Theorem 2 (Characterization of Passive Testability). A property P is passively testable if and only if the following two conditions hold: (1) I |= P iff [[I]] ⊆ LP , and (2) LP is suffix-closed. Using Theorem 2, we can characterize passively testable properties as a natural special subclass of safety-properties. Corollary 4. A property P is a passively testable property if and only if there is a prefix-closed and suffix-closed language L of traces such that I |= P iff [[I]] ⊆ L. By Lemma 1, as established in Examples 2 and 3, we know that tracecontainment is the only conformance relation for which we can hope to obtain complete coverage for passive testing. Using Theorem 2, we can also establish the class of specifications (with regard to any modeling formalism) with respect to which trace containment can be passively tested. Corollary 5. Consider any modeling formalism that is expressively sufficient and let M be a specification model in this formalism. Then the property Ptr = {I | [[I]] ⊆ [[M ]]}, of being trace-contained in M , is passively testable if and only if [[M ]] is suffix-closed. Our next set of results derive more efficient algorithms for passive testing than the homing algorithm HM of Section 3. Theorem 3. Suppose that P is a passively testable property. Then PT (P) = LP . Theorem 3 can be used to derive an efficient algorithm for passively testing trace-containment with respect to specifications that admit complete fault coverage. Recall from Definition 4 that obtaining a complete passive testing algorithm for a property is essentially a matter of checking membership in PT of that property. By Theorem 3, this merely amounts to checking membership in the specification itself without any requirement for homing or accounting for what state the implementation could be in, as in the algorithm HM . The benefit of not having to keep track of a set of states we have homed in to is that in the case that the specification is a deterministic finite-state automaton, the reduction in complexity is by the factor of the size of the automaton. Theorem 4 (Passive Testing Trace Containment). Suppose that M is a specification model in a formalism is expressively sufficient, such that [[M ]] is suffix-closed. Let Ptr = {I | [[I]] ⊆ [[M ]]} be the property of being trace-contained by M . Then the algorithm A which checks for membership in M , i.e., A accepts a trace σ iff σ ∈ [[M ]], is a complete passive testing algorithm for the property Ptr , admitting complete coverage. If M is a deterministic finite automaton, the running-time of A is O(n) where n is the length of the trace, or O(1) in each observation seen. An alternative method to establish that a property P is passively testable is obtained by considering the complement of LP , the set of faulty executions. A property is passively testable if and only if the set of faulty executions satisfies
Correct Passive Testing Algorithms and Complete Fault Coverage
313
the closure condition that any trace containing a faulty subtrace must itself also be faulty. This can be informally captured by the slogan “once a fault, always a fault”: if a faulty subtrace is observed then no (unobserved) past behavior could provide mitigating circumstances to make the complete trace correct. Corollary 6. A property P is passively testable iff the set S = LP of faulty executions satisfies the following closure property: If σ ∈ S then for any σ , σ we have that σ · σ · σ ∈ S.
5
An Example: Application to TCP
In this section, we apply the general results developed to testing an implementation for conformance to the Transmission Control Protocol (TCP) [17]. We choose to consider TCP because it is one of the most widely deployed IP protocols in today’s internet and, as has been argued in [9], the behavior of deployed TCP implementations has a significant impact on the performance of the overall Internet. As might be expected (c.f. Example 4), we can show that requirements on initial conditions for establishment of a TCP connection are not testable with complete coverage. However, the results of this section are surprisingly reassuring in that they show that all other properties of the TCP specification are prefixand suffix-closed, and therefore passively testable with complete coverage. In particular, this includes the more complex and intricate core of the TCP protocol that is concerned with congestion control and adaptive retransmissions. Thus, the aspects of TCP that are more critical from the perspective of adversely impacting the network as a whole through faulty implementations, are well amenable to passive testing. Our examination of TCP is structured as follows. Our overall goal is to construct a monitor that examines the packets at a TCP client (sender or receiver) to diagnose the implementation’s conformance. Note that a single client can simultaneously participate in multiple TCP sessions and as both a sender and receiver — therefore the trace of packets observed by our monitor potentially includes packets belonging to different sessions. To facilitate analysis, in Section 5.1, we first consider each of several aspects of TCP in isolation and assume that all the packets being observed belong to a single session. In Section 5.2, we show how the analysis for each individual property and one session can be lifted to demonstrate passive testability of an unfiltered trace of packets belonging to multiple sessions for conformance to any boolean combination of the several aspects of TCP. 5.1
Single TCP Session and Individual Properties
TCP implements reliable, in-order stream delivery through positive acknowledgements and retransmissions while attempting to optimize throughput with a well-tuned “sliding window”. The most basic parts of the TCP specification describe formats for segment headers and bodies, and how acknowledgements
314
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
are sent in response to received segments. The more complex aspects of TCP deal with retransmissions of unacknowledged segments, and how the sender adjusts window size to optimize throughput while avoiding congestion. Finally, the specification details how a session is established and closed. We examine each of these aspects in turn, and state and informally argue whether they are passively testable, i.e., prefix-, suffix-closed. For many properties this analysis is straightforward; other properties require careful recasting into a form that allows passive testability. TCP Segment Formats: The specifications of what constitutes a valid segment format all take the form of being an invariance property. Formally, these properties can be expressed as languages of the form {a0 . . . an | ∀i. P (ai )}, where P is a propositional condition. Invariance properties can be seen to be prefix- and suffix-closed, since if a0 . . . an satisfies the property then we have that P (ai ) for i = 0, . . . , n and hence any prefix a0 . . . am for m ≤ n and any suffix ak . . . an for any 0 ≤ k ≤ n also satisfies the property. An example of a segment format specification is that the checksum field of each segment sent is set correctly. This condition can be checked for each segment individually (by using its source ip address, destination ip address, zero, protocol, and tcp length fields as a pseudo header) and is therefore an invariance property which is passively testable. Responsiveness of Acknowledgements: The TCP specification allows a leeway in how acknowledgements are generated. TCP prescribes that a receiver must generate an ack at least every two segments — so, an implementation may decide to not ack every single segment (although, this would meet the specification as well). Let RAck be the set of implementations (TCP receivers) that meet this specification, and LRAck be the corresponding language of traces. The easiest way to see that RAck is a passively testable property is to consider the complement of LRAck . This includes traces that have any subtrace σ which includes more than two segment receipts without any interleaving ack. This, trivially, satisfies the closure condition of Corollary 6. Sequence Numbers of Acknowledgements: In TCP, acknowledgements are used to specify the sequence number of the next octet that the receiver expects to receive. This is achieved by requiring the sequence number of each acknowledgement (sent by the receiver) to be set to value one greater than the highest octet position in the contiguous prefix of the stream received. Let SNA be the property which holds of all TCP receivers that generate correct sequence numbers in their ack messages. The language LSNA can be defined as follows. For any TCP session, the starting octet number is not necessarily 1, but specified by the sender in its first message (that associated with a syn message). For a trace σ, let ISn σ , the initial sequence number of σ, be this first octet number received in σ. Then LSNA consists of all traces σ such that for any σ1 , σ2 with σ = σ1 aσ2 and a an ack message, we have that the sequence number sent in a, SN (a) = mσ1 + 1 where mσ1 is the maximum n such that octets ISn σ1 , ISn σ1 + 1, . . . , n have been received in σ1 . Recall that I |= SNA iff [[I]] ⊆ LSNA . The language LSNA is prefix-closed but not suffix-closed because octets of the transmitted stream do
Correct Passive Testing Algorithms and Complete Fault Coverage
315
not necessarily arrive in increasing order. Consider a trace in which octets with sequence numbers 3, 1, and 2 are received in order after which the subsequent ack would have sequence number 4. If we consider a suffix of this trace that does not include the first message containing octet number 3, then this suffix would fail to satisfy this property. Therefore, a passive testing algorithm that tests for membership in LSNA would reject some correct implementations. Our solution to passively testing whether an implementation satisfies the property SNA is to define a prefix- and suffix-closed language L with LSNA ⊆ L and to test membership in L. In other words, we check for a passively testable property that is weaker than SNA. The precise extent to which this is a complete test for the property SNA is given by the following additional properties that our definition of L will ensure. Proposition 2. 1. For any trace σ, we have that σ ∈ L iff there exists a σ with σ · σ ∈ LSNA . 2. Suppose that σ ∈ L ∩ LRAck . Then there exists a prefix σ1 of σ such that for any trace σ we have that if σ · σ1 ∈ LSNA then σ · σ ∈ LSNA . If the only prefix σ such that σ · σ ∈ LSNA is σ = then the prefix σ1 = . The first property states that the traces accepted are exactly those that are observable from a correct implementation. The second property states that for any accepted trace (which meets the requirement of acknowledgement responsiveness), the execution satisfies the property SNA provided that the unobserved prefix and a bounded initial prefix of the observed trace is correct. In other words, for an accepted trace, any faults are restricted to the unobserved part of the execution and some bounded initial segment. The bounded initial segment has the additional property that it is empty if the trace observed is complete. By the first property, a test for membership in L is a complete passive testing algorithm for SNA. Although LSNA itself is not prefix-,suffix-closed, by the second property, we have an exact delimitation of the scope of faults (with respect to SNA) for any accepted trace (with respect to a test for membership in L). Due to space considerations, we omit the details of the construction of L. The analysis of TCP aspects related to adaptive retransmission and timer backoffs, and congestion windows and congestion control are analogous to that for acknowledgement sequence numbers just detailed. Besides the standard mechanisms of multiplicative decrease and slow-start recovery or additive increase, this analysis also applies to congestion control mechanisms and TCP options more recently proposed such as TCP-Reno and SACK [2, 5] which can also be shown to be passively-testable in a manner that allows exact delineation of the scope of faults. 5.2
Multiplicity of Sessions and Properties
We have shown how all aspects of the TCP protocol, except for conditions on the initial messages for establishing a TCP session, can be passively tested with complete coverage assuming we consider each of them in isolation and assuming
316
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
that a client participates in only one TCP session. In this section, we extend our results to remove this restriction on the client. The assumption of only one TCP session is tantamount to requiring that the monitor is given a trace obtained by filtering from the actual trace only segments belonging to a particular session. The property of a segment belonging to a session is a propositional property (it is a condition on the source port and destination port fields of any individual segment) — we therefore begin by formalizing the notion of filtering a trace with respect to a propositional property, which we call projection. Definition 9 (Projections). Let ϕ be any propositional property over the set of atomic propositions A. We define a projection function | · |ϕ : (P(A))∗ →(P(A))∗ as follows: ||ϕ = a · |σ|ϕ if a |= ϕ |a · σ|ϕ = otherwise |σ|ϕ The class of prefix-, suffix-closed languages is closed under inverse projections and positive boolean combinations. Proposition 3. 1. Suppose that L is a language that is prefix-closed and suffixclosed. For any propositional property ϕ, we have that the language L−1 ϕ = {σ | |σ|ϕ ∈ L} is prefix-closed and suffix-closed. 2. Suppose that {Li }i∈C isa family of prefix-closed, suffix-closed languages. Then both i∈C Li and i∈C Li are prefix-closed and suffix-closed. The two parts of Proposition 3 together with the results argued in Section 5.1 immediately yield a powerful array of TCP properties that can be passively tested with complete coverage. Because the property of belonging to a particular TCP session is propositional, by using projections and conjunction it follows that checking a trace for being faithful to a TCP specification for all sessions in it is passively testable. Because both conjunction and disjunction preserve the properties of being prefix and suffix-closed, we can check for arbitrary combinations of TCP implementation requirements and impose independent requirements on each session. For example, the property that all TCP sessions follow either slow-start or TCP-Reno or the property that a particular session follow multiplicative increase and another has ECN notification, is passively testable as well since each of these properties is a positive boolean combination of inverse projections of prefix-,suffix-closed properties.
6
Conclusions
Our contributions to the understanding of passive testing are as follows. Due to the nature of passive testing, one cannot, in general, detect all faulty executions with respect to some correctness requirement. For an arbitrary behavior requirement, we have captured the notion of a passive testing algorithm detecting as many faulty executions as possible through the formal criteria of soundness and
Correct Passive Testing Algorithms and Complete Fault Coverage
317
completeness. Using these formulations, we have analyzed the homing algorithm and formally proven it to be the best possible algorithm for passively testing conformance to a specification automaton, with respect to several conformance relations. We have provided necessary and sufficient conditions on a fault notion for it to be completely detectable via passive testing. For such fault notions, we have presented a more efficient algorithm than the homing algorithm for passively testing them with complete fault coverage. Finally, we have analyzed the TCP specification and shown that most of it is completely checkable through passive testing. In addition to the works already referenced in the introduction, the other closely related work is [1], where monitoring algorithms are proposed that take into account infidelity of observed traces due to buffering and packet loss. The work, however, assumes that the device under test is in its initial state when monitoring begins. The algorithms proposed are sound (i.e., rejected executions are indeed faulty), but analysis of their adequacy, in the sense of Definition 4, is not addressed, and completeness of fault coverage is not considered either. On the other hand, the work presented here does not account for buffering or packet loss and it would be interesting to consider the impact of these issues in our results. Another study, conducted in a different context but close in spirit is that of [15], where it is informally argued that the class of security policies that are enforceable by monitoring system executions are exactly the safety properties. However, the monitoring mechanisms considered there also observe the system from its initial state. In this work, we have considered the setting where monitoring begins mid-stream and our characterizations have been formally proven. Some future directions for extending this work are as follows. Our work has shown that the condition of prefix- and suffix-closure identifies an important class of languages and correctness properties. It would, therefore, be useful to provide techniques for facilitating the specification of properties satisfying this closure condition. To provide specifications declaratively as logical formulas, this would translate to formulating a logic whose expressive power is exactly the prefix and suffix closed properties. This could be done, for example, by characterizing the structure of formulas in temporal logic that yield this closure condition, as is done in [16] for safety and liveness properties. In the context of specifying the desired behavior operationally as an automaton, one could look for an algebraic characterization of prefix- and suffix-closed languages as suitable varieties of semigroups, in the style of [12]. Finally, in addition to fault detection, an important part of fault management is fault location which identifies the faulty local site which is responsible for the observed faulty global execution, and it would be interesting to examine systematic formal approaches to the fault location problem.
Acknowledgements The authors would like to thank Richard Buskens, Patrice Godefroid, and Raymond Miller for many helpful comments on earlier drafts of this paper.
318
Arun N. Netravali, Krishan K. Sabnani, and Ramesh Viswanathan
References 1. Karthikeyan Bhargavan, Satish Chandra, Peter J. McCann, and Carl A. Gunter. What packets may come: automata for network monitoring. In Symposium on Principles of Programming Languages, pages 206–219, 2001. 2. S. Floyd and T. Henderson. The NewReno Modification to TCP’s Fast Recovery Algorithm, April 1999. RFC2582. 3. D. Lee, D. Chen, R. Hao, R. Miller, J. Wu, and X. Yin. A formal approach for passive testing of protocol data portions. In Proceedings of the IEEE International Conference on Network Protocols, pages 122–131, 2002. 4. D. Lee, A. Netravali, K. Sabnani, B. Sugla, and A. John. Passive testing and applications to network management. In Proceedings of the IEEE International Conference on Network Protocols, pages 113–122, October 1997. 5. M. Mathis, J. Mahdavi, S. Floyd, and A. Romanow. TCP Selective Acknowledgement Options, October 1996. RFC2018. 6. R.E. Miller. Passive testing of networks using a CFSM specification. In IEEE International Performance Computing and Communications Conference, pages 111– 116, February 1998. 7. R.E. Miller and K. Arisha. On fault location in networks by passive testing. In IEEE International Performance Computing and Communications Conference, February 2000. 8. R.E. Miller and K. Arisha. Fault identification in networks by passive testing. In IEEE Advanced Simulation Technologies Conferences, April 2001. 9. Jitendra Padhye and Sally Floyd. On Inferrring TCP Behavior. In SIGCOMM 2001, August 2001. 10. V. Paxson. Automated packet trace analysis of tcp implementations. Computer Communication Review, 27(4), October 1997. 11. V. Paxson. Bro: A system for detecting network intruders in real-time. Computer Networks, 31(23-24):2435–2463, December 1999. 12. Jean-Eric Pin. Finite semigroups and recognizable languages: An introduction. In J. Fountain, editor, NATO Advanced Study Institute Semigroups, Formal Languages and Groups, pages 1–32. Kluwer academic publishers, 1995. 13. M.J. Ranum, K. Landfield, M. Stolarchuk, M. Sienkiewicz, A. Lambeth, and E. Wall. Implementing a generalized tool for network monitoring. In Proceedings of the Eleventh Systems Administration Conference (LISA XI), pages 1–8, 1997. 14. E. C. Rosen. Vulnerabilities of network control protocols: An example. ACM SIGSOFT Software Engineering Notes, 6(1), January 1981. 15. Fred B. Schneider. Enforceable security policies. Information and System Security, 3(1):30–50, 2000. 16. A. P. Sistla. Safety, liveness and fairness in temporal logic. Formal Aspects of Computing, 6:495–511, 1994. 17. W. Richard Stevens. TCP/IP Illustrated, Volume I: The Protocols. Addison Wesley, Reading, Massachusetts, 1984. 18. P. Travis. Why the AT&T Network Crashed. Telephony, 218(4), January 1990.
QoS Functional Testing for Multi-media Systems Tao Sun1 , Keiichi Yasumoto1 , Masaaki Mori2 , and Teruo Higashino3 1
Graduate School of Information Science, Nara Institute of Science and Technology, {song-t,yasumoto}@is.aist-nara.ac.jp 2 Department of Information Processing and Management, Shiga University, [email protected] 3 Graduate School of Information Science and Technology, Osaka University, [email protected]
Abstract. In this paper, we propose a testing method for QoS functions in distributed multi-media systems, where we test whether playback of media objects is correctly implemented or not in a client side program according to the quality designated in advance, and/or whether a time lag between parallel playbacks of multiple media objects is controlled within the specified time interval. In the proposed technique, we describe test scenarios in timed EFSMs where we specify behavior of an input flow transfered to a given IUT (implementation under test) and behavior of playback with certain QoS functions observed from the IUT (e.g., the range of fluctuation of frame rates) . From the scenarios, we generate test sequences to test whether a given IUT realizes the QoS functions specified in the scenarios. In the proposed test method, we use a statistical approach where test sequences take samplings of actual frame rates and/or time lags when an IUT is executed, and report test results from ratio of samplings with low quality below a threshold in a normal distribution of all samplings. We have implemented a test system for test sequence execution in Java, and applied it to a video playback system.
1
Introduction
As broadband infrastructure is widespread in the Internet in recent years, it has been needed to establish a high-reliable development method for multi-media communication systems. It is important for such systems to provide multi-media services with certain QoS (Quality of Service) functions to end users. Among various QoS functions, control mechanisms for the frame rate (the number of frames displayed every second) and for the lip synchronization [8] among multiple concurrent media objects seem most important ones. For development of multi-media systems with high-reliability, it is desirable to establish a method for testing if those QoS functions are correctly implemented in a given IUT (Implementation Under Test). Traditional software testing methods which have succeeded in protocol engineering, focus mainly on the correctness of input / output correspondences[11]. Therefore those methods could not be directly applied to QoS testing such as video / audio playback timings. Essentially important test problems of multi-media systems are not only correspondence relations of input / output actions, but time difference between an input and the corresponding output or the time duration in executing a sequence of actions. Then, H. K¨onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 319–334, 2003. c IFIP International Federation for Information Processing 2003
320
Tao Sun et al.
even if all the correspondence relations of input / output actions hold, it is not necessarily guaranteed to pass a test due to the time difference between input and output actions. Even if temporal relations among multi-media objects are specified in detail by a formalism such as Timed CTL [2] used in real time systems, it makes test sequences be explosively complicated and is not realistic to test multi-media systems. Suppose that a specification for a video playback system specifies that a video frame is drawn exactly every 33 msec plus/minus 5msec. In general, when an IUT does not satisfy such a specification a little (e.g., only a frame were delayed for 10msec), it may not be considered a problem as long as media objects are played back naturally. So, for QoS testing for the playback of media objects, it is desirable to statistically analyze the temporal relations and give test results based on statistically calculated information[14]. There exist some studies on multi-media testing such as testing of multi-media transmission systems [5], the quality of multi-media contents [6] and interoperability and performance testing of distributed systems [14]. However they do not deal with testing on temporal relations of input / output actions. A few researches, which deal with temporal relations in multi-media systems explicitly, have been reported [4, 12]. These studies propose a method to test binary temporal relations on the starting time and/or the ending time between two objects by using a statistical approach. However they do not deal with the quality during playback of an object. Moreover, [16] proposes a method for functional testing of media synchronization protocols using a concurrent timed I/O automata model, where a given IUT is tested by executing each input action within an appropriate time interval calculated in advance, and by observing whether execution timings of output actions are within the appropriate time interval. However, this approach does not consider statistical aspects of multi-media systems. As a different approach, [3] proposes a model checking method for media constraints such as lip synchronization among multiple media objects. In this paper, we suppose typical distributed multi-media systems consisting of servers and clients connected via a network, and propose a method for testing QoS of media playback functions w.r.t. frame rates and lip-synchronization for a client program (IUT). In the proposed method, we specify scenarios for QoS functional tests for an IUT in timed EFSM (a hybrid model of EFSM and timed automata [1]), where we designate the input flow characteristics like jitter / packet loss ratio and the play-back quality of frames to be realized for the given traffic. Furthermore, we specify the quality of inter-media synchronization as a constraint to be satisfied among sub-scenarios corresponding to concurrent playbacks of different media objects (e.g., video and corresponding audio) by using the constraint oriented description style [13]. From those test scenarios, we generate test sequences to test whether a given IUT realizes the specified QoS. In the proposed test method, we use a statistical approach where test sequences take samplings of actual frame rates and/or time lags between the latest frames on multiple objects when an IUT is executed, and report test results from ratio of low quality samplings (e.g., frame rates less than a threshold) below a specified threshold in a normal distribution of all samplings.
QoS Functional Testing for Multi-media Systems spec.䋺
input
output
?a[1≤t≤3]
!b[5≤t≤9]
if output time is not within the time range in spec, test fails
pass䇭䇭䇭䇭fail
䇭t =2 a
b
t =8
IUT
frame rate
321
t =10
䌴 transient delays may not be a problem in multimedia systems
Max(35)
? tolerance
OK
Min(25)
NO time problems
Fig. 1. Existing real-time testing methods
We have implemented a test system for executing test sequences in real-time in Java language, and applied it to a sample video playback program. Our experimental results show that our method works effectively for QoS functional tests.
2
Outline of Proposed QoS Functional Testing
As a target, we suppose distributed multi-media systems where a server transmits a stream of a requested media object to each client. Here, we test whether the playback quality of media objects at a client computer is feasible or not according to the characteristic of the given input flow. In existing real-time testing methods as in [7, 10], tests are carried out by giving each input to the IUT at appropriate time, and by observing and testing if the corresponding output action is executed at appropriate time satisfying the constraints given in the specification (see Fig. 1). However, testing playback quality of media objects in multimedia systems should be different from those existing methods since some jitter in multi-media playback which may be caused by packet losses/delays is allowed to a certain extent. So, we need a new testing method for playback quality of multi-media objects. In the proposed method, we adopt the statistical technique for testing playback quality of a single media object and of preciseness of inter-media synchronization among multiple object playbacks at a client computer of a client-server based system. 2.1
Outline of Proposed Method
In the proposed method, we calculate the ideal playback quality of an object for a given data stream (flow), and test whether or not the IUT works satisfying the constraints in the specified test scenario by observing the time at which the object outputs each data unit (called frame. e.g., a video picture, a unit of audio data, etc) as shown in Fig. 2.
322
Tao Sun et al. p x Frequency
Tester provide packets at appropriate time
IUT observe time when frames are drawn
ε
Fig. 2. Environment for QoS Functional Testing
µ fps '
fps
Fig. 3. Distribution Graph of Frame Rates
In general, when we measure the frame rate (the number of frames displayed every second) of an object in a relatively short time interval (denoted as SP ), it can vary due to the characteristics of an input flow such as jitter in packet arrival time and packet losses. In the proposed method, we take a frame rate as a sampling every SP time interval for a sufficiently long time interval (denoted as LP ), calculate statistic information from distribution of those samplings, and judge from the information whether or not the IUT correctly implements the control mechanism for the frame rate. We compose a test scenario of the following two sub-scenarios: (1) traffic testing scenario which characterizes an input flow, and (2) quality testing scenario which represents behavior of the playback with certain quality. From those scenarios, we generate the following test cases (a set of test sequences). – each test sequence transmits packets to the IUT at time within the allowable time range considering jitters and bursts specified in the traffic testing scenario. – each test sequence measures actual packet loss ratio in the IUT for a time interval M P (such that SP ≤ M P ≤ LP ), and calculates the ideal frame rate f ps which is defined in Sect. 2.2. – each test sequence measures average frame rate every time interval SP by observing output from the IUT, and keeps it as a sampling. The test sequence collects samplings for time interval LP , and calculates the average value and the standard deviation from those samplings. The test sequence judges whether the IUT correctly implements the frame rate control mechanism with the specified QoS level, based on those calculated statistical values and maximum tolerance acceptable denoted by which the test examiner gives in advance (see Fig. 3). For the sake of simplicity, we assume that the distribution of frame rates follows the normal distribution like in Fig. 3. Then the judgment process can be described as the following procedure. 1. calculate the average value µ and the standard deviation s derived from the samplings kept during time interval LP . 2. apply normalization expression z = (x − µ)/s to , and calculate area C that is an integral of (−∞, ( − µ)/s] in the standard normal distribution (see Fig. 3).
QoS Functional Testing for Multi-media Systems
323
3. when the value of C is smaller than the reliance level r which was given by the test examiner in advance, we conclude that the IUT passes the test. In general, as shown in Fig. 3, we expect that the average frame rate µ measured during time interval LP may match neither the original frame rate f ps nor the frame rate considering packet losses f ps explained in the next section, due to external and/or internal load factors. 2.2
Discussion about Playback Quality of Objects
The following factors are considered to give some influences to playback quality of objects. – jitter in packet arrival time and packet loss ratio – heavy load/low performance at a client computer For example, suppose that a server transmits to a client a video file encoded in 30 frames/sec at a fixed transmission rate. A client computer receives packets from the server and tries to play back the video at an appropriate frame rate. In this case, the playback quality depends on the receiving rate, packet loss ratio, jitters in packet arrival time, and load of the client computer. If the client receives packets at almost the same rate as the server transmits, if packet loss ratio is almost 0 %, and if its load is light enough, the frame rate to be achieved will be close to the originally encoded one (i.e., 30 frames/sec). On the other hand, if the packet loss ratio is high and/or the client’s load is high, the frame rate will be less than 30 frames/sec. According to the above discussion, we define the ideally achievable frame rate as the following expression. f ps = f ps · (1 − f (Loss)) · β Here, f ps and Loss denote the originally encoded frame rate and the packet loss ratio, respectively. f (x) (0 ≤ f (x) ≤ 1) denotes the function representing ratio of how much each packet’s loss causes the frame loss. Here, f (x) = x when each frame is transmitted by exactly one packet. When each frame is transmitted by several packets and/or there is inter-frame dependency like MPEG movies, f (x) will be larger than x. β (0 < β ≤ 1) is another factor such as CPU load other than flow characteristics at a client computer. For the sake of simplicity, we suppose that β = 1 in this paper.
3
Test Scenarios for Multi-media Systems
As explained before, each test scenario for a multi-media system consists of a multiple sub-scenarios. We specify these scenarios in a timed EFSM. In timed EFSM, variables and guard expressions with those variables (i.e., execution condition of transitions) used in EFSM can be used in addition to the basic functions of timed automata[1]. Moreover, synchronization and constraints among multiple timed EFSMs are specified in the form of synchronized parallel execution of those timed EFSMs using the multiway synchronization of LOTOS [9]. That is, we specify behavior of the whole system by
324
Tao Sun et al.
making timed EFSMs execute synchronously and in parallel with the constraint oriented description style[13]. A timed EFSM is given as 6-tuple M =< S, A, C, V, δ, s0 >, where S = {s0 , s1 , · · · , sn } is a finite set of states, A is a finite set of actions (events), C is a finite set of clock variables, V is a finite set of variables, δ : S × A × C × V → S × V is a transition function, and s0 is an initial state. Let G be a set of gates which represent interaction points to an external environment and IO be a set of inputs/outputs from/to a gate. Here, A ⊆ G × IO. g?x represents an action which inputs a value from gate g and stores it in variable x, and g!E represents an action which outputs the value of expression E g?x[Guard]
−→
to gate g, respectively. A transition function δ is represented by s Def s where s and s are the current state and the next state just after an action is executed at state s, respectively. A transition condition for an action, denoted by Guard, is represented by a logical conjunction of linear inequality with clock variables in C, variables in V and constants. Def is a set of value assignments to variables including reset of clock variables, which is represented as {x := x + 1, clock := 0} for example, and a value assignment is executed when a state transition occurs. We specify interaction and synchronization among timed EFSMs with the multi-way synchronization mechanism. The test scenario for the whole system S can be defined as follows. S ::= S |[gate list]| S | S ||| S | (S) | EF SM Here, EF SM is a name of a timed EFSM, and |[gate list]| is the synchronous parallel operator where gate list is a gate list of the events to be synchronized between its operator’s both sides of timed EFSMs. The operator ||| is the asynchronous parallel operator, and it denotes that its operator’s both sides of timed EFSMs can run in parallel without any synchronization. Those parallel operators can be used recursively. 3.1
Test Scenario for Object Playback Functions
We suppose an IUT which plays back media objects such as audio and video data. We specify a test scenario to test a playback function of the IUT with two timed EFSMs: ST and SQ , which correspond to the traffic testing scenario and the quality testing scenario, respectively. The whole test scenario P layer is given as follows. P layer := ST |||SQ ST specifies traffic characteristics which the IUT receives, and SQ specifies quality constraints about frame displaying time which the IUT should satisfy. Note that these scenarios test given IUTs from external environments. In ST , we explicitly specify an allowable time interval between subsequent packets which the IUT receives. Here, for applicability to various network environments, we use four parameters: (1) transmission rate AvRT of a media object, (2) maximum burst length Burst, (3) maximum packet loss ratio Loss, and (4) maximum jitter in packet arrival time JT . For the sake of simplicity, we assume that all packets have the same size and denote this by P ctSz. We show example description of ST in Fig. 4 where a double circle means the initial state.
QoS Functional Testing for Multi-media Systems
ST
n!pct[TP(q)-JT ≤ clk ≤ TP(q)+JT] {pn:=pn+1,clk:=0} clk:=0
325
n!pct[clk < TP(q)-JT and burst+PctSz ≤ Burst] {burst:=burst+PctSz, pn:=pn+1,clk:=0}
burst_end
loss[TP(q)+JT+1 = clk and (ln+1)/(pn+ln+1)
burst_start reset[MP/TP(q)≤ln+pn] {ln:=0,pn:=0,burst:=0}
Fig. 4. Traffic Testing Scenario
clk:=0 clk2:=0
SQ
skip[TF(q)+FJT+1= clk and (sn+1)/(sn+1+vn) < f(Loss)] {sn:=sn+1, clk:=0}
v?frame[TF(q)-FJT ≤ clk ≤ TF(q)+FJT and (sn+vn+1)·TF(q)-MD ≤ clk2 ≤ (sn+vn+1)·TF(q)+MD] {vn:=vn+1, clk:=0}
reset[MP/TF(q)≤sn+vn] {sn:=0,vn:=0}
Fig. 5. Quality Testing Scenario
In Fig. 4, clk and T P (q) represent a clock variable and a time interval by which a server transmits each packet to realize playback quality q of a media object, respectively. Here, T P (q) = P ctSz/AvRT . ln and pn denote the numbers of lost packets and transmitted packets during a time interval M P , respectively. There are four branches in ST : (1) normal mode: each packet is transmitted to gate n(n!pct) in a time range of maximum jitter JT , that is, T P (q) − JT ≤ clk ≤ T P (q) + JT ; (2) burst transmission: when going into burst transmission mode (burst start), each packet is transmitted in smaller interval, that is, clk < T P (q) − JT while the totally transmitted data size does not exceed Burst. When burst transmission finishes, the current state returns to a normal mode (burst end); (3) packet loss: each packet can be lost if packet loss ratio ((ln + 1)/(pn + ln + 1)) measured during time interval M P is less than Loss; and (4) initialization: pn, ln and burst are initialized to 0 (reset) every time interval M P . As we will explain in Sect.4, by executing these choices repeatedly in an appropriate probability we can test the IUT in the environment including jitter, loss and burst to receive packets. Similarly, we give SQ on playback quality of frames. For SQ , we use two parameters F JT and M D, where F JT specifies the maximum value of fluctuation on the time interval of subsequent frames while a media object is played back, and M D specifies the maximum time skew representing how long the current frame can be delayed or preceding from the expected displaying time of the frame (e.g., 1000th frame in 30 fps video is expected to be displayed at 1000×33ms=33sec after the video started). We show an example description of SQ in Fig. 5, where T F (q) indicates the standard time interval
326
Tao Sun et al.
between two subsequent frames with quality q, and vn and sn indicate the numbers of displayed frames and skipped frames measured during time interval M P , respectively. There are three branches in SQ of Fig. 5: (1) frame display: when the current time (clk) is within the appropriate time interval (T F (q) − F JT ≤ clk ≤ T F (q) + F JT ) and the current frame (sn + vn + 1-th frame) is not too much delayed or preceding from the expected time ((sn+vn+1)·T F (q)−M D ≤ clk2 ≤ (sn+vn+1)·T F (q)+M D), a frame is allowed to be displayed (v?f rame); (2) frame skipping: when the current time exceeds the allowable time interval without displaying any frames and the frame skipping rate (sn + 1)/(sn + vn + 1) measured during M P is less than f (Loss) defined in Sect. 2.2, a frame is allowed to be skipped (skip[T F (q) + F JT + 1 = clk]); and (3) initialization: we initializes variables sn and vn to 0 every time interval M P . 3.2
Scenario for Testing Lip-Synchronization among Multiple Objects
We describe a sub-scenario for testing lip-synchronization among multiple media objects as a constraint among multiple quality testing scenarios for those objects, using the constraint oriented description style[13]. For example, let P layer[nv , v, skipv ] and P layer[na , a, skipa ] be quality testing scenarios for video playback and for audio playback, respectively, and we assume that these two scenarios are executed independently in parallel. We also denote nv , na and v, a to be input gate names and output gate names of video and audio, respectively. skip behaviors for video and audio are distinguished by skipv and skipa . Moreover, we let cv and ca denote the sequence numbers of frames of video and audio frames, and T Fv (qv ) and T Fa (qa ) denote the playback interval of video and audio frames, respectively. Here, we describe the sub-scenario Constsync such that the maximum time skew between video and audio must be within Tlip msec as shown in Fig. 6. In general, Tlip should be less than 80msec. In Fig. 6, it is explicitly described that each output of a video frame v? (output of an audio frame a?) is allowed only if the time skew between the expected time of the current frame and that of audio (video) is kept less than Tlip msec. The test scenario for the whole system including the lip-synchronization constraint is given by the following constraint oriented description. (P layer[nv , v, skipv ]|||P layer[na , a, skipa ])|[v, a, skipv , skipa ]|Constsync
Const sync skipv {cv:=cv+1}
skipa {ca:=ca+1}
cv:=0 ca:=0
v?data[(cv+1)·TFv(qv)-ca·TFa(qa) ≤Tlip] {cv:=cv+1}
a?data[(ca+1)·TFa(qa)-cv·TFv(qv) ≤Tlip] {ca:=ca+1}
Fig. 6. Constraint for Lip Synchronization
QoS Functional Testing for Multi-media Systems
4
327
Test Case Generation
We derive test sequences from the traffic testing scenario, the quality testing scenario, and the constraint for lip synchronization, explained in Sect. 3. Hereafter, we denote each test sequence as the following sequence T seq. T seq := a.T seq|T seq +p T seq|(T seq)|T seq ∗K Here, a.T seq, T seq +p T seq and T seq ∗K denote sequential execution of actions, choice between two sequences and iterative execution of the sequence, respectively. T seq1 +p T seq2 specifies that T seq1 and T seq2 are executed at probability 1 − p and p, respectively. In T seq ∗K , K denotes the number of iterations. If these values are not specified, default values such as p = 0.5 and K = 100 are used when executing test sequences. 4.1
Test Case Generation for a Single Object Playback
In the proposed method, the test system observes time at which each frame is displayed in the IUT, takes a sampling of a frame rate every time interval SP , and reports the test result by calculating ratio of samplings with low frame rate below a threshold in a normal distribution of all samplings as explained in Sect. 2.1. Consequently, from test scenarios ST and SQ , we derive test sequences T estT and T estQ by adding new sequences for collecting a sampling every time interval SP and for test verdict computation when monitoring period LP expires, and by fixing the probability of choice “+” and the number of iteration “*” in the sequences. We show examples of T estT and T estQ in Table 1 and Table 2, respectively. In Table 1, Open() and Read() denote some file operation primitives. P acket() denotes a primitive to create a packet. In Table 2 Sampling(x), CalcStatistics and Judgesult are primitives which record x as a sampling, calculates statistical information, and calculates test verdict, respectively. Table 1. Example Test Sequence T estT for Testing Input Traffic T estT := {f p := Open(f ile)}. {clk := 0, Loss := 0.0, ln := pn := burst := 0}. ({pct := P acket(Read(f p))}. n!pct[T P (q) − JT ≤ clk ≤ T P (q) + JT ]{pn := pn + 1, clk := 0} +[M P/T P (q) ≤ pn + ln]{pn := ln := 0}. +([T P (q) + JT + 1 = clk and (ln + 1)/(pn + ln + 1) ≤ Loss] {ln := ln + 1, clk := 0} +(n!pct[clk < T P (q) − JT and burst + P ctSz ≤ Burst] {burst := burst + P ctSz, pn := pn + 1, clk := 0} )∗(Burst/P ctSz) ) )∗(LP/T P (q))
328
Tao Sun et al. Table 2. Example of Test Sequence T estQ for Testing Playback Quality
T estQ := {clk2 := 0}. ({clk := 0, vn := sn := 0}. (v?f rame[T F (q) − F JT ≤ clk < T F (q) + F JT and (sn + vn + 1) · T F (q) − M D ≤ clk2 ≤ (sn + vn + 1) · T F (q) + M D] {vn := vn + 1, clk := 0} +skip[T F (q) + F JT + 1 = clk]{sn := sn + 1, clk := 0} +[M P/T F (q) ≤ sn + vn]{sn := vn := 0}. )∗(SP/T F (q)) .Sampling(vn/SP ){vn := 0, sn := 0} )∗(LP/SP ) .CalcStatistics.JudgeResult
Derived test sequences T estT and T estQ must be executed in parallel for an IUT. Since each action in those sequences can be executed at any time instance within a specified time interval, the number of possible action sequences for their parallel composition will be so many. Therefore, we do not serialize those sequences. Instead, we make the test system capable of executing multiple sequences in parallel. 4.2
Test Case Generation for Lip-synchronization among Multiple Objects Playback
In the proposed method, a test of the lip-synchronization among multiple playbacks of different media objects is similarly carried out using the statistical method stated in Sect. 2.1, where a time lag of the latest frames between two objects are collected as samplings. From test scenario Constsync in Sect. 3.2, we can derive a test sequence T estsync as shown in Table 3. Let us denote T estv and T esta be test sequences for testing playbacks of video and audio objects, respectively. Here, T estv := (T estTv |||T estQv ). With T estv , T esta and T estsync , we finally obtain the following test sequence for testing a given IUT w.r.t. lip synchronization and playback qualities. (T estv |||T esta )|[v, a, skipv , skipa ]|T estsync Table 3. Example Test Sequence T estsync for Lip Synchronization T estsync := {ca = cv = 0}. (v?data{cv := cv + 1}.Sampling((cv + 1) · T Fv (qv ) − ca · T Fa (qa )) +skipv {cv := cv + 1} +a?data{ca := ca + 1}.Sampling((ca + 1) · T Fa (qa ) − cv · T Fv (qv )) +skipa {ca := ca + 1} )∗(LP/M in(T Fv (qv ),T Fa (qa )) .CalcStatistics.JudgeResult
QoS Functional Testing for Multi-media Systems
329
Since the above test sequence contains parallel and synchronization behaviors, we have to implement a test system which provides parallel and synchronous execution of multiple test sequences. Details of a test system are given in Sect. 5.
5
Implementation of Test System
A test system consists of a given IUT and a program which executes test sequences derived in Sect. 4. We call the program as a tester. We would like to treat a given IUT as a black box. So, we make the IUT and its tester run in parallel as different processes, and make them communicate with each other. 5.1
Implementation of Tester Program
Test sequences which we derived in Sect. 4 have the following characteristics. (1) each action in a sequence specifies a time range during which it can be executed. The exact execution time is not specified. (2) a probability is specified in each choice “+” between two sub-sequences. The number of iterative execution of a sub-sequence is also specified. (3) for testing an object playback, two sequences are specified to be executed in parallel. (4) for lip-synchronization among multiple object playbacks, a constraint sequence is also specified to be executed synchronously with multiple test sequences for those objects. (5) statistical calculation primitives such as Sampling(), CalcStatistics(), JudgeResult() are contained in test sequences. We have implemented a tester program which satisfies the above requirements in Java language. Since test sequences are given in the syntax defined in Sect. 4, first we have developed a parser program using JavaCC. Based on some techniques used in our real-time LOTOS compiler [17], we have implemented parallel execution and synchronization mechanisms for multiple test sequences. For the above (1), it is desirable to test if the IUT works correctly for all time instances within the specified time range of each action in a given test sequence. However, it is impossible since combination of time instances in multiple actions will be infinite (in case of dense time). So, we have just implemented our tester only to select a time instance at random within the specified range if the next action in the test sequence is an output to the IUT. If the next action is an input from the IUT, the tester measures the clock value based on the current system time and checks whether or not the action has been executed within the specified time range. If so, the tester continues. Otherwise, it stops to report that the test has failed. For the above (2), the tester just selects one of branching sub-sequences based on random numbers, and repeats the specified sub-sequence the specified times, respectively. To improve the validity of the test result in (1), we can increase the number of iterations1 . For the above (5), we have implemented statistical calculation primitives in Java, according to techniques explained in Sect. 2.1. 1
In [4, 12], time instances near the borders of time ranges are intensively selected for tests. We can also adopt the similar technique to improve the test validity.
330
Tao Sun et al.
TestT v
TestT a
nv
na
TestT n
IUT
Tester
a
v
IUT TestQ v
v
TestQ a
Test sync
TestQ
(a) Single Object Playback
(b) Lip Synchronization between Two Objects Fig. 7. Test Environment
5.2
Construction of Test Environment
The tester must be able to observe the time when each frame is output in the IUT. Here, we assume that a certain event occurs and the time is notified to the tester via gate v when a frame is output in the IUT. The test sequence for a single object playback derived in Sect. 4 contains parallel execution of two sub test sequences: T estT and T estQ . In this case, the whole test system is executed as shown in Fig. 7 (a). The test sequence for lip synchronization between two objects contains four sub-test sequences (two for each) and one constraint T estsync . These sequences are executed as shown in Fig. 7 (b). In order to reduce the influence coming from the test environment such as additional delay and jitter, we execute both the tester and the IUT in the same computer or in the separate computers in the LAN where the influence of delay is smaller.
6
Experimental Results
With the test system explained in Sect. 5, we have executed test sequences and a given IUT and measured distribution of actual frame rates. Our test purpose is to investigate whether a given IUT works satisfying QoS functions (specified by ideal frame rate f ps , maximum tolerance acceptable , and reliance level r of area below in the standard normal distribution) when the IUT receives packets according to the specified traffic pattern (given by packet loss ratio Loss, maximum jitter JT in packet arrival time, and maximum burst length Burst). Two kinds of programs have been used as IUT in our experiments: IU Ta which decodes and displays frames immediately after receiving packets (not regulate frame rates); and IU Tb which receives packets and stores them in a given buffer for absorbing jitters of the packet arrival time in order to display frames at the specified frame rate. We have implemented those IUTs in JMF2.1.1c(Java Media Framework) [18].
QoS Functional Testing for Multi-media Systems Table 5. Test Results
Table 4. Parameters used in Experiments
Exp1 Exp2 Exp3 Exp4 Exp5 Exp6 Exp7 Exp8 Exp9 Exp10
JT 30ms 10ms 30ms 30ms 30ms 30ms 30ms 30ms 30ms 30ms
331
Loss Burst(bit) 0.0 0 0.0 0 0.1 0 0.1 58800 0.2 58800 0.0 0 0.0 58800 0.1 0 0.2 0 0.2 58800
Exp1 Exp2 Exp3 Exp4 Exp5 Exp6 Exp7 Exp8 Exp9 Exp10
average standard deviation 24.6 2.65 24.8 1.71 22.0 3.50 19.6 4.36 20.1 5.03 25.0 — 25.0 — 22.5 4.23 20.0 4.86 19.7 3.80
ratio under test result
25.0 25.0 22.5 22.5 20.0 25.0 22.5 18.0 16.0 16.0
4.2% 0.0% 12.3% 21.0% 20.3% 0.0% 0.0% 1.8% 16.6% 20.3%
failed passed failed failed failed passed passed passed failed failed
With the test system explained in Sect.5, by changing the above parameters given to IU Ta and IU Tb , we have examined the quality of playback mechanism in those IUTs (Exp1 to Exp 10). The list of parameters is shown in Table 4. We have used a motion JPEG stream (320×240pixels, 25fps, the size of each frame is 5.88kbit) in all of our experiments and have applied SP=1s, MP=60s, LP=1800s and TP=40ms (i.e, each frame is transmitted by one packet) to the IUT. In the experiments we have measured the distribution of frame rates, by which we can decide whether the IUT passes the test or not. First, we have executed Exp1 to Exp5 for the IU Ta . In the Exp1 and Exp2 we have investigated the difference in the distribution of the frame rate by changing the value of JT . From Exp3 to Exp5 we have executed test sequences which contains jitters, packet losses (Exp3, Exp4) and burst transmission (Exp5) to the IU Ta . The distribution of samplings for these experiments are shown in Fig. 8 and Fig. 9. These figures show that samplings are distributed in the wide range where the center is around f ps = 25 × (1 − Loss), and the distribution range of samplings is influenced by each of jitters, packet losses, and burst transmission.
1000
350
exp1 JT=30,Loss=0,Burst=0 exp2 JT=10,Loss=0,Burst=0 exp3 JT=30,Loss=0,Burst=0
900
exp4 JT=30,Loss=0.2,Burst=0 exp5 JT=30,Loss=0.2,Burst=58800
300
800 250
700 600
200 500 150
400 300
100
200 50 100 0 16
18
20
22
24
26
28
Fig. 8. Distribution for Experiments 1,2,3
30
0 10
12
14
16
18
20
22
24
26
Fig. 9. Distribution for Experiments 4,5
28
332
Tao Sun et al.
1800
600
exp6 JT=30,Loss=0,Burst=0 with buffer exp7 JT=30,Loss=0,Burst=58800 with buffer
exp8 JT=30,Loss=0.1,Burst=0 with buffer exp9 JT=30,Loss=0.2,Burst=0 with buffer exp10 JT=30,Loss=0.2,Burst=58800 with buffer
1600 500 1400
1200
400
1000 300 800
600
200
400 100 200
0 24
24.2
24.4
24.6
24.8
Fig. 10. Distribution for Experiments 6,7
25
0 10
12
14
16
18
20
22
24
26
Fig. 11. Distribution for Experiments 8,9,10
Then, we have executed Exp6 to Exp10 for the IU Tb which has a buffer and can control the frame rate. In Exp6 and Exp7, we have executed the test sequence only containing jitters, and the test sequence containing both jitters and burst transmission, respectively. In Exp8 and Exp9, we have executed the test sequence containing jitters and packet losses, where the value of Loss is bigger in Exp9 than in Exp8. In the last experiment Exp10, the test sequence contain all factors: jitters, packet losses and burst transmission. The distribution of these experiments are shown in Fig. 10 and Fig. 11. In Fig. 10, we see that all of samplings concentrate in 25(f ps ) or 24(f ps − 1) because Jitters were absorbed. On the other hand, if we compare Exp8 with Exp9 in Fig. 11, we see that the distributed range of samplings is wider when the value of Loss is higher. We think that this is because we specify Loss as the maximum packet loss ratio for period M P =60s, but the actual packet loss ratio measured during short period (e.g., SP ) may be more or less than the value of Loss. In Fig. 11 comparing Exp8 with Exp9, we see that the influence due to burst transmission is small. Next, with the method explained in Sect.2.1 , we have decided whether tests pass or not. We calculated the average and standard deviation of samplings for each experiment by supposing their normal distribution. Here, for example we set maximum tolerance acceptable as f ps ± 20% and reliance level r as 2%. The list of the average, the standard deviation, the ratio of area under and the test result for all experiments are shown in table 5. According to the table, we see that the IU Ta passes the test in the condition which JT was within 10ms and Loss was close to 0 (Exp2). About IU Tb , it passes the test when JT was within 30ms and Loss was within 0.1 (Exp6, 7, 8). In order to evaluate the validity of our assumption which the distribution of frame rates follow the normal distribution, we calculated the proportion of the samplings under (or upper when > f ps ) to the whole of samplings and the proportion of C [−∞, (− µ)/s] to the whole area in the normal distribution. We show the result in Table 6. Comparing the normal distribution and the distribution of the actual samplings, we see that the proportion in the normal distribution is in most cases bigger than in the actual samplings for each . If the test passes on the proposed method, then the actual proportion under was not bigger than reliance level r. So we think our assumption is valid enough.
QoS Functional Testing for Multi-media Systems
333
Table 6. Comparison between Normal Distribution and Distribution of Actual Samplings proportion under(upper) frame rate normal distribution actual samplings 16 0.04182 0.002277 17 0.07493 0.010245 18 0.12302 0.026750 19 0.19215 0.088218 20 0.27759 0.198633 21 0.38209 0.355150 0.49601 0.582242 22 23 0.39358 0.417758 24 0.28774 0.211725 25 0.20045 0.076836 26 0.12924 0.018213 27 0.07927 0.003984
7
Conclusion
In this paper, we proposed a test method for QoS functions in distributed multi-media systems. In the proposed method, using timed EFSM model, we describe a test scenario which specifies input flow characteristics and play-back quality to be realized for the flow, and generate test sequences from the scenario. Using the generated test sequences, we can statistically test whether a given IUT realizes certain quality for a given input flow. Through experiments with our test system and sample IUTs, it is confirmed that the proposed test method can efficiently test given IUTs depending on target network environments and required playback quality. As part of future work, we would like to test various IUTs where some QoS control mechanisms (lip synchronization, prioritized media scaling, and so on) are implemented, assuming various types of network traffic. Through such experiments, applicability of our method should be clarified.
References 1. Alur, R. and Dill, D. L.: “Theory of timed automata”, Theoretical Computer Science, Vol. 126, pp. 183–235 (1994). 2. Alur, R. and Henzinger, T. A.: “Logics and Models of Real Time: A Survey”, “Real Time: Theory in Practice”, LNCS 600, pp.74–106 (1992). 3. Bowman, H., Faconti, G. and Massink, M. : “Specification and verification of media constraints using UPPAAL”, Proc. of 5th Eurographics Workshop on the Design, Specification and Verification of Interactive Systems, pp. 261–277 (1998). 4. Cheung, S.C., Chanson, S.T. and Xu, Z. : “Toward Generic Timing Tests for Distributed Multimedia Software Systems”, IEEE Int’l. Symp. on Software Reliability Engineering (2001). 5. Fibush, D.K. : “Testing multimedia transmission systems”, IEEE Design & Test of Computers, Vol.12, No.4, pp.24-44 (1995). 6. Grabowski, J. and Walter, T. : “Testing Quality-of-Service Aspects in Multimedia Applications”,Proc. of 2nd Workshop on Protocols for Multi-media Systems (PROMS) (1995).
334
Tao Sun et al.
7. Higashino, T., Nakata, A., Taniguchi, K. and Cavalli, A.R.: “Generating Test Cases for a Timed I/O Automaton Model”, Proc. 12th IFIP Workshop on Testing of Communicating Systems (IWTCS’99), pp. 197–214 (1999). 8. Huang, C. M. and Wang, C. : “Synchronization for Interactive Multimedia Presentations”, IEEE MULTIMEDIA, Vol. 5, No. 4, pp.44-62 (1998). 9. ISO : “Information Processing System, Open Systems Interconnection, LOTOS - A Formal Description Technique Based on the Temporal Ordering of Observational Behaviour”, ISO 8807 (1989). 10. Kone, O: “A Local Approach to the Testing of Real-time Systems”, The Computer Journal, Vol. 44, No. 5 (2001). 11. Lee, D. and Yannakakis, M.: “Principles and Methods of Testing Finite State Machines – A Survey”, Proc. of the IEEE, Vol. 84, No. 8 (1996). 12. Misic, V. B., Chanson, S. T. and Cheung, S.: “Towards a Framework For Testing Distributed Multimedia Software Systems”, Proc. of 1998 Int’l. Symp. on Software Engineering for Parallel and Distributed Systems (PDSE98) (1998). 13. Vissers, C. A., Scollo, G. and Sinderen, M. v.: “Specification Styles in Distributed Systems Design and Verification”, Theoretical Computer Science, Vol. 89, No. 1, pp. 178 – 206 (1991). 14. Walter, T., Scheferdecker, I. and Grabowski, J. : “Test Architectures for Distributed Systems - State of the Art and Beyond (Invited Paper)”, Testing of Communication Systems, Vol.II, Chapman & Hall (1998). 15. W3C: “Synchronized Multimedia Integration Language (SMIL) 1.0 Specification”, http://www.w3c.org/TR/REC-smil/ 16. Yamada, M., Mori. T., Fukada, A., Nakata, A. and Higashino, T.: “A Method for Functional Testing of Media Synchronization Protocols”, Proc. of the 16th Int’l. Conf. on Information Networking (ICOIN-16) (2002). 17. Yasumoto, K., Umedu, T., Yamaguchi, H., Nakata, A. and Higashino, T.: Protocol animation based on event-driven visualization scenarios in real-time LOTOS, Computer Networks, Vol. 40, No. 5, pp. 639–663 (2002). 18. Sun Microsystems: “Java Media Framework Home Page”, http://java.sun.com/products/javamedia/jmf/
Towards Testing Stochastic Timed Systems Manuel N´ un ˜ez and Ismael Rodr´ıguez Dept. Sistemas Inform´ aticos y Programaci´ on, Facultad de Inform´ atica, Universidad Complutense de Madrid, E-28040 Madrid, Spain, {mn,isrodrig}@sip.ucm.es
Abstract. In this paper we present a first approach to the definition of conformance testing relations for systems presenting stochastic timed behavior. By stochastic time we mean that the probability of performing an event may vary according to the elapsed time. In particular, we will consider delays specified by means of random variables. In order to define our formal model, we will provide a stochastic extension of the notion of finite state machine. We will give a first implementation relation and we will discuss its practical drawbacks. That is, we will show that this relation cannot be appropriately checked under a black/grey-box testing methodology. We will also present other alternative implementation relations that can be checked up to a certain degree of confidence. We will define test cases and how they are applied to implementations. Finally, we will give a test generation algorithm providing complete, up to a degree of confidence, test suites. Keywords: Conformance testing, test theory, performance testing
1
Introduction
Testing consists in checking the correctness of an implementation by performing experiments on it. Usually, correctness is considered with respect to a specification describing the desired behavior of the system. In order to perform this task, several techniques, algorithms, and semantic frameworks have been introduced in the literature (see e.g. [6, 17, 18] for overviews on the topic). In recent years the testing community has shown a growing interest in extending these frameworks so that not only functional properties but also quantitative ones could be tested. Thus, there has been several proposals for timed testing (e.g. [8, 10, 15, 21, 23]). In these works time is considered to be deterministic. In fact, in most of the cases, time is introduced by means of clocks following [3]. Even though the inclusion of time allows the specifier to give a more precise description of the system to be implemented, there are frequent situations that cannot be accurately described by using this notion of time. For example, we may desire to specify a system where a message is expected to be received with probability 12 in the interval (0, 1], with probability 14 in (1, 2], and so on. This
Research supported in part by the Spanish MCYT projects AMEVA and MASTER and the Junta de Castilla-La Mancha project DISMEF.
H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 335–350, 2003. c IFIP International Federation for Information Processing 2003
336
Manuel N´ un ˜ez and Ismael Rodr´ıguez
is an advantage with respect to usual deterministic time where we could only specify that the message arrives in the interval (0, ∞). Thus, stochastic extensions of classical formal models, as process algebras and Petri Nets, have appeared in the literature (see e.g. [1, 2, 5, 7, 11, 12, 14, 16, 20]). As we have shown in the previous example, the main idea underlying stochastic models is that time information is incremented with some kind of probabilistic information. In contrast with testing of timed systems, stochastic testing has received almost no attention. In fact, to the best of our knowledge, there are only two works in the field [4, 19], where extensions of the classical theory of testing [9, 13] are given. We think that this lack of research in this area is due to the technical difficulties in the definition of the corresponding notions of testing. For example, even if we consider white-box testing, as it is the case of [4, 19], we still have technical problems as the aggregation of delays. In the case of grey/black-box testing, that we consider in this paper, the problem of detecting time faults is much more involved than in the case of timed testing. This is so because we will suppose that the test(er) has no access to the probability distribution functions associated with delays. Let us remark that due to the probabilistic nature of time in stochastic timed systems, several observations of a system may lead to different times of execution. Actually, this may happen even if the implementation performs in all the cases the same sequence of actions (and through the same sequence of states). In this paper we give notions of conformance testing for systems presenting stochastic time information. In order to do so, we need to introduce a formal framework to specify this kind of systems. We will consider a suitable extension of finite state machines where (stochastic) time information is included. Intuitively, transitions in finite state machines indicate that if the machine is in a state s and receives and input i then it will produce and output o and it will change its i/o
state to s . An appropriate notation for such a transition could be s −→ s . If we consider a timed extension of finite state machines (see e.g. [22]), transitions as i/o
s− −−−→ t s indicate that the time between receiving the input i and returning the output o is equal to t. In the new model that we introduce in this paper for stochastic transitions, we will consider that the delay between the input is applied and the output is received is given by a random variable ξ. Thus i/o
−−−→ ξ s is: If the machine is in state s the interpretation of a transition s − and receives an input i then it will produce the output o before time t with probability P (ξ ≤ t) and it will change its state to s . The rest of the paper is organized as follows. In Section 2 we present our stochastic finite state machine model. In Section 3 we define our first implementation relation and we show its weakness from the practical point of view. In Section 4 we give our notion of test case and we define how they are applied to implementations under test. In Section 5 we take up again the study of implementation relations. We give a first notion where an implementation conforms a specification up to a certain degree of confidence, with respect to a (multi)set of observations from the implementation. The idea, regarding time, is that we
Towards Testing Stochastic Timed Systems
337
try to decide whether the times observed from the implementation correspond to the random variable indicated by the specification. Next we give other alternative notions where the speed of the implementation is taken into account. In Section 6 we give a test derivation algorithm and we show that, given a specification, the generated test suite is complete, for a certain confidence level, with respect to the first implementation relation given in Section 5. In Section 7 we present our conclusions and some lines for future work. In the appendix of this paper we formally introduce Pearson’s contrast, which is (abstractly) used along the paper.
2
Stochastic Finite State Machines
In this section we introduce our notion of finite state machines with stochastic time. We use random variables to model stochastic delays. Thus, we need to introduce some basic concepts on random variables. We will consider that the sample space (that is, the domain of random variables) is the set of real numbers IR. Besides, random variables take positive values only in IR+ . The reason for this restriction is that they will always be associated with time distributions, so they cannot take a negative value. Definition 1. We denote by V the set of random variables (ξ, ψ, . . . to range over V). Let ξ be a random variable. We define its probability distribution function as the function Fξ : IR −→ [0, 1] such that Fξ (x) = P (ξ ≤ x), where P (ξ ≤ x) is the probability that ξ assumes values less than or equal to x. Let ξ, ξ ∈ V be random variables. We write ξ = ξ if for any x ∈ IR we have Fξ (x) = Fξ (x). Given two random variables ξ and ψ we consider that ξ +ψ denotes a random variable distributed as the addition of the two random variables ξ and ψ. We will call sample to any multiset of positive real numbers. We denote the set of multisets in IR+ by ℘(IR+ ). Let ξ be a random variable and J be a sample. We denote by γ(ξ, J) the confidence of ξ on J. In the previous definition, a sample simply denotes an observation of values. In our setting, samples will be associated with times that implementations take to perform sequences of actions. We have that γ(ξ, J) takes values in the interval [0, 1]. Intuitively, bigger values of γ(ξ, J) indicate that the observed sample J is more likely to be produced by the random variable ξ. That is, this function decides how similar the probability distribution function generated by J and the one corresponding to the random variable ξ are. In the appendix of this paper we show how confidence is formally defined. Next we introduce our notion of stochastic finite state machines. Definition 2. A Stochastic Finite State Machine, in short SFSM, is a tuple M = (S, I, O, δ, sin ) where S is the set of states, I and O denote the sets of input and output actions, respectively, δ is the set of transitions, and sin is the initial state. Each transition belonging to δ is a tuple (s, i, o, ξ, s ) where s, s ∈ S are the initial and final states, i ∈ I and o ∈ O are the input and output ac-
338
Manuel N´ un ˜ez and Ismael Rodr´ıguez i1 /o1
M1
i1 /o2
M3 i2 /o1
1
1
i1 /o2 i2 /o1
2
i2 /o1
1
i2 /o2
i1 /o1
M2
i2 /o2 i1 /o3
i2 /o1
i1 /o1
3
i1 /o2
i1 /o1
i1 /o2
i2 /o1
2
i1 /o1
2
i2 /o3
i1 /o2
Fig. 1. Examples of SFSM.
tions, and ξ ∈ V is the random variable defining the delay associated with the i/o
transition. Transitions will be sometimes denoted as s − −−−→ ξ s .
Intuitively, a transition (s, i, o, ξ, s ) indicates that if the machine is in state s and receives the input i then the machine emits the output o before time t with probability Fξ (t) and the machine changes its current state to s . In order to avoid side-effects, we will assume that all the random variables appearing in the definition of a SFSM are independent. Let us note that this condition does not restrict the distributions to be used. In particular, there can be random variables identically distributed even though they are independent. Next we define some conditions that are usually required to finite state machines. Definition 3. Let M = (S, I, O, δ, sin ) be a SFSM. We say that M is inputenabled if for any state s ∈ S and input i ∈ I there exist s , o, ξ, such that (s, i, o, ξ, s ) ∈ δ. We say that M is deterministically observable if for any s, i, o there do not exist two different transitions (s, i, o, ξ1 , s1 ), (s, i, o, ξ2 , s2 ) ∈ δ. First, let us remark that the previous concepts are independent of the stochastic information appearing in SFSMs. Regarding the notion of deterministically observable SFSM, it is worth to point out that it is different from the more restricted notion of deterministic finite state machine. In particular, we allow transitions from the same state labelled by the same input action, as far as the outputs are different. Example 1. Let us consider the finite state machines depicted in Figure 1. In order to transform these machines into stochastic finite state machines, we need to add random variables to all the transitions. Let us consider M2 . We have M2 = ({1, 2}, {i1 , i2 }, {o1 , o2 , o3 }, δ, 1) where the set of transitions δ is given by: δ = {(1, i2 , o1 , ξ1 , 1), (1, i1 , o1 , ξ2 , 2), (2, i1 , o2 , ξ3 , 1)}
Towards Testing Stochastic Timed Systems
339
In order to complete our specification of M2 we need to say how random variables are distributed. Let us suppose the following distributions: 0 if x ≤ 0 Fξ1 (x) = x3 if 0 < x < 3 1 if x ≥ 3 0 if x < 4 Fξ2 (x) = 1 if x ≥ 4 1 − e−3·x if x ≥ 0 Fξ3 (x) = 0 if x < 0 We say that ξ1 is uniformly distributed in the interval [0, 3]. Uniform distributions allow us to keep compatibility with time intervals in (non-stochastic) timed models in the sense that the same weight is assigned to all the times in the interval. We say that ξ2 is a Dirac distribution in 4. The idea is that the corresponding delay will be equal to 4 time units. Dirac distributions allow us to simulate deterministic delays appearing in timed models. We say that ξ3 is exponentially distributed with parameter 3. Let us consider the transition (1, i2 , o1 , ξ1 , 1). Intuitively, if M2 is in state 1 and it receives the input i2 then it will produce the output o2 after a delay given by ξ1 . For example, we know that this delay will be less than 1 unit of time with probability 13 , it will be less than 1.5 units of time with probability 12 , and so on. Finally, once 3 units of time has passed we know that the output o1 has been performed (that is, we have probability 1). Regarding the notions of input-enabled and deterministically observable, we have that M1 fulfills the first of the properties but not the second one (there are two transitions from the state 1 labelled by i2 /o1 ). The first property does not hold in M2 (there is no outgoing transition labelled by i2 from the state 2) while the second one does. Finally, both properties hold for M3 . Usually we need to consider not only single evolutions of a SFSM but also sequences of transitions. Thus, we introduce the notion of trace. Definition 4. Let M = (S, I, O, δ, sin ) be a SFSM. We write the generalized (i1 /o1 ,...,in /on )
transition s ===========⇒ ξ s if there exist s1 , . . . , sn−1 , ξ1 , . . . , ξn such that i1 /o1
i2 /o2
in /on
s −−−−−→ ξ1 s1 −−−−−→ ξ2 s2 · · · sn−1 −−−−−→ ξn s and ξ = ξ1 + . . . + ξn . We say that ρ = (i1 /o1 , . . . , in /on ) is a non-stochastic trace, or simply a ρ trace, of M if there exist s ∈ S and ξ ∈ V such that sin ==⇒ ξ s . We say that ρs = ((i1 /o1 , . . . , in /on ), ξ) is a stochastic trace of M if there exist s ∈ S such ρ that sin ==⇒ ξ s . We denote by NSTraces(M ) and STraces(M ) the sets of non-stochastic and stochastic traces of M , respectively. Traces are defined as sequences of transitions. In this case, the random variable associated with stochastic traces is computed from the corresponding to each transition of the sequence. In fact, we consider the addition of all the random variables appearing in the trace. Intuitively, the time that it will take for
340
Manuel N´ un ˜ez and Ismael Rodr´ıguez
the trace to be performed is equal to the sum of the delays corresponding to each of the transitions.
3
Stochastic Implementation Relations: A First Attempt
In this section we introduce our first implementation relation. It follows the classical pattern: An implementation I conforms to a specification S if for any possible evolution of S the outputs that the implementation I may perform after a given input are a subset of those for the specification. In addition to the nontimed conformance of the implementation, we will require some time conditions to be held. Next, we formally define the sets of specifications and implementations: Spec and Imp. We will consider that both specifications and implementations are given by deterministically observable SFSMs. That is, we do not allow a machine to have two different transitions as (s, i, o, ξ1 , s ) and (s, i, o, ξ2 , s ). Note that we do not restrict observable non-determinism, that is, we may have the transitions (s, i, o1 , ξ1 , s1 ) and (s, i, o2 , ξ2 , s2 , ) as far as o1 = o2 . Besides, we assume that input actions are always enabled in any state of the implementation, that is, implementations are input-enabled according to Definition 3. This is a usual condition to assure that the implementation will react (somehow) to any input appearing in the specification. Next, we introduce our first implementation relation. Definition 5. Let I and S be SFSMs. We say that I non-stochastically conforms to S, denoted by I confns S, if for each ρ = (i1 /o1 , . . . , in /on ) ∈ NSTraces(S), with n ≥ 1, we have ρ = (i1 /o1 , . . . , in /on ) ∈ NSTraces(I) implies ρ ∈ NSTraces(S) We say that I stochastically conforms to S, denoted by I confs S, if I confns S and for any ρs = (ρ, ξ) ∈ STraces(I) we have ρ ∈ NSTraces(S) implies (ρ, ξ ) ∈ STraces(S) ∧ ξ = ξ
Intuitively, the idea underlying the definition of the non-stochastic conformance relation I confns S is that the implementation I does not invent anything for those inputs that are specified in the specification. Let us note that if the specification has also the property of input-enabled then we may remove the condition “for each ρ = (i1 /o1 , . . . , in /on ) ∈ NSTraces(S), with n ≥ 1”. Example 2. Consider the finite state machines M2 and M3 depicted in Figure 1 (center and right). We have M3 confns M2 . Note that the traces of M3 having as prefix the sequence i1 /o1 , i2 /o, with o ∈ {o1 , o3 }, are not checked since M2 (playing the role of specification) cannot perform those traces. Let us now consider that M2 is extended with the transition (2, i2 , fail, ξ2 , 2), for a random variable ξ2 , so that it fulfills the conditions required for implementations (input-enabled). Then, M2 does not conform to M3 . For example, M3
Towards Testing Stochastic Timed Systems T1
T2
T3
T4
i2
i1
i2
i1
o2
o1
o3
o2
o1
o3
f ail
i2
f ail
f ail
i1
f ail
o2
o1
o3
o1
o2
o3
f ail
i1
f ail
o1
o2
o3
pass
f ail
f ail
pass
o2 f ail
o1 pass
o3 f ail
f ail
f ail
o2
o1
o3
f ail
i1
f ail
o1
o2
o3
f ail
i2
f ail
o1
o2
o3
pass
f ail
341
f ail
Fig. 2. Examples of Test Cases.
may perform the trace ρ = i1 /o1 , i2 /o3 , M2 has the trace ρ = i1 /o1 , i2 /fail, but ρ does not belong to the set of non-stochastic traces of S3 . Note that ρ and ρ have the same prefix i1 /o1 , i2 . In addition to requiring this notion of non-timed conformance, we have to ask for some conditions on delays. Thus, I confs S also requires that any stochastic trace of the specification that can be performed by the implementation must have the same associated delay. Even though this is a very reasonable notion of conformance, the fact that we assume a grey/black-box testing framework disallows us to check whether the corresponding random variables are identically distributed. In fact, we would need and infinite number of observations from a random variable of the implementation (with an unknown distribution) to assure that this random variable is distributed as another random variable from the specification (with a known distribution). Thus, we have to give more realistic implementation relations based on a finite set of observations. In the next sections we will present other implementation relations that are less accurate but that are checkable.
4
Tests Cases for Stochastic Systems
In this section we introduce test cases and we present how they are applied to implementations under test. We consider that a test case is simply a sequence of inputs applied to the implementation. Once an output is received, we check whether it is the expected one or not. In the latter case, a fail signal is produced. In the former case, either a pass signal is emitted (indicating successful termination) or the testing process continues by applying another input. If we are testing an implementation with input and output sets I and O, respectively, tests are deterministic acyclic I/O labelled transition systems (i.e. trees) with a strict alternation between an input action and the whole set of output actions. After an
342
Manuel N´ un ˜ez and Ismael Rodr´ıguez
output action we may find either a leaf or another input action. Leaves can be labelled either by pass or by fail. In the first case we add a random variable. The idea is that we will record the time that it takes for the implementation to arrive to that point. We will collect a sample of times (one for each test execution) and we will compare this sample with the random variable. By comparison we mean that we will apply a contrast to decide, with a certain confidence, whether the sample could be generated by the corresponding random variable. Definition 6. A test case is a tuple T = (S, I, O, δ, s0 , SI , SO , SF , SP , ζ) where S is the set of states, I and O, with I ∩ O = ∅ are the sets of input and output actions, respectively, δ ⊆ S × I ∪ O × S is the transition relation, s0 ∈ S is the initial state, and the sets SI , SO , SF , SP ⊆ S are a partition of S. The transition relation and the sets of states fulfill the following conditions: – SI is the set of input states. We have that s0 ∈ SI . For any input state s ∈ SI there exists a unique outgoing transition (s, a, s ) ∈ δ. For this transition we have that a ∈ I and s ∈ SO . – SO is the set of output states. For any output state s ∈ SO we have that for any o ∈ O there exists a unique state s such that (s, o, s ) ∈ δ; in each case, s ∈ / SO . Moreover, there do not exist i ∈ I and s ∈ S such that (s, i, s ) ∈ δ. – SF and SP are the sets of fail and pass states, respectively. We say that these states are terminal. That is, for any state s ∈ SF ∪ SP we have that there do not exist a ∈ I ∪ O and s ∈ S such that (s, a, s ) ∈ δ. Finally, ζ : SP −→ V is a function associating random variables with passing states. ρ Let ρ = (i1 /o1 , . . . , ir /or ). We write T =⇒ s, if s ∈ SF ∪ SP and there exist states s12 , s21 , s22 , . . . sr1 , sr2 ∈ S such that {(s0 , i1 , s12 ), (sr2 , or , s)} ⊆ δ, for any 2 ≤ j ≤ r we have (sj1 , ij , sj2 ) ∈ δ, and for any 1 ≤ j ≤ r − 1 we have (sj2 , oj , s(j+1)1 ) ∈ δ. We say that a test case is valid if the graph induced by T is a tree with root at the initial state s0 . In Figure 2 we give some test cases, where random variables associated with passing states have been omitted. Before we define the application of a test to an implementation, we need to introduce an auxiliary definition. As we said before, we will compare the time that the implementation needs to perform the test with the random variable appearing in the reached passing state of the test. Thus, we suppose that there exists a mechanism allowing to observe the time that the implementation needed to perform the sequence offered by the test and that leads the test to the corresponding passing state. Definition 7. Let I be a SFSM. We say that ((i1 /o1 , . . . , in /on ), t) is the observed timed execution of I, or simply timed execution, if the observation of I shows that the sequence (i1 /o1 , . . . , in /on ) is performed in time t. Let Φ = {ρ1 , . . . , ρm } be a set of traces and H = {|(ρ1 , t1 ), . . . , (ρn , tn )|} be a multiset of timed executions. We say that Sampling(H,Φ) : Φ −→ ℘(IR+ ) is a sampling application of H for Φ if Sampling(H,Φ) (ρ) = {|t | (ρ, t) ∈ H|}, for any ρ ∈ Φ.
Towards Testing Stochastic Timed Systems
343
Regarding the definition of sampling applications, we just associate with each trace the observed times of execution. Next we define the application of a test to an implementation. Definition 8. Let I = (S1 , I, O, δ1 , sin ) be an implementation under test and T = (S2 , I, O, δ2 , s0 , SI , SO , SF , SP , ζ) be a valid test. We denote the application of the test T to the implementation I as I T . ρ ρ We write I T =⇒t sT if T =⇒ sT and (ρ, t) is the observed timed execution of I. In this case we say that (ρ, t) is a test execution of I and T . Let H = {|(ρ1 , t1 ), . . . , (ρn , tn )|} be a test executions sample of I and T , ρ 0 ≤ α ≤ 1, Φ = {ρ | ∃ sT , t : I T =⇒t sT }, and let us consider Sampling(H,Φ) . We say that the implementation I (α, H)−passes the test T if for any trace ρ ρ ∈ NSTraces(I) with I T =⇒t sT we have both that sT ∈ SF and if sT ∈ SP then γ(ζ(sT ), Sampling(H,Φ) (ρ)) > α. Intuitively, an implementation passes a test if two conditions hold. First, there is no evolution leading to a fail state (see the condition sT ∈ SF ). Once we know that the functional behavior of the implementation is correct with respect to the test, we need to check time conditions. The set H corresponds to the observations of the (several) applications of T to I. Thus, we have to decide whether, for each trace ρ, the observed times (that is, Sampling(H,Φ) (ρ))) match the definition of the random variable appearing in the successful state of the test corresponding to the execution of that trace (that is, ζ(sT )). As we commented previously, we assume a function γ that can perform this hypothesis contrast. In the appendix of this paper we give the technical details about the definition of this function (we will use Pearson’s χ2 ). Next we extend the notion of passing a test to deal with test suites. In order to increase the degree of reliability, we will not take the classical approach where passing a test suite is defined according only to the results for each test. In our approach, we will put together all the observations, for each test, so that we have more samples for each trace. In particular, some observations will be used several times. In other words, an observation from a given test may be used to check the validity of another test sharing the same observed trace. Definition 9. Let I be a SFSM and Ω = {T1 , . . . , Tn } be a set of tests. Let H1 , . . . , H n be test execution samples of I and T1 , . . . , Tn , respectively. Finally, n let H = i=1 Hi . We say that the implementation I (α, H)−passes the test suite Ω if for any 1 ≤ i ≤ n we have that I (α, Hi )−passes Ti , where Hi = ρ {|(ρ, t) | (ρ, t) ∈ H ∧ ∃ sT , t : I Ti =⇒t sT |}.
5
Implementation Relations Based on Samples
In Section 3 we presented an implementation relation that fulfilled a nice definition and it seemed appropriate for our framework. Unfortunately, this notion is useful only from a theoretical point of view since, under our assumptions, it cannot be tested in finite time that an implementation conforms with respect to
344
Manuel N´ un ˜ez and Ismael Rodr´ıguez
a specification. In this section we introduce a new implementation relation that, inspired by our testing framework, takes into account the observations that we may get from the implementation. Definition 10. Let I and S be two SFSMs. Let H be a multiset of timed executions of I, 0 ≤ α ≤ 1, Φ = NSTraces(I) ∩ NSTraces(S), and let us consider Sampling(H,Φ) . We say that I (α, H)−stochastically conforms to S, denoted by I confs(α,H) S, if I confns S and for any non-stochastic trace ρ = (i1 /o1 , . . . , in /on ) ∈ NSTraces(I) we have that if there exists a stochastic trace ((i1 /o1 , . . . , in /on ), ξ) ∈ STraces(S) then γ(ξ, Sampling(H,Φ) (ρ)) > α. The idea underlying the new relation is that the implementation must conform to the specification in the usual way (that is, I confns S). Besides, for any trace of the implementation that it can be performed by the specification, the observed execution times fit the random variable indicated by the specification. Again, this notion of fitting is given by the function γ that it is formally defined in the appendix of this paper. A first direct result says that if we decrease the confidence level then we keep conformance. Lemma 1. Let I and S be two SFSMs such that I confs(α1 ,H) S. If α2 < α1 then we have I confs(α2 ,H) S. The next result, whose proof is straightforward, says that if we have two samples sharing some properties then our conformance relation gives the same result for both of them. Lemma 2. Let I and S be two SFSMs, H1 , H2 be multisets of timed executions for I, and let bi = {|(ρ, t) | (ρ, t) ∈ Hi ∧ ρ ∈ NSTraces(I) ∩ NSTraces(S)|}, for i = {1, 2}. If b1 = b2 then we have I confs(α,H1 ) S iff I confs(α,H2 ) S. Next we present different variations of the previous implementation relation. First, we define the concept of shifting a random variable with respect to its mean. For example, let us consider a random variable ξ following a Dirac distribution in 4 (see Example 1 for the formal definition). If we consider a new random variable ξ following a Dirac distribution in 3, we say that ξ represents a shift of ξ. Moreover, we also say that ξ and ξ belong to the same family. Definition 11. We say that ξ is a mean shift of ξ with mean M , and we denote it by ξ = MShift(ξ, M ), if ξ, ξ belong to the same family and the mean of ξ , denoted by µξ , is equal to M . Let I and S be two SFSMs. Let H be a multiset of timed executions of I, 0 ≤ α ≤ 1, Φ = NSTraces(I) ∩ NSTraces(S), and let us consider Sampling(H,Φ) . We say that I (α, H)−stochastically conforms to S with speed π, denoted by (α,H) Iconfmπ S, if I confns S and for any ρ = (i1 /o1 , . . . , in /on ) ∈ NSTraces(I) we have that if there exists a stochastic trace ((i1 /o1 , . . . , in /on ), ξ) ∈ STraces(S) then γ(MShift(ξ, µξ · π), Sampling(H,Φ) (ρ)) > α. An interesting remark regarding this new relation is that when α is small enough and/or π is close enough to 1, then it may happen that we have both
Towards Testing Stochastic Timed Systems
345
(α,H)
I confs(α,H) S and Iconfmπ S. Nevertheless, it is enough to increase α, as far as π = 1, so that we do not have both results simultaneously. Let us note that in the previous notion, a value of π greater than 1 indicates that the new delay is slower. This observation induces the following relation. Definition 12. Let I and S be two SFSMs. Let H be a multiset of timed executions of I. We say that I is generally faster (respectively generally slower) than S for H if there exist 0 ≤ α ≤ 1, and 0 < π < 1 (respectively π > 1) such that (α,H) Iconfmπ S but I confs(α,H) S does not hold. Given the fact that, in our framework, an implementation could fit better to a specification with higher or lower speed, it will be interesting to detect which variations of speed would make the implementation to fit better the specification. Intuitively, the best variation will be the one allowing the implementation to conform to the specification with a higher level of confidence α. Definition 13. Let I and S be two SFSMs. Let H be a multiset of timed execu(α,H) tions of I. Let us consider 0 ≤ α ≤ 1 and π ∈ IR+ such that Iconfmπ S and (α ,H) + S. Then, we say that there do not exist α > α and π ∈ IR with Iconfmπ π is a relative speed of I with respect to S for H. The concept of relative speed allows us to define another implementation relation which is more restrictive than those presented so far. Basically, the implementation must both (α, H)−stochastically conform to the specification and have 1 as a relative speed. Let us note that the latter condition means that the implementation fits perfectly in its current speed. However, let us remark that this new notion correspond neither to our first implementation relation (see Definition 5) nor to have a confidence level α equal to 1. Definition 14. Let I and S be two SFSMs. Let H be a multiset of timed executions of I and 0 ≤ α ≤ 1. We say that I (α, H)−stochastically and precisely conforms to S, denoted by I confp(α,H) S, if I confs(α,H) S and we have that 1 is a relative speed of I with respect to S for H. The following result relates some of the notions presented in this section. Lemma 3. Let I and S be two SFSMs. We have I confp(α,H) S iff I confs(α,H) S and neither I is generally faster than S for H nor I is generally slower than S for H.
6
Test Derivation
In this section we provide an algorithm to derive tests from specifications. In addition, we will show that the derived test suite is complete, up to a given confidence α and for a sample H, with respect to the conformance relation confs(α,H) given in Definition 10. As usually, the idea consists in traversing the specification to get all the possible traces in the adequate way. So, each test is generated so that it focuses on chasing a concrete trace of the specification.
346
Manuel N´ un ˜ez and Ismael Rodr´ıguez
Input: M = (S, I, O, δ, sin ). Output: T = (S , I, O, δ , s0 , SI , SO , SF , SP , ζ). Initialization: – S := {s0 }, δ := SI := SO := SF := SP := ζ := ∅. – Saux := {(sin , ξ0 , s0 )}. Inductive Cases: Apply one of the following two possibilities until Saux = ∅. 1. If (sM , ξ, sT ) ∈ Saux then perform the following steps: (a) Saux := Saux − {(sM , ξ, sT )}. (b) SP := SP ∪ {sT }; ζ(sT ) := ξ. 2. If Saux = {(sM , ξ, sT )} is a unitary set and there exists i ∈ I such that out(sM , i) = ∅ then perform the following steps: (a) Saux := ∅. (b) Choose i such that out(sM , i) = ∅. (c) Create a fresh state s ∈ / S and perform S := S ∪ {s }. T (d) SI := SI ∪ {s }; SO := SO ∪ {s }; δ := δ ∪ {(sT , i, s )}. (e) For each o ∈ / out(sM , i) do – Create a fresh state s ∈ / S and perform S := S ∪ {s }. – SF := SF ∪ {s }; δ := δ ∪ {(s , o, s )}. (f) For each o ∈ out(sM , i) do – Create a fresh state s ∈ / S and perform S := S ∪ {s }. – δ := δ ∪ {(s , o, s )}. M – sM 1 := after(s , i, o). M M – Let (s , i, o, ξ1 , sM 1 ) ∈ δ. Saux := Saux ∪ {(s1 , ξ + ξ1 , s )}. Fig. 3. Test Derivation Algorithm.
However, if during the execution of the test it is detected an output which does not correspond to such a trace, then the testing process stops and finishes in either a pass or a fail state. The status of the final state depends on whether such an output is allowed by the specification at this point. First, we give some auxiliary functions. Definition 15. Let M = (S, I, O, δ, sin ) be a SFSM. We define the set of possible outputs in state s after input i as out(s, i) = {o | ∃s : (s, i, o, ξ, s ) ∈ δ}. For any transition (s, i, o, ξ, s ) ∈ δ we write after(s, i, o) = s . Let us remark that due to the assumption that SFSMs are deterministically observable we have that after(s, i, o) is uniquely determined. Our derivation algorithm is presented in Figure 3. By considering the possible available choices we get a set of tests extracted from the specification M . We denote this set of tests by tests(M ). In this algorithm, the set of pending states Saux keeps track of the states of the test under construction whose definition has not been finished yet. A tuple (sM , ξ, sT ) ∈ Saux indicates that the current state in the traversal of the
Towards Testing Stochastic Timed Systems
347
specification is sM , that the random variable accounting for the elapsed time in the specification from the initial state is ξ, and that we did not conclude yet the description of the state sT in the test. The set Saux initially contains a tuple with the initial states (of both specification and test) and a random variable ξ0 following a Dirac distribution in 0 (i.e. no time has yet elapsed). For each tuple in Saux we may choose one possibility. It is important to remark that the second possibility is applied at most to one of the possible tuples. Thus, our derived tests correspond to valid tests as given in Definition 6. The first possibility simply indicates that the state of the test becomes a passing state. The second possibility takes an input and generate a transition in the test labelled by this input. Then, the whole sets of outputs is considered. If the output is not expected by the implementation, a transition leading to a failing state is created. This could be simulated by a single branch in the test, labelled by else, leading to a failing state (in the algorithm we suppose that all the possible outputs appear in the test). For the rest of outputs, we create a transition with the corresponding output and add the appropriate tuple to the set Saux . Finally, let us remark that finite test cases are constructed simply by considering a step where the second inductive case is not applied. For example, the test cases appearing in Figure 2 can be generated by applying the previous algorithm to the SFSM M2 given in Example 1. In addition, we have to define the random variables corresponding to the passing states. Given that each of these tests has a unique passing state, we will denote by ψi the random variable associated with the passing state of the test Ti . We have ψ1 = ξ1 + ξ1 + ξ2 , ψ2 = ξ2 + ξ3 , ψ3 = ξ1 , and ψ4 = ξ2 + ξ3 + ξ1 . The next result states that for any specification S we have that the test suite tests(S) can be used to distinguish those (and only those) implementations that conforms with respect to confs. However, we cannot say that the test suite is complete since both passing tests and the considered implementation relation have a probabilistic component. So, we can talk of completeness up to a certain confidence level. Proposition 1. Let I and S be SFSMs. For any 0 ≤ α ≤ 1 and multiset of timed executions H we have I confs(α,H) S iff I (α, H)−passes tests(S). Proof Sketch: I confs(α,H) S requires that I confns S and that for any trace belonging to both the specification and the implementation, the confidence of the random variable of the specification on the samples observed in the implementation is higher than α. The way our algorithm deals with non-stochastic information of the traces is quite similar to other test derivation algorithms. Regarding stochastic information, let us remark that the samples collected from the tests will be exactly the samples we apply to check whether the implementation relation holds. So, the conditions we require about the confidence of the random variables on the samples will be the same both to pass the test and to make the implementation relation to hold. The previous idea can be easily extended to some of the implementation relations presented in Section 5. For example, we may suppose that tests(S, π)
348
Manuel N´ un ˜ez and Ismael Rodr´ıguez
denotes the test suite generated by replacing the last instruction of the algorithm in Figure 3 by Saux := Saux ∪{(sM 1 , ξ+MShift(ξ1 , µξ1 ·π), s )}, and then applying the resulting algorithm. Proposition 2. Let I and S be SFSMs. For any 0 ≤ α ≤ 1, π ∈ IR+ , and multiset (α,H) S iff I (α, H)−passes tests(S, π). of timed executions H we have Iconfmπ
7
Conclusions and Future Work
We have introduced a model of stochastic timed processes and we have presented several implementation relations for this model. Each of them has some advantages and drawbacks, so experiments on them are necessary to find out their practical usefulness. In particular, the most appropriate relation is not checkable if we consider a grey/black-box testing framework. We have included time by means of the delay between the reception of an input and the generation of an output. This delay is given by a random variable. Regarding testing, we have defined an appropriate notion of test case and its application to the implementation under test. We have given a derivation algorithm producing, for each specification, a test suite. Finally, we have presented a notion of pseudo-completeness of a test suite, for a certain degree of confidence. A question that we do not address in this paper is test coverage as this is beyond the scope of a first approach to this difficult topic. However, we think that this is a relevant issue and we plan to confront it in the near future.
References 1. M. Ajmone Marsan, A. Bianco, L. Ciminiera, R. Sisto, and A. Valenzano. A LOTOS extension for the performance analysis of distributed systems. IEEE/ACM Transactions on Networking, 2(2):151–165, 1994. 2. M. Ajmone Marsan, G. Conte, and G. Balbo. A class of generalized stochastic petri nets for the performance evaluation of multiprocessor systems. ACM Transactions on Computer Systems, 5(2):93–122, 1984. 3. R. Alur and D. Dill. A theory of timed automata. Theoretical Computer Science, 126:183–235, 1994. 4. M. Bernardo and W.R. Cleaveland. A theory of testing for markovian processes. In CONCUR’2000, LNCS 1877, pages 305–319. Springer, 2000. 5. M. Bernardo and R. Gorrieri. A tutorial on EMPA: A theory of concurrent processes with nondeterminism, priorities, probabilities and time. Theoretical Computer Science, 202:1–54, 1998. 6. B.S. Bosik and M.U. Uyar. Finite state machine based formal methods in protocol conformance testing. Computer Networks & ISDN Systems, 22:7–33, 1991. 7. M. Bravetti and R. Gorrieri. The theory of interactive generalized semi-Markov processes. Theoretical Computer Science, 282(1):5–32, 2002. 8. D. Clarke and I. Lee. Automatic generation of tests for timing constraints from requirements. In 3rd Workshop on Object-Oriented Real-Time Dependable Systems, 1997.
Towards Testing Stochastic Timed Systems
349
9. R. de Nicola and M.C.B. Hennessy. Testing equivalences for processes. Theoretical Computer Science, 34:83–133, 1984. 10. A. En-Nouaary, R. Dssouli, and F. Khendek. Timed Wp-method: Testing real time systems. IEEE Transactions on Software Engineering, 28(11):1024–1039, 2002. 11. N. G¨ otz, U. Herzog, and M. Rettelbach. Multiprocessor and distributed system design: The integration of functional specification and performance analysis using stochastic process algebras. In 16th Int. Symp. on Computer Performance Modelling, Measurement and Evaluation (PERFORMANCE’93), LNCS 729, pages 121–146. Springer, 1993. 12. P.G. Harrison and B. Strulo. SPADES – a process algebra for discrete event simulation. Journal of Logic Computation, 10(1):3–42, 2000. 13. M. Hennessy. Algebraic Theory of Processes. MIT Press, 1988. 14. H. Hermanns, U. Herzog, and J.-P. Katoen. Process algebra for performance evaluation. Theoretical Computer Science, 274(1-2):43–87, 2002. 15. T. Higashino, A. Nakata, K. Taniguchi, and A. Cavalli. Generating test cases for a timed I/O automaton model. In 12th Workshop on Testing of Communicating Systems, pages 197–214. Kluwer Academic Publishers, 1999. 16. J. Hillston. A Compositional Approach to Performance Modelling. Cambridge University Press, 1996. 17. R. Lai. A survey of communication protocol testing. Journal of Systems and Software, 62:21–46, 2002. 18. D. Lee and M. Yannakakis. Principles and methods of testing finite state machines: A survey. Proceedings of the IEEE, 84(8):1090–1123, 1996. 19. N. L´ opez and M. N´ un ˜ez. A testing theory for generally distributed stochastic processes. In CONCUR 2001, LNCS 2154, pages 321–335. Springer, 2001. 20. N. L´ opez, M. N´ un ˜ez, and F. Rubio. Stochastic process algebras meet Eden. In Integrated Formal Methods 2002, LNCS 2335, pages 29–48. Springer, 2002. 21. D. Mandrioli, S. Morasca, and A. Morzenti. Generating test cases for real time systems from logic specifications. ACM Transactions on Computer Systems, 13(4):356–398, 1995. 22. M. N´ un ˜ez and I. Rodr´ıguez. Encoding PAMR into (timed) EFSMs. In FORTE 2002, LNCS 2529, pages 1–16. Springer, 2002. 23. J. Springintveld, F. Vaandrager, and P.R. D’Argenio. Testing timed automata. Theoretical Computer Science, 254(1-2):225–257, 2001.
Appendix. Statistics Background: Hypothesis Contrasts In this appendix we introduce one of the standard ways to measure the confidence degree that a random variable has on a sample. In order to do so, we will present a methodology to perform hypothesis contrasts. The underlying idea is that a sample will be rejected if the probability of observing that sample from a given random variable is low. In practice, we will check whether the probability to observe a discrepancy lower than or equal to the one we have observed is low enough. We will present Pearson’s χ2 contrast. This contrast can be applied both to continuous and discrete random variables. The mechanism is the following. Once we have collected a sample of size n we perform the following steps: – We split the sample into k classes which cover all the possible range of values. We denote by Oi the observed frequency at class i (i.e. the number of elements belonging to the class i).
350
Manuel N´ un ˜ez and Ismael Rodr´ıguez
– We calculate the probability pi of each class, according to the proposed random variable. We denote by Ei the expected frequency, which is given by Ei = npi . – We calculate the discrepancy between observed frequencies and expected 2 n i) frequencies as X 2 = i=1 (Oi −E . When the model is correct, this discrepEi ancy is approximately distributed as a random variable χ2 . – We estimate the number of freedom degrees of χ2 as k − r − 1. In this case, r is the number of parameters of the model which have been estimated by maximal likelihood over the sample to estimate the values of pi (i.e. r = 0 if the model completely specifies the values of pi before the samples are observed). – We will accept that the sample follows the proposed random variable if the probability to obtain a discrepancy greater or equal to the discrepancy observed is high enough, that is, if X 2 < χ2α (k − r − 1) for some α low enough. Actually, as such margin to accept the sample decreases as α decreases, we can obtain a measure of the validity of the sample as min{α | X 2 < χ2α (k − r − 1)}. According to the previous steps, we can now present an operative definition of the function γ which is used in this paper to compute the confidence of a random variable on a sample. Definition 16. Let ξ be a random variable and let J be a multiset of real numbers representing a sample. Let X 2 be the discrepancy level of J on ξ calculated as explained above by splitting the sampling space into the set of classes C = {[0, a1 ), [a1 , a2 ), . . . , [ak−1 , ak ), [ak , ∞)}, where k is a given constant and for i all 1 ≤ i ≤ k we have ai = q where P (ξ ≤ q) = k+1 . We define the confidence of ξ on J with classes S, denoted by γ(ξ, J), as min{α | X 2 < χ2α (k − 1)}. Let us comment some important details. First, given the fact that the random variables that we use in our framework denote the passing of time, we do not need classes to cover negative values. Thus, we will suppose that the class containing 0 will also contain all the negative values. Second, let us remark that in order to apply this contrast it is strongly recommended that the sample has at least 30 elements while each class must contain at least 3 elements.
Formal Design of Interactive Multimedia Documents Jean-Pierre Courtiat LAAS – CNRS 7 Av. du Colonel Roche 31077 Toulouse Cedex 4 – France [email protected]
Abstract. The expressiveness power and flexibility of high-level authoring models (such as W3C SMIL 2.0 language) used for editing complex interactive multimedia documents can lead authors to specify inter-media synchronization relations that cannot be met at document presentation time, leading often the document presentation to a temporal deadlock, called a temporal inconsistency. To avoid these undesirable behaviors, a document formal design method is presented in this paper for identifying and then possibly correcting temporal inconsistencies. It is shown how the results of the verification phase can be used by a scheduling automaton for avoiding undesirable temporal inconsistencies at presentation time, as well as for generating a new document temporal model free from temporal inconsistency. The proposed method is instantiated for the SMIL 2.0 authoring model. The automatic translation of a SMIL 2.0 document into a RT-LOTOS specification is addressed. The formal verification of the RT-LOTOS specification is performed using RTL (the RT-LOTOS Laboratory) developed at LAAS-CNRS. The scheduling of the document presentation, taking into account all the document temporal non-determinism, is performed through the use of a new type of time automaton, called a TLSA (Time Labeled Scheduling Automaton). Potential state space explosion problems are addressed at the level of the translation between a SMIL 2.0 document and a RT-LOTOS specification. Simple examples illustrate the main concepts of the paper and the results achieved.
1 Introduction Designing interactive multimedia documents addresses the issue of managing the coordinated presentation of different types of information (text, images, audio, video, etc.) possibly associated with user interactions. The expressiveness power and flexibility of high-level authoring models (such as W3C SMIL 2.0 language) used for editing complex interactive multimedia documents can easily lead authors to specify inter-media synchronization relations that cannot be met at document presentation time, leading often the document presentation to a temporal deadlock, called a temporal inconsistency. To avoid these undesirable behaviors, this paper presents a document formal design method for identifying and possibly correcting temporal inconsistencies. It is shown how the results of the verification phase can be used by a scheduling H. König, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 351–366, 2003. IFIP International Federation for Information Processing 2003
352
Jean-Pierre Courtiat
automaton for avoiding undesirable temporal inconsistencies at presentation time, as well as for generating a new document temporal model free from temporal inconsistency. The proposed method is instantiated for the SMIL 2.0 authoring model. The paper is organized as follows. Section 2 introduces the document formal design method. Section 3 explains how the temporal consistency analysis of interactive multimedia documents can be achieved relying on standard reachability analysis of RT-LOTOS specifications. Section 4 presents the techniques used for scheduling an interactive multimedia document based on a specific scheduling automaton synthesized from the reachability graph. Section 5 addresses the application of the formal design method to SMIL 2.0 interactive multimedia documents. Section 6 presents some conclusions.
2
The Formal Design Method
The proposed method provides a framework for the design (specification, verification and presentation) of complex Interactive Multimedia Documents (IMD). Relying on the formal description technique RT-LOTOS, and its associated simulation/ verification environment RTL, it yields three main contributions: it permits to define a formal semantics of the high-level document authoring model, describing without any ambiguity the behavior of the document presentation; it permits to check consistency properties on the RT-LOTOS formal specification derived from the authoring model, using standard verification techniques (reachability analysis and model checking); it permits to generate automatically a scheduling automaton from the underlying reachability graph, providing an easy way to automatically correct the document temporal structure by removing undesirable temporal inconsistencies. 2.1
Main Steps of the Formal Design Method
Main steps of the formal design method are presented in Figure 1. First step: an interactive multimedia document is edited using a high-level authoring model. The proposed design method is not specific to one modeling language. It applies to any authoring technique, which enables translation of document models into RT-LOTOS specifications. So far RT-LOTOS translation algorithms have been defined for an ad-hoc IMD authoring language easily translatable into RT-LOTOS [1], general-purpose authoring models like NCM [2,3], SMIL 1.0, and SMIL 2.0 [4]. Second step: the document’s temporal structure expressed in the selected authoring model is translated into a RT-LOTOS specification. The purpose is to define a general and “automatic” translation procedure between the high-level authoring model and RT-LOTOS, in such a way a document author does not need to learn the RTLOTOS language. Third step: a minimal reachability graph is derived from the RT-LOTOS specification obtained at Step 2. Using reachability analysis, it is then possible to perform a consistency analysis of the document. If all the temporal constraints of the document
Formal Design of Interactive Multimedia Documents
High-Level edition of the IMD
Correction of the IMD
Inconsistent Inconsistent IMD IMD
Automatic into Automatictranslation translation into an an RT-LOTOS specification RT-LOTOS specification
Derivation of the theminimal minimal Derivation of reachability graph reachability graph
353
Analysis of of consistency consistency Analysis properties properties
Potentially Consistent IMD Derivation ofthe theconsistent consistent Derivation of scheduling graph scheduling automaton
Enforcing the controllability of the document presentation
Presentation ofofthe IMD Presentation the IMD
Fig. 1. Main steps of the formal design method
can be met at presentation time (i.e. when the document is consistent), then the presentation scheduling may be performed based on a scheduling automaton directly derived from the reachability graph. This scheduling automaton is simple and provides means to ensure the controllability of the document presentation (controllability is required when the document is only potentially consistent, as defined in paragraph 3.2). That means that the document presentation is scheduled while enforcing some time constraints at document presentation time to avoid undesirable inconsistencies. On the opposite, if the document is inconsistent, its high-level description must be revisited and there is a feedback to the initial authoring step. 2.2
RT-LOTOS
RT-LOTOS [5] is a temporal extension of the LOTOS (Language of Temporal Ordering Specification) Formal Description Technique. It is very similar to the ET-LOTOS [16] temporal extension of LOTOS, with the exception of the way time nondeterminism is handled. RT-LOTOS defines an operator for expressing time nondeterminism: the latency operator. More detailed information on RT-LOTOS and its relationships with other temporal extensions of LOTOS can be found in [5]. The RT-LOTOS FDT is supported by a toolset developed at LAAS-CNRS and called RTL (RT-LOTOS Laboratory) [5]. Main functionalities of RTL are presented in Figure 2. Detailed information on how to use RTL is available at http://www.laas.fr/RT-LOTOS.
354
Jean-Pierre Courtiat simulation
verification RT-LOTOS Specification
Simulation [rtl]
Traces - step by step (debug) - intensive (measure) > observers
Translation [rtl] Simulation
Timed Automaton
[dtasim]
DTA
Reachability Analysis [rtl]
Region Graph - analyze > observers
Translation [dta2kronos]
Kronos Automaton model-checking (true/false)
Fig. 2. The RTL toolset
Using RTL, a timed automaton, called a DTA [5], is derived from a RT-LOTOS specification, on which a reachability analysis is performed leading to a region graph, called a minimal reachability graph. Each node of the reachability graph represents a reachable region, which can include an infinite number of configurations according to the current value of time. These configurations are gathered in a same region when they meet the same reachability properties in terms of future and past actions [6]. Each arc of the graph corresponds either to the occurrence of an RT-LOTOS action, or a global progression of time (an arc labeled by the action time or simply t). Reachability analysis can also be carried out on the fly while the DTA is generated. Different tools are used for the derivation and visualization of the minimal reachability graph, such as ALDEBARAN (which outputs an equivalent reachability graph according to various equivalence relations such as the observational equivalence), DOTTY, ATG and BCG [7]. 2.3
Illustration
To illustrate some characteristics of the design method we will adopt the simple interactive multimedia document presented above. This scenario has been edited with the SMIL 2.0 authoring language and we assume for the moment that a RT-LOTOS specification has been generated for this scenario. The scenario describes the parallel presentation of a composition of an interactive image (interactiveButton) with the sequential composition of an exclusive presentation of two audio objects (audio1 and audio2) followed by a video object (video). The presentation duration of objects audio1, audio2, video and interactiveButton are re-
Formal Design of Interactive Multimedia Documents
355
spectively [0,5] seconds, [0,5] seconds, indefinite1 and [0,20] seconds, and the following synchronization constraints are considered: (i) the presentations of audio1, audio2 and interactiveButton must start simultaneously, (ii) the presentations of video and interactiveButton must end simultaneously, (iii) if an user interaction occurs during the presentation, the scenario is interrupted and then immediately restarted.
audio1 [0,5] video [0,+∞) audio2 [0,5] start
end
interactiveButton [0,20]
Fig. 3. Illustration of an interactive multimedia scenario
3
Verification of the Temporal Consistency Properties of an Interactive Multimedia Document
Depending on how document synchronization constraints are defined at authoring time, there exists a risk to create inconsistent scenarios, i.e. situations where different contradictory synchronization requirements cannot be satisfied together at presentation time, leading to undesirable deadlocks during the document presentation. Consistency analysis of an interactive multimedia document consists in performing a reachability analysis of the underlying RT-LOTOS specification, consistency properties being expressed through reachability properties defined on this graph. A reachability graph is a labeled transition system where actions correspond to the begin or end of the presentation of media objects, to user interactions, to an action that represents the triggering of a hypermedia link (triggerLink) and to the progression of time. 3.1
Illustration of Temporal Inconsistencies
Many reasons may lead to temporal inconsistencies when an author uses a high-level and flexible authoring model. Examples are for instance: inconsistencies between the expected duration of the nodes and the logic of the synchronization links enforcing their termination; conflicting synchronization links; bad timing of the links, etc. Let us consider for instance the simple scenario of Figure 4. It describes the presentation of three pictures P1, P2 and P3 (each one with a fixed duration of 5s) followed by the presentation of a text (T) (no timing constraint is associated with the 1
An indefinite duration characterizes the presentation of an object inside the interval [0,+∞[
356
Jean-Pierre Courtiat dur [5,5]
dur [5,5]
P1
dur [5,5]
P2
dur [0,+∞)
T
P3
start
dur [15, +∞)
end
A
Fig. 4. Illustration of a temporally consistent scenario
presentation of T). The start of the presentation of P1 activates an audio object (A). Since A has a duration greater than 15s, the scenario is consistent and the end of A determines the end of T. Let us assume now that the author changes his scenario by providing some user interactivity, permitting the user to stop the audio presentation at any time (Figure 5). It is then obvious that the scenario may present a temporal inconsistency depending on the time at which the user interaction occurs. If the presentation of A terminates before the start of the presentation of T, the latter cannot terminate, leading to a deadlock. dur [5,5]
dur [5,5]
P1
P2
start
dur [5,5]
P3
dur [0,+∞)
T
dur [15, +∞)
end
A
Fig. 5. Illustration of a temporally inconsistent scenario
3.2
Document Consistency Definitions
The basic idea about verifying the temporal consistency of a document is to analyze in the underlying minimal reachability graph the reachability of the action characterizing the end of the document presentation (action end). Definition 1: a document is potentially consistent if there exists at least one path starting from the reachability graph initial node leading to an action characterizing the end of the document presentation (action end). Such a path is called a consistent path. A path, which is not consistent, is called an inconsistent path. Definition 2: a document is consistent if the action characterizing the start of the document presentation (action start is by construction the only action enabled in the reachability graph initial node) is necessarily followed, some time later, by an action characterizing the end of the document presentation (action end). This means that all the paths starting from the reachability graph initial node are consistent. Note that each consistent path of the reachability graph corresponds to a potential scheduling solution for the document presentation. The purpose of the document presentation scheduling, addressed in Section 4, is to ensure that the document presentation follows a consistent path, and that, in the presence of several consistent paths, it follows the best consistent path with respect to some criteria.
Formal Design of Interactive Multimedia Documents
3.3
357
Characterization of Temporal Inconsistencies
The reachability graph expresses all the possible behaviors for the presentation of the document. Temporal inconsistencies are mostly the consequence of the occurrence of internal and/or external non-deterministic events [8]. Internal non-deterministic events are associated with the controlled adjustment of the presentation duration of a media; inconsistencies generated by internal nondeterministic events, i.e. the associated inconsistent paths in the reachability graph, may easily be removed at scheduling time since these events are controllable by the scheduler. The scheduler will thus be able to decide, without any interaction with the environment, at which time to start and end the presentation of each particular media; the document will be successfully presented as soon as it is potentially consistent. External non-deterministic events are associated with the occurrence of external actions which are not directly controllable by the scheduler, such as user interactions; in this case the document could only be successfully presented if all the paths depending on external non-deterministic events are consistent; however, it is still possible to automatically correct the document presentation temporal structure, by removing from the reachability graph the associated inconsistent paths, as soon as it is possible to express refined time constraints for the occurrence of the external nondeterministic events. If such a correction may be performed, the document will be successfully presented as soon as it is potentially consistent. As an illustration, let us consider the multimedia scenario presented in Figure 6. The associated reachability graph is illustrated in Figure 7, where the inconsistent paths are marked in bold. The occurrence of the internal non-deterministic events (see the time progression (t) between nodes 2-(30 30)->2-(30.5 30.5), 12-(0 0)->12-(30 30), 12-(19.5 30)->12-(20 30) and 7-(10 0)->7-(0.5 0.5)) and the external nondeterministic events (see the user interactions (user) between nodes 2-(30 30)->4-(30 0), 3-(0 30)->10-(0 0), 12-(9.5 30)->11-(0 0) and 12-(0 30)->11-(30 0)) can easily be checked. Thus the document is only potentially consistent and the scenario presentation will deadlock if the duration of objects A, B and C does not respect the synchronization constraints or if a user interaction occurs during the presentation of A or during the first 10 seconds of the presentation of B. A [0,+∞]
B [10,20]
start
end
C [30,40]
Fig. 6. A scenario with external and internal non-deterministic events
Enforcing the controllability of the scenario consists in removing all the inconsistent paths, generated either by internal or external non-deterministic events. Removing inconsistent paths generated by internal non-deterministic events is performed by the
358
Jean-Pierre Courtiat 0−() i(start) 1−() i(sA_sC) 2−(0 0) t 2−(10 10) t 2−(10.5 10.5) t 2−(20 20) t 2−(20.5 20.5)
i(eA)
t i(eA)
i(eA)
2−(30 30)
t i(eA)
i(eA)
2−(30.5 30.5)
user
t i(eA)
2−(40 40)
i(eA)
user
user i(eC) i(eC) 5−(30 0)
i(eA)
4−(30 0) i(eA)
3−(0 30.5) user
user
3−(0 10.5) i(sB)
3−(0 20.5)
user
12−(0 10.5)
t
t
12−(0 40)
t i(eA)
6−(0 970)
i(sB)
user
12−(20 40) user
user
user
6−(0 0)
11−(0 0)
11−(20 0)
11−(30 0)
user
i(eC) user
user user
7−(0 0) i(eC)
12−(0 30) t
12−(30 30) i(eC)
t 7−(0.5 0.5) t 7−(30 0)
i(eC)
t
12−(10 30.5) t
t
12−(10 40)
user
t 12−(40 40)
i(eC)
12−(0 10) t
12−(20 30)
i(sB) i(sB)
12−(9.5 30)
t
11−(10 0)
i(eC)
i(sB)
t
12−(10 30)
t
user i(sB)
12−(0 0)
3−(0 10)
12−(0 20)
t
user user
i(sB)
12−(0 20.5)
t
i(eA)
3−(0 40) i(sB)
12−(19.5 30)
i(eC)
5−(1000 970)
3−(0 0)
i(sB)
12−(0 30.5) i(sB)
5−(30.5 0.5) i(eA)
3−(0 20)
i(sB)
10−(0 0)
t
3−(0 30)
i(eC)
i(eC) 7−(20 0) i(eB)
7−(10 0)
t
i(eB)
i(eC)
8−() i(end) 9−()
Fig. 7. Reachability graph with external and internal non-deterministic events
scheduler at presentation time without any modification to the document temporal structure; however, removing inconsistent paths generated by external nondeterministic events leads to a correction of the document temporal structure: new temporal windows, i.e. new time constraints are associated with the occurrence of the external events (for instance the occurrences of an user interaction); this correction mechanism has been completely automated and will be detailed in the next section.
4
Scheduling of an Interactive Multimedia Document
As previously discussed, a document may be either potentially consistent, or consistent or even inconsistent. If the document is inconsistent, that means that there is no consistent path in the reachability graph leading the document presentation to its normal end; as a consequence, the document cannot be presented and both its logical and temporal structures have to be revisited at the design level.
Formal Design of Interactive Multimedia Documents
359
If the document is consistent, that means that all the paths in the reachability graph are consistent and each path represents a valid presentation solution; two points have then to be addressed: • Point 1: how to represent in a more compact and operational way all the consistent paths; this point deals with the synthesis of a scheduling automaton (called a TLSA [9]) from the reachability graph; it will be addressed in paragraph 4.1 • Point 2: how to select among the consistent paths, the one which is the best with respect to some criteria; this point deals with the scheduling of an IMD based on a TLSA; it will be addressed in paragraph 4.2 If the document is potentially consistent, that means that there is at least one consistent path in the reachability graph. All the inconsistent paths have then to be removed from the reachability graph; this is automatically performed by removing the undesirable blocking nodes, as well as the paths starting from the reachability graph initial node and leading to these blocking nodes (see [11] for details). Once inconsistent paths have been removed, a new reachability graph is obtained which is by definition consistent (it was potentially consistent before removing the inconsistent paths). Points 1 and 2 have then to be addressed for this new reachability graph. 4.1
Generating a Scheduling Automaton
Timed automata were proposed to model real-time systems with finite states [10]. A timed automaton is characterized by a set of finite control states and a finite number of clocks. The evolution of all the clocks follows the same rate and measures the amount of time elapsed since they were initialized. Each transition of the system can reset certain clocks, and is described by an enabling condition expressed in the form of a constraint depending on the values of the clocks. A TLSA features some specific characteristics, which differentiate it from traditional timed automata. A TLSA has as many clock as the number of states defined in the automaton. These clocks are called timers in order to distinguish them from the traditional clocks. Each timer measures the time spent by the automaton in the associated control state. No explicit function defines when a timer must be initialized. Indeed, the timer associated with a control state is reset when the automaton enters this state, and its current value is frozen when the automaton leaves it (for this reason, we say that a TLSA is a single clock model, since, for any control state, there is only one active timer). Two temporal conditions are associated with each TLSA transition: • A firing window (indicated as W), which defines the temporal interval inside which the transition can be triggered. It is represented as an inequality to be satisfied by the timer associated with the current control state; • An enabling condition (indicated as K) which defines the temporal constraints to be satisfied in order to trigger the transition. It is represented as a conjunction of inequalities to be satisfied by a subset of timers, with exception of the timer associated with the current control state. Intuitively, W characterizes the time during which the system can remain in the current control state. The enabling condition is related only to previous timers and
360
Jean-Pierre Courtiat
thus characterizes the enabled transitions according to the behavior of the system. The formal semantics of the TLSA was defined in [9], and the algorithms for deriving automatically a TLSA from a reachability graph were developed in [11]. In summary, a TLSA is a single clock automaton (there is always only one running clock), which can be used for scheduling a document. However, some rules must still be defined to allow the orchestration of the document based on the occurrence of the actions described by the transitions of the TLSA. These rules are introduced in paragraph 4.2. In order to illustrate the generation of a TLSA, let us consider our initial example of Figure 3. The reachability graph associated with this scenario is presented in Figure 8(a). This reachability graph describes all the consistent and inconsistent presentation behaviors of the document. The consistent reachability graph (Figure 8(b)) is obtained by eliminating all the undesirable blocking nodes (nodes 11-(1000.5 1000.5) and 14-(1000.5 1000.5)) as well as the paths leading to these blocking nodes. The TLSA derived from the consistent reachability graph is presented in Figure 9. 0-() i(start) 1-() i(triggerLink<1>) 2-() i(linkExec<1>) 3-() i(presentDoc) 4-() i(sInteractiveButton) 7-(0 0)
i(excl_sAudio1_sAudio2) 5-(0 0)
t activateEvent activateEvent 9-(0 0)
i(excl_eAudio1_eAudio2)
7-(10 10)
i(excl_eAudio1_eAudio2)
i(excl_eAudio1_eAudio2)
9-(10 0)
8-(0 0)
i(sVideo) 19-(0 0)
t
i(sVideo)
9-(0.5 0.5) t
6-(0 0)
i(sInteractiveButton)
i(excl_eAudio1_eAudio2) i(excl_eAudio1_eAudio2) 9-(10 10)
i(excl_eAudio1_eAudio2)
activateEvent
i(sInteractiveButton) 14-(0 0)
i(excl_eAudio1_eAudio2)
t 10-(0 10)
10-(0 0)
activateEvent i(sVideo)
i(sVideo)
activateEvent
11-(0 0) t 11-(0.5 0.5) t 11-(1000.5 1000.5)
i(eInteractiveButton_eVideo)
15-() i(eInteractiveButton_eVideo) 12-()
i(triggerLink<0>) 16-()
i(triggerLink<1>) 13-()
14-(20 20) t
14-(20.5 20.5) t 14-(1000.5 1000.5)
i(endRequest) 17-() i(end) 18-()
(a) Fig. 8. Reachability graphs associated with the scenario of Figure 3
i(linkExec<1>)
Formal Design of Interactive Multimedia Documents
0-() i(start) 12-() i(excl_sAudio1_sAudio2)
i(sInteractiveButton)
5-(0 0)
7-(0 0)
i(excl_eAudio1_eAudio2)
t
6-(0 0)
i(excl_eAudio1_eAudio2)
i(sVideo)
i(sInteractiveButton)
19-(0 0)
7-(10 10)
i(excl_eAudio1_eAudio2) 8-(0 0)
i(sInteractiveButton)
i(sVideo)
9-(10 0) activateEvent
i(eInteractiveButton_eVideo)
9-(0 0)
i(excl_eAudio1_eAudio2)
14-(0 0) t
activateEvent
activateEvent
i(excl_eAudio1_eAudio2)
10-(0 0) activateEvent
activateEvent
i(sVideo)
14-(20 20)
11-(0 0)
i(eInteractiveButton_eVideo) 15-() i(end) 18-()
(b) Fig. 8. (Cont.) 0 t0=0 i(start) 12 t12=0 i(excl_sAudio1_sAudio2) 5 t5=0 i(sInteractiveButton)
t5=0 i(excl_eAudio1_eAudio2)
7 t11=0 i(eInteractiveButton_eVideo)
0<=t7<=10 activateEvent
6 0<=t7<=10 i(excl_eAudio1_eAudio2)
9
8 t9=0 i(excl_eAudio1_eAudio2)
t6=0 i(sVideo) 19
t8=0 activateEvent
10
t8=0 i(sVideo)
t19=0 i(sInteractiveButton)
14 t10=0 i(sVideo)
11
t6=0 i(sInteractiveButton)
0<=t14<=20-t7 activateEvent
t14=20-t7 i(eInteractiveButton_eVideo) 15 t15=0 i(end) 18
Fig. 9. TLSA derived from the consistent reachability graph (Figure 8(b))
361
362
Jean-Pierre Courtiat
In the TLSA of Figure 9, transitions 12-5 and 5-7 represent the start of the mutual exclusive presentation of audio1 and audio2, followed by the start of presentation of interactiveButton. If there is no user interaction on interactiveButton within 10 seconds (an user interaction is represented here by action activateEvent), the end of the mutual exclusive presentation may occur followed immediately by the start of the presentation of video (transitions 7-8 and 8-14). Later, the presentation of interactiveButton terminates as well as the presentations of video and of the scenario (transitions 14-15 and 15-18). If however, a user interaction takes place during the presentation of the scenario (transitions 7-9, 8-10 and 14-11), the presentation is interrupted and then restarted (transition 11-12). Note that the presentation of video is synchronized to the end of interactiveButton (which occurs within [0,20] seconds - transition 14-15). 4.2
Scheduling an Interactive Multimedia Document Based on the TLSA
The TLSA (Time Labeled Scheduling Automaton) was proposed in [9] as a scheduling graph, which permits the temporal formatting (the definition of the valid temporal intervals for the presentation) of a document. The scheduling of the document can be carried out based on timers which measure the time the system "spent" in each state of the automaton and which is also used to determine the triggering condition of a transition. Moreover, each transition of the TLSA is associated with the actions that can be managed by the presentation system such as starting or ending a presentation, announcing the occurrence of a user interaction, etc. The scheduling of an IMD using a TLSA can be accomplished based on the definition of some important issues, such as handling active and passive actions. An action is said active if its occurrence does not depend on its environment (e.g., the end of presentation of an image decided by the system). Thus, active actions may be related to start and end actions of all media objects (e.g., video, audio, text, image, etc.). These actions can be generated as soon as the scheduler decides when to trigger them based on their associated temporal firing window (W) specified in the associated TLSA An action is said passive if its occurrence does depend on the environment (e.g., an user interaction, or the end of the presentation of a continuous media). The occurrence of passive actions cannot be predicted, but can be controlled within their valid temporal firing window in the TLSA. Thus, the scheduler waits until the environment triggers these actions and ensures that they are triggered inside their temporal firing window. The notion of active and passive actions enables to determine scheduling policies for the execution of all the actions for the presentation of a document; let thus W = [min,max] be the firing window associated with transition t, τ the firing time of transition t, and a the action labeling transition t. • If a is active, then τ = min; if a is passive, then τ ∈ [min, max] Note finally that the scheduler may force at τ = max the firing of a passive action or the firing of an exception action.
Formal Design of Interactive Multimedia Documents
5
363
Application of the Design Method to SMIL 2.0 Documents
The Synchronized Multimedia Integrated Language (SMIL) [4] has been applied to the design and presentation of interactive multimedia documents distributed over the Web. One important feature of SMIL 2.0 is its flexible temporal model, which eventually can lead authors to describe synchronization constraints that cannot be resolved consistently at document presentation time (tools like Grins, RealOne behave differently in such circumstances). Efforts have been reported for defining a formal semantics of SMIL [13] but few work [15] has been reported on analyzing consistency properties of interactive multimedia documents [1,2,3,8,14] authored in SMIL. The purpose of this section is to show how the formal design method proposed in the paper may be applied to SMIL 2.0 interactive multimedia documents.
SMIL 2.0 Document Operational Components
Contextual Components
RT-LOTOS Specification
Consistent SMIL 2.0 Document
Consistency Analysis
Contextual Information
Scheduling Automaton (TLSA)
SMIL 2.0 Players
TLSA Player
Fig. 10. Application of the formal design method to SMIL 2.0 documents
A SMIL 2.0 document may be decomposed into operational and contextual components. The operational components describe the logical and temporal structure of the document; they are translated into a RT-LOTOS specification. The contextual components describe essentially the spatial synchronization requirements as well as a description of the document content (type and location of the media); they are translated into a data structure called the Contextual Information. Consistency analysis is applied as previously on the RT-LOTOS specification derived from the operational components. Assuming that the document is potentially consistent, the document temporal structure may be corrected by generating a consistent scheduling automaton (TLSA). Two approaches are possible for presenting the resulting consistent document. Either a new consistent SMIL 2.0 document is generated from the TLSA and the Contextual Information, and the presentation may then be performed using commercial
364
Jean-Pierre Courtiat
tools like Grins or RealOne; or, the TLSA and the associated Contextual Information are directly presented using a dedicated tool, the TLSA Player, developed at LAASCNRS. Two main issues related to the application of the design method to SMIL 2.0 documents are addressed in the sequel: (i) how to translate the operational components into a RT-LOTOS specification, (ii) how to minimize the potential state space explosion.
5.1
Translating the Operational Components into a RT-LOTOS Specification
The translation procedure is performed in two phases. In the first phase, two data structures, the temporal tree and the synchronization arcs are derived from the SMIL document. The temporal tree describes hierarchically the components of the document (media objects, containers like par (parallel composition) or seq (sequential composition) or excl (exclusive composition), anchors, …) and their temporal characteristics. The synchronization arcs describe the causal relations among the components; they are expressed by condition-action relations; a condition is related to the occurrence (possibly associated with a time constraint) of either the begin or the end of a component, or an user interaction: an action is related to the execution of the begin or the end of a component. In the second phase, two additional data structures, called ProcRTL and the synchronization points, are derived; from these data structures, the RT-LOTOS processes are automatically generated. ProcRTL describes the structure of each RT-LOTOS process (process Id, behavior type referring to a library of predefined processes, observable gates, hidden gates, sub-processes, …) and the synchronization points define the synchronization relations to be applied when composing the RT-LOTOS processes. Details of the translation procedure can be found in [15]. 5.2
Overcoming the State Space Explosion
If each operational component of a SMIL 2.0 document is described by an elementary RT-LOTOS process, the resulting specification corresponds to the parallel composition with synchronization of all these processes, leading potentially to a state space explosion of the associated reachability graph. To overcome this problem, three main techniques have been implemented in the RT-LOTOS translation procedure: 1. To replace single actions that are known to occur simultaneously by composed actions, 2.
To transform interleaved actions into serialized actions by taking into account their associated temporal constraints, and
3.
To define so-called semantics actions (such as latest_, earliest_, excl_) whose semantics is to be interpreted at presentation time, instead of being detailed in RT-LOTOS.
Formal Design of Interactive Multimedia Documents
365
These techniques have permitted to reduce drastically the size of the derived reachability graph (for instance, from 63 nodes and 116 transitions to 30 nodes and 24 transitions for the scenario in Figure 3).
6
Conclusion
The formal design method presented in this paper is not dependent on a particular high-level authoring model, and different applications of this design method have been carried out. The underlying formal description technique, RT-LOTOS, remains hidden to the document author, which makes the approach more accessible and intuitive. One main advantage of this design method is that the author has not to worry about the temporal consistency of his document presentation. He can precisely specify the temporal constraints he wants to enforce leaving all the others temporal constraints unspecified (i.e. defined as [0, ∞[). This will normally lead to numerous temporal inconsistencies which can automatically be removed at the level of the reachability graph, leading then to a consistent scheduling automaton (TLSA), characterizing all the valid time constraints for both internal and external events. A potential shortcoming of the approach is related to the state space explosion, which is taken into account at the level of the RT-LOTOS translation procedure. Acknowledgments I would like to thank Roberto Cruz de Oliveira, Celso Alberto Saibel Santos, Paulo Nazareno Maia Sampaio and Christophe Lohr who have been actively involved in this project. Thanks are also due to Pierre de Saqui-Sannes for proofreading this paper.
References 1. Courtiat, J.-P.; Oliveira, R.C. Proving temporal consistency in a new multimedia synchronization model. In Proc of ACM Multimedia’96, pp.141-152, Boston, USA, Nov. 1996 2. Santos, C.A.S.; Soares, L.F.G.; Souza, G.L.; Courtiat, J.-P. Design methodology and formal validation of hypermedia documents. In: Proc. of ACM Multimedia’98, Bristol, UK, Sep. 1998. pp.39-48 3. Santos, C.A.S.; Courtiat, J.-P.; Saqui-Sannes, P. A design methodology for the formal specification and verification of hypermedia documents. In Proc. of FORTE/PSTV’98, Paris, France, November, 1998. Chapman & Hall 4. http://www.w3.org/AudioVideo/ 5. Courtiat, J.P.; Santos, C.A.S.; Lohr, C.; Outtaj, B. Experience with RT-LOTOS, a temporal extension of the LOTOS formal description technique. In Computer Communications 23, July 2000. http://www.laas.fr/RT-LOTOS 6. Yannakakis, M; Lee, D. An efficient algorithm for minimizing real-time transition systems. In Proc of CAV’93, Lecture Notes in Computer Science, Vol 697, Springer Verlag, 1993
366
Jean-Pierre Courtiat
7. http://www.inrialpes.fr/vasy/cadp.html 8. Santos, C.A.S.; Sampaio, P.N.M.; Courtiat, J.-P. Revisiting the concept of hypermedia document consistency. In Proc of ACM Multimedia’99, Orlando, USA, November 1999 9. Lohr, C.; Courtiat, J.P. From the specification to the scheduling of time-dependent systh tems. In Proc of 7 International Symposium on Formal Techniques in Real-Time and Fault-Tolerant Systems, Oldenburg, Germany, September 2002, Lecture Notes in Computer Science, Vol 2469, Springer Verlag, pp 129-145 10. Alur, R.; Dill, D.L. The theory of timed automata. In Proc of REX Workshop “Real-Time: Theory in Practice”, Lecture Notes in Computer Science, Vol 600, Springer Verlag, 1991 11. Lohr, C. Contribution à la conception de systèmes temps-réel s’appuyant sur la technique de description formelle RT-LOTOS, PhD Dissertation (in french), Université Paul Sabatier, Toulouse, December 2002 12. Rutledge, L. SMIL 2.0 – XML for Web Multimedia. In IEEE Internet Computing, pp. 7884, September-October 2001 13. Jourdan, M. A formal semantics of SMIL: a Web standard to describe multimedia documents. In Computer Standards and Interfaces, 23 (2001), pp. 439-455, 2001 14. Layaida, N.; Keramane, C. Mantaining Temporal Consistency of Multimedia Documents. In Proc of ACM Workshop on Effective Abstractions in Multimedia, San Francisco, 1995 15. Sampaio, P. Conception formelle de documents multimédia interactifs : une approche s’appuyant sur RT-LOTOS, PhD Dissertation (in french), Université Paul Sabatier, Toulouse, April 2003 16. Léonard, L ; Leduc, G. An introduction to ET-LOTOS for the description of time-sensitive systems. In Computer Networks and ISDN Systems, Vol 29, 1997, pp. 271-292
Progressive Solutions to a Parallel Automata Equation Sergey Buffalov1, Khaled El-Fakih2, Nina Yevtushenko1, and Gregor v. Bochmann3 1 Tomsk
State University, Russia [email protected] , [email protected] 2 Department of Computer Science, American University of Sharjah, UAE [email protected] 3 School of Information Technology and Engineering, University of Ottawa, Canada [email protected]
Abstract. In this paper, we consider the problem of deriving a component X of a system knowing the behavior of the whole system C and the other components A. The component X is derived by solving the parallel automata equation A ◊ X ≅ C. We present algorithms for deriving the largest progressive solution to the equation that combined with A does not block any possible action in C and we introduce a new simulation relation between automata in order to characterize all progressive solutions.
1
Introduction
The equation solving problem is to describe a behavior of a component X of a system knowing the specifications of the other components and of the whole system. This problem may be formulated by the equation A ◊ X ≅ C over finite automata, where A represents the specification of the known part of the system, ◊ is a parallel composition operator, ≅ is a trace equivalence relation, and C represents the specification of the whole system. In 1980, a first paper [2] (see also [7]) gives a solution to the problem for the case when the system behavior is described in terms of labeled transition systems (LTS). This work was later extended to the cases where the behavior of the components is described in CCS or CSP [8], by FSM [9, 14] or input/output automata [11, 6, 3]. The applications of the equation solving problem were first considered in the context of the design of communication protocols, where the components A and C represent two protocol entities [7]. Later it was recognized that this method could also be useful for the design of protocol converters in communication gateways [5, 12, 6], and for the selection of test cases for testing a module in a context [10]. Another application area of equation solving is the design of controllers for discrete event systems [13, 1]. Solutions to the automata equation A ◊ X ≅ C are characterized in [3, 14] as proper reductions of the largest solution. However, not each solution to the equation is of practical use. Usually we are required to get a composed system that does not block any action that is possible in the specification, i.e. we are interested in what is called a progressive solution [6]. It is desirable to determine the largest progressive solution [6, 14] to the equation (if it exists) that contains all progressive H. König, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 367–382, 2003. IFIP International Federation for Information Processing 2003
368
Sergey Buffalov et al.
solutions. In this case, a progressive solution is a reduction of the largest progressive solution. That is, the set of traces of a progressive solution is a subset of that of the largest progressive solution. The largest progressive solution can be viewed as a reservoir of all possible solutions of our interest. However, not each reduction of the largest progressive solution possesses the property. For this reason, in order to determine an optimal solution we need to completely characterize all the reductions of the largest progressive solution that are progressive. The problem has been studied in [3] for Input/Output automata. In this paper, we generalize the results given in [6]. Given a solution to the automata equation, we suggest a procedure that derives its largest progressive reduction. First, we split the states of the given solution and obtain an equivalent perfect automaton. This automaton has a nice property: If a given sequence cannot be in a progressive solution, then this sequence takes the perfect automaton from its initial state to a state that is only reachable through non-progressive sequences. Consequently, we delete from the perfect automaton all states that are only reachable through non-progressive sequences and we obtain the largest progressive reduction of a given solution. Moreover, in this paper, we consider automata with both accepting and non-accepting states and we establish necessary and sufficient conditions for a solution to be progressive. For this purpose, for each state of a perfect automaton, we associate an appropriate collection of regular sets of actions. A solution is progressive if and only if there exists a simulation relation between the solution and the perfect automaton such that for each state pair of the simulation relation, the language generated at the state of the solution intersects each set of the collection associated with the state of the perfect automaton. In Section 3 we present the details of the above described work, while in Section 2 we include all related definitions. In Section 4 we conclude the paper.
2
Finite State Automata Relations, Operators, and Composition *
An alphabet V is a finite nonempty set of symbols. As usual, we let V denote the set of all finite sequences of symbols of V including the empty sequence ε. A language * * over the alphabet V is a subset of V . Given a sequence α ∈V and an alphabet W, a Wrestriction of α, written α ↓W, is obtained by deleting from α all symbols that belong to the set V \ W. If α has no letters from alphabet W then the W-restriction α ↓W is the empty word. In the paper, we consider only regular languages, i.e. languages that are represented by finite state automata [4]. A finite state automaton, often called an automaton throughout the paper, is a quintuple P = 〈S, V, δ P, s0, FP〉, where S is a finite nonempty set of states with the initial state s0 and a subset FP of final (or accepting) states, V is an alphabet of actions, and δ P ⊆ S ×V × S is a transition relation. We say that there is a transition from a state s to a state s ' labeled with an action v, if and only if the triple (s, v, s ') is in the transition relation δP. The automaton P is called deterministic, if for each state s ∈ S and any action v∈V there exists at most one state s ', such that (s, v, s ')∈δ P. If P is not deterministic, then it is called nondeterministic.
Progressive Solutions to a Parallel Automata Equation
369
As usual, the transition relation δP of the automaton P can be extended to sequences over the alphabet V. The extended relation is also denoted by δP and is a subset of * S × V × S. By definition, for each state s∈S of the automaton P the triple (s, ε, s) is in the relation δP. Given a triple (s, α, s ')∈δ P and an action v∈V, the triple (s, α v, s '') belongs to δ P, if and only if (s ', v, s '')∈δ P. s * Given a state s of the automaton P, the set L (P) = {α ∈V | (s 0, α, s)∈δ P} is called the * language accepted at the state s and the set Ls(P) = {α ∈V | ∃ s '∈FP ((s, α, s ')∈δ P)} is called the language, generated at the state s. The language, generated by the automaton P at the initial state, is called the language generated or accepted by the automaton P and is denoted by L(P), for short. The language L(P) is the union of all languages accepted at final states of P. By definition, the language L(P) has the empty sequence, if and only if the initial state of P is final. It is worth to note that different automata can accept the same language. When we are interested only in the language of a given automaton we can use a reduced form of the automaton that does not have superfluous states at which the empty language is generated. In this paper, we call an automaton reduced if the language generated at each state is not empty1 The automaton 〈{s 0}, V, δ, s 0, {s0}〉, where δ = S×V×S, is called chaos and is denoted by CHAOS(V). By definition, the chaos automaton CHAOS(V) accepts the * language V . A state s of an automaton is said to be reachable, if there exists a sequence that takes the automaton from the initial state to s, i.e. the state s accepts a nonempty language. The automaton is called connected, if each state is reachable. Any state that is not reachable, can be deleted from the automaton without affecting the language of the automaton. By this reason, we further consider only connected automata. Here, we recall some relations between finite automata defined over the same alphabet. Let P = 〈R, V, δ P, r 0, FP〉 and B = 〈T, V, δ B, t 0, FB 〉 be automata. A relation ϕ ⊆ T × R, is called a simulation relation [1], if for each pair (t, r)∈ϕ the following holds: 1. t ∈ FB ⇒ r ∈ FP. 2. For each (t, v, t ')∈δ B there exists r'∈R such that (r, v, r ')∈δ P and (t ', r')∈ϕ. The automaton P simulates the automaton B or the automaton B is said to be simulated by the automaton P, written P ⊇ϕ B, if there exists a simulation relation ϕ, such that the pair (t0, r0) of the initial states is in the relation ϕ. The state t of the automaton B is called a reduction of the state r of automaton P, written t ≤ r, if the language of R generated at state t is a subset of that generated by the P at state r. Automaton R is called a reduction of the automaton P, written R ≤ P, if the language of R is a subset of that of P, i.e. L(R) ⊆ L(P). An automaton accepting the empty language is a reduction of any automaton over the same alphabet. The simulation relation refines the reduction relation [1], i.e. if P ⊇ϕ B then B ≤ P. The converse is not always true. However, a deterministic automaton simulates any of its reductions, i.e. the following statement holds. Proposition 1. [1]. Given a deterministic automaton P, let B be an automaton over the same alphabet. Then B is a reduction of P, if and only if P simulates B.
1
A reduced automaton may have equivalent states, i.e. states where equal languages are generated.
370
Sergey Buffalov et al.
Automata P and B are called trace equivalent or simply equivalent, written R ≅ B, if they accept the same language, i.e. B is a reduction of P and vice versa. Let P = 〈R, V, δ P, r 0, FP〉 and R = 〈Q, W, δ R, q 0, FR 〉 be two automata. We further describe some operations over finite state automata that will be used throughout the paper. Deterministic representation. Given the automaton P, there exists an equivalent deterministic automaton obtained from P by applying the algorithm of subset construction [4]. We denote this automaton by DFA (P) and call it the deterministic representation of P. Note that a state of DFA (P) is a subset of states of P and accepts the intersection of their languages. Due to the construction, the following statement holds. Prefix closure. Given the automaton P, the automaton is obtained from P by declaring all states of P as accepting states. The language of the automaton < P > is the prefix closure of that of P, i.e. the language of < P > comprises each prefix of each sequence of the language L(P). Intersection. If alphabets V and W intersect then the intersection P ∩ R of automata P and R is the largest connected sub-machine of the automaton 〈S × Q, V∩ W, δ, (s0, q0), FP × FR〉. Given an action a∈V∩ W and a state (s, q), there is a transition at the state (s, q) labeled with a, if and only if there are transitions at states s and q labeled with a, i.e. δ = {((s, q), a, (s', q')) | (s, a, s ')∈δP ∧ (q, a, q ')∈δR }. The automaton P ∩ R accepts the intersection of languages L(P) and L(R). If V and W are disjoint then intersection of P and R is not defined, since the alphabet of an automaton can not be empty. Proposition 2. Given an automaton P, let B = 〈T, V, δ B, t 0, FB 〉 be a reduced reduction of P and t be a state of B. There exists a state r of P such that the pair (t,r) is a state of the intersection of B ∩ P. Moreover, if P is deterministic, then for each state (t,r) of the intersection B ∩ P state t is a reduction of r. Restriction. Given an alphabet U, the U-restriction of P is the deterministic form * P↓U of the automaton 〈S, U, δ, s 0, FP〉, where δ = {(s, u, s ') | ∃ α∈V ∃ (s, α, s ')∈δ P * (α ↓U = u)}. The automaton P↓U accepts the language L(P)↓U = {α ∈U | ∃β ∈L(P) (α = β ↓U)} called the U-restriction of the language L(P). The restriction of the language is empty if and only if the language is empty. Due to the definition of the restriction, the following statement can be established. Proposition 3. Given the U-restriction P↓U of the automaton P and state p = {s1, ..., sk} p of the P↓U, let L be the language accepted at state p. The set p is the set of all states of p P that accept the language over the alphabet V with the U-restriction L . Expansion. Given an alphabet U, the U-expansion of P is the automaton P↑U = 〈S, V ∪U, δ, s 0, FP〉, where δ = δ P ∪{(s, u, s) | s ∈ S ∧ u ∈ U \ V }. The automaton P↑U is obtained from P by adding at each state a loop transition labeled with each action of the alphabet U \ V. If U is a subset of V then the automaton P↑U coincides with the automaton P. Automaton P↑U accepts the language L(P)↑U = * {α ∈(V ∪ U ) | ∃ β ∈L(P) (α ↓V = β )} called the U-expansion of the language L(P). The U-expansion of the language is empty if and only if the language is empty.
Progressive Solutions to a Parallel Automata Equation Ext1 Ext
U Ext2
Ext1
A Int
Ext
B
Fig. 1. Automata composition
A
U Ext2
371
Int X C
Fig. 2. Equation solving paradigm
Consider a system of two interacting automata A = 〈T, W, δ A, t0, FA〉 and B = 〈S, V, δ B, s0, FB〉 shown in Figure 1. We assume A and B execute each action of the set V∩W together when both of them are ready to execute the action. Moreover, automata A and B share actions from the sets Ext1 = W \ V and Ext2 = V \ W, respectively, with an environment and execute these actions independently from each other, but not simultaneously. Moreover, we suppose that the subset U ⊆ V∩ W of actions shared by the automata can be observed externally. Thus, actions of the set Ext = Ext1 ∪ Ext2 ∪ U are called external, while actions from the alphabet Int = (V ∩ W) \ U are called internal. For an external observer, the automata interaction is described by the sequence of external actions. However, two consecutive external actions can be separated by a sequence of internal actions. Given the set Ext of external actions, the composition of automata A and B is the automaton A ◊Ext B ≅ (B↑W ∩ A↑V)↓Ext. The composition accepts the language (L(A)↑W ∩L(B)↑V)↓Ext. By definition, if a component automaton accepts the empty language, then the composition accepts the empty language as well.
3
Solving Automata Equations
Let A = 〈S, W, δ A, s0, FA〉 and C = 〈Q, Ext, δ C, q0, FC〉 be two deterministic reduced automata. A notation A ◊Ext X ≅ C is called an equation w.r.t. a free variable X, which is considered to be an automaton with a given alphabet V ⊆ W ∪ Ext. One may think of a composition A ◊Ext X as a network possessing the desired external behavior C as it is shown in Figure 2. The automaton A is usually called a context, and the automaton C is usually called a specification. Accepting states of the specification can be viewed as finishing an appropriate task [13]. An automaton B over the alphabet V is called a solution to the equation A ◊Ext X ≅ C, if A ◊Ext B ≅ C. Since the set of classes of equivalent automata is ordered by the reduction relation, we can introduce the largest solution that includes all solutions to the equation A ◊Ext X ≅ C as its reductions, i.e. each solution to the equation is a reduction of the largest solution. Not each solution to the equation is known to be of practical use. A practical solution is required to be progressive. A solution is called progressive if, when combined with the context, it will not block the occurrence of an external event if the latter is possible in the specification. If an equation has a progressive solution we will be interested in characterizing all such solutions in order to be able to select an
372
Sergey Buffalov et al.
optimal one according to some criteria. In general, the equation may have an infinite number of progressive solutions. Thus, the problem of characterizing all of them appears to be not trivial. In this paper, we further show that if the equation has a progressive solution then it has a largest progressive solution. The set of traces of a progressive solution is a subset of that of the largest progressive solution. Thus, the largest progressive solution can be viewed as a general solution to the equation. Any progressive solution is a reduction of the largest. However, the converse is not true. Therefore, to completely characterize progressive solutions we first want to find the largest progressive solution to the equation A ◊Ext X ≅ C and then describe all its reductions that are progressive. We note that when the unknown component has no external actions a technique for the derivation of the largest progressive solution is proposed in [6].
e
a
A
1
2
1
e,e
1
2
e,e,i
c
e1, e2, x, i
e1, e2, x
1
i
b
1. Context A
2. Specification C
3. Automaton B1
Fig. 3. The example of equation solving
x
x
A
x
aA 1
aA 1
e1 2
e ,e
e 1, e 2
1
2 1
2
e ,e
1
i
x
e ,e ,i
2
e 1, e 2, i
1
e,e,i
cA 1
x
B
x
bA 1
2. Automaton Λ(A, B1,C)
1. Automaton B2
x
bB 1
3.AutomatonΛ(A, B2,C)
Fig. 4. Progressive and non-progressive solutions
As an example of equation solving (see Figure 3), we consider the context A defined over the alphabet W = {e1, e2, i}, and the specification C defined over the alphabet Ext = {e1,e2, x} of external actions. Moreover, consider the automaton B1 defined over the alphabet V = {e1, e2, i, x} and shown in Figure 3.3. The behavior of the whole system A ◊{e , e , x} B1 is equivalent to the given specification. Thus, B1 is a 1 2
solution to the equation A ◊Ext X ≅ C. 3.1
A Progressive Solution
In this subsection, we introduce the notion of a progressive solution to the equation A ◊Ext X ≅ C. Then, we give a detailed overview of the method how to derive a largest
Progressive Solutions to a Parallel Automata Equation
373
progressive solution if it exists. Afterwards, we present the consecutive steps of this method along with application examples. Let A = 〈S, W, δ A, s0, FA〉 be a deterministic context, C = 〈Q, Ext, δ C, q0, Q〉 be a deterministic specification. Given an automaton P = 〈R, V, δ P, r0, FP〉 over alphabet V, a state (s, r, q) of the automaton A↑V ∩ P↑W ∩ C↑W∪V is called progressive, if the Ext-restriction of the language generated at the (s, r, q) coincides with the language generated by the specification C at state q, i.e. L(s, r, q)( A↑V ∩ P↑W ∩ C↑W ∪V )↓Ext = Lq(C ). Otherwise, the state (s, r, q) is called non-progressive. A solution B to the equation A ◊Ext X ≅ C is called progressive, if each state in A↑V ∩ B↑W ∩ C↑W ∪V is progressive. By definition, if B is a progressive solution then B combined with the context does not block an external event that is possible in the specification. Hereafter, for simplicity of presentation, we let the automaton Λ (A, P, C) denote the automaton A↑V ∩ P↑W ∩ C↑W∪V. A state of Λ (A, P, C) is a triple (s, r, q), where s is a state of the automaton A, r is a state of the automaton P, and q is a state of the automaton C. We note that the equation A ◊Ext X ≅ C can have both progressive and nonprogressive solutions. For example, consider the context A shown in Figure 3.1 and the specification C shown in Figure 3.2. The solution B1 shown in Figure 3.3 is not progressive, since the automaton Λ(A, B1, C), shown in Figure 4.2, has a nonprogressive state c1A. On the other hand, another solution B2, shown in Figure 4.1, is progressive, since all the states of the automaton Λ (A, B2, C), shown in Figure 4.3, are progressive. Since a progressive solution is defined through properties of the automaton Λ (A, P, C), we establish some properties of the states of the automaton and of the states of its V-restriction to the alphabet V of a solution. By definition of the expansion operator, we establish conditions for a triplet (s, r, q) to be reachable from the initial state of the intersection A↑V ∩ B↑W ∩ C↑W∪V. Proposition 4. Let (s, r, q) be a triplet, where s is a state of the automaton A, r is a state of the automaton P, and q is a state of the automaton C. The triplet is a state of the intersection A↑V ∩ B↑W ∩ C↑W∪V if and only if the there exists a sequence β over the alphabet W∪V such that the W-restriction of β takes the context A from the initial state to state q, the V-restriction of β takes the automaton P from the initial state to state r, and the Ext-restriction of β takes the specification C from the initial state to state q. Proposition 5. Given a deterministic automaton P over the alphabet V, let B be a reduction of P and (t,r) be a state of the intersection B∩ P. Given states s and q of A and C, if the triplet (s,t,q) is a state of the intersection A↑V ∩ B↑W ∩ C↑W∪V , then the triplet (s,r,q) is a state of the intersection A↑V ∩ P↑W∩ C↑W∪V. Moreover, the language generated at state (s,t,q) of the A↑V ∩ B↑W ∩ C↑W∪V is a subset of that generated at state (s,r,q) of the automaton A↑V ∩ P↑W ∩ C↑W∪V. Consider now the state p = {(s1, r1, q1), ..., (sk, rk, qk)} of the V-restriction of the p automaton A↑V ∩ P↑W∩ C↑W∪V and let L be the language accepted at state p. Due to Proposition 3, the set p is the set of all states of the intersection that accept the p language with the V-restriction L . Therefore, each state r1, ..., rk accepts the language
374
Sergey Buffalov et al.
p
L in the automaton P (Proposition 4). Since P is deterministic, there exists only one state accepting the language, i.e. the following statement holds. Proposition 6. Given the V-restriction of the automaton A↑V ∩ P↑W∩ C↑W∪V, let p = {(s1, r1, q1), ..., (sk, rk, qk)} be a state of the V-restriction. If P is deterministic then r1 = ... = rk. Given a solution M to the equation A ◊Ext X ≅ C, we now establish necessary and sufficient conditions for a state the of the automaton Λ (A, M, C) to be progressive Given an automaton A = 〈S, W, δ A, s 0, FA〉 representing the context and an automaton C = 〈Q, Ext, δ C, q 0, Q〉 representing the specification, consider the automaton M = 〈R, V, δ M, r0, FM〉. Let (s, r, q) be a state of the automaton Λ (A, M, C) and e ∈ Ext be an external action such that there is a transition from state q with the action e. If the action e takes the automaton C from the state q to a non-final state then we define the * set Re[(s, r, q), e] to be the set of sequences β ∈(W ∪V ) such that β is a prefix of a sequence in the language generated at state (s, r, q) and β ↓Ext = e. If the action e takes the automaton C from the state q to a final state then the set Re[(s, r, q), e] is defined to * be the set of sequences β ∈(W ∪V ) such that β is in the language of the automaton Λ (A, M, C) generated at state (s, r, q) and β ↓Ext = e. Formally, if the action e takes the automaton C from the state q to a non-final state then Re[(s, r, q), e] = {β | β ↓Ext = e & β ∈ < L(s, r, q)( Λ (A, P, C))>}. If the action e takes the automaton C from the state q to a final state then Re[(s, r, q), e] = {β | β ↓Ext = e & β ∈ L(s, r, q)( Λ (A, P, C))}. Based on the construction of the sets Re[(s, r, q), e], we can show, by induction, that each state of the automaton Λ (A, M, C) is progressive if and only if for each state (s, r, q) of the automaton and each external action e for which there is a transition from state q with the action e, the set Re[(s, r, q), e] is not empty. The above result is stated in the following proposition. Proposition 7. Given a solution M to the equation A ◊Ext X ≅ C, each state of the automaton Λ (A, M, C) is progressive if and only if for each state (s, r, q) of the automaton and each external action e for which there is a transition from state q with the action e, the set Re[(s, r, q), e] is not empty. Here we note that since the restriction and prefix closure of a regular language are regular, each set Re[(s, r, q), e] is a regular set and thus, can be represented as an automaton.
3.2
An Overview of the Method for Solving the Problem
For automata that accept prefix-closed languages, and for a composition topology where the alphabet of a solution is a subset of that of the context, i.e. V ⊆ W, it is shown in [6] that the equation A ◊Ext X ≅ C has a progressive solution, if and only if a largest progressive solution to the equation exists. In Section 3.5 we generalize the result for the more general composition topology shown in Figure 1. Moreover, we propose an algorithm that returns the largest progressive reduction of an automaton over the alphabet V (if exists). As a corollary, we obtain a largest progressive solution if we start from the chaos automaton CHAOS(V) or the largest solution to the equation. The obtained largest progressive solution has a nice property that it includes all
Progressive Solutions to a Parallel Automata Equation
375
progressive solutions, and thus can be used later for the characterization of these solutions. We also note that each automaton P over the alphabet V can be considered as an automaton over a bigger alphabet V′⊇V with the same set of transitions and final states. For this reason, if the equation A ◊Ext X ≅ C has no progressive solution over the alphabet W ∪ Ext then the equation has no progressive solution over any alphabet V ⊂ W ∪ Ext. Therefore, without any loss of generality we only consider the largest progressive solution over the alphabet V = W ∪ Ext. The problem of characterizing all progressive reductions of a largest progressive solution is not trivial, since the number of these reductions is infinite and, moreover, not each reduction of a largest progressive solution is progressive. We solve the problem by introducing the notion of a perfect automaton, the operation of a regular extension, and regular simulation relation. The idea behind the approach is described in details in Section 3.4. 3.3
Largest Progressive Solutions
Given two progressive solutions to the equation A ◊Ext X ≅ C, their union is also a progressive solution. In other words, the set of all progressive solutions ordered by the reduction relation is a semilattice. In general, the semilattice of all progressive solutions can be infinite, and thus the problem of determining if it has a largest element, i.e. if the equation A ◊Ext X ≅ C has a largest progressive solution, is not trivial. It is known [6] [14] that a solvable equation has a largest solution, i.e. there exists an automaton M, such that any solution to the equation is a reduction of M. Therefore, before we determine a largest progressive solution, we could check if the equation is solvable at all. Given a context A = 〈S, W, δ A, s 0, FA〉 and a specification C = 〈Q, Ext, δ C, q 0, Q〉 where each state is final, in [7] it is shown that the equation A ◊Ext X ≅ C is solvable if and only if the automaton A◊C\A◊ C 2 is a solution to the equation. The automaton A◊C\A◊ C is not the largest solution to the equation since the language of this automaton does not comprise traces that do not participate in the composition with the given context. The largest solution to an arbitrary automata equation is the automaton M ≅ A ◊ Ext C [YVPBS99] if the composition A ◊Ext M is equivalent to C. If the composition is not equivalent to C, then the equation has no solution. The automaton B1 shown in Figure 3.3 is the chaos machine over alphabet {e1, e2, i, x} and therefore, B1 is the largest solution to the equation A ◊Ext X ≅ C, where A and C are shown in Figures 3.1 and 3.2, respectively. If the largest solution M = 〈R, V, δ M, r0, FM〉 to the equation A ◊Ext X ≅ C exists and is progressive, then it is a largest progressive solution. Otherwise, in order to obtain a largest progressive solution or to show that it does not exist, we first build a so-called perfect automaton Mperfect and then we use this automaton to get the largest reduction that is a progressive solution to the equation. The perfect automaton can also be used for the complete characterization of all progressive solutions of a given automata 2
C denotes the automaton that accepts the complement of the language of C.
376
Sergey Buffalov et al.
equation. In the following two subsections we give the ideas and the details of building a perfect automaton and its largest progressive reduction. Let P = 〈R, V, δ P, r0, FP 〉 be an automaton over the alphabet V. Given a nonprogressive state (s, r, q) of the automaton Λ(A, P, C), let β be a sequence that takes this automaton from its initial state to the state (s, r, q). We call the corresponding r sequence α ∈ L (P), where α is the V-restriction of β (i.e. α = β ↓V), a non-progressive r sequence. In other words, if a sequence α ∈ L (P) is non-progressive then there is no progressive solution with this sequence. Otherwise, the sequence α is called progressive. That is for a progressive sequence α, each sequence β with the Vrestriction α must take the automaton Λ(A, P, C) from the initial state to a progressive state. In order to derive the largest reduction of P that is a progressive solution (if it exists) we have to eliminate all non-progressive sequences from the language of the P. However, in general, the number of non-progressive sequences is infinite. On the other hand, we cannot delete states from the automaton P, since a state of the automaton P can accept both progressive and non-progressive sequences. As an example, consider the context A shown in Figure 3.1, the specification C shown in Figure 3.2, and the largest solution B1 shown in Figure 3.3. The initial state A of B1 accepts a non-progressive sequence ii. However, if we delete this state, this implies that there is no progressive solution. Nevertheless, the solution B2 (Figure 4.1) is progressive. i.e. there exists a progressive solution. Consequently, we refine the automaton P and obtain the equivalent automaton Pperfect such that the largest reduction is the largest sub-machine of Pperfect that does not have non-progressive states. The number of sub-machines of an automaton is finite and the largest sub-machine without non-progressive states can be obtained by iterative deleting non-progressive states. Therefore, we refine P by splitting its states in order to obtain an equivalent automaton Pperfect such that each state of Pperfect accepts either progressive or nonprogressive sequences. The obtained automaton Pperfect is called perfect (w.r.t. the given context and specification). Each sub-machine obtained from Pperfect by deleting from Pperfect one of its non-progressive states, with its incoming and outgoing transitions, is perfect too. Thus, we (iteratively) delete from Pperfect all states that accept nonprogressive sequences. If the initial state of Pperfect is deleted, then we conclude that there is no progressive solution to the given equation that is a reduction of the P. Otherwise, the obtained automaton is the largest reduction of P that is a progressive solution. A largest progressive solution can be obtained when the initial automaton P is the largest solution to the equation or it is the chaos automaton over alphabet V, i.e. CHAOS(V), that generates the language V*. Any automaton over alphabet V is a reduction of CHAOS(V). 3.3.1 Perfect Automata In this subsection, we first discuss the idea of constructing a perfect automaton. Afterwards, we present an algorithm for building such an automaton. The problem we face with an automaton P over alphabet V that in particular can be seen as a largest solution to the equation, is the following. Given a state r of P, there could exist sequences β1 and β2 in the language of Λ(A, P, C) with the V-restrictions α1 and α2 such that the sequence β1 takes the automaton Λ(A, P, C) from the initial state
Progressive Solutions to a Parallel Automata Equation
377
to the triplet (s1, r, q1) that is progressive, while the β2 takes the automaton from the initial state to the triplet (s2, r, q2) that is non-progressive. Therefore, sequences α1 and α2 accepted at the state r of the automaton P possess different features: sequence α1 is progressive while α2 is a non-progressive sequence. Our objective is to delete the state r from P because it is reachable through the non-progressive sequence α2. However, when deriving the largest progressive reduction of the P we cannot delete r, since it is also reachable through the sequence α1 that can be executed by a progressive solution. Consequently, for such two sequences, we would like to split r into several states and obtain a perfect automaton Pperfect such that these sequences take Pperfect to two different states. As a result, we will not have any triplet in Λ(A, Pperfect, C) that is reachable by two sequences such that the V-restriction of these sequences are equal to α1 and α2. Therefore, each state r′ of Pperfect will only be reachable through either progressive or non-progressive sequences. This allows us later to delete state r′ if it accepts nonprogressive sequences without losing a progressive solution that is a reduction of the automaton P. Formally, given the context A and the specification C, an automaton P = 〈R, V, δ P, r0, FP〉 is called perfect (w.r.t. the given context and specification), if for any state (s, r, q) of the automaton Λ (A, P, C) the V-restriction of the language accepted at the state (s, r, q) coincides with the language accepted at the state r of the r (s, r, q) ( Λ (A, P, C) )↓V. We further let Pperfect denote the automaton P, i.e. L (P) = L perfect automaton obtained from P. Proposition 8. Given a perfect automaton Pperfect (w.r.t. a given context A and specification C), each state of Pperfect accepts either non-progressive or progressive sequences. Moreover, each sub-machine, Sub(Pperfect), obtained from Pperfect by deleting from Pperfect one of its non-progressive states with its incoming and outgoing transitions, is also perfect. Given an automaton P over the alphabet V, the idea of constructing a perfect automaton Pperfect that is equivalent to P is as follows. For each sequence α in the language of the automaton P, we determine the subset of all triplets in Λ (A, P, C) reachable through sequences with the V-restriction equal to α. In general, for many sequences in the language of P, we will have the same subset of triplets in Λ (A, P, C). Each triplet of a subset accepts the language of sequences with the same Vrestriction (Proposition 3). Consider states s and q of the automata A and C such that the triplet (s, r, q) is a state of the subset. Due to Proposition 4, the V-restriction of the s (s, r, q) q s q ∩ L (C) where L (A) and L (C) are languages accepted at intersection L (A) ∩ L (s, r, q) states s and q, equals to L . The latter implies that such subsets of triplets can serve as states of the automaton Pperfect. Consequently, since each triplet of the subset accepts the language with one and the same set of V-restrictions, then the V-restrictions of the sequences accepted by the triplets are either progressive or non-progressive, depending if the subset includes a non-progressive triplet. We then add to the language of Pperfect, all sequences of the language of P that do not participate in the composition with the context A. This is done in order for Pperfect to be equivalent to P. For example, the automaton B1 shown in Figure 3.3 is not perfect. The progressive sequence e1 and the non-progressive sequence e1i take the automaton B1 to the same state A. On the contrary, the automaton B2 shown in Figure 4.1 is perfect. Here we note that for every automaton P, there exists an equivalent perfect automaton Pperfect. Below we propose an algorithm to derive Pperfect.
378
Sergey Buffalov et al.
Algorithm 1. Deriving the perfect automaton Pperfect of P Input: The automaton P = 〈R, V, δ P, r0, FP〉, context A = 〈S, W, δ A, s 0, FA〉, and specification C = 〈Q, Ext, δ C, q 0, FC〉. Output: The deterministic perfect automaton Pperfect that is equivalent to P. Declare all states of A↑V and C↑W ∪V as accepting states and derive the automaton Λ (A, P, C) = A↑V ∩ P↑W ∩ C↑W ∪V. Restrict the intersection to the alphabet V and let P′ = 〈R′, V, δ P′, r′0, FP′〉 denote the resulting automaton. The automaton Pperfect = 〈R ∪ R′, V, δ , r′0, FP′ ∪ FP〉 is obtained from P and P′ as follows. The initial state of Pperfect is the initial state of P′, and the transition relation δ contains the union of the transition relations δ P′ and δ P of both automata P′ and P. Moreover, for each transition (r,a,r′) of P, we add a transition with the label a from the subset of triplets of P′ comprising the triplet (s, r, q) to state r′ of P if and only if there is no transition with the label a from the subset.
Theorem 1. The automaton Pperfect returned by Algorithm 1 is deterministic, equivalent to P and perfect (w.r.t. the given context and specification). € 3.3.2 An Algorithm for Deriving a Largest Progressive Solution Given the equation A ◊Ext X ≅ C, let P be an automaton over the alphabet V. We let Pperfect denote the perfect automaton for P. Below, we present an algorithm that trims Pperfect by iteratively deleting its states that correspond to non-progressive states in Λ (A, Pperfect, C). If the initial state is deleted in Pperfect, then none of the reductions of P is a progressive solution to the A ◊Ext X ≅ C. Otherwise, the obtained submachine PLargest-Prog. of Pperfect is the largest progressive reduction of P. Algorithm 2. Deriving a largest progressive solution Input: The automaton P = 〈R, V, δ P, r0, FP〉, context A = 〈S, W, δ A, s 0, FA〉, and specification C = 〈Q, Ext, δ C, q 0, FC〉. Output: The largest reduction PLargest-Prog. of P that is a progressive solution to the equation A ◊Ext X ≅ C if it exists. Step-1. Derive, using Algorithm 1, the perfect deterministic automaton Pperfect that is equivalent to the P and the automaton Λ (A, Pperfect, C). Step-2.If a state (s, r, q) of the automaton Λ (A, Pperfect, C) is non-progressive then: -Delete from the automaton Pperfect the state r and all the states that become unreachable from the initial state; -Delete from the automaton Λ (A, Pperfect, C) each state that has the second component equal to r and all the states that become unreachable from the initial state; -Repeat Step 2 of the algorithm until no more states can be deleted in the automaton Λ (A, Pperfect, C). If the initial state is deleted then the equation A ◊Ext X ≅ C has no progressive solutions that are reductions of P. Otherwise, the obtained submachine PLargest-Prog. of Pperfect is the largest reduction of P that is a progressive solution to the equation A ◊Ext X ≅ C.
Progressive Solutions to a Parallel Automata Equation
(A
x
)
e1 e,e
1
2
i
cCp1
2
e,i
bA 1
x e 1, e
p
)
2
x
x
bBp1
x
e 1, e 2, x , i
1. The perfect automaton for B1
aA p 1
i
(B
A
e 1, e 2, i
2
1
(C p )
x
aAp1
e 1, e 2, i
e,e,i
cA 1
x
p
e 1, e 2
aA 1
1
e1, e2
x e
379
2. Automaton Λ(A,Mperfect,C)
bB p 1 3.Automaton Λ(A,Mperfect,C)
Fig. 5. Deriving a largest progressive solution. If we start with the chaos machine CHAOS(V) (i.e. P = CHAOS(V)) or with the largest solution M (i.e. P = M) to the equation A ◊Ext X ≅ C, Algorithm 2 returns a largest progressive solution to the equation if it exists. As an application example of Algorithm 2, we consider the context A and the specification C shown in Figures 3.1 and 3.2, respectively. We assume that {e1, e2, i, x} is the alphabet of a solution X to the equation A ◊{e , e , x} X ≅C. The largest solution 1 2 M = B1 to this equation shown in Figure 3.3 is not progressive. Therefore, first, we apply Step 1 of the above algorithm to M and we derive the perfect deterministic automaton Mperfect shown in Figure 5.1. For the sake of simplicity, we rename the states of Mperfect as shown in Figure 5.1, where Ap = aA1, Bp = bA1, Cp = cA1. The automaton Λ (A, Mperfect, C) is shown in Figure 5.2. State cCp1 of this automaton is not progressive. Consequently, in Step 2 we delete from Λ (A, Mperfect, C) all the states that include state c, i.e. cCp1, and we obtain the automaton shown in Figure 5.3. Moreover, we delete state Cp from the perfect automaton Mperfect. Since the automaton in Figure 5.3 does not have non-progressive states, the algorithm terminates and returns the automaton shown in Figure 4.1 as the largest progressive solution. 3.4
Characterization of Progressive Solutions and Re-simulation Relation
A characterization of progressive solutions to the equation A ◊Ext X ≅ C over I/O automata is proposed in [3]. In this section, we introduce a new Re-simulation relation between finite automata that allows us to describe all progressive solutions for parallel automata equations. That is we propose a complete characterization of all progressive solutions of the automata equation A ◊Ext X ≅ C. Our characterization is very close to that proposed in [3]. We associate with each state of a largest progressive solution a family of regular sets. A reduction of the largest progressive solution is a progressive solution if and only if it is simulated by the largest progressive solution and for each pair (t,r) of the simulation relation, the language of the reduction at state t intersects each regular set of the family associated with the state r of the largest progressive solution. We recall that if the largest solution to a given automata equation is progressive then it is a largest progressive solution. Moreover, we note that we may have many
380
Sergey Buffalov et al.
largest progressive solutions to a given equation. Unfortunately, not each largest progressive solution can be used for the complete characterization of all progressive solutions. However, the largest progressive solution that is perfect can be used for the complete characterization of all progressive solutions. Given an arbitrary largest progressive solution ML, each progressive solution is a reduction of ML. However, not each reduction of ML is progressive. By definition, a reduction B = 〈T, V, δ B, t 0, FB〉 of ML is progressive if and only if each state of the automaton Λ (A, B, C) is progressive. Given a state (s, t, q) of Λ (A, B, C), let β∈ L (s, t, q) ( Λ (A, B, C) ) be a sequence such that the V-restriction α of β (i.e. α =β ↓V) takes the intersection B ∩ ML of automata ML and B to state pair (t, r). Since B is a reduction of the deterministic ML, for a given t there always exists such r. Now, let (s, r, q) be a state of the automaton Λ (A, ML, C) that is reachable from the initial state through the sequence β. Since ML is progressive, each state (s, r, q) of the automaton Λ (A, ML, C) is progressive. This means that for each external action e that can be executed at state q of the specification C the set of sequences Re[(s, r, q), e] is not empty (Proposition 7) and thus, the V–restriction Re[(s, r, q), e]↓V of Re[(s, r, q), e] is also not empty. Since B is a reduction of ML, the set of sequences generated at state (s, t, q) of Λ (A, B, C) is a subset of that generated at state (s, r, q) of Λ (A, ML, C) (Proposition 5). Therefore, for (s, t, q) to be progressive, at least one sequence from the set Re[(s, r, q), e]↓V should be generated at state t. Therefore, for each state (s, r, q) and for each external action e produced at state q, we associate the corresponding set of sequences Re[(s, r, q), e]↓V with state r of ML. We call the automaton ML with associated sets of sequences a regular extension of ML, and we denote it by Re (ML ). Therefore, for a reduction B of ML to be progressive, it is sufficient that for each pair (r, t) in the intersection ML ∩ B, the automaton B at state t generates at least one sequence from each set of sequences associated with r. In this case, we say that ML Re-simulates B. Unfortunately, for an arbitrary largest progressive solution that is not a perfect automaton, we could have a progressive solution that does not satisfy the above condition. This happens when for some (s, r, q) of the automaton Λ (A, ML, C) there does not exist a corresponding state (s, t, q) in Λ (A, B, C). However, by construction, we have selected un-needed (or superfluous) sequences from all the sets that relate to (s, r, q) and every external action e that can be produced at state (s, r, q), independent of whether there exists a (s, t, q). Actually, for this reason, we could have progressive solutions that are not Re-simulated by ML. However, the above cannot happen for a perfect automaton due to Theorem 1 and according to the following proposition. Proposition 9. Given the context A and specification C, let Mperfect= 〈R, V, δ M, r 0, FM〉 be a deterministic perfect automaton that is equivalent to a largest progressive solution ML of the equation A ◊Ext X ≅ C. Let the automaton B be a reduction of Mperfect, a pair (t, r) be a state of the intersection B ∩ Mperfect, and states s and q be states of the automata A and C. If the automaton Λ (A, Mperfect, C) has a state (s, r, q) then the automaton Λ (A, B, C) has a state (s, t, q). Consequently, in order to have a complete characterization of all progressive solutions over a given alphabet, we use a largest progressive solution MPerfect that is a deterministic perfect automaton. The automaton Mperfect has the nice property that each progressive solution is Re-simulated by it and vice versa.
Progressive Solutions to a Parallel Automata Equation
381
By definition, if a triple (s, r, q) is not a state of the automaton Λ (A, Mperfect, C), then for each external action e ∈ Ext the set Re[(s, r, q), e] is empty. We denote by Re(r) the set of all nonempty sets Re[(s, r, q), e]↓V, for all (s, q, e)∈ S× Q × Ext. Given an automaton Mperfect, we let the pair 〈Mperfect, Re〉 denote the regular extension of the automaton Mperfect, where Re is a collection of all Re(r), where r is a state of Mperfect. An automaton B = 〈T, V, δ B, t 0, FB〉 is said to be simulated by the regular extension of an automaton M = 〈R, V, δ M, r 0, FM〉, if B is simulated by M with the simulation relation ϕ ⊆ T × R, such that for each pair (t, r)∈ϕ the prefix-closure of the language generated at state t of the automaton B intersects each set from Re(r), i.e. the following holds: Re (r) ≠ ∅ ⇒ ∀L ∈ Re (r) (L ∩ Lt(B) ≠ ∅). The simulation relation ϕ with the above property is called a regular simulation relation or simply a Re-simulation relation. Let A = 〈S, W, δ A, s 0, FA〉 be the context and C = 〈Q, Ext, δ C, q 0, Q〉 be a reduced deterministic specification. Due to Theorem 1, if there exists a progressive solution to the equation A ◊Ext X ≅ C then there exists a perfect automaton Mperfect such that r (s, r, q) L (Mperfect) = ( L ( Λ (A, Mperfect, C) ))↓V. Mperfect can be derived as proposed in Algorithm 1. Theorem 2. Given a deterministic perfect largest progressive solution Mperfect to the equation A ◊Ext X ≅ C, a reduction B of the automaton Mperfect is a progressive solution to the equation if and only if B is Re-simulated by Mperfect. €
4
Conclusions
In this paper we address the problem of characterizing progressive solutions to a composed automata equation where the automata communicate by rendezvous. A progressive solution is of special interest, since when combined with the context it does not block any action of the environment that is possible according to the specification. Particularly, we have proposed a technique for deriving the largest reduction of an automaton that is a progressive solution to the equation (if it exists). The technique can be used in order to determine the largest progressive solution. However, not each reduction of the largest progressive solution is progressive and therefore, the problem of characterizing all progressive solutions is not trivial. In order to solve the problem, we have introduced a new Re-simulation relation between finite automata that allows us to describe all progressive solutions. The complete characterization of progressive solutions enables us to select an “optimal” solution, where an optimal solution can be defined as the one with the least number of states, actions and transitions, or the fastest one. Currently, we are working on techniques for deriving optimal progressive solutions.
382
Sergey Buffalov et al.
Acknowledgments The first and the third authors acknowledge the partial support of the program “Russian Universities”. The second author acknowledges the partial support of the American University of Sharjah.
References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
Barrett G., Lafortune S.: Bisimulation: The Supervisory Control Problem, and Strong Model Matching for Finite State Machines. Discrete Event Dynamic Systems: Theory and Application. 8(4):377-429 (1998). Bochmann G. v., Merlin, P.: On the Construction of Communication Protocols. ICCC, 1980, 371-378, reprinted in "Communication Protocol Modeling", edited by C. Sunshine, Artech House Publ. (1981). Drissi J., Bochmann G. v.: Submodule Construction for Systems of I/O Automata. ftp://beethoven.site.uottawa.ca/Publications/Dris99b.pdf Hopcroft J. E., Ullman J. D. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley (1979). Kelekar, S.G.H: Synthesis of Protocols and Protocol Converters Using the Submodule Construction Approach. Proc. PSTV, XIII, A. Danthine et al (Eds) (1994). Kumar R., Nelvagal S., Marcus S. I.: A Discrete Event Systems Approach for Protocol Conversion. Discrete Event Dynamical Systems: Theory and Applications. 7(3):295315 (1997). Merlin P., Bochmann G. v.: On the Construction of Submodule Specifications and Communication Protocols. ACM Trans. On Programming Languages and Systems. 5(1):1-25 (1983). Parrow, J.: Submodule Construction as Equation Solving in CCS. Theoretical Computer Science. Vol. 68 (1989). Petrenko, A., Yevtushenko, N.: Solving Asynchronous Equations. In Proc. of IFIP FORTE/PSTV’98 Conf., Paris, Chapman-Hall (1998). Petrenko, A., Yevtushenko, N., Bochmann, G. v., Dssouli, R.: Testing in Context: Framework and Test Derivation. Computer Communications Journal, Special issue on Protocol engineering. Vol. 19, 1236-1249 (1996). Qin, H., Lewis, P.: Factorisation of Finite State machines Under Strong and Observational Equivalences. Journal of Formal Aspects of Computing, Vol. 3, 284-307 (1991). Tao, Z., Bochmann, G.v., Dssouli, R.: A Formal Method for Synthesizing Optimized Protocol Converters and its Application to Mobile Data Networks. Mobile Networks & Applications. 2(3):259-69 (1997). Wonham W. M., Ramadge P. J.: On the Supremal Controllable Sublanguage of a Given Language. SIAM J. Control. Optim. 25(3):637-659 (1987). Yevtushenko, N., Villa, T., Brayton, R.K., Petrenko, A., Sangiovanni-Vincentelli, A.: Solving a Parallel Language Equation. Proc. of the ICCAD’01, USA, (2001).
Type Abstraction in Formal Protocol Specifications with Container Types Joachim Thees University of Kaiserslautern, Postfach 3049, D-67653 Kaiserslautern, Germany, [email protected]
Abstract. In this paper, we propose a seamless integration of the concept of “(universal) container types” into Formal Description Techniques (FDTs), which introduces a new concept of data abstraction. We show how this syntactical and semantic extension increases the expressiveness in the area of component reuse, without sacrificing the formal precision of the FDT. The ideas are exemplified for Estelle, but apply to other FDTs in the protocol domain (e.g., SDL) as well. Furthermore we will demonstrate, how this extension increases the capability to formally specify the static and even the dynamic packet composition and decomposition of pre-existing protocols (like TCP/IPv6 or XTP).
1
Introduction
Type safety is an important requirement to the formal (i.e. mathematically precise) specification of communication systems. Therefore all data handling operations must have an implementation independent and unique semantics. However, the level of type safety enforced by many FDTs in the protocol domain (e.g., Estelle [1, 2] and SDL [4]) has a negative impact on the complexity and usability of large, hierarchically structured, and heterogeneous protocol stacks, especially against the background of reuse approaches of protocol components (e.g., as open systems with SDL or Open Estelle [10]). In this paper, we will demonstrate why this level of type safeness hampers a generic and application independent definition of communication protocols and services. This limitation becomes apparent especially at very complex, heterogeneous specifications and against the background of reuse approaches of protocol components (e.g., as open systems with SDL or Open Estelle [10]). As a solution to this problem, we propose a seamless integration of the concept of “(universal) container types”, which introduces a new concept of data abstraction, but avoids the overhead of a complete data description technique like ASN.1 [3]. We show how this syntactical and semantic extension increases the expressiveness in the area of component reuse, without sacrificing the formal precision of the FDT. The ideas are exemplified for Estelle, but apply to other FDTs in the protocol domain (e.g., SDL) as well. H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 383–398, 2003. c IFIP International Federation for Information Processing 2003
384
Joachim Thees
N+1
N+1 Service Interface Layer N
N
N Service Interface Layer N-1 N-1
Fig. 1. Layered model for structured communication systems N+1A
N+1B
N+1 Service Interface Layer N
N
NA
NB
Fig. 2. Independence of service users and service providers
1.1
Hierarchical Communication Systems
Service hierarchies are an important means for the structuring of communication systems. A system is structured into a number of layers (see Fig. 1), which provide services to higher layers by making use of the services of lower layers. The service interface of these layers hides the internal details of each layer from all other layers. So these interfaces can be restricted to service aspects only. This concept becomes even more important, if different service users access the same service (see left hand side of Fig. 2) or a service user shall be bound to different service providers without modifications (see right hand side of Fig. 2). Such situations are very common in real world communication systems. For example, we are used to running different applications on our workstation with the same TCP/IP protocol implementation without any system reconfiguration. On the other hand, the TCP/IP implementation on a workstation should not depend on the kind of basic technology that is used to access the internet, especially if different basic technologies are used concurrently. Obviously the concept of information hiding and the abstraction provided by minimal service interfaces are very important requirements for heterogeneous structured communication systems. 1.2
Data Representation in Hierarchical Communication Systems
The OSI Reference Model [5] defines access to data transfer services in terms of Service Access Points (SAPs), which allow a service user (layer N+1) to pass its payload as a Service Data Unit (N-SDU) to a service provider (layer N, see Fig. 3). The protocol machine of layer N will now create a Protocol Data Unit
Type Abstraction in Formal Protocol Specifications with Container Types layer N+1
N-SDU
N-SDU
N-SAP
layer N
N-SDU
385
N-SAP
N-PDU
N-SDU
= N-1-SDU
N-PDU = N-1-SDU
N-1-SAP
N-1-SAP
N-1-SDU
layer N-1
N-SDU
N-PDU
Fig. 3. Nesting of SDUs into PDUs N-SDU b0
N-PDU-header
bn
N-PDU-trailer
N-PDU = N-1-SDU
N-1-PDU-header
N-1-PDU-trailer
N-1-PDU
Fig. 4. Framing of SDUs into PDUs at byte encoding level
(N-PDU) that includes the N-SDU (i.e. the initial payload) and some additional protocol specific data. This N-PDU itself is now used as a N-1-SDU for the SAP to the next lower service (layer N-1). As soon as this service at layer N-1 delivers the N-1-SDU to the peer protocol machine, the payload (N-SDU) is extracted and transferred to the layer N+1 service user. This mechanism can be found in most layered communication systems which honor the concept of separation of concerns between the layers: the payload of any service user is handled and transmitted by the lower service providers basically without any interpretation of its contents.1 Therefore at implementation level payloads (SDUs) are most often represented as unstructured byte sequences and the inclusion of an SDU into an PDU is handled as a simple concatenation of byte sequences (header, payload and trailer), known as framing (see Fig. 4). 1.3
Formal Specification of Hierarchical Communication Systems
A natural representation of services and protocol machine structures in Estelle is based on modules. In Fig. 1 we have seen a typical module instance hierarchy implementing a protocol stack and its service structure. This is at first glance 1
Some integrated protocols like TCP and IP share some data (e.g., destination IPAddress) inside the payload between different layers, but these could also be passed redundantly as payload and separate service parameter.
386
Joachim Thees
appropriate to our information hiding requirements, since Estelle modules have a well defined external interface and encapsulate all further internal details from their environment. But as soon as we start to model the internal aspects of the protocol machines, we will have to specify the framing and un-framing mechanisms described above. The type safeness of Estelle implies only one precise way for doing this: On every layer (N) the SDU (N-SDU) is embedded into the PDU (N-PDU) as a recordcomponent.2 Framing is implemented by assigning SDU value to the appropriate PDU component under construction. The resulting N-PDU is already the N-1SDU and can transferred (also type safe3 ) by the underlying communication service N-1. At the destination module instance of layer N, the un-framing is implemented by direct access to the N-SDU component of the N-PDU record. The advantage of this approach is obvious: All data transfers and assignments are type safe across the whole system. The disadvantages become apparent as soon as we consider systems with a great number of framing layers: since for every layer N the N-PDU aggregates its N-SDU (i.e. the N+1-PDU), the data structures become more and more complex with every layer we step down in the hierarchy (see Fig. 5). Obviously there is some kind of “inheritance” of payload types down the protocol stack.4 This is even more undesirable as it acts inversely compared to the service complexity5 provided at the individual layers. The solution appears even worse if we consider heterogeneous protocol stacks, where all services may be used by different protocols or applications (see Fig. 2). Except of the pathological case, where all users of a service N use exactly the
service complexity
high
low
00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000 00 00 00 00 00 00 00 low
N+3
N+3
N+2
N+2
N+2-SDU
N+2-SDU N+1-SDU
N+1
N+1 N+2-SDU N+1-SDU
N
N-SDU
SDUs complexity
00 00 00 00 00 00 00 00 00 00 00 00 000000 00 00 00 00 00 00 00 00 00 00 00 00 000000 00 00 00 00 00 00
high
Fig. 5. Complexity of Services and SDUs in Communication Hierarchies 2
3 4 5
Alternatively also an array over N-SDU-types could be used, but in most cases this is only useful if the array is part of an N-PDU-Record, which also holds additional protocol specific data for N. The type safeness of the system can be proved by structural induction over the number of layers. We call this composing of types “vertical” (orthogonal to the “horizontal composition” noted below). In most cases we put a service (or protocol) on top of another service in order to improve it in any way.
Type Abstraction in Formal Protocol Specifications with Container Types
387
same N-SDU (i.e. payload) type, a handling of different N-SDUs is necessary. The obvious solution is to embed not only one N-SDU type into the N-PDU, but all possible N-SDU (i.e. payload) types, e.g., as variants of a variant record.6 Since heterogeneous protocol applications can occur on every layer and the resulting variant records are also “inherited” to the external interfaces of all service interfaces below, the combination of horizontal and vertical composition results in a real type explosion of exponential complexity.7 1.4
Data Type Abstraction
Obviously the kind of type safe SDU-PDU-nesting shown above is only useful for protocol specifications with a low number of layers and very little heterogeneity. But this requirement is contradictory to the approach of true generic service and protocol machine specification. Especially if we try to specify communication services separately from and independently of concrete service users (e.g., as an open system with the Estelle extension Open Estelle [10]) we would have to specify the payload types of all possible8 users in advance. On the other hand, the internal structure of the payloads is of no interest for most data transfer services, since they simply transmit them without any interpretation.9 Consequently the internal structure of the PDU of a protocol machine could be kept as one of its internal secrets, which are isolated from the environment in terms of the external interface. Basically we are looking for a data type abstraction for SDU and PDU types in formally specified protocol machines for the following tasks: 1. SDU types of services (and also of protocols) should be abstract, as long as only the service users are interested in their concrete structure and contents. This allows us to give an abstract service specification without reference to a concrete payload type. Furthermore, the independence from any concrete payload type also proves automatically, that the service is defined independently of the concrete payload type.10 2. Protocol machines should be able to keep their concrete PDU types as an internal secret, as long as lower services do not have to consider their content. This simplifies the external interface, since it can reflect only service 6 7 8 9
10
We call this composing of types “horizontal” (orthogonal to the “vertical composition”noted above). In a system with n service layers and m variants on every layer we have a PDU type with O(mn ) at the lowest service provider. For a truely generic service (e.g. specified as open system in Open Estelle) any not pointer containing type would have to be supported. In implementation level services payload is most often represented and handled as simple byte sequence, where only the number of bytes and abstract properties like their checksum are considered. In Fig. 5 service provider N knows the complete structure of the payload (N-SDU) and therefore could access or even modify any substructure from higher layers (e.g., the N+2-SDU). In most cases this is not intended and therefore should be avoided at conceptional level.
388
Joachim Thees
aspects and can be kept free of internal details. For example, the external interface of a transport layer protocol machine should not depend on protocol mechanisms like acknowledgement strategies or sliding window lengths. 3. Service users (including protocol machines) should be able to pass their payload types to the abstract SDU-parameters of these abstract service providers and protocol machines. Of course this step must be reversible at the receipt of SDU-parameters by the peer service users. 4. All operations must be semantically formal, i.e. type safe. Unfortunately, Estelle has no means to do this kind of data abstraction, especially if we take into consideration the demand to formally specify services with Open Estelle completely independent of their later users: – The SDU-type polymorphism already discussed above is only applicable if all service users are known in advance, and even then it is only useful for a small number of type variants. – The use of incomplete type specifications (e.g., “TYPE T = ... ;”) makes the whole specification incomplete, i.e. it has no formal semantics. – Any kind of type parametrization11 of formally described open systems is only useful for a single SDU type, but if several service users with different SDU-types access the same service provider instance in the same system, the resulting system suffers from the same problems (see left hand side of Fig. 2). – The application of primitive encoding and decoding functions as proposed in Annex B of [2] represents all SDU types as byte arrays of fixed size. Since the size of these arrays has to be specified and therefore limited in advance, these SDU types do not lead to a truly universal service definition.12 Apart from this, the abstraction level of specifications using this technique is only appropriate if we have to consider encoding specific aspects, which is far below the goals of Estelle as a formal description technique. The introduction of data type description languages like ASN.1 [3] into Estelle requires a close coupling and interaction of both, the Estelle type description and the ASN.1 type descriptions. This goes beyond our goals described above, since ASN.1 aims especially to the exchange of data between different, heterogeneous worlds. In the following section we will present a very simple and fully embedded solution for the data abstraction problem described above.13 11 12 13
The concept of type parametrization is not part of Standard Estelle. Obviously, for every number of bytes in this array, we can find a data type that cannot be encoded into it in all cases. The data serialisation mechanism of Java doesn not provide a true container type according to Def. 1, since the conversion is not implicit. Another (also not universal) container type candidate in Java is the class Object that is a base class for all non-primitive types in Java.
Type Abstraction in Formal Protocol Specifications with Container Types
2
389
Universal Container Types
As a solution for the data abstraction problems in hierarchical communication systems we will now introduce the concept of “(Universal) Container Types” to Estelle. We will start with some language independent considerations. Definition 1. Container Type A Type TX is called Container Type of Type T if TX and T are assignment compatible and for all Values x of type T is valid: if x is converted to type TX and then back again to type T, then both conversions are allowed and the resulting value is equal to x. The idea of this definition is that a container type TX of a type T can hold any value of type T without loss. For example, the Estelle type INTEGER is a container type for the INTEGER sub-range type T=0..9. On the other hand, T=0..9 is not a container type for INTEGER, since the value 10 can’t be converted legally to type T. Furthermore, every type T is its own (trivial) container type. For any pair of types with val(T X) ⊇ val(T ), TX is a container type for T, but the definition it is not restricted to these situations. For example, with an implicit conversion rule for integers to character strings (e.g., in hex-representation) and vice versa, character strings could serve as container types for integers. A universal container type is a type that has the ability to serve as a container type for any type. Some languages, which support the concept of data serialization (e.g., into character strings in Java), may have universal container types. 2.1
Estelle Extension “Universal Container Type”
Obviously Estelle does not have a universal container type, i.e. a type that can serve as a container type for any Estelle type T. Hence we will now introduce a new Estelle type “any-type”, which extends the Estelle syntax given in [2]: Definition 2. Syntax of the Estelle Container Type “any-type” any-type = “ANY” “TYPE” . type-denoter = — | any-type . With this extension we can use the non-terminal14 any-type as a new typedenoter for the definition of variables, parameters, new types, etc., similar to a predefined type name. Most interesting is its application as a interaction parameter in the channel definition below: Example 1. Syntactical Use of any-type 14
We use the combination of Standard-Estelle keywords “any” and “type” to avoid the introduction of a new keyword. This simplifies the integration of our extension into existing specifications, since no collisions with identifiers are possible. Furthermore the term “any type” mimics Estelle constructs like “any integer”.
390
Joachim Thees TYPE T = ANY TYPE; VAR x: ANY TYPE; PROCEDURE f(x: ANY TYPE); BEGIN (* ... *) END; CHANNEL ChService_N(User,Provider); BY User: D_Send(Data: ANY TYPE); BY Provider: D_Recv(Data: ANY TYPE);
The syntactical non-terminal any-type denotes a new type (also called “anytype” here). As already suggested by it’s name, this new type has special properties concerning its compatibility with other types. These properties are defined by the following extension of the definition of assignment compatibility given in section 6.4.6, Annex C15 of [2]: Definition 3. Extended Type Compatibility of the any-type extension A value of type T2 shall be designated assignment-compatible with a type T1 if any of the following seven statements is true: a .. e) { unmodified } f) T1 is the any-type and T2 is not pointer-containing. g) T1 is not pointer-containing and T2 is the any-type. At any place where the rule of assignment-compatibility is used a, b) { unmodified } c) it shall be an error, if T1 is the any-type and the value of T1 was not created by conversion from type T2 to the any-type. { rest unmodified } Clause (f) means, that assignments to the any-type are allowed from all types, which are not pointer containing.16 As a consequence, the any-type itself is also not pointer containing.17 This restriction is a requirement to use the any-type as parameters to interactions (see channel definition in example 1). This syntactical extension already fulfills our requirements for abstract communication services in hierarchical communication systems. The SDU type anytype with its assignment compatibilities allows us to specify really abstract service interfaces. Any service user can convert its specific payload type into an any-type and pass it as its SDU to the abstract service provider (e.g., N-1 in Fig. 1). The service provider passes this any-type SDU without further consideration of its possible contents to the destination service user (still as any-type SDU). This destination service user can convert the any-type value into its original type and value and handle its contents appropriately. 15 16
17
Annex C defines the Pascal-subset contained in Estelle. Obviously the proposed extension could also be applied to native imperative languages like Pascal. Obviously the any-type is not really a universal container type. But it is in fact universal for the set of types that can be passed as interaction parameters between module instances (i.e. all not pointer containing types). It is not pointer containing by value. Technically being no real structured type, the definition of pointer containing in [ISO97] is not appropriate for this type, since it refreres only to its syntactical structure.
Type Abstraction in Formal Protocol Specifications with Container Types
391
Apparently we attenuate the type safeness of Estelle with this kind type conversions into the any-type and back. This is only acceptable, if the semantics of the conversions is unambiguous in a mathematical sense. This is achieved by the following two requirements: 1. Besides assignment and the conversions defined in Def. 3, there are no operations or actions on instances of the any-type. 2. If there is a conversion from an arbitrary type to the “any-type”, then the resulting any-type value can only be converted back to the initial type (see clause (c) in Def. 3). So the type safeness of the possible operations with any-type is secured by construction. Obviously an important requirement to the assignment compatibility, clause (c) in Def. 3, can only be verified at runtime. This is not a new concept to Estelle, since e.g., also the correctness of pointer values or variant records cannot be verified statically (see Sections 6.4.3 and 6.4.4 of Annex C of [2]). We will come back to this aspect in Sections 3 and 4. The semantics of the proposed Estelle extension is based directly on the definition of container types (see Def. 1): Definition 4. Semantics of the any-type The any-type is a container type for all not-pointer-containing types. Consequently, the use of the any-type has a precise semantics and a specification does not become “not well-formed” because of its use (instead of e.g., the type denoter “...”; see section 8.2.3 of [2]). 2.2
Application of the Estelle Extension “Universal Container Type”
For the demonstration of the practical application of the proposed any-type extension, we will now implement the essential aspects of the communication scenario shown in Fig. 6. Two service users communicate through an abstract and application independent service interface based on the any-type as SDU types (see example 2).
User
User
IpToProvider
IpToProvider
abstract service interface IpToUser[1]
IpToUser[2]
Provider
Fig. 6. Module and Connection Structure of Example Communication Scenario
392
Joachim Thees
Example 2. Abstract Service Interface TYPE Td = ANY TYPE; CHANNEL ChService_N(User,Provider); BY User: D_Send(Data: Td); BY Provider: D_Recv(Data: Td);
With this definition of Td the service user can send any payload (here: local type T1) without explicit conversion as interaction parameter: Example 3. Service User (Sender) IP IpToProvider: ChService_N(User); (* external IP *) (* ... *) TYPE T1 = RECORD a: REAL; b, c: BOOLEAN; END; VAR x1: T1; TRANS BEGIN OUTPUT IpToProvider.D_Send(x1); (* any-type conversion *) END;
In the opposite direction the any-type parameter received with the D_Recv interaction can be converted back to its original type, in order to evaluate its contents: Example 4. Service User (Receiver) TRANS WHEN IpToProvider.D_Recv(Data: Td) VAR x: T1; BEGIN x := Data; (* any-type back-conv. *) (* evaluates x ... *) END;
As in example 4, another service user may transfer completely different payload types through the same service and the same interaction parameter. But it is important that the any-type value sent is finally received by the right receiver in order to be converted back to the right (i.e. the sent) type. The most interesting part finally is the service provider, which becomes completely independent of any possible service user. The any-type payload is simply handled without any knowledge of its specific contents: Example 5. Service Provider IP IpToUser: ARRAY [1..2] OF ChService_N(Provider); (* ext. IPs *) (* ... *) TRANS ANY i: 1..2 DO WHEN IpToUser[i].D_Send(Data: Td) BEGIN OUTPUT IpToUser[3-i].D_Recv(Data); END;
Type Abstraction in Formal Protocol Specifications with Container Types
393
Obviously this kind of service abstraction can be used on all service levels of a hierarchical communication systems (see e.g., Fig. 1). Like the user modules in the example above, also the protocol machines can hide their specific PDU structure internally. A very interesting result of this approach is that finally the SDU types of all service interfaces at all layers may be identical (i.e. any-type) and therefore even some or all service interfaces could be defined identically.18 This proofs, how far this approach reduces the service interfaces and the external interfaces of protocol machines to aspects induced only by core requirements.
3
Dynamic Aspects of Container Types in Communication Systems
An important requirement to the correctness of a conversion from an any-type value back to a regular Estelle type is the conformity of this destination type with the initial type, which created the any-type value (see clause (c) in Def. 3). We will now discuss, how this correctness can be ensured in more complex situations. Therefore we will first have a look at manual implementations of data type handling in existing (“real world”) protocols. 3.1
Data Type Handling in Real World Protocol Implementations
In real world communication systems (e.g., TCP/IP) several protocols have to share the same basic data transport services. As we have already seen in Section 1.2, these data transport services represent SDUs as unstructured byte arrays (frames). If such a data frame is received from the lower data transport service, its internal structure must be reconstructed. This means, the data must be reinterpreted from an unstructured data object to a (more) structured one. Obviously this is also exactly the idea behind a cast from an any-type to a more specific type. But how can we assign a structure (i.e. a type) to the yet unstructured data frame? If we can expect only one type of data frames with always the same structure, we can simply assign it to this type. E.g., if our service users send exclusively single two-byte little-endean integers to the data transport service and we assert a faultless service, we can also expect that every frame received contains only such integers.19 This shows the basic idea of the transfer of structured data as unstructured SDUs: on receipt we reassign a structure to the unstructured data based on our a priori knowledge (or at least our expectation) of its original type. If our 18 19
Of course, this can only happen if possible additional service specific parameters (e.g., destination addresses or q.o.s. parameters) are identical, too. Obviously in this example we could at best check the size of these frames (each should be 2 bytes long).
394
Joachim Thees
expectation is correct, we will be able to reconstruct the data sent correctly. If the data received is of different type than expected, we will fail: at best case we will be able to detect this mismatch at means of other assertions (e.g., wrong frame size, illegal contents, wrong checksums), but if not, we will reconstruct and handle wrong data (i.e. data never sent). This is a basic property of any communication over a not strictly type safe communication systems. So finally the assignment of the correct type to a yet unstructured piece of data is a basic task in all real communication systems. The container type extension just introduces this idea into formal protocol specifications: The assignment of the correct type to a unstructured piece of data is modeled by the cast of an any-type value to a more specific type. And analogous to the real world implementations, the correctness of this type assignment is left to the specifier and cannot be checked statically.20 3.2
Successive Data Decomposition
We have seen that we have to assign the right structure (i.e. type) to a unstructured data received from our communication system. But what if there may be different data types that are transmitted over the same service, i.e. the service is multiplexed? In this case all known protocols use frame types that have a common substructure for all variants. These common parts are in most cases placed at beginning of the frame (the so called header). Since the structure of this common part is known a priori, we can reconstruct its contents without knowledge of the complete structure of the whole frame. In this common structure we will find additional parameters for the further type assignment of the data object. So we can reconstruct the complete type structure of frame step by step. We illustrate this idea by means of the TCP/IPv4 protocol [6]. All TCP/IP frames start with a common IP header, followed by some payload data (Fig. 7). Inside of this common header we find a field named “Protocol”, which (partially) identifies the substructure of the data field: A value of 6 indicates a TCP data field [7], a value of 17 indicates a UDP data field [8].
4
Ver.
8
IHL
16
Total length
Identification Time to Live
32 bit
Type of Service Flags Protocol
Fragment Offset Header Checksum
Source Address Destination Address Option+Padding Data
Fig. 7. IPv4 PDU structure 20
There may be consistency checks, which detect wrong type casts in implementation or simulations (see Section 4). In some cases also a full static check may be possible (e.g. in simple systems, where only one type is converted into the any-type).
Type Abstraction in Formal Protocol Specifications with Container Types IP-frame with TCP-PDU ....
Protocol = 6
395
IP-frame with UDP-PDU ....
Data (TCP)
TCP-PDU
....
Protocol = 17
....
Data (UDP)
UDP-PDU
8
16
Source Port
32 bit
Destination Port
8
Source Port
Sequence Number ....
16
32 bit
Destination Port
Length
Checksum Data*
Option+Padding Data*
Fig. 8. TCP- and UDP-PDUs embedded into IPv4-PDU
In order to decomposed a IPv4 frame received from a lower service, we will first have to assign the a priori known structure to the IP header with its protocol field. The Data field of the Frame is kept unstructured, yet. In a second step we can start to assign a structure to the IPv4 Data field, depending on the Protocol value (see Fig. 8). With this knowledge of the TCP or UDP structure we can further detect the Destination Port, pass the nested Data part to the bound application and continue its decomposition with application level knowledge of its structure, and so on. Obviously we are practicing some kind of (vertical) successive data decomposition: Starting from the a priori known structure of a frame we assign types and decompose the frame step by step. In order to model this kind of decomposition with our container type extension, we have to create a nested data structure with a structural known part and an unknown part. The known part (e.g., the frame header) is modeled with regular Estelle types, whereas the unknown part is an any-type. Both parts are aggregated into a record (see type IPv4_Frame in example 6). Example 6. Type Hierarchy for Successive Data Decomposition TYPE Abstr_Frame = ANY TYPE; TYPE IPv4_Header = RECORD (* ... *) Protocol: 0..255; (* ... *) END; TYPE IPv4_Frame = RECORD Header: IPv4_Header; Data: ANY TYPE; END; TYPE TCP_PDU = ... ; TYPE UDP_PDU = ... ;
If we receive a frame (modeled as an any-type, since the lower service provider does not know anything about the frame structure), we first convert it into the type IPv4_Frame, based on our a prior knowledge about its structure (see
396
Joachim Thees
example 7). Now we can access the header with its Protocol field. Then we can continue the successive data decomposition for any known value of Protocol (here: 6 and 17 for TCP and UDP). Example 7. Successive Data Decomposition for IPv4 TRANS WHEN FromLowerService.Frame{atf: Abs_Frame} VAR f: IPv4_Frame; tpdu: TCP_PDU; updu: UDP_PDU; BEGIN f := atf; (* type known a priori *) IF f.Header.Protocol = 6 THEN BEGIN tpdu := f.Data; (* type for Protocol 6: TCP *) (* ... *) END ELSE IF f.Header.Protocol = 17 THEN (* ... *); END;
The composition of such a frame has to be done exactly in the opposite way, in order to make every later decomposition step well defined (see Section 2.1). Finally we will demonstrate the potential of our approach at the specification of truly dynamic data types, as they are used in many modern protocols. In protocols like IPv6 [9] or XTP 4.0 [13], frames are no longer of fixed structure with a single, variable payload part, but instead consist of several parts, which are optional, repetitive or of variable size. These so called segments are chained inside the packet, starting from a (once again a priory known) header of fixed type (see Fig. 9). Standard Estelle has no appropriate means to specify such highly dynamic frame structures. With the container type extension we can use a variable of type any-type to hold any intermediate state of the packet composition (see Fig. 10). Starting with the last segment (which is directly assigned to the anytype variable), we insert step by step one segment, by creating an auxiliary record value with a component of the current segment type and an any-type component for the already constructed rest of the frame (like IPv4_Frame in example 6). With this method we can construct segment sequences of arbitrary structure. The construction process is done in this “reverse order”, because the decomposition process has to be done the same way, but in opposite order, starting with the forefront (i.e. a priori known) header.
IPv6-Header
Routing-Header
Authentication-Header
...
...
...
next Header = Routing
next Header = Authentication
next Header = TCP
TCP-Header + TCP-Data
Fig. 9. TCP-PDU with different segments of a IPv6-PDU
Type Abstraction in Formal Protocol Specifications with Container Types
397
TCP-Data
conversion to any-type Hdr3 any-type
next = 7
conversion to any-type Hdr1 any-type
next = 3
conversion to any-type any-type
Fig. 10. Successive Data Composition any-type-Aggregation
4
Implementation Issues
Besides a basic implementation approach for the implementation of the any-type on top of not object oriented implementation platforms, we have also implemented it with our C++ based Estelle compiler XEC [11, 12]. Because of its object oriented data model, the container type extension could be integrated easily. By the use of class templates for the internal abstraction of the contained data objects and dynamic_cast-operators for the casts from an any-type value back to a specific type, a full dynamic type check is provided at implementation level.
5
Summary
We have shown how the level of type safety enforced by many FDTs in the protocol domain (e.g., Estelle and SDL) has a negative impact on the complexity and usability of large, hierarchically structured, and heterogeneous protocol stacks, especially against the background of reuse approaches of protocol components (e.g., as open systems with SDL or Open Estelle). As a solution to this problem, we proposed the concept of “(universal) container types” and their seamless integration into FDTs, which introduced a new concept of data abstraction, but avoids the overhead of a complete data description technique like ASN.1. We further demonstrated how this syntactical and semantic extension increases the expressiveness in the area of component reuse and flexible data representation, without sacrificing the formal precision of the FDT. The ideas were exemplified as the “any-type”-extension for Estelle, but apply to other FDTs in the protocol domain (e.g., SDL) as well.21
21
This work has been supported by the Deutsche Forschungsgemeinschaft (DFG) under grant Go 503/4-2.
398
Joachim Thees
References 1. Dembinski, P., Budkowski, S.: Specification Language Estelle, in: M. Diaz et al. (eds.), “The Formal Description Technique Estelle”, North-Holland, 1989 2. ISO/TC97/SC21: Estelle - A Formal Description Technique Based on an Extended State Transition Model, ISO/TC97/SC21, IS 9074, 1997 3. ITU-T Recommendation X.680 – X.683 (07/02): Abstract Syntax Notation One (ASN.1), International Telecommunication Union (ITU), 2002 4. ITU-T: CCITT Specification and Description Language (SDL), Recommendation Z.100 (03/03), 1994 5. ISO/TC 97/SC 16, ISO 7498, “Data Processing – Open Systems Interconnection – Basic Reference Model”, 1981 6. J. Postel (Edt.), “Internet Protocol, Specification”, RFC791, 1981 7. J. Postel (Edt.), “Transmission Control Protocol, Specification”, RFC793, 1981 8. J. Postel (Edt.), “User Datagram Protocol, Specification”, RFC768, 1980 9. S. Deering, R. Hinden (Edts.), “Internet Protocol, Version 6 (IPv6), Specification”, RFC1883/2460, 1995 10. J. Thees, R. Gotzhein: Open Estelle - An FDT for Open Distributed Systems, in: S. Budkowski et.al. (Edts.): Formal Destcription Techniques and Protocol Specification, Testing and Verification (FORTE XI/PSTV XVIII’98), Kluwer Academic Publishers, Boston/Dordrect/London, 1998 11. J. Thees: The eXperimental Estelle Compiler - Automatic Generation of Implementations from Formal Specifications, in: Formal Methods in Software Practice (FMSP’98), Clearwater Beach, Florida, USA, 1998 12. J. Thees: Protocol Implementation with Estelle - from Prototypes to Efficient Implementations, in: S. Budkowski, et.al.: 1st International Workshop of the Formal Description Technique Estelle (ESTELLE’98), Evry, France, Nov. 1998 13. XTP Forum, Xpress Transport Protocol Specification, XTP Rev. 4.0, XTP Forum, Santa Barbara, USA, 1995
Decomposing Service Definition in Predicate/Transition-Nets for Designing Distributed Systems Hirozumi Yamaguchi1 , Gregor von Bochmann2 , and Teruo Higashino1 1
Graduate School of Information Science and Technology, Osaka University, 1-3 Machikaneyamacho, Toyonaka, Osaka 560-8531, Japan, {h-yamagu,higashino}@ist.osaka-u.ac.jp 2 School of Information Technology and Engineering, University of Ottawa, 800 King Edward Avenue, Ottawa, Ontario K1N 6N5, Canada, [email protected]
Abstract. In this paper, we propose a new algorithm for the derivation of a protocol specification in Pr/T-nets, which is the specification of communicating N entities (N can be given), from a given service specification in Pr/T-nets and an allocation of the places of the service specification to the N entities. Our algorithm decomposes each transition of the service specification into a set of communicating Pr/T-subnets running on the N entities. Moreover, for the efficient control of conflict of shared resources, we present a timestamp-based mutual exclusion algorithm and incorporate it into the derivation algorithm.
1
Introduction
Designing highly reliable distributed systems is still a challenging task and a number of techniques have been proposed to reduce design costs and errors. Especially, for the specification phase in the design of distribute systems, there exists a useful design methodology called protocol derivation (or protocol synthesis, for surveys see [2]). The derivation methods have been used to derive the specification of a distributed algorithm (hereafter called protocol specification) automatically from a given specification of services to be provided by the distributed system to its users (called service specification). The service specification is written in the form of a centralized model, and does not contain any message exchanges between different physical locations. However, the protocol specification of the cooperating entities’ programs, called protocol entities (PE’s), includes the message exchanges between these entities. Protocol synthesis methods have been used to specify and derive such complex message exchanges automatically in order to reduce the design costs and errors that may occur when manual methods are used. Recently, many synthesis methods have been proposed which use CCS based models or LOTOS [3–5], FSM based models[6, 10] and Petri net based models [7–9] as service definition languages. H. K¨ onig, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 399–414, 2003. c IFIP International Federation for Information Processing 2003
400
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
The most popular extension of Petri nets is known as coloured Petri nets (CPN) [1] and predicate/transition-nets (Pr/T-nets) [12] where tokens have values and the firability of transitions can be determined by those values. These models have enough modeling and analytical power to specify, verify and analyze large and practical software systems, communication protocols, control systems and so on [1] and many software tools are provided to help design of these systems using the models. They have been used to model large-scale distributed systems which often include multiple processes running concurrently, such as e-commerce systems where multiple customers may look at, purchase and sell items managed by distributed databases. So what is desired here is to enable designers to define services in these extended Petri nets, and it is also desirable that the protocol specifications are derived from the service definition automatically. In this paper, we propose a new algorithm for the derivation of a protocol specification in Pr/T-nets, which is the specification of communicating N entities (N can be given), from a given service specification in Pr/T-nets and an allocation of the places of the service specification to the N entities. Our algorithm decomposes each transition of the service specification into a set of communicating Pr/T-subnets running on the N entities. Moreover, for the efficient control of conflict of shared resources, we present a timestamp-based mutual exclusion algorithm and incorporate it into the derivation algorithm. The method has been applied manually to an example specification of a distributed database management system[12] to show the applicability of our algorithm to practical applications. The result is presented in [14]. Our approach is very powerful in the sense that non-restricted Pr/T-nets are allowed to be used for specifying services. Since such Pr/T-nets include complex conflict structures made by choice places, synchronization transitions and multiple tokens with values, we have to consider how to implement those complex conflict structures by multiple entities. In our approach, a timestamp-based mutual exclusion algorithm is presented and elegantly incorporated into the derivation algorithm in order to implement such a structure. Moreover, in order to implement each transition of the service specification handling multiple tokens with values, a new protocol to exchange tokens between entities is introduced. Some existing synthesis methods also allow to treat variables (parameters) in their modeling languages like a CCS-based model with I/O parameters[4] and Petri nets with external variables[7, 9]. However, since these existing methods mainly focus on value exchanges between entities, only simple control flows are allowed (the combination of choices and synchronization involving parameters, which often represents resource conflict, is not allowed). Therefore, the class has been considerably extended from the existing work and as far as we know, no paper has presented synthesis approaches for a first order extension of Petri nets. This paper is organized as follows. Section 2 gives the definition of Pr/T-nets which we use in this paper and examples of service and protocol specifications. In Section 3 our derivation algorithm is presented and Section 4 enhances the algorithm to handle timestamp-based mutual exclusion. Section 5 gives brief
Decomposing Service Definition in Pr/T-Nets
401
discussion on the validation and applicability of the algorithm, and Section 6 concludes the paper.
2
Service and Protocol Specifications in Pr/T-Nets
2.1
Predicate/Transition-Nets
We use predicate/transition-nets (Pr/T-nets) for the specification of target systems. In Pr/T-nets, an arc from a place p to a transition t (denoted by (p, t)) has a finite multi-set m(p, t) of tuples of variables. m(p, t) is defined as m(p, t) = i ki Vi where ki is a non-negative integer and Vi is a tuple of variables like v1 , v2 , ...vn . Each token has a tuple of values Ci , and we say that a token with a tuple Ci of values is assignable to Vi iff the type of each value in Ci matches that of the corresponding variable in Vi and |Vi | = |Ci |. A multi-set of tokens which can be assigned to m(p, t) is called an assignable set. Moreover, a transition may have a predicate of variables from the multi-sets on input arcs, called a condition. The arc from the transition t to a place p also has a multi-set (denoted by m (t, p )) whose variables are from the multi-sets on the input arcs of t. A transition t can fire iff there exists an assignable set in each input place and the token values in the assignable sets satisfy the condition of t. If t fires, new tokens are generated and put into the output places according to the multisets on the output arcs. For example, in Fig. 1(a), the input arc (P1 , T ) has a multi-set “< i1 , n1 > + < i2 , n2 >” where i1 , n1 , i2 and n2 are variables. This means that two tokens which consist of 2-tuples of values are necessary in place P1 for firing of T . Here, since the assignable sets “(1,“Steve”)+(2,“John”)” in P1 , “(“Steve”,“Tokyo”,10000)+(“John”,“Tokyo”,20000)” in P2 and “2( e)” in P3 satisfy the condition “(n1 == m1 ) &(n2 == m2 ) & (b1 == b2 == T okyo) & (s == e)” for firing of T , T can fire by these sets. Note that “ e” is a normal token (i.e. a token which has no value). Such a token is represented as a black dot in the following figures and is called an empty value token hereafter. After the firing of T , new tokens are generated to the output places P4 and P5 using those token values. The marking after the firing of T is shown in Fig. 1(b). P1
P2
"100" "10"
P1
+ [n1==m1 & n2==m2 T & b1==b2=="Tokyo" & s==’e] +
P4
P1
(1, "Steve") P2 (2, "John") (3, "Michael")
("Steve", "Tokyo", 10,000) ("Steve", "Osaka", 5,000) ("John", "Tokyo", 20,000)
<m1,b1,a1>+<m2,b2,a2>
P3 2<s> 2<s>
P5
+ [n1==m1 & n2==m2 & b1==b2=="Tokyo" & s==’e]
("Steve", "Osaka", 5,000)
+
P4
P5 "30" "50"
Tu [x>y]
P3
"500"
<x,y,x+y+i>
<m1,b1,a1>+<m2,b2,a2>
P3
T
P4
2<s> <x,y,j>
2<s>
P6
<j> Tv
P5
("Steve", 10,000) ("John", 20,000)
(a)
<x>
P2 (3, "Michael")
"20" "5"
<x+1>
(b)
(c)
Fig. 1. (a) An example of Pr/T-nets. (b) After firing of transition T . (c) Service specification of an example system
402
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
2.2
Service Specification
Fig. 1(c) shows a service specification of an example system. The system works as follows. At the initial marking, transition Tu can fire, since there exists an assignable set in each input place of Tu and these assignable sets satisfy the condition of Tu . For example, “100” in P1 , “20” in P2 , “500” in P3 and “30” in P5 are such assignable sets that satisfy the condition “x > y”. Let us assume that these tokens are used for the firing of Tu . If Tu fires, these tokens are removed and new tokens “650” and “(100, 20, 150)” are generated in the output places P3 and P4 , respectively. After that, Tu can still fire using the remaining tokens in its input places. At the same time, Tv can fire now using the new token in P4 . 2.3
Protocol Specification
Fig. 2 shows a protocol specification corresponding to the example system in Fig. 1(c). A protocol specification is a set of specifications of N entities communicating with each other asynchronously, called sites in this paper. In protocol specifications, we introduce places for modeling asynchronous (and reliable) communication channels (i.e. buffers), called communication places, like “fusion places” in coloured Petri nets[1]. We assume that two communication places with a common name “Xu.ij ” (X=α or X = β, explained in the next section) in the Pr/T-nets of two different sites i and j represent the end points (send and receive buffers) of a reliable communication channel from site i to site j. site A
site B
site C
P1 "100" P5 "30"
P2
"10"
P3
"20" "5"
"500"
"50"
<x>
αu.ca
Tu.cancel "’e,’e"
αu.cb
Tu.read
Tu.cancel
Tu.read
<x> <x,i> <x,i>
βu.ab βu.ac
βu.ba βu.bc
βu.ba
βu.ab
<x,i> <x,i>
<x>
<x> <x>
Tu.commit
<x,y,j>
[x==’e Tu.fail1 || x=
αv.ab
αv.ab
βv.ba
<x,y,j>
Tu.commit
βu.ac
βu.bc
<x,i>
βv.ba
[x>y]
Tu.fail1
Tu.commit
[x==’e || y==’e || x=
Tv.start
αu.cb
[x>y]
Tu.fail2
<x,y,x+y+i>
P4
αu.ca
<x,i>
[x>y]
Tu.fail2 [y==’e Tu.fail1 || x= <x>
Tu.start
Tv.read
note1: arcs with no multiset carry empty value tokens (=’e) <x,y,j>
<x+1>
note2: "||" is the OR operator
Tv.commit
<j>
P6
Tv.commit
Fig. 2. Protocol specification corresponding to service specification in Fig. 1(c)
Decomposing Service Definition in Pr/T-Nets
403
If a token is put on “Xu.ij ” at site i, the token is eventually removed and put onto “Xu.ij ” at site j. Note that u means that these communication places are used with respect to the execution of transition Tu of the service specification. Communication places are represented as dotted circles in the following figures. In distributed systems, computer resources such as databases are usually distributed over multiple sites. This means that the input and output places of each transition of the service specification may be located on different sites, and we need a protocol to collect/distribute tokens from/to these places to execute the transition in a distributed environment. We determine an efficient protocol in our derivation algorithm where the action of a transition T is implemented by multiple transition sequences on different sites. These transitions are categorized as shown in Table 1. Now let us consider the firing of Tu in Fig. 1(c) to explain how our protocol works. In the corresponding protocol specification in Fig. 2, the input places P1 and P5 are located on site A, P2 on site B, and P3 on site C. In our derivation algorithm, one of the sites which have input places of Tu starts the execution of Tu . In this protocol specification, site C starts the execution by making the “start” transition “Tu .start” fire, which sends empty value tokens via communication places “αu.ca ” and “αu.cb ” to sites A and B, respectively. If site A has tokens (assignable sets) in the input places P1 and P5 and if it receives the empty value token from site C, it makes the “read” transition “Tu .read” fire, which sends the tokens in P1 and P5 to sites B and C via communication places “βu.ab ” and “βu.ac ”, respectively. If either P1 or P5 does not have an assignable set, the “cancel” transition “Tu .cancel” will eventually fire on site A. The firing of the cancel transition means that the execution of Tu will be canceled due to the lack of assignable sets in input places P1 and P5 of Tu 1 . In order to let other sites know the fact, empty value tokens are sent to sites B and C by the firing Table 1. Semantics of transitions in protocol specifications Name T.start
Semantics initiates the execution of T by reading tokens from the input places of T and sends them to the other sites T.read (following T.start,) reads tokens from the input places of T and sends them to the other sites T.cancel (following T.start,) reads no token from the input places of T and sends empty value tokens to the other sites to let them know that an input place has no assignable set T.commit commits the execution of T T.f ail1 cancels the execution of T due to the lack of tokens on the other sites or the condition of T T.f ail2 cancels the execution of T due to the lack of tokens on the local site 1
In the Petri net formalism, Tu .cancel may fire even when Tu .read can fire. In a practical aspect, it can be easily avoided by prioritizing the firing of Tu .read than that of Tu .cancel.
404
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
of Tu .cancel. Similarly, site B reads a token from P2 and sends it to both sites A and C. Consequently, every site can examine (i) whether all the input places of Tu have assignable sets or not, and (ii) whether the assignable sets satisfy the condition of Tu or not if (i) is true. If (i) and (ii) are true, the “commit” transition “Tu .commit” on each site fires and new tokens are generated on sites A and C to the output places P4 and P3 , respectively (i.e. the execution of Tu has been committed). If either (i) or (ii) does not hold, the “fail” transition Tu .f ail1 or Tu .f ail2 on each site fires. Tu .f ail1 fires in case that an input place at an other site does not have an assignable set or (ii) does not hold, and Tu .f ail2 fires in case that an input place at the site itself does have an assignable set. The tokens read from the input places are returned to the input places, i.e., the execution of Tu is aborted.
3
Derivation Algorithm
Our derivation algorithm decomposes a given service specification Sspec into a set of N specifications that represent the protocol behaviors of the N sites of the distributed system (called the protocol specification P spec). The derived protocol depends on the given allocation of the places of the service specification to the N sites. 3.1
Overview of the Protocol for Executing a Given Transition
The basic protocol for executing a transition T of Sspec over multiple sites is as follows. Depending on a given allocation of places, we identify the set of sites called reading sites which have at least one input place of T , and also the set of sites called writing sites which have at least one output place of T . Then we select one of the reading sites as the primary site. At first, at the primary site (say site i), if there exists an assignable set (a set of tokens assignable to the multi-set on an arc) in each input place allocated to site i, site i takes those assignable sets from the places, and sends the token values to the reading and writing sites which need those values. Note that for the reading sites which do not need the token values, the primary site also sends empty value tokens. Consequently, at least one token is sent to each reading site. When a reading site (say site j) receives token(s) from the primary site, site j selects an assignable set from each input place of T allocated to site j (if such a set exists). Then site j sends the tokens to the other reading and writing sites. If such a set does not exist, site j sends empty value tokens to the other reading and writing sites. As a result, the reading and writing sites can examine (i) whether all the input places of T have assignable sets or not, and (ii) whether the assignable sets satisfy the condition of T or not if (i) is true. If (i) and (ii) are true, reading sites discard the assignable sets and writing sites generate new tokens to the output places of T which are allocated to them. Otherwise the assignable sets which have been acquired by the reading sites are returned to
Decomposing Service Definition in Pr/T-Nets
405
the original input places of T . As stated above, in order to prevent deadlocks due to waiting for tokens where an assignable set does not exist in an input place of a transition, we consider a mechanism to cancel the execution of the transition when at least one of the input places has no assignable set. 3.2
Algorithm Description
According to the protocol explained in the previous section, we present our derivation algorithm in this section. The input to the algorithm is a service specification (denoted by Sspec) in the form of a Pr/T-net, the number N of sites and an allocation of the places to the N sites. The output is a protocol specification (denote by P spec) in the form of Pr/T-nets corresponding to the service specification and the allocation of the places to the N sites. For better readability, we use the example specification in Fig. 1(c), especially transition Tu . Let us assume that N = 3 and P1 , P4 and P5 are allocated to site A, P2 to site B and P3 to site C as shown in Fig. 3(a). This allocation is the one that was used to derive the protocol specification in Fig. 2. According to this allocation of places, the reading sites of Tu are sites A, B and C, and the writing sites are sites A and C. We have chosen site C as the primary site of Tu . [Derivation Algorithm] 1. Decompose T into a start transition T.start at the primary site, read transitions T.read and commit transitions T.commit at the reading and writing sites. Note that read transitions at writing sites and commit transitions at reading sites are necessary for consistent execution and this is explained later. Let each commit transition have the condition of T . Then at each reading site, connect the input places of T allocated to the sites to T.read (or T.start). Similarly, at each writing site, connect T.commit at the site to the output places of T allocated to the site. Introduce a place between T.read and T.commit. In the example, site C has T.start and T.commit. Sites A and B have pairs of T.read and T.commit. 2. From T.start at the primary site (say site i) to T.read at each site (say site j), introduce a communication place “αij ” which carries from site i to site j (a part of) assignable sets read from the input places of T allocated to site i. These are used to generate new tokens or to examine the condition of T . If site j needs no value in those tokens, let the place carry an empty value token. Since the primary site needs to let every site j know that T has been selected to examine its executability, such a token is introduced. 3. Then from T.read (or T.start) at each reading site (say site j) to T.commit at each site (say site k), introduce a communication place “βjk ” which carries from site j to site k (a part of) assignable sets read from the input places of T allocated to site j. If site k needs no value in those tokens, let the place carry an empty value token. This is necessary to let the other sites know that site j has already read tokens. Also, from T.read at each writing site j
406
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
site A
site B
(P1,P4,P5)
P5
P1
<x>
site A
site B
P3
"20" "5"
P5
"500"
P1
P2
"30" "50"
"100" "10"
<x>
αu.ca
"500"
αu.cb
Tu.read
Tu
[x>y]
P3
"20" "5"
Tu.read
<x,y,x+y+i>
site C
(P3)
P2
"30" "100" "50" "10"
site C
(P2)
<x,i>
<x>
<x,i>
<x,i>
Tu.commit
βu.ba
P4
Tu.start
βu.ab
βu.ac
<x>
Tu.commit
Tu.commit
[x>y]
βu.bc <x,i>
[x>y]
[x>y]
<x,y,x+y+i>
P4
(a) service specification and place allocation
(b) after step 3
site A
site B
site C
P1 P5 "30" "50"
step 4 Tu.cancel
P2
"100" "10"
<x>
αu.ca
step 4 Tu.cancel
Tu.read <x,i> "’e,’e" <x>
<x,i>
βu.ba <x,i> <x,i>
P3
"20" "5"
"500"
αu.cb
Tu.start
Tu.read
βu.ab <x>
βu.ac βu.bc
<x> <x>
<x,i> <x,i>
[x>y] Tu.fail1 <x,y,x+y+i> Tu.commit [y==’e || x=
Tu.fail2
step 5 <x>
P4
[x>y]
Tu.fail2
Tu.fail1 Tu.commit
Tu.fail1
[x==’e || x=
step 5
[x==’e || y==’e || x=
[x>y]
Tu.commit
step 5
(c) after step 5
transitions added at step 4 or 5
Fig. 3. Derivation algorithm snapshots
to T.commit at the primary site i, introduce a communication place “βji ” which carries an empty value token. This lets the primary site know that the site j has received the token from the primary site. Fig. 3(b) shows the specification after this step is applied. From Tu .start on the primary site C to Tu .read on sites A and B, communication places “αu .ca ” and “αu .cb ” are introduced, respectively. Moreover, from these Tu .read to Tu .commit on sites A, B and C, “βu .ab ”, “βu .ac ”, “βu .ba ” and “βu .bc ” are introduced. 4. For each reading site j, add a cancel transition T.cancel which has αij as the input place and the output places of T.read as the output places. Let T.cancel generate an empty value token to each of its output places. For example, in Fig. 3(c), the cancel transition on site A has “αu .ca ” as the input place. It also has “βu .ab ”, “βu .ac ” and a normal place between Tu .read and Tu .commit as the output places. 5. For each reading or writing site, introduce a fail transition T.f ail1 which has the same input places as T.commit, the input places of T as the output
Decomposing Service Definition in Pr/T-Nets
407
places, and the condition “C(T ) x1 ==e x2 ==e ...” where C(T ) is the condition of T and xi is a variable in the multi-sets on the incoming arcs. Therefore this transition fires iff the condition of T does not hold or at least one reading site has failed to acquire an assignable set. Moreover, for each reading site except the primary site, introduce a fail transition T.f ail2 which has the same input places as T.f ail1 . Let T.f ail2 read an empty value token from the place between T.read and T.commit. Therefore this transition fires iff the site itself has failed to acquire an assignable set. Fig. 3(c) shows the specification after this step is applied. Since site C is the primary site, it does not have Tu .f ail2 . 6. For each reading site or writing site, introduce a normal place with an empty value token. Let the place have T.commit, T.f ail1 and T.f ail2 as the input transitions and T.read and T.cancel as the output transitions. By this place, transition T is not executed by the other assignable sets before the current execution of T is completed. 7. Split each communication place into two places so that the specification of each site can be an independent Pr/T-net.
4
Timestamp-Based Mutual Exclusion
In the Petri net formalism, resources of systems are usually modeled as tokens in places. Therefore concurrent transitions which require the same token (resources) share the places and thus form a choice structure. In Pr/T-nets, a choice structure may be quite complex involving multiple synchronization transitions, multiple choice places and multiple tokens with values. However, it is not easy to realize such a complex structure in a distributed environment where these places are allocated to different sites (distributed choice), since we have to consider deadlock problems and efficiency. A simple example is as follows. Fig. 4(a) shows a service specification and a place allocation where two transitions require tokens in Pb and Pc . Pb and Pc are allocated to sites B and C, respectively. An example execution sequence of the protocol specification corresponding to this service specification and place allocation is shown site A (Pa)
(siteA) Pa
T1
< b+c >
< b+c >
(siteB) Pb "2"
"1"
Pc (siteC)
site B (Pb)
site C (Pc)
T2.start
T1.start
< b-c >
T2
T2.read
(siteD) Pd
site D (Pd)
T1.read
T1.cancel T2.cancel T1.fail2
< b-c >
T2.fail2
T2.fail1
T1.fail1
T1.fail1 T2.fail1
(a) (b) Fig. 4. (a) Service specification and place allocation with distributed choice places. (b) Timing chart (the execution of both T1 and T2 failed)
408
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
in Fig. 4(b). In Fig. 4(b), the sites A and D (the primary sites of T1 and T2 , respectively), sent tokens to sites B and C to let them acquire tokens in Pb and Pc . In this scenario, T1 could acquire the token in Pb and T2 could acquire the token in Pc . Therefore, if both T1 and T2 wait for the other token which has been acquired by T2 and T1 , respectively, a deadlock results. In our derivation algorithm of Section 3, such a deadlock never occurs since we included a cancel mechanism which can be executed when tokens do not exist in input places of transitions. For example, in the above case, the execution of T2 is canceled by “T2 .cancel” transition on site B, and the execution of T1 is canceled by the “T1 .cancel” transition on site C. However, this scenario may be repeated until either T1 or T2 has the chance to acquire tokens in both Pb and Pc . This will result, in general, in a number of trial and errors in acquiring resources. Moreover, there may be the case that one transition repeatedly acquires the tokens and the other is blocked. In order to realize efficient control, in this section, we introduce a timestampbased control mechanism. However, unlike usual cases such as concurrent transaction control in database systems[13], concurrent transitions require multiple resources distributed over multiple sites in our case, and the problem is much more complicated. Therefore, we have to design a new protocol exchanging timestamps and resources to be suitable for our derivation algorithm that uses highlevel Petri net formalism. 4.1
Preliminaries
We formally define the structures to which our timestamp-based control should be applied. For a place or transition s, let •s (s•) denote the set of input (output) transitions is said to be a conflict transition or places of s. A set T of transitions set iff | t∈T •t| > 1. The place set t∈T •t is called a conflict place set. This means that the transitions in a conflict transition set share more than one input place. Here, places in a conflict place set that never lose their tokens by firing of transitions in the conflict transition set are called persistent places. We apply our timestamp-based mutual exclusion control to persistent places that belong to the same conflict place set and are allocated to different sites, and their output transitions (i.e. they belong to a conflict transition set). For example, places Pb and Pc in the service specification of Fig. 4(a) are in a conflict place set since they are shared by T1 and T2 which form a conflict transition set, and also Pb and Pc are allocated to different sites. The reason why we control access to places in a conflict place set is that such places may be accessed by multiple transitions each of which represents the synchronization of these places, i.e., the transition requires tokens in all the places. This results in conflict situation as exemplified above. Moreover, the reason why we focus only on persistent places is that in such a place, tokens will be returned and transitions can wait for tokens to be back even if some other transitions currently use them. For the algorithm in the next section, we classify the pairs of a persistent place P and one of its output transitions T as shown in Table 2, (a) RW-persistent,
Decomposing Service Definition in Pr/T-Nets
409
Table 2. Classification of a pair of a persistent place p and its output transition t type RW-persistent
condition t reads tokens from p and writes new tokens to p. t uses the token values to generate tokens to (some other) output places t reads tokens from p and writes back the same tokens. t uses the token values to generate tokens to (some other) output places t reads tokens from p and writes new tokens to p. t does not use the token values to generate any token.
RO-persistent
WO-persistent
p
p
<x>
<x>
t < x > < x+y >
(a)
p
t <x>
(b)
<x>
<x>
t
(c)
Fig. 5. Examples of a persistent place and a transition pairs. (a) RW-persistent, (b) RO-persistent and (c) WO-persistent
(b) RO-persistent and (c) WO-persistent. “RW” indicates that T refers and modifies token values, “RO” indicates that T only refers token values and “WO” indicates that T never refers but modifies token values. Examples are shown in Fig. 5. In Fig. 5(a), T reads a token (it is assigned to variable x) and writes a new token x + y to P . On the other hand, in Fig. 5(b), x is used to generate tokens, however the token in P is not modified (the token is returned with the same value). In Fig. 5(c), x is not used to generate new tokens, and token y is returned instead of x. 4.2
Algorithm for Adding Timestamp-Based Mutual Exclusion Mechanism
We assume that each site has a clock that is synchronized with the clocks of the other sites2 . The protocol presented in this section adds a pair of timestamps (read and write timestamps) to each token in persistent places in a conflict place sets, and determines the access order of transitions in a conflict transition set based on the time when the primary sites tried to execute the transitions. This enables the transitions in the conflict transition set to wait for the assignable sets (tokens) to be returned to the persistent places without causing deadlocks. The detailed description of our timestamp-based solution is presented below. 2
We use these clocks just to determine the total order of the execution of transitions in a conflict transition set. In this sense, these clocks are not needed to be synchronized precisely.
410
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
[Algorithm for Adding Timestamp-Based Mutual Exclusion Mechanism] Let T be a conflict transition set and P be the conflict place set corresponding to T . Let us assume that at least two persistent places in P are allocated to different sites. This algorithm is applied to the protocol specification which is obtained by the algorithm of Section 3. 1. Let each token c in a persistent place have two variables R-T S(c) (a read timestamp) and W -T S(c) (a write timestamp). Let the values of those variables at the initial marking be zero. 2. Let the primary site (say site i) of tu ∈ T generate a timestamp tsu on tu .start and include it to tokens sent to the other reading sites which have places in P . 3. If a reading site (say site j) has a persistent place p, – Build the conjunction of timestamp conditions (see Table 3) of tokens in an assignable set taken from p. Then add this condition to the current condition of tu .read. Moreover, add its negation to the current condition of tu .cancel. Then let tu .read generate dummy tokens from the tokens in the assignable set. A dummy token of the token c has an empty value and a pair of timestamps obtained by updating the timestamps of c according to the rules in Table 3. – Let tu .commit read the dummy tokens corresponding to the tokens which site j has read and kept, for the execution of tu . Also let tu .commit change the empty value in the dummy token to the new value. The idea is that we first classify the types of tu based on how tu modifies tokens in the persistent place p. Then we derive the timestamp condition like “if tu only reads the token (read-only), the read operation should be later than the last write operation” as shown in Table 3. Note that the fourth row in the table is known as Thomas’s write rule[13]. The rule allows a write-only operation request issued earlier than the last write operation to be “ignored” if it has been issued after the last read operation has done. If tu ’s timestamp satisfies the condition in the table, tu has the right to acquire an assignable set even though there is currently no assignable set in p (tu can wait for tokens to be returned without deadlock). It would be much better to see an example to understand how the mutual exclusion works. Fig. 6 shows the protocol specification which corresponds to Table 3. Condition for timestamp of tu to acquire token c and update rules of c’s timestamps type of (p, tu ) RW-persistent RO-persistent WO-persistent WO-persistent
timestamp condition for tsu (R-TS(c) < tsu ) and (W-TS(c) < tsu ) W-TS(c) < tsu (R-TS(c) < tsu ) and (W-TS(c) < tsu ) R-TS(c) < tsu < W-TS(c)
update rules R-TS(c):=W-TS(c):= tsu R-TS(c):= tsu W-TS(c):= tsu –
Decomposing Service Definition in Pr/T-Nets
411
the service specification in Fig. 4(a), and Fig. 7 shows its example timing charts. Fig. 7(a) shows the following scenario. In the service specification in Fig. 4(a), Pb and Pc are persistent places in a conflict place set and T1 and T2 are in the conflict transition set corresponding to the conflict place set. In the protocol specification, the primary sites of T1 and T2 are sites A and D, respectively, and Pb and Pc are allocated to site B and site C, respectively.
siteA
siteD
Pa
Pd
T1.start
T2.start
ts1=gen_ts1()
ts2=gen_ts2()
α1.ab α1.ac
α2.db α2.dc
β1.ba β1.ca
β2.bd
T2.fail1 T1.commit
[b==’e || c==’e]
α1.ab
<’e, ts1, ts1>
<’e, ts2, ts2>
T1.cancel
[b!=’e and r-ts and w-ts
β1.ba β1.bc
α2.db
T2.read
T1.read
T2.commit
[b==’e || c==’e]
siteB
[b==’e or ts1<=r-ts or ts1<=w-ts]
β2.cd
T1.fail1
T2.cancel
[b!=’e and r-ts
[b==’e or ts2<=r-ts or ts2<=w-ts]
β2.bd β2.bc
"2, 000, 000"
Pb
β1.cb
T1.fail2
[c==’e]
T1.fail1
T1.commit
<’e, ts2, ts2>
<’e, ts1, ts1>
<’e, ts2, ts2>
<’e, ts1, ts1>
<’e, ts2, ts2>
α1.ac
T1.cancel
T1.read
[c!=e or ts1<=r-ts or ts1<=w-ts]
β1.ca
β1.cb
T2.commit
<’e, ts1, ts1>
siteC
β2.cb
T2.fail1
T2.fail2
α2.db
T2.read
[c!=’e and r-ts
[c==’e]
[c!=’e and r-ts
T2.cancel
β2.cd
β2.cb
[c!=’e or ts2<=r-ts or ts2<=w-ts]
"1, 000, 000"
Pc
β1.bc
T1.fail2
[b==’e]
T1.fail1
β2.bc
T1.commit
T2.commit
<’e, ts1, ts1>
<’e, ts2, ts2>
<’e, ts1, ts1>
<’e, ts2, ts2> α1.ab β1.ab
T2.fail1
[b==’e]
T2.fail2
communication places carrying tokens concerned with "T1" from site "A" to site "B"
Fig. 6. Protocol specification corresponding to service specification and place allocation in Fig. 4(a)
412
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino site A
site B
site C
site D
T1.start ts1=gen_TS( ) ts1 comparing timestamps, T2 decides to wait for token b
ts2 ts2
T2.read
ts1
T2.start ts2=gen_TS( )
T1.read
T1.cancel
"’e"
T1.fail1
"’e"
T1.fail2 comparing timestamps, T1 decides not to wait for token c
T2.read T2.commit
T2.commit
T1.fail1
T2.commit
(a) site A
site B
T1.start ts1=gen_TS()
ts1 ts1
site C
T1.read
comparing timestamps, T2 decides to wait for token b
T1.read ts2 ts2 T1.commit
T1.commit T2.read
site D T2.start ts2=gen_TS()
comparing timestamps, T2 decides to wait for token c
T2.read
T2.commit
T2.commit T2.commit
(b)
Fig. 7. Timing charts for protocol specification in Fig. 6
– The timestamp of T2 (=ts2 ) was newer than that of T1 (=ts1 ) (i.e. ts2 > ts1 ). – The timestamp ts1 arrived at site C after the arrival of ts2 . Since ts2 > ts1 and T2 has already kept the token < c > in Pc , the execution of T1 was canceled at the site C, and empty value tokens indicating that “T1 was canceled at site C” were sent to sites A and B. – On the other hand, at site B, the arrival of ts1 was earlier than ts2 . T1 has kept the token < b > and waited for the notification of from site C. However, the tokens from site C indicated that the execution of T1 had been canceled at site C. Then site B immediately canceled the execution of T1 and released the token < b >. – While T1 was keeping the token < b >, the timestamp ts2 arrived at site B. Even though Pb had no token at that time, T2 waits for < b > to be released since Pb is a persistent place and ts2 is newer than ts1 . – After the execution of T1 is canceled at site B, T2 could keep the token < b > and send the token values to sites A and C. At this point, the sites A, B and C had acquired tokens in the input places Pb , Pc and Pd of T2 and thus had been ready to examine the condition of T2 . – Let us assume that the token values satisfy the condition of T2 . Then the execution of T2 is finished.
Decomposing Service Definition in Pr/T-Nets
413
Fig. 7(b) shows another scenario where T1 and T2 were accepted in this order. However, because of space limitation, the explanation is omitted here.
5
Validation and Example
The validation of the derivation algorithm is an important issue to confirm the correctness of the proposed method. To validate the algorithm, we have to show that the derived protocol is equivalent to the given service. Moreover, a practical example is mandatory to show the applicability of the method. As an example, we focus on a distributed database management system (DBMS) described as Pr/T-net in Ref.[12], which is one of the typical systems to show the expressive and analytical power of Pr/T-nets. Although this example is rather traditional, we think that the concept can be applied to recent applications which use databases such as information management service systems on the web implemented by collaborative web servers. Because of space limitation, these issues are given in a different document. Readers may refer to Ref. [14] for details.
6
Conclusion
We have proposed a protocol synthesis technique for systems modeled as Pr/Tnets (predicate/transition-nets), a first-order extension of Petri nets. Our technique is based on a top-down approach where a service requirement is defined in the form of a Pr/T-net like a centralized program, and then it is decomposed into communicating components located on different sites which, together, provide the required service. Our approach is original in the sense that it allows nonrestricted class of Pr/T-nets for specifying the services. This is a very important feature to model recent distributed collaborative systems since they often include multiple (and to be distinguished) processes such as mobile users. Moreover, we have presented a mutual exclusion algorithm for a distributed environment based on timestamps, which may improve the performance of the distributed systems. The applicability of our algorithm has been shown by an example. Deriving protocol specification by hand is very complex and we truly need tool supports. Therefore we have a plan to develop a derivation tool which coworks with existing designing tools such as Design/CPN, and this is part of our future work.
References 1. Jensen, K.: Coloured Petri Nets. Basic Concepts, Analysis Methods and Practical Use. Springer-Verlag (1997) 2. Saleh, K.: Synthesis of Communication Protocols: an Annotated Bibliography. ACM SIGCOMM Computer Communication Review, Vol. 26, No. 5 (1996) 40–59 3. Erdogmus, H., Johnston, R.: On the Specification and Synthesis of Communicating Processes. IEEE Trans. on Software Engineering, Vol. SE-16, No. 12 (1990)
414
Hirozumi Yamaguchi, Gregor von Bochmann, and Teruo Higashino
4. Gotzhein, R., Bochmann, G. v.: Deriving Protocol Specifications from Service Specifications Including Parameters. ACM Trans. on Computer Systems, Vol. 8, No. 4 (1990) 255–283 5. Kant, C., Higashino, T., Bochmann, G. v.: Deriving Protocol Specifications from Service Specifications Written in LOTOS. Distributed Computing, Vol. 10, No. 1 (1996) 29–47 6. Chu, P. -Y. M., Liu, M. T.: Protocol Synthesis in a State-transition Model. Proc. of COMPSAC ’88 (1988) 505–512 7. Kahlouche, H., Girardot, J. J.: A Stepwise Requirement Based Approach for Synthesizing Protocol Specifications in an Interpreted Petri Net Model. Proc. of INFOCOM ’96 (1996) 1165–1173 8. Al-Dallal, A., Saleh, K.: Protocol Synthesis Using the Petri Net Model. Prof. of 9th Int. Conf. on Parallel and Distributed Computing and Systems (PDCS’97) (1997) 9. Yamaguchi, H., El-Fakih, K., Bochmann, G.v., Higashino, T.: Protocol Synthesis and Re-synthesis with Optimal Allocation of Resources Based on Extended Petri Nets. Distributed Computing, Vol. 16, No. 1 (2003) 21–35 10. Khoumsi, A., Saleh, K.: Two Formal Methods for the Synthesis of Discrete Event Systems, Computer Networks and ISDN Systems, Vol. 29, No. 7 (1997) 759–780 11. Kapus-Koler, M.: Deriving Protocol Specifications from Service Specifications with Heterogeneous Timing Requirements. Proc. of 1991 Int. Conf. on Software Engineering for Real Time Systems (1991) 266–270 12. Voss, K.: Using Predicate/Transition-Nets to Model and Analyze Distributed Database Systems. IEEE Trans. on Software Engineering, Vol. 6, No. 6 (1980) 539–544 13. Korth, H. F., Silberschatz, A.: Database System Concepts. McGraw-Hill (1991) 14. Yamaguchi, H., Bochmann, G. v., Higashino, T.: Decomposing Service Definition in Predicate/Transition-Nets for Designing Distributed Systems. Online Document, http://www-tani.ist.osaka-u.ac.jp/techreport-e.html (2003)
Towards an Efficient Performance Evaluation of Communication Systems Described by Message Sequence Charts Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann Institute for Computer Science and Business Information Systems University of Duisburg-Essen, 45127 Essen, Schützenbahn 70 {Hesham, bmc}@informatik.uni-essen.de www.informatik.uni-essen.de
Abstract. A message sequence chart (MSC) is a high-level description of the message interaction between system components and their environment. Communication between distributed instances can be described by MSCs and these descriptions can be extended by notions for time consumption and resources and afterwards included in a system performance model. Such models can be evaluated by discrete event simulation or under reasonable assumptions alternatively with analytical queueing network algorithms. In this way steady state performance measures like resource utilizations and end-to-end delays can be calculated with low effort. The simulation uses the same input like the analytical formulas and allows for the investigation of dynamic performance behaviour or for the study of models including features which can not be handled by analytical formulas.
1 Introduction The motivation for this work originates from the IPonAir project on architectures of future mobile communication systems [13]. The IPonAIR/MxRAN1 project aims at a flexible radio access architecture that supports multi-band, multi-standard radio systems integration and the usage of existing and future IP-based protocols. A part of this project is the development of a discrete event simulation system which is to study the performance behaviour of different system designs. In [9 and 29] it is proposed to develop a simulation environment to analyze alternative network architectures and protocol stacks with respect to signalling performance. The authors describe a use case approach to construct a general event driven signalling protocol performance model. To this end Message Sequence Charts (MSCs) are employed as an input of use cases to a performance simulation tool. Many approaches do exist to enhance formal description techniques by nonfunctional information on time and resources. In the field of SDL and MSC an overview on the role of performance aspects is given in [21, 22 and 23]. Examples for tools combining the SDL and/or MSC methodology and performance evaluation are QUEST, SPEET, and SPECS [11, 12, 18, 22 and 23]. Much work has also been especially done with respect to Timed MSCs [22 and 23] and Performance MSC [18]. 1
MxRAN stands for Multi-band, Multi-standard Radio Access Network
H. König, M. Heiner, and A. Wolisz (Eds.): FORTE 2003, LNCS 2767, pp. 415–429, 2003. IFIP International Federation for Information Processing 2003
416
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
In [18], the Performance Message Sequence Chart (PMSC) language extends MSC96 by annotations to integrate performance aspects. Annotations have semantical meanings for performance evaluation tools as developped e.g. at the university of Erlangen-Nuremberg [10] but they are comments in the original language to allow standard tools to process the specification. PMSC is described in earlier versions in [6] and [7]. PMSC introduces a concept of time for an executed MSC by interpreting MSC events as actions that are executed by tasks which need some time to complete. Every task has a start and completion events that occur at some point in time. In PMSC a system model is used that has two separate sub-models, namely the load model and the machine model. The load model includes the MSC, which describes the functional dependencies between load units, the machine requirements, which are annotated with every load unit (action), and the traffic sources, that specify the intensity of the load. The machine model consists of queueing stations that model processors or channels between processors. To complete the system model a mapping from instances on modeled processors and communication paths on modeled channels must be obtained. To allow flexibility the concepts are separated in different documents. There are some approaches to integrate time and performance into MSC. [28] extends MSC-92 (MSC-Real Time) by language constructs rather than by annotations. [30] introduces an extension of MSC-96, called Timed MSC, to support performance testing. Performance simulation on the basis of formalised use cases with a language similar to MSC-96 is reported in [4]. A tool that uses MSC-96 for deriving performance models in early phases of the object-oriented software engineering process is described in [31]. In [17] a formal timed semantical model based on term rewriting rules is introduced for MSC-92. Most approaches to support specification based performance evaluation of systems in the SDL/MSC context extend SDL itself (e.g. the approach described in [5]). Since SDL and MSC are often combined in one project SDL- and MSC-based performance prediction should be integrated and share common documents to support consistency between both specifications. Here we follow the ideas sketched above; in particular we will use MSCs notions which are extended by annotations to describe required resource consumptions. The instances are assumed to run on resources which have a certain processing speed. In this way a performance model is established which can be quantitatively evaluated, either by discrete event simulation or by queueing network algorithms. Here we mainly follow the latter approach to efficiently calculate mean values for end-to-enddelays and resource utilizations. Moreover a simulation tool has been developed which allows evaluating models which do not satisfy the necessary assumptions to obtain analytical solutions. Additionally simulation can be used to study the dynamic performance behaviour. This paper illustrates the basic ideas by a simplified real world example taken from a project on future wireless communication.
2 Extending MSCs by Time and Resources 2.1 Introduction A message sequence chart (MSC) is a high-level description of the message interaction between system components and their environment. A major advantage of
Towards an Efficient Performance Evaluation of Communication Systems
417
the MSC language is its clear and unambiguous graphical layout, which immediately gives an intuitive understanding of the described system behavior. The syntax and semantics of MSCs are standardized by ITU-T, as recommendation Z.120. Message Sequence Charts is a language to describe the interaction between a numbers of independent message-passing instances. The basic constituents of the Message Sequence Chart are instance, message, general ordering, condition, timer, action, instance creation and termination. For more details see the ITU standardization documents [25, 26]. 2.2 An MSC Example Here our focus is on MSCs consisting only of instances and messages. The most fundamental language constructs of MSCs, are instances (e.g., entities of SDL systems, blocks, processes and services). Instances are reactive entities whose communication behavior is described by the MSCs. The message exchange is the only mean of communication among instances. Within the instance body the ordering events are specified. A message can be as simple as a signal or as complex as a sophisticated data packet. Each message is associated with a send and a receive event. To illustrate the basic ideas Fig. 1 shows a simple MSC-example.
Fig. 1. An example of an MSC (Graphical notation) 2.3 High Level MSC To define more complex scenarios, the High Level MSC (HMSC) provides a mean to graphically define how a set of MSC can be combined. A HMSC is a directed graph where different types of nodes can be found. An HMSC reference (a component) consists of a frame with rounded corners enclosing the name of the referenced HMSC. Every component has exactly one start node, indicated by an upside-down triangle. Also, it may contain a number of end nodes depicted by a triangle and several HMSC references.
418
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
(a)
(b)
(c)
(d)
Fig. 2. Basic Graphical Syntax of HMSC (taken from [1])
MSCs can be composed via operators into high-level MSCs (HMSC). MSCs are identified in HMSCs by so called MSC-references. To gain flexibility these high-level MSCs can be MSC-references themself. The various compositional operators of HMSC are sketched below, cf. [16 and 19]. Sequencing: Whenever two MSCs M1 and M2 are sequenced or concatenated, it is interpreted to be vertically composed. A strong sequencing of Ml and M2 is interpreted to mean that transfer to M2 is possible only after the termination of all events in Ml whereas weak sequencing of Ml and M2 denotes the parallel execution of Ml and M2 with the restriction that an action from M2 can be executed only if that is permitted by Ml as defined by consistency requirements for the MSCs. Selection: The selection operator is shown in Fig. 2(a). In Fig. 2(a), the branch MSC:M4 will be taken only if the condition denoted by 'C' is true and branch bMSC:M5 will be taken otherwise. Note that the feature introduces the notion of variables into MSCs and is useful in representing scenarios even though it adds complexity into the model. Parallel composition: This is also called horizontal composition, and means that multiple MSCs "run" in parallel. There is no restriction among the MCSs. Loops: A "Loop" is used to represent the possible execution of an MSC an arbitrary number of times with the possibility of termination. The loops are not explicit declared as an operation, but they can be constructed due the fact that the HMSC is a digraph.
Other HMSC operators are repetition, option, and exception. The operators option and exception are only abbreviations that can be encoded using (delayed) choice. Similarly finite repetition can be encoded using (delayed) choice and (weak) sequencing essentially by unfolding of the loop. Through the partial order of MSC
Towards an Efficient Performance Evaluation of Communication Systems
419
events a set of (totally ordered) traces is specified by one plain MSC. An HMSC with only finite loops can be seen as the definition of a set of plain MSCs where the sequential composition glues MSCs together, choice is a set of all possible branches and parallel composition is a set of all possible combinations of free merges where the precedences between MSC events in each MSC is preserved. 2.4 Introducing Time and Resources In order to construct quantitatively assessable models we extend MSCs by time and resources. This can be done in a rather straightforward way. Each message is associated with a service amount ai to be executed at the receiving instance i. Each instance has a speed gi, such that the service time is simply calculated by si=ai/gi. Of course we can group messages into classes and distinguish them, say by index j, j=1,.., m; hence we get the notion si,j = aij/gi, describing the service time of a message of class j at station i. Furthermore we consider the instances to behave like queueing stations, i.e. messages arriving at a busy instance are stored in a queue and will have to wait for service. Fig. 3 displays the execution of a timed MSC; each message has to spend some wait time at arrival at an instance (including the case of zero wait time) followed by a service time which depends on speed of the instance and the required service amount.
Instance1
Instance2
Instance3
Instance4 Wait time
m1 Endto-end delay
m3
Service time
m2 m4 m5
Fig. 3.Wait and service times during execution of a timed MSC
Moreover we consider MSCs to be “open“, i.e. the start of an MSC is triggered from the environment according to some interarrival distribution. Since we will employ analytical mean value formulas based on queueing network theory the interarrival distribution is assumed to be negative exponential. The same assumption is made for the service amounts. By combining MSCs using the HMSC operators of composition more complex traces can be defined. As a consequence we can define end-to-end delays also for HMSCs; this is done in a later section.
420
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
3 Mapping of MSC-Scenarios to Queueing Network Models Here we describe the derivation of a model which can be quantitatively assessed by means of analytical or simulative techniques. Since the instances are queueing stations and the messages can be considered to be customers or jobs we obtain a queueing network. Each queueing station consists of a wait queue and a server. Messages are generated according to an arrival rate λ, are served at the stations 1 through 4, and finally leave into a sink. CPU 4 Source
m4 CPU 1
m3
m5 CPU 2
m1
CPU 3
m2
Sink
Fig. 4. The example MSC transformed into a queueing network model
Depending on the interarrival distribution of messages, the service time distribution of the messages and the service disciplines of the stations such a network has the so called product form property and can be solved analytically, i.e. performance measures, like utilization of stations or response time can be derived very fast. Theory and algorithms are well established; indeed in this scenario we have a queueing network of Jackson type [14, 20]. Note that the numbering of messages defines their order of execution, here source ! m1! m2 ! m3 ! m4 ! m5 ! sink. On the other hand, the queueing network formula2 to be applied here does neglect the correct order of visits! What really matters when deriving mean performance measures is the number of visits (not their order) and the amount of requested service at the stations. Here we assume that each station is of type -/M/1-FCFS and MSC arrivals occur according to a Poisson stream and the service times of the messages are also negative exponentially distributed. In general we assume that a system consists of n stations and m different MSCs classes which arrive with an overall MSC arrival rate λ [MSCs/sec]. Each MSC consists of a certain number of messages which are to be served by the different stations. The arrival rate at station i is Pi λ, [messages/sec] where Pi is the number of messages to be served by station i, i = 1, 2, …, n for all MSCs of the classes j, j=1,.2, …, m. Let cij be the number of messages of an MSC of class j which are served at station i, then we can define Pi, the total number of messages received and served by station i, as follows: 2
In case any of these assumptions is not valid, we have to use approximation algorithms or discrete event simulation.
Towards an Efficient Performance Evaluation of Communication Systems
Pi =
m
∑c
ij
, i = 1, 2, ..., n,
for all stations i
j =1
421
(1)
The same way, we can define the message arrival rates λi,j [messages/sec] at station i for all messages of MSC class j as:
λ ij = c ij λ , i = 1, 2, ..., n ,
j = 1, 2, ..., m
(2)
Hence, the overall message arrival rate λi at station i for all messages of all MSC classes is:
λi = Pi λ , i = 1, 2, ..., n
(3)
Let µij be the service rate (messages of MSC class j / sec) at station i, i = 1, 2, …, n. According to our definition of service amount aij and speed of stations gi we have the service time sij = aij/gi and hence these service rates are defined by µij=1/sij [messages/sec].
4 Computing Performance Measures by Queueing Network Analysis Under the definitions given by equations 1, 2 and 3 we can easily compute mean values for stationary performance measures like station utilizations and response times. Of course the response times for each MSC class and the overall end-to-end delay (E2E) for the execution of a all MSCs can also be computed. 4.1 MSC Response Times Note that we calculate performance measures for the execution of MSCs, i.e. response time refers to the mean execution time of one MSC including wait times as well as service times. Link delays are only included if links are explicitly modeled as instances. Performance measures for single messages are not considered; moreover all messages belonging to the same MSC are not distinguished. An extension to distinguish between messages would lead to a three-indexed service amount, say aijk. This can be done, but is not in the scope of this paper. The utilization ρij of station i with respect to MSC class j is defined as
ρ ij =
λij , i = 1, 2, ..., n, µ ij
j = 1, 2, ..., m
(4)
Of course the overall utilization ρi for station i with respect to all MSC classes is m
λij =λ j = 1 µ ij m
ρ i = ∑ ρ ij = ∑ j =1
m
c ij
∑µ j =1
ij
, i = 1, 2, ..., n
(5)
422
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
Let Rij denote the response time for an MSC of class j that is served by station i, then we can apply the M/M/1 formula to get the response times Rij as follows:
Rij =
1 ρij ⋅ λ 1 − ρi
(6)
Let Rj denotes the overall response time for MSC of class j that is served by all stations, then we can apply the M/M/1 formula to get the Rj as follows:
1 n ρ ij R j = ∑ Rij = ∑ λ i = 1 1 − ρi i =1 n
(7)
4.2 End-to-End Delay for Strong Sequencing Composition in HMSC In the previous section, we assumed that Rj denotes the overall response time for MSC of class j that is served by all stations and the corresponding formula is given by equation 7. In this section we will derive a formula for calculating the end-to-end delay E2E. We can define the end-to-end delay to be the time between the arrival of the first message in the first MSC of the HMSC and the departure of the last message in the last MSC of that HMSC, i.e. the time needed to run a complete HMSC. We assume that we have n MSCs that are strongly sequenced and that the calculated response times are Rj , j = 1, 2,…, n. In this case the average end-to-end delay E2E gives the average time duration of one single execution of all MSCs by: m
m
ij ρ ij 1 n j =1 1 n ρi = = ∑ ∑ ∑ λ i =1 1 − ρ i λ i =1 1 − ρ i j =1 λ i =1 1 − ρ i m
E 2E = ∑ R j = ∑ j =1
∑ρ
1
n
(8)
Equation 8 gives a formula to calculate the end-to-end delay which can be applied in cases similar to the example, in which we have two MSCs that are vertically composed (see Fig. 7). According to the definition of the sequencing, the HMSC in the example represents a strong sequencing case. Note that we assumed that there is no time gap between the MSCs. The analytical computation of average end-to-end delay for other cases of HMSC compositions can be done under assumptions which must be defined more precisely. For the simulation we just determine the time between the start of the first and the end of the last message of all simulated HMSCs and calculate some statistic measures, like mean values, confidence intervals, minimum and maximum.
5 An Example from Mobile Communications We study an example which is closely related to current projects on third and fourth wireless initiatives, like the one pursued in the IPonAir-project. We consider the
Towards an Efficient Performance Evaluation of Communication Systems
423
communication interaction between User Equipment (UE, these are users with mobile terminals), one or several NodeBs (which are the UMTS equivalent to the Base Transceiver Stations, in the context of GSM known as BTS), a Radio Network Controller (RNC) and the Core Network (CN). This communication needs dozens of system functions which are structured into many MSCs with many hundreds of messages. Here we consider a scenario following system functions named “RRC connection setup” and “RRC connection release” as shown in Fig. 5 and Fig. 6. These two MSCs may grouped together to build a High Level MSC as displayed in Fig. 7. We consider a strongly sequenced pair of setup and release functions as a workload model. To build a scenario for performance evaluation we have to consider the execution of this HMSC assuming a certain traffic model, e.g. assuming a Poisson stream of HMSCs according a certain arrival rate; also a certain system configuration must be described.
UE
NodeB
RNC
CN
RRC_setup_req NBAP_setup_req
MSC_1 for Connection Setup
NBAP_setup_resp
CN_setup_req CN_setup_resp
ALCAP_setup_req ALCAP_setup_resp RRC_setup_complete
Fig. 5. MSC_1 for connection setup (partially fictitious)
UE
NodeB
RNC
CN
RRC_release_req CN_release_req
MSC_2 for Connection Release
CN_release_resp NodeB_release_req NodeB_release_resp
Fig. 6. MSC_2 for connection release (partially fictitious)
424
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
Start
MSC_1
Connection Setup
MSC_2
Connection Release
End Fig. 7. High Level MSC consisting of MSC1 and MSC2
We consider four queueing stations which are to execute (or do represent) the four instances and the HMSC combining the connection setup (MSC_1) and the connection release (MSC_2) respectively as displayed in Fig. 7. We assume speeds of 1000, 2000, and 5000 messages/sec for the stations, named UE, NodeB and CN. We run a series of model evaluations for three different RNCconfigurations by setting the speed of the station RNC to 3000, 4000 and 5000 messages/sec. The service amounts of the messages are set to 2.0 for service at NodeB, to 5.0 at the RNC, and to 10.0 at the CN-station; in this way we account roughly for the fact that a single message may represent multiple messages. We considered for each configuration the HMSC arrival rates λ =10, 20, …, 130 HMSC/sec, i.e. the number of Setup/ Release-Pairs described by HMSC are varied in the range from 10 to 130 per second. Please note, that we do just consider a part of the signalling traffic; neither other signalling traffic nor user traffic is included in this example. Note that the kind of queueing stations used in these calculations can be differently chosen to better describe real system properties, e.g. the UE-cluster should be modelled as an infinite-server station and the Radio Network Controler (RNC) and Core Network (CN) as multi-server stations. This would still result in analytically solvable models implying minor modifications of the analytical formulas. The evaluation of the formulas yields the end-to-end delays for the connection setup. As expected the evaluations provide exponentially increasing curves as displayed in Fig. 8. Such curves are useful to investigate in early design stages which amount of traffic can be carried by the planned configuration, or the other way round, what kind of resources are needed to carry the traffic under specified service levels. Although the necessary assumptions with respect to the independence of messages and negative exponential service normally do not hold exactly, these evaluations may be extremely helpful for a system developer. Such analytical results show the scope of possible parameter settings and allow a better planning of simulation scenarios which include more details and are closer to reality.
Towards an Efficient Performance Evaluation of Communication Systems
425
end-to-end delay
0.25
0.2
RNC speed = 3000
0.15
RNC speed = 4000
0.1
RNC speed = 5000
0.05 Speed is given in messages/sec 0 0
50
100
150
MSC arrivals [MSC/sec]
Fig. 8. End-to-end delay of MSC connection setup
6 Simulation of MSC Based Models Additional to the analytical formulas a simulation system has been developed, which uses the same input as the analytical model and delivers the same results, i. e. mean values and confidence intervals. Of course the simulator can be used to evaluate models which do not satisfy the conditions necessary for analytical evaluations; important examples for model features which violate these conditions are nonexponential distributed service times (e.g. low service time variations or even deterministic service), non-Poisson arrivals (e.g. bursty sources) and priority scheduling. This simulator has been written in Java using the JavaDEMOS package [8, 15 and 24]. JavaDemos is a Java library for discrete event simulation, which was inspired by the DEMOS system written by G. M. Birtwistle [2 and 3]. JavaDemos is based on an implementation of the DEMOS features in Java. The syntax of the procedures is as close as possible to DEMOS, in order to simplify the translation of DEMOS programs to JavaDemos. In addition, JavaDemos consists of a graphical front-end which permits the visualization of a simulation run and which allows basic interactions with the simulation system. The basic concept of JavaDEMOS include process-like objects which do implement behaviour patterns, which may acquire and release resources, may wait until certain conditions are fulfilled, are able to interact with each other in a master/slave mode and can of course be scheduled in the event list. Fig. 9 has taken from the simulation of our example described in a previous section. In the simulation the messages are entities and the visited stations (UE, NodeB, …) are modeled as resources. Fig. 9 (on the left) shows the entities which are scheduled in the event list according to their event times. Moreover, the state of all objects can be inspected at any time; Fig. 9 (on the right) shows the current values of the state variables of the station RNC, in particular the maximum queue length Q-
426
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
Fig. 9. The graphical user interface of JavaDEMOS
MAX, the current queue length Q-NOW, the average queue length and the average wait time. Observing these parameters dynamic performance behaviour can be inspected. As an example consider the values displayed in Fig. 9 showing a snapshot of the simulation at a certain point of time (here after approximately 34.43 seconds); since the utilization of the system is rather large the simulation is still in its transient phase and the average queue length is 12.27 (26444 observed messages, RNC utilization 93.6%,) in contrast to an average queue length of 15.4 after more than 773000 observed messages and 1000 sec model time (and we have still slightly growing utilization of 93.95 %), cf. Fig. 11. Also the maximum observed queue lengths of 61 (at time point 34.43) and 156 (at time point 1000, at the end of the simulation) respectively, illustrate some aspects of the dynamic system behaviour. The true stationary values (obtained by the analytical formulas) are still significantly higher than those obtained by simulation, namely 96.25 % for utilization and 26.66 for the average queue length. In Fig. 10 we can see the trace-window in which we can see step by step how the simulation proceeds. It shows the model times, the messages and their actions with respect to resource acquirements and resource releases.
Towards an Efficient Performance Evaluation of Communication Systems
427
Fig. 10. Trace window showing a running MSC simulation
Fig. 11. Report-window for the MSC simulation
A complete report can be obtained as shown in Fig. 11. We see in Fig. 11 the resources report which shows the observation number (the number of messages that visited each station), the maximum queue length for each station, the average queue length and the average wait time for entities in the queue for each station and finally the % usage (utilization) for each station. Other performance measures like the end-to-end-delay for a system function defined by one or several MSCs is not part of JavaDEMOS and has been programmed additionally including a batch means procedure for the estimation of confidence intervals.
Conclusion and Outlook Currently the tool is in a state that demonstrates the feasibility of the approach. In particular the automatic inclusion of complex system functions consisting of many procedures described as MSCs and HMSCs will allow to build up and evaluate
428
Hesham Kamal Arafat Mohamed and Bruno Müller-Clostermann
performance models with rather low effort. The analytical results can be used to get a fast overview on the overall stationary performance or potential bottlenecks. Simulation can alternatively used to study the dynamic behaviour or to show the impact of features which can not be represented sufficiently in analytical models. Future work will be directed towards the application of these methods and the associated tool to real world projects. Hence, the mapping of systems specified by MSC and HMSC to queueing networks must be conceptually enhanced and implemented. This includes the extension of the analytical formulas to a richer model world; for this purpose the field of queueing network theory provides vast resources. Acknowledgements
This work has been inspired by related work done in the IPonAir/MxRAN project. The authors acknowledge the contributions of Peter Schefczik, Michael Söllner, Wilfried Speltacker (all with Lucent Technologies, Nuremberg), Andreas MitscheleThiel (Technical University of Ilmenau), Georgios Nikolaidis (University of Athens) and Anja Wiedemann (University of Duisburg-Essen).
References 1. Belachev, M., Shyamasundar, R. K.: MSC+: From Requirement to Prototyped Systems. 13th Euromicro Conference on Real-Time Systems, Technical University of Delft, Delft, The Netherlands, June 13th - 15th, (2001), 117-124. 2. Birtwistle G. M.: DEMOS a System for Discrete Event Modelling on Simula. Macmillan, http://www.cosc.canterbury.ac.nz/teaching/classes/cosc327/ 3. Birtwistle G. M.: DEMOS Reference Manual, (1985) http://www.informatik.uni-essen.de/Lehre/Material/DiskreteSim/DemosRefMan.txt 4. Braga L., Manione, R., and Renditore, P.: A Formal Description Language for the Modelling and Simulation of Timed Interaction Diagrams. In: Gotzhein and Bredereke (eds.) [11], (1996) 245-260. 5. Diefenbruch, M., Hintelmann, J., and Müller-Clostermann, B.: The QUEST-Approach for the Performance Evaluation of SDL-Systems. In: Gotzhein and Bredereke (eds.) [11], (1996) 229-244. 6. Faltin, N., Lambert, L., Mitschele-Thiel, A., and Slomka, F.: An Annotational Extension of Message Sequence Charts to Support Performance Engineering. In: SDL'97: Time for Testing - SDL, MSC and Trends, Evry, France, Eighth SDL Forum, North-Holland, (1997) 307-322 7. Faltin, N., Lambert, L., Mitschele-Thiel, A., and Slomka F.: PMSC - Performance Message Sequence Chart. Technical Report 10/97, Universität Erlangen-Nürnberg, IMMD VII, Erlangen (1997) 8. Flüs, C., Mohamed, H., Müller-Clostermann, B.: JavaDEMOS: Java-based Discrete Event Simulation. In: MMB-Mitteilungen Nr. 41, (2002), cf. http://www.informatik.unibwmuenchen.de/mmb/mmb41/inhalt.htm 9. Frangiadakis, N., Nikolaidis, G., Schefczik, P., Wiedemann, A.: MxRAN Functional Architecture Performance Modeling. OPNET Conference, (2002) cf. http://www.iponair.de/publications.shtml 10. Friedrich-Alexander-Universität Erlangen-Nürnberg, Department of Computer Science 7 Homepage: http://www7.informatik.uni-erlangen.de
Towards an Efficient Performance Evaluation of Communication Systems
429
11. Gotzhein, R. and Bredereke, J. (eds.): Formal Description Techniques IX: Theory, application and tools, IFIP TC6 WG6.1 International Conference on Formal Description Techniques IX / Protocol Specification, Testing and Verification XVI, Kaiserslautern, Germany (1996) 12. Herzog, U.: Formal Methods in Performance Evaluation. In: Brinksma, E., Hermanns, H., Katoen, J.-P. (eds.): Lectures on Formal Methods and Performance Analysis; LNCS 2090, Springer (2001) 13. IPonAir Homepage : http://www.iponair.de 14. Jain, R.: The Art of Computer Systems Performance Analysis: Techniques for Experimental Design, Measurement, Simulation, and Modeling. John Wiley & Sons, Inc., New York (1991) 15. JavaDEMOS software on the JavaDEMOS home page: http://www.informatik.uniessen.de/SysMod/JavaDEMOS/ 16. Jonsson, B., Padilla, G.: An Execution Semantics for MSC2000. 10th International SDL Forum Copenhagen, Denmark, Springer Verlag LNCS 2078 (2001) 17. Kosiuczenko, P.: Time in Message Sequence Chart. In Lengauer C., Griebl M., and Gorlatch, S. (eds.), Euro-Par'97 Parallel Processing, Springer LNCS 1300, 562-566, (1997) 18. Lambert, L.: PMSC for Performance Evaluation. in: Mitschele-Thiel, A.; MüllerClostermann, B.; Reed, R. (eds.); Workshop on Performance and Time in SDL and MSC; February 17-19, 1998, University of Erlangen-Nürnberg 19. Mauw, S. and Reniers, M.A.: High-Level Message Sequence Charts. In Cavalli and Sarma [6], (1997) 291–306. 20. Menascé, D., Almeida, V. and Dowdy, L.: Capacity Planning and Performance Modeling: From Mainframes to Client-Server Systems. Prentice-Hall (1994) 21. Mitschele-Thiel, A.: Integrating Performance and Time in SDL and MSC – Current State and Vision. In [22] 22. Mitschele-Thiel, A., Müller-Clostermann, B. and Reed, R.(eds.): Proc. of Workshop on Performance and Time in SDL and MSC. February 17-19, 1998, University of ErlangenNürnberg 23. Mitschele-Thiel, A.: Systems Engineering with SDL – Developing Performance Critical Applications. Wiley (2000) 24. Mohamed, H.: Discrete Event Simulation Using JavaDEMOS. Technical Report, University of Essen, (2001) http://www.informatik.uni-essen.de/SysMod/publikationen/index.html, 25. MSC Standard, ITU-T. Recommendation Z.120, Message Sequence Charts. Geneva, (1999) 26. MSC-2000 MESSAGE SEQUENCE CHART (MSC), (revised in 2001), SDL Forum Version of Z.120 (11/99) rev. 1(14/11/01) 27. Padilla, G.: An Execution Semantics for MSC2000. August 2000, http://citeseer.nj.nec.com/padilla00execution.html 28. Schaffer. C.: MSC/RT: A Real-Time Extension to Message Sequence Charts (MSCs). Technical Report TR140-96, Johannes Kepler Universitat Linz, Institut für Systemwissenschaften (1996) 29. Schefczik, P., Mitschele-Thiel, A., Soellner, M. and Speltacker, W.: On MSC-Based Performance Simulation. the Third International Workshop on Software and Performance (WOSP 2002), Rome (2002) 30. Schieferdecker, I., Rennoch A., and Mertens, O.: Timed MSCs - an Extension to MSC96. In Wolisz et al. [32], (1997) 165-174. 31. Smith, C.U. and Williams, L.G.: Performance Engineering Evaluation of Object-Oriented Systems with SPEED. In R. Marie, B. Plateau, M. Calzarossa, and G. Rubino, (eds.), Computer performance evaluation, Springer LNCS 1245 (1997) 32. Wolisz, A., Schieferdecker, I. and Rennoch, A. (eds.): Formale Beschreibungstechniken für verteilte Systeme. GMD-Studie Nr. 315, Berlin, Germany, GI/ITG, GMD-Forschungszentrum (1997)
Author Index
Netravali, Arun N. 303 Noack, Andreas 193 N´ un ˜ez, Manuel 335
Basu, Samik 79 Beyer, Dirk 193 Billington, Jonathan 209 Bochmann, Gregor von 367, 399 Bowman, Howard 177 Broy, Manfred 48 Buffalov, Sergey 367
Peled, Doron
Qu, Hongyang 127 Quaglia, Francesco 62
Carrez, Cyril 111 Cibario Bertolotti, Ivan 224 Ciciani, Bruno 62 Courtiat, Jean-Pierre 351
Robinson, Peter 144 Rodr´ıguez, Ismael 335 Romano, Paolo 62 Romero, Milton 62 Rychwalski, Pawe´´l 1
Duale, Ali Y. 273 Durante, Luca 224 El-Fakih, Khaled
Sabnani, Krishan K. 303 Saha, Diptikalyan 79 Shankland, Carron 144 Sisto, Riccardo 224 Smolka, Scott A. 79 Stirling, Colin 95 Sun, Tao 319
367
Fantechi, Alessandro 111 Fecko, Mariusz A. 273 Gallasch, Guy Edward 209 G´ omez, Rodolfo 177 Gotzhein, Reinhard 31
Taghdiri, Mana 240 Thees, Joachim 383 Turner, Kenneth J. 15
Herrmann, Peter 257 Hierons, Robert M. 289 Higashino, Teruo 319, 399 Hwang, Geng-Dian 160 Jackson, Daniel
240
Kempster, Tim
95
Lin, Yow-Jian
Najm, Elie
Ural, Hasan 289 ¨ Uyar, M. Umit 273 Valenzano, Adriano 224 Viswanathan, Ramesh 303 Wang, Farn 160 Wytr bowicz, Jacek
79
Mohamed, Hesham Kamal Arafat Mori, Masaaki 319 M¨ uller-Clostermann, Bruno 415 111
127
1
415 Yamaguchi, Hirozumi 399 Yasumoto, Keiichi 319 Yevtushenko, Nina 367 Yu, Fang 160