Colored Petri Nets Anis Yousefi ayousefice sharif edu

  • Slides: 55
Download presentation
Colored Petri Nets Anis Yousefi a_yousefi@ce. sharif. edu Elmira Movahedi Mehr elmiramovahedi@mehr. sharif. edu

Colored Petri Nets Anis Yousefi a_yousefi@ce. sharif. edu Elmira Movahedi Mehr elmiramovahedi@mehr. sharif. edu Coloured Petri Nets 18/09/2020 1

Contents u Petri Nets u Colored Petri Nets u Hierarchical Colored Petri Nets u

Contents u Petri Nets u Colored Petri Nets u Hierarchical Colored Petri Nets u Timed Colored Petri Nets u Simulation u Formal Verification Coloured Petri Nets 18/09/2020 2

Petri Nets u Petri Nets (PN) are a graphical tool for the formal description

Petri Nets u Petri Nets (PN) are a graphical tool for the formal description of the flow of activities in complex systems. u Petri net consists of places, transitions, directed arcs and tokens. u Places may contain any number of tokens. u Transitions fire, that is consume tokens from input positions and produce tokens in output positions. A transition is enabled if there are tokens in every input position. u Arcs connect a place to a transition and vice versa. There are no arcs between two places, nor between two transitions. u Tokens represents the state which (part of) the system may be in. Coloured Petri Nets 18/09/2020 3

Producer, Consumer Problem Coloured Petri Nets 18/09/2020 4

Producer, Consumer Problem Coloured Petri Nets 18/09/2020 4

What is a Coloured Petri Net? u Modelling language for systems where synchronisation, communication,

What is a Coloured Petri Net? u Modelling language for systems where synchronisation, communication, and resource sharing are important. u Combination of Petri Nets and Programming Language. n Control structures, synchronisation, communication, and resource sharing are described by Petri Nets. n Data and data manipulations are described by functional programming language. u CPN models are validated by means of simulation and verified by means of state spaces and place invariants. u Coloured Petri Nets is developed at University of Aarhus, Denmark over the last 25 years. Coloured Petri Nets 18/09/2020 5

What are models used for? u u Static Model n Modular architecture of systems

What are models used for? u u Static Model n Modular architecture of systems n Data model n Class diagrams Dynamic Models n Behaviour of systems n Exchange of messages n State changes Coloured Petri Nets 18/09/2020 6

Why do we make models? u u We make models to: n Learn new

Why do we make models? u u We make models to: n Learn new things about a system. n To check that the system design has certain expected properties. CPN models are dynamic: n They can be executed on a computer. n This allows us to play and investigate different scenarios. Coloured Petri Nets 18/09/2020 7

Simple protocol Coloured Petri Nets 18/09/2020 8

Simple protocol Coloured Petri Nets 18/09/2020 8

Simple protocol Places Coloured Petri Nets 18/09/2020 9

Simple protocol Places Coloured Petri Nets 18/09/2020 9

Simple protocol Transitions Coloured Petri Nets 18/09/2020 10

Simple protocol Transitions Coloured Petri Nets 18/09/2020 10

Simple protocol Place Coloured Petri Nets 18/09/2020 Type (colour set) 11

Simple protocol Place Coloured Petri Nets 18/09/2020 Type (colour set) 11

Simple protocol Place Coloured Petri Nets 18/09/2020 Initial Marking 12

Simple protocol Place Coloured Petri Nets 18/09/2020 Initial Marking 12

Marking of Send INTx. DATA Send 8 1 ` (1, "Modellin") + 1 `

Marking of Send INTx. DATA Send 8 1 ` (1, "Modellin") + 1 ` (2, "g and An") + 1 ` (3, "alysis b") + 1 ` (4, "y Means ") + 1 ` (5, "of Colou") + 1 ` (6, "red Petr") + 1 ` (7, "i Nets##") + 1 ` (8, "####") Number of tokens Multi-set of token colours Coloured Petri Nets 18/09/2020 13

Simple protocol Arc Inscriptions Coloured Petri Nets 18/09/2020 14

Simple protocol Arc Inscriptions Coloured Petri Nets 18/09/2020 14

Simple protocol Coloured Petri Nets 18/09/2020 15

Simple protocol Coloured Petri Nets 18/09/2020 15

Simple protocol Buffer places Interface Coloured Petri Nets 18/09/2020 16

Simple protocol Buffer places Interface Coloured Petri Nets 18/09/2020 16

Simple protocol Packets to be sent Coloured Petri Nets 18/09/2020 17

Simple protocol Packets to be sent Coloured Petri Nets 18/09/2020 17

Simple protocol Counter Coloured Petri Nets 18/09/2020 18

Simple protocol Counter Coloured Petri Nets 18/09/2020 18

Simple protocol Counter Coloured Petri Nets 18/09/2020 19

Simple protocol Counter Coloured Petri Nets 18/09/2020 19

Simple protocol Data received Coloured Petri Nets 18/09/2020 20

Simple protocol Data received Coloured Petri Nets 18/09/2020 20

Simple protocol Coloured Petri Nets 18/09/2020 21

Simple protocol Coloured Petri Nets 18/09/2020 21

Send packet u p = "Modellin" The binding <n=1, p="Modellin"> (1, p) is enabled.

Send packet u p = "Modellin" The binding <n=1, p="Modellin"> (1, p) is enabled. u When the binding occurs it adds a token to place A. u This represents that the packet (1, "Modellin") is sent to the network. u The packet is not removed from place Send and the Next. Send counter is not n=1 changed. Coloured Petri Nets 18/09/2020 1 1`(1, "Modellin") 22

Simple protocol Coloured Petri Nets 18/09/2020 23

Simple protocol Coloured Petri Nets 18/09/2020 23

Transmit packet r 1. . 10 if Ok(s, r) then 1`(n, p) else empty

Transmit packet r 1. . 10 if Ok(s, r) then 1`(n, p) else empty INTx. DATA Transmit Packet (n, p) A 1 1`(1, "Modellin") n = 1, p = "Modellin" u Coloured Petri Nets 18/09/2020 s 8 RP INTx. DATA B s=8 1 1`8 Int_0_10 All enabled bindings are on the form: n <n=1, p= "Modellin", s=8, r=. . . > n where r 1. . 10 24

Loss of packets u The function Ok(s, r) checks whether r s. n n

Loss of packets u The function Ok(s, r) checks whether r s. n n u if Ok(s, r) then 1`(n, p) else empty For r 1. . 8, Ok(s, r)=true. The token is moved from A to B. This means that the packet is successfully transmitted over the network. For r 9. . 10, Ok(s, r)=false. No token is added to B. This means that the packet is lost. The CPN simulator makes random choices between bindings: 80% chance for successful transfer. Coloured Petri Nets 18/09/2020 25

Simple protocol Coloured Petri Nets 18/09/2020 26

Simple protocol Coloured Petri Nets 18/09/2020 26

Receive packet u The number of the incoming packet n and the number of

Receive packet u The number of the incoming packet n and the number of the expected packet k are compared. Coloured Petri Nets 18/09/2020 27

Simple protocol Coloured Petri Nets 18/09/2020 28

Simple protocol Coloured Petri Nets 18/09/2020 28

Transmit acknowledgement Coloured Petri Nets 18/09/2020 u This transition works in a similar way

Transmit acknowledgement Coloured Petri Nets 18/09/2020 u This transition works in a similar way as Transmit Packet. u The marking of RA determines the success rate. 29

Simple protocol Coloured Petri Nets 18/09/2020 30

Simple protocol Coloured Petri Nets 18/09/2020 30

Receive acknowledgement u When an acknowledgement arrives to the Sender it is used to

Receive acknowledgement u When an acknowledgement arrives to the Sender it is used to update the Next. Send counter. n Coloured Petri Nets 18/09/2020 In this case the counter value becomes 2, and hence the Sender will begin to send packet number 2. 31

CP-nets has a formal definition u u The existence of a formal definition is

CP-nets has a formal definition u u The existence of a formal definition is important: n Basis for simulation, i. e. , execution of the CP-net. n Basis for the formal verification methods (e. g. , state spaces and place invariants). It is not necessary for a user to know the formal definition of CP-nets: n Correct syntax is checked by the CPN editor. n Correct semantics is guaranteed by the CPN simulator and the CPN verification tools. Coloured Petri Nets 18/09/2020 32

High-level Petri nets u u The relationship between CP-nets and ordinary Petri nets (PT-nets)

High-level Petri nets u u The relationship between CP-nets and ordinary Petri nets (PT-nets) is analogous to the relationship between high-level programming languages and assembly code. n In theory, the two levels have exactly the same computational power. n In practice, high-level languages have much more modelling power – because they have better structuring facilities, e. g. , types and modules. Several other kinds of high-level Petri Nets exist. However, Coloured Petri Nets is the most widely used – in particular for practical work. Coloured Petri Nets 18/09/2020 33

CP-nets are used for large systems u A CPN model consists of a number

CP-nets are used for large systems u A CPN model consists of a number of modules. n Also called subnets or pages. n Well-defined interfaces. u A typical industrial application of CP-nets has: n 10 -200 modules. n 50 -1000 places and transitions. n 10 -200 types. u Industrial applications of this size would be totally impossible without: n Data types and token values. n Modules. n Tool support. Coloured Petri Nets 18/09/2020 34

Modules Coloured Petri Nets 18/09/2020 35

Modules Coloured Petri Nets 18/09/2020 35

Three different modules Receiver Sender I/O Network Out In u Coloured Petri Nets 18/09/2020

Three different modules Receiver Sender I/O Network Out In u Coloured Petri Nets 18/09/2020 In Out Port places are used to exchange tokens between modules. 36

Abstract view Protocol HS HS HS Sender Network Receiver u Coloured Petri Nets 18/09/2020

Abstract view Protocol HS HS HS Sender Network Receiver u Coloured Petri Nets 18/09/2020 u Substitution transitions refer to modules. Socket places are related to port places. 37

Modules can be reused Protocol HS Receiver HS HS Sender Network HS Receiver Coloured

Modules can be reused Protocol HS Receiver HS HS Sender Network HS Receiver Coloured Petri Nets 18/09/2020 38

Hierarchical descriptions u We use modules to structure large and complex descriptions. u Modules

Hierarchical descriptions u We use modules to structure large and complex descriptions. u Modules allow us to hide details that we do not want to consider at a certain level of abstraction. u Modules have well-defined interfaces, consisting of socket and port places, through which the modules exchange tokens with each other. u Modules can be reused. Coloured Petri Nets 18/09/2020 39

Time analysis u CP-nets can be extended with a time concept. This means that

Time analysis u CP-nets can be extended with a time concept. This means that the same modelling language can be used to investigate: n Logical correctness. Desired functionality, absence of deadlocks, etc. n Performance. How fast is the system and how many resources are used. Coloured Petri Nets 18/09/2020 40

How to add time u Time has been added to Petri net models in

How to add time u Time has been added to Petri net models in many different ways – typically by specifying delays on places or transitions. CPN model data value (token colour) token time value (time stamp) u Time stamp determines when the token can be used, i. e. , consumed by a transition. n Delays can be fixed. n Determined by an arbitrary distribution. Coloured Petri Nets 18/09/2020 41

A timed CP-net for protocol Retransmission delay Coloured Petri Nets 18/09/2020 Fixed delay Variable

A timed CP-net for protocol Retransmission delay Coloured Petri Nets 18/09/2020 Fixed delay Variable delay 42

Application areas Protocols and Networks u u u Intelligent Networks at Deutsche Telekom IEEE

Application areas Protocols and Networks u u u Intelligent Networks at Deutsche Telekom IEEE 802. 6 Configuration Control at Telstra Research Labs Allocation Policies in the Fieldbus Protocol in Japan ISDN Services at Telstra Research Laboratories Protocol for an Audio/Video System at Bang & Olufsen TCP Protocols at Hewlett-Packard Local Area Network at University of Las Palmas UPC Algorithms in ATM Networks at University of Aarhus BRI Protocol in ISDN Networks Network Management System at RC International A/S Interprocess Communication in Pool IDA at King's College Software u u u u Coloured Petri Nets 18/09/2020 Mobile Phones at Nokia Bank Transactions & Interconnect Fabric at Hewlett-Packard Mutual Exclusion Algorithm at University of Aarhus Distributed Program Execution at University of Aarhus Internet Cache at the Hungarian Academy of Science Electronic Funds Transfer in the US Document Storage System at Bull AG ADA Program at Draper Laboratories 43

Control of Systems u u u u Security and Access Control Systems at Dalcotech

Control of Systems u u u u Security and Access Control Systems at Dalcotech A/S Mechatronic Systems in Cars at Peugeot-Citroën in France European Train Control System in Germany Flowmeter System at Danfoss Traffic Signals in Brazil Chemical Production in Germany Model Train System at University of Kiel Hardware u u u Superscalar Processor Architectures at Univ. of Newcastle VLSI Chip in the US Arbiter Cascade at Meta Software Corp. Military Systems u u Military Communications Gateway in Australia Influence Nets for the US Air Force Missile Simulator in Australia Naval Command Control System in Canada Other Systems u Bank Courier Network at Shawmut National Coop. u Nuclear Waste Management Programme in the US Coloured Petri Nets 18/09/2020 44

Simulation of CP-nets u When a syntactical correct CPN diagram has been constructed, the

Simulation of CP-nets u When a syntactical correct CPN diagram has been constructed, the CPN tool generates the necessary code to perform simulations. n Calculates whether the individual transitions and bindings are enabled. n Calculates the effect of occurring transitions and bindings. We distinguish between two kinds of simulations: n In an interactive simulation the user is in control, but most of the work is done by the system. n In an automatic simulation the system does all the work. Coloured Petri Nets u 18/09/2020 45

Simulation report 1 Send. Pack@(1: Top#1){n=1, p="Modellin"} 2 Tran. Pack@(1: Top#1){n=1, p="Modellin", r=6, s=8}

Simulation report 1 Send. Pack@(1: Top#1){n=1, p="Modellin"} 2 Tran. Pack@(1: Top#1){n=1, p="Modellin", r=6, s=8} 3 Send. Pack@(1: Top#1){n=1, p="Modellin"} 4 Tran. Pack@(1: Top#1){n=1, p="Modellin", r=3, s=8} 5 Rec. Pack@(1: Top#1) {k=1, n=1, p="Modellin", str= 6 Send. Pack@(1: Top#1){n=1, p="Modellin"} Transition Coloured Petri Nets 18/09/2020 Module Binding 46

State spaces u A state space is a directed graph with: n A node

State spaces u A state space is a directed graph with: n A node for each reachable marking (i. e. , state). n An arc for each occurring binding element. transition + binding 2 Cycle 5 1 3 4 Coloured Petri Nets 18/09/2020 7 Deadlock 6 8 47

State space tool u State spaces are often very large. u The CPN state

State space tool u State spaces are often very large. u The CPN state space tool allows the user to: u n Generate state spaces. n Analyse state spaces to obtain information about the behaviour of the modelled system. Generation is totally automatic while analysis is automatic or semi-automatic (based on queries from the user). Coloured Petri Nets 18/09/2020 48

State space report u Generation of the state space report takes often only a

State space report u Generation of the state space report takes often only a few seconds. n The report contains a lot of useful information about the behaviour of the CP -net. n The report is excellent for locating errors or to increase our confidence in the correctness of the system. Coloured Petri Nets 18/09/2020 49

State spaces - pro/contra u u State spaces are powerful and easy to use.

State spaces - pro/contra u u State spaces are powerful and easy to use. n Construction and analysis can be automated. n No need to know the mathematics behind the analysis methods. The main drawback is the state explosion, i. e. , the size of the state space. Coloured Petri Nets 18/09/2020 50

Place invariants u The basic idea is similar to the use of invariants in

Place invariants u The basic idea is similar to the use of invariants in program verification. u An invariant describes a property which is fulfilled for all reachable states. n We first construct a set of place invariants. n Then we check whether they are fulfilled. n Finally, we use the place invariants to prove behavioural properties of the CP-net. Coloured Petri Nets 18/09/2020 51

Invariants - pro/contra u Invariants can be used to verify large systems. n n

Invariants - pro/contra u Invariants can be used to verify large systems. n n u No complexity problems. It is possible to combine invariants from individual modules. The main drawback is that the user needs some ingenuity to: n n Coloured Petri Nets 18/09/2020 Construct invariants. This can be supported by computer tools – interactive process. Use invariants. This can also be supported by computer tools – interactive process. 52

Conclusion u One of the reasons for the success of CP-nets is the fact

Conclusion u One of the reasons for the success of CP-nets is the fact that we simultaneously have worked in all three areas. Coloured Petri Nets 18/09/2020 53

References u De Figueiredo and Kristensen, “Using Coloured Petri Nets to Investigate behavioural and

References u De Figueiredo and Kristensen, “Using Coloured Petri Nets to Investigate behavioural and performance issues of TCP protocols”, University of Aarhus, Denmark, 2003. u K. Jensen: “An Introduction to the Theoretical Aspects of Coloured Petri Nets”. In: J. W. de Bakker, W. -P. de Roever, G. Rozenberg (eds. ): A Decade of Concurrency, Lecture Notes in Computer Science Vol. 803, Springer-Verlag 1994, 230– 272. u Jensen, K. : “An Introduction to the Practical Use of Coloured Petri Nets”. In: Reisig, W. , Rozenberg, G. (eds. ): Lectures on Petri nets II. LNCS 1492. Berlin, Heidelberg, New York: Springer Verlag, 1998, pp. 237{292 u A. S. Tanenbaum, “Computer Networks”, , Prentice Hall fifth edition, 2003. u CPN Tools Help Coloured Petri Nets 18/09/2020 54

Thanks for your attention! Questions? Coloured Petri Nets 18/09/2020 55

Thanks for your attention! Questions? Coloured Petri Nets 18/09/2020 55