Dr. Eng Amr T. Abdel-Hamid

Slides:



Advertisements
Similar presentations
School of Computer Science & Software Engineering
Advertisements

Principles of Engineering System Design Dr T Asokan
Workflow Management Systems © Dr. Rafael A. Calvo – Edited by Mark Aufflick (pumptheory.com) School of Electrical and Information Eng, University of Sydney.
1 Petri Nets I Paul Fishwick author From
1 SE-561 Formal Methods in Software Petri Nets - I.
Course: Software Engineering II academic year: Course Web-site: [ Lecturer: Catia Trubiani.
An Introduction to Petri Nets
Principles of Engineering System Design Dr T Asokan
Introduction to Petri Nets Hugo Andrés López
Petri Nets Section 2 Roohollah Abdipur.
Based on: Petri Nets and Industrial Applications: A Tutorial
PROTOCOL VERIFICATION & PROTOCOL VALIDATION. Protocol Verification Communication Protocols should be checked for correctness, robustness and performance,
Chapter 3 Petri nets Learning objectives : Introduce Petri nets
1 Modeling based on Petri-nets. Lecture 8. 2 High-level Petri nets The classical Petri net was invented by Carl Adam Petri in A lot of research.
IE 469 Manufacturing Systems
Discrete Interaction Design Specification Prof. Dr. Matthias Rauterberg Faculty Industrial Design Technical University of Eindhoven
Lei Bu Petri Nets 11 Dining Philosphier 4 States , 5 transitions.
Synthesis of Embedded Software Using Free-Choice Petri Nets.
Petri Nets Overview 1 Definition of Petri Net C = ( P, T, I, O) Places P = { p 1, p 2, p 3, …, p n } Transitions T = { t 1, t 2, t 3, …, t n } Input.
CSC 402 Requirements Engineering 1 Requirements Techniques, cont. Formal requirements analysis techniques include: – DFD (covered) – ERD (covered) – Finite.
1 Gas Station and Cruise Control Specifications Ronnie Apcar Edwin Chiu Hasmik Jerejian November 2, 2000 CSCI 599 Formal Methods November 2, 2000 Concurrency.
1 Petri Nets H Plan: –Introduce basics of Petri Net models –Define notation and terminology used –Show examples of Petri Net models u Calaway Park model.
FunState – An Internal Design Representation for Codesign A model that enables representations of different types of system components. Mixture of functional.
Data and Knowledge Representation Lecture 6 Qing Zeng, Ph.D.
1 Petri Nets Marco Sgroi EE249 - Fall 2001 Most slides borrowed from Luciano Lavagno’s lecture ee249 (1998)
Mata kuliah :K0362/ Matematika Diskrit Tahun :2008
PETRINETS Nipun Devlekar Zauja Lahtau. PETRINETS DEFINITION : DEFINITION :  PETRINET (place/ transition net): a formal, graphical, executable technique.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
An Introduction to Petri Nets Marjan Sirjani Formal Methods Laboratory University of Tehran.
Modeling with ordinary Petri Nets Events: Actions that take place in the system The occurrence of these events is controlled by the state of the system.
CY2003 Computer Systems Lecture 7 Petri net. © LJMU, 2004CY2003- Week 72 Overview Petri net –concepts –Petri net representation –Firing a transition –Marks.
Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Modelling and Validation of Concurrent Systems.
Stochastic Activity Networks ( SAN ) Sharif University of Technology,Computer Engineer Department, Winter 2013 Verification of Reactive Systems Mohammad.
Generalized stochastic Petri nets (GSPN)
Petri Nets Lecturer: Roohollah Abdipour. Agenda Introduction Petri Net Modelling with Petri Net Analysis of Petri net 2.
Modelling by Petri nets
Ch5: Software Specification. 1 Petri Nets  Introduced by C. Adams Petri in  Widely used in the modeling and analysis of computer systems.  Basic.
CSCI1600: Embedded and Real Time Software Lecture 11: Modeling IV: Concurrency Steven Reiss, Fall 2015.
School of Computer Science & Software Engineering
CAP 4800/CAP 5805: Computer Simulation Concepts
1 Petri Nets Ina Koch and Monika Heiner. 2 Petri Nets(1962) Carl Adam Petri.
Petri-Nets and Other Models
2008/10E-Enterprise Integration - eEI1 Lecture 6 Petri Net Techniques for Modeling Workflows and Their Support of Reuse.
Page 1 8/29/2001 Reachability Analysis CFSM: Communicating Finite State Machines C1 C2 +A+A Sender 2 1 -R-R +R+R -A-A Receiver 2 1 CFSM Communicating Finite.
Process Mining – Concepts and Algorithms Review of literature on process mining techniques for event log data.
Dr. Eng Amr T. Abdel-Hamid
Requirements Techniques, cont.
Advantages of FSM Their simplicity make it easy for inexperienced developers to implement with little to no extra knowledge (low entry level)
Concurrent Systems Modeling using Petri Nets
Finite State Machines Dr K R Bond 2009
Operating systems Deadlocks.
PROTOCOL CORRECTNESS Tutorial 3 Theoretical
Clockless Computing COMP
COT 5611 Operating Systems Design Principles Spring 2014
Concurrent Systems Modeling using Petri Nets – Part II
Workflow Management Systems
CAP 4800/CAP 5805: Computer Simulation Concepts
CAP 4800/CAP 5805: Computer Simulation Concepts
بسمه‌تعالي فصل چهاردهم شبکه‌هاي پتري.
CSCI1600: Embedded and Real Time Software
Introduction to Petri Nets (PNs)
Modeling based on Petri-nets.
Operating systems Deadlocks.
COT 5611 Operating Systems Design Principles Spring 2012
Coloured Petri Nets Modelling and Validation of Concurrent Systems
CAP 4800/CAP 5805: Computer Simulation Concepts
Petri Net :Abstract formal model of information flow Major use:
CSE 486/586 Distributed Systems Global States
CSCI1600: Embedded and Real Time Software
Petri Nets Laurie Frazier.
Presentation transcript:

Dr. Eng Amr T. Abdel-Hamid NETW 703 Network Protocols Petri Nets Dr. Eng Amr T. Abdel-Hamid Spring 2008 Based on lectures from: * Dr Chris Ling, School of Computer Science & Software Engineering Monash University * Claus Reinke, Computing Lab, UKC

Introduction First introduced by Carl Adam Petri in 1962. A diagrammatic tool to model concurrency and synchronization in distributed systems. Very similar to FSMs. Used as a visual communication aid to model the system behaviour. Based on strong mathematical foundation. 2/47

Example: EFTPOS System (STD of an FSM) Initial 1 digit d1 d2 d3 d4 OK pressed approve Approved Rejected Initial state Final state Reject 3/47

Example: EFTPOS System (A Petri net) Initial 1 digit d1 d2 d3 d4 OK pressed approve approved Reject Rejected! 4/47

Petri Net Example Arc with w=1 Arc Place Token Transition I(tj) = {pi P : (pi, tj) A} O(tj) = {pi P : (tj, pi) A} I(pi) ={tj T : (tj, pi) A} O(pi) ={tj T : (pi, tj) A} 5/47

EFTPOS System Scenario 1: Normal Enters all 4 digits and press OK. Scenario 2: Exceptional Enters only 3 digits and press OK. 6/47

Example: EFTPOS System (Token Games) Initial 1 digit d1 d2 d3 d4 OK pressed approve approved Reject Rejected! 7/47

A Petri Net Specification ... consists of three types of components: places (circles), transitions (rectangles) and arcs (arrows): Places represent possible states of the system. Transitions are events or actions which cause the change of state. Every arc simply connects a place with a transition or a transition with a place. 8/47

A Change of State … is denoted by a movement of token(s) (black dots) from place(s) to place(s); and is caused by the firing of a transition. The firing represents an occurrence of the event or an action taken. The firing is subject to the input conditions, denoted by token availability. 9/47

A Change of State A transition is firable or enabled when there are sufficient tokens in its input places. After firing, tokens will be transferred from the input places (old state) to the output places, denoting the new state. Note that the EFTPOS example is a Petri net representation of a finite state machine (FSM). 10/47

Example: Vending Machine The machine dispenses two kinds of snack bars – 20c and 15c. Only two types of coins can be used – 10c coins and 5c coins. The machine does not return any change. 11/47

Example: Vending Machine (STD of an FSM) 0 cent 5 cents 10 cents 15 cents 20 cents Deposit 5c Deposit 10c Take 20c snack bar Take 15c snack bar 12/47

Modeling FSMs vend 15¢ candy 10 15 5 5 5 5 5 10 10 20 10 5 10 10 20 10 vend 20¢ candy 13/47

Modeling FSMs state machines: each transition has exactly vend 15¢ candy 10 5 state machines: each transition has exactly one input and one output 5 5 5 10 10 vend 20¢ candy 14/47

Example: Vending Machine (A Petri net) Take 15c bar Deposit 5c 0c Deposit 10c Deposit 5c 10c Deposit 20c 15c Take 20c bar 15/47

Example: Vending Machine (3 Scenarios) Deposit 5c, deposit 5c, deposit 5c, deposit 5c, take 20c snack bar. Scenario 2: Deposit 10c, deposit 5c, take 15c snack bar. Scenario 3: Deposit 5c, deposit 10c, deposit 5c, take 20c snack bar. 16/47

Example: Vending Machine (Token Games) Take 15c bar Deposit 5c 0c Deposit 10c Deposit 5c 10c Deposit 20c 15c Take 20c bar 17/47

Multiple Local States In the real world, events happen at the same time. A system may have many local states to form a global state. There is a need to model concurrency and synchronization. 18/47

Example: In a Restaurant (A Petri Net) Waiter free Customer 1 Customer 2 Take order Take order wait Order taken wait eating eating Tell kitchen Serve food Serve food 19/47

Example: In a Restaurant (Two Scenarios) Waiter takes order from customer 1; serves customer 1; takes order from customer 2; serves customer 2. Scenario 2: Waiter takes order from customer 1; takes order from customer 2; serves customer 2; serves customer 1. 20/47

Example: In a Restaurant (Scenario 1) Waiter free Customer 1 Customer 2 Take order Take order wait Order taken wait eating eating Tell kitchen Serve food Serve food 21/47

Example: In a Restaurant (Scenario 2) Waiter free Customer 1 Customer 2 Take order Order taken Tell kitchen wait Serve food eating 22/47

Net Structures A sequence of events/actions: Concurrent executions: e1 23/47

Net Structures Non-deterministic events - conflict, choice or decision: A choice of either e1, e2 … or e3, e4 ... e1 e2 e3 e4 24/47

Net Structures Synchronization e1 25/47

Net Structures Synchronization and Concurrency e1 26/47

Modeling communication protocols ready to send ready to receive buffer full send msg. receive msg. wait for ack. proc.2 proc.1 msg. received receive ack. send ack. buffer full ack. received ack. sent 28/47

Modeling Protocols Using Petri Nets (Stop and Wait Protocol) The transmitter sends a frame and stops waiting for an acknowledgement from the receiver (ACK) Once the receiver correctly receives the expected packet, it sends an acknowledgement to let the transmitter send the next frame. When the transmitter does not receive an ACK within a specified period of time (timer) then it retransmits the packet. Timer Transmitter Receiver Frame 0 Frame 1 ACK 0 ACK 1 29/47

Stop and Wait Protocol: Normal Operation Ack 1 pkt 0 Ack 0 pkt 1 Get Pkt 0 Get Pkt 1 Send Pkt 0 Send Pkt 1 Wait Ptk 1 Wait Pkt 0 Wait Ack 0 Wait Ack 1 Transmitter State Receiver State 30/47 Channel State

Stop and Wait Protocol: Normal Operation Ack 1 pkt 0 Ack 0 pkt 1 Get Pkt 0 Get Pkt 1 Send Pkt 0 Send Pkt 1 Wait Ptk 1 Wait Pkt 0 Wait Ack 0 Wait Ack 1 Transmitter State Receiver State 31/47 Channel State

Stop and Wait Protocol: Deadlock Ack 1 pkt 0 Ack 0 pkt 1 Get Pkt 0 Get Pkt 1 Send Pkt 0 Send Pkt 1 loss Wait Ptk 1 Wait Pkt 0 Wait Ack 0 Wait Ack 1 Transmitter State Receiver State 32/47 Channel State

Stop and Wait Protocol: Deadlock Avoidance Using Timers Ack 1 pkt 0 Ack 0 pkt 1 Get Pkt 0 Get Pkt 1 Send Pkt 0 Send Pkt 1 loss timer Wait Ptk 1 Wait Pkt 0 Wait Ack 0 Wait Ack 1 timer Transmitter State Receiver State 33/47 Channel State

Stop and Wait Protocol: Loss of Acknowledgements pkt 0 Ack 0 pkt 1 Get Pkt 0 Get Pkt 1 Send Pkt 0 Send Pkt 1 loss Reject 0 timer Wait Ptk 1 Wait Pkt 0 Wait Ack 0 Wait Ack 1 timer Reject 1 Transmitter State Receiver State 34/47 Channel State

Behavioural Properties Reachability “Can we reach one particular state from another?” Boundedness “Will a storage place overflow?” Liveness “Will the system die in a particular state?” 35/47

Recalling the Vending Machine (Token Game) Take 15c bar Deposit 5c 0c Deposit 10c Deposit 5c 10c Deposit 20c 15c Take 20c bar 36/47

A marking is a state ... M0 = (1,0,0,0,0) M1 = (0,1,0,0,0) p4 M0 = (1,0,0,0,0) t4 M1 = (0,1,0,0,0) p2 t1 M2 = (0,0,1,0,0) M3 = (0,0,0,1,0) p1 M4 = (0,0,0,0,1) t3 t7 t5 Initial marking:M0 t6 p5 t2 p3 t9 37/47

Reachability p1 t8 t1 t2 p2 t3 p3 t4 t5 t6 p5 t7 p4 t9 Initial marking:M0 M0 = (1,0,0,0,0) M1 = (0,1,0,0,0) M2 = (0,0,1,0,0) M3 = (0,0,0,1,0) M4 = (0,0,0,0,1) M0 M1 M2 M3 M4 t3 t1 t5 t8 t2 t6 38/47

Reachability A firing or occurrence sequence: M0 M1 M2 M3 M4 t3 t1 t5 t8 t2 t6 A firing or occurrence sequence: “M2 is reachable from M1 and M4 is reachable from M0.” In fact, in the vending machine example, all markings are reachable from every marking. 39/47

Boundedness A Petri net is said to be k-bounded or simply bounded if the number of tokens in each place does not exceed a finite number k for any marking reachable from M0. The Petri net for vending machine is 1-bounded. A 1-bounded Petri net is safe. 40/47

Liveness A Petri net with initial marking M0 is live if, no matter what marking has been reached from M0, it is possible to ultimately fire any transition by progressing through some further firing sequence. A live Petri net guarantees deadlock-free operation, no matter what firing sequence is chosen. 41/47

Liveness The vending machine is live and the producer-consumer system is also live. A transition is dead if it can never be fired in any firing sequence. 42/47

An Example A bounded but non-live Petri net t1 p3 t3 t4 p1 p2 p4 t2 43/47

Analysis methods (1) Coverability tree tree representation of all possible markings root = M0 nodes = markings reachable from M0 arcs = transition firings if net is unbounded, then tree is kept finite by introducing the symbol  Properties a PN is bounded iff  doesn’t appear in any node a PN is safe iff only 0’s and 1’s appear in nodes a transition is dead iff it doesn’t appear in any arc if M is reachable form M0, then exists a node M’ that covers M 44/47

Coverability tree example 45/47

Coverability tree example “dead end” p2 t1 t0 t2 p3 46/47

Coverability tree example “dead end” M3=(10) p2 t1 t0 t2 p3 47/47

Coverability tree example “dead end” M3=(10) t1 p2 t1 t0 M4=(01) t2 p3 48/47

Coverability tree example “dead end” M3=(10) t1 t3 p2 t1 t0 M4=(01) M3=(10) “old” t2 p3 49/47

Coverability tree example “dead end” M3=(10) t1 t3 p2 t1 t0 M4=(01) M6=(10) “old” t2 t2 p3 M5=(01) “old” 50/47

Coverability tree example 100 t1 t3 t1 t3 M1=(001) “dead end” M3=(10) 001 10 t1 t3 t1 t3 M4=(01) M6=(10) “old” 01 t2 t2 M5=(01) “old” coverability graph coverability tree 51/47

For a petrinet to be Rechable (Cr = m) r is the rank of C x is n x 1 column vector of nonnegative integers and is called the firing count vector For a petrinet to be Rechable (Cr = m) r is the rank of C 54/47

-2 1 1 0 1 -1 0 -2 1 0 -1 2 1 -1 0 -2 0 1 -1 4 0 0 0 0 55/47