Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Modelling and Validation of Concurrent Systems.

Similar presentations


Presentation on theme: "Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Modelling and Validation of Concurrent Systems."— Presentation transcript:

1 Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Modelling and Validation of Concurrent Systems Kurt Jensen & Lars Michael Kristensen {kjensen,lmkristensen} @cs.au.dk Chapter 2: Non-hierarchical Coloured Petri Nets

2 Kurt Jensen Lars M. Kristensen 2 Coloured Petri Nets Department of Computer Science Simple protocol

3 Kurt Jensen Lars M. Kristensen 3 Coloured Petri Nets Department of Computer Science Informal description SenderNetworkReceiver No loss of packets No overtaking

4 Kurt Jensen Lars M. Kristensen 4 Coloured Petri Nets Department of Computer Science Coloured Petri Net Place Transition Arc Net inscriptions Nodes

5 Kurt Jensen Lars M. Kristensen 5 Coloured Petri Nets Department of Computer Science Places represent the state of the system Name (no formal meaning; large impact on readability) Initial marking (multiset of tokens) Colour set (type) Definition of colour sets: colset NO = int; (* integers *) colset DATA = string; (* text strings *) colset NOxDATA = product NO * DATA; Each token in the initial marking must have a colour that belongs to the colour set  Each place contains a number of tokens.  Each token carries a colour (data value).  The colour set specifies the set of allowed token colours.

6 Kurt Jensen Lars M. Kristensen 6 Coloured Petri Nets Department of Computer Science Current marking during simulation Information about current marking (changes during simulation) The thick border line indicates that the transition is enabled (ready to occur) Circle: 6 tokens Square: Detailed token values One token with value 1 Values: Token colours (multiset of actual token colours) Type: Colour set (set of allowed token colours)

7 Kurt Jensen Lars M. Kristensen 7 Coloured Petri Nets Department of Computer Science Transitions and arcs Arc expression Name (no formal meaning) The arc expression must evaluate to a colour in the colour set of the attached place (or a multiset of such colours) Declaration of variables: var n : NO; (* integers *) var d : DATA; (* strings *) Binding of variables: Evaluation of expressions: (n,d)  (3, " CPN " ) : NOxDATA n  3 : NO

8 Kurt Jensen Lars M. Kristensen 8 Coloured Petri Nets Department of Computer Science Enabling of transition Two variables: var n : NO; (* integers *) var d : DATA; (* strings *) Binding: Transition is enabled if we can find a binding so that each input arc expression evaluates to one or more colours that are present on the corresponding input place NO DATA ? ?

9 Kurt Jensen Lars M. Kristensen 9 Coloured Petri Nets Department of Computer Science Enabling of SendPacket One token with value 1 Binding: We want to find a binding for the variable n such that the arc expression n evaluates to a colour which is present on the place NextSend Arc expression

10 Kurt Jensen Lars M. Kristensen 10 Coloured Petri Nets Department of Computer Science Binding: Enabling of SendPacket Six different tokens Binding: We want to find a binding for the variable d such that the arc expression (n,d) evaluates to a colour which is present on the place PacketsToSend Arc expression

11 Kurt Jensen Lars M. Kristensen 11 Coloured Petri Nets Department of Computer Science 1 (1,"COL") Enabling of SendPacket Binding: We have found a binding so that each input arc expression evaluates to a colour that is present on the corresponding input place Transition is enabled (ready to occur)

12 Kurt Jensen Lars M. Kristensen 12 Coloured Petri Nets Department of Computer Science Occurrence of SendPacket in binding (1,"COL") Remove: (1,"COL") Add a new token: (1,"COL") Remove: 1 1 (1,"COL")

13 Kurt Jensen Lars M. Kristensen 13 Coloured Petri Nets Department of Computer Science New marking after occurrence of SendPacket in binding The first packet has been removed A copy of the first packet has been put on A No token on this place Transition is no longer enabled (thin border line)

14 Kurt Jensen Lars M. Kristensen 14 Coloured Petri Nets Department of Computer Science New marking M 1 Transition enabled

15 Kurt Jensen Lars M. Kristensen 15 Coloured Petri Nets Department of Computer Science Binding: Binding of TransmitPacket Current marking Arc expression Binding:

16 Kurt Jensen Lars M. Kristensen 16 Coloured Petri Nets Department of Computer Science Occurrence of TransmitPacket in binding Remove: (1,"COL") (1, "COL") Add a new token: (1,"COL")

17 Kurt Jensen Lars M. Kristensen 17 Coloured Petri Nets Department of Computer Science New marking M 2 Binding: 1 1`2 XXXX 1 1`(1,"COL")

18 Kurt Jensen Lars M. Kristensen 18 Coloured Petri Nets Department of Computer Science Binding: 1 1`2 XXX New marking M 3

19 Kurt Jensen Lars M. Kristensen 19 Coloured Petri Nets Department of Computer Science Binding: 1 1`2 XXX New marking M 4

20 Kurt Jensen Lars M. Kristensen 20 Coloured Petri Nets Department of Computer Science We have successfully transmitted the first packet and the acknow- ledgement for it We are ready to start transmission of packet number two New marking M 5

21 Kurt Jensen Lars M. Kristensen 21 Coloured Petri Nets Department of Computer Science 1 (SendPacket, ) 2 (TransmitPacket, ) 3 (ReceivePacket, ) 4 (TransmitAck, ) 5 (ReceiveAck, ) TransitionBinding (, ) Binding element First five steps

22 Kurt Jensen Lars M. Kristensen 22 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 4 New marking M 5

23 Kurt Jensen Lars M. Kristensen 23 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 1 4 New marking M 6

24 Kurt Jensen Lars M. Kristensen 24 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 2 1 1`3 4 New marking M 7

25 Kurt Jensen Lars M. Kristensen 25 Coloured Petri Nets Department of Computer Science Binding: 2 1`(2,"OUR") 1 1`3 1 4 New marking M 8

26 Kurt Jensen Lars M. Kristensen 26 Coloured Petri Nets Department of Computer Science Binding: 2 1`(2,"OUR") 1 1`3 4 New marking M 9

27 Kurt Jensen Lars M. Kristensen 27 Coloured Petri Nets Department of Computer Science We have successfully transmitted the first two packets and the acknowledgements for them We are ready to start transmission of packet number three New marking M 10

28 Kurt Jensen Lars M. Kristensen 28 Coloured Petri Nets Department of Computer Science Marking after 30 steps Dead marking (no transitions are enabled) We have successfully transmitted all six packets and the acknowledgements for them There are no more packets to transmit

29 Kurt Jensen Lars M. Kristensen 29 Coloured Petri Nets Department of Computer Science Second version of protocol Constant

30 Kurt Jensen Lars M. Kristensen 30 Coloured Petri Nets Department of Computer Science Declaration of constants val AllPackets = 1‘(1,"COL") ++ 1‘(2,"OUR") ++ 1‘(3,"ED ") ++ 1‘(4,"PET") ++ 1‘(5,"RI ") ++ 1‘(6,"NET");  Saves a little bit of space in the diagram.  Enhances readability.  Can be reused (at other places).  We use the following constant to specify the initial marking of PacketsToSend.

31 Kurt Jensen Lars M. Kristensen 31 Coloured Petri Nets Department of Computer Science Double-headed arcs Double-headed arc A double-headed arc is a shorthand for two oppositely directed arcs with the same arc expression We no longer remove the tokens from the input places Retransmission becomes possible

32 Kurt Jensen Lars M. Kristensen 32 Coloured Petri Nets Department of Computer Science More complicated arc expression (if-then-else expression)

33 Kurt Jensen Lars M. Kristensen 33 Coloured Petri Nets Department of Computer Science If-then-else expression 1`(1,"COL") var success : BOOL; b + = b – = success = true Successful transmission over the network 1 1`(1,"COL") 1 New variable:

34 Kurt Jensen Lars M. Kristensen 34 Coloured Petri Nets Department of Computer Science If-then-else expression empty var success : BOOL; success = false Packet is lost during transmission 1 1`(1,"COL") No packet is added b + = b – =

35 Kurt Jensen Lars M. Kristensen 35 Coloured Petri Nets Department of Computer Science New name and new type New type New name Initial marking: empty text string

36 Kurt Jensen Lars M. Kristensen 36 Coloured Petri Nets Department of Computer Science New place: NextRec New place Plays a similar role as NextSend Contains the number of the expected packet

37 Kurt Jensen Lars M. Kristensen 37 Coloured Petri Nets Department of Computer Science 1`(1,"COL") 1 Correct packet arrives Empty text string 1 1`1 Binding: 1 1`2 1 2 2 "COL" Update NextRec (from 1 to 2) Send acknoweledgement (with sequence number of next packet) Add received data: "COL” to DataReceived 1 1`"COL" ^ is the concatenation operator Packet no 1 arriving Packet no 1 expected 1 1`"" 1 1`(1,"COL")

38 Kurt Jensen Lars M. Kristensen 38 Coloured Petri Nets Department of Computer Science 1 1`(1,"COL") 1 1 1`3 1`(1,"COLOUR") Wrong packet arrives 1 1`(1,"COL") 1 1`"COLOUR" 1 1`3 Binding: 1 1`3 1 1 1`"COLOUR" 3 3 "COLOUR" Do not change NextRec Send acknowledgement (with sequence number of next packet ) No data is added to DataReceived Packet no 1 arriving Packet no 3 expected

39 Kurt Jensen Lars M. Kristensen 39 Coloured Petri Nets Department of Computer Science Acknowledgements can be lost Also possible to loose acknowledgements

40 Kurt Jensen Lars M. Kristensen 40 Coloured Petri Nets Department of Computer Science NextSend is updated NextSend is updated with sequence number from acknowledgement

41 Kurt Jensen Lars M. Kristensen 41 Coloured Petri Nets Department of Computer Science Two enabled transitions SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, )  These binding elements need the same token  They are in conflict with each other

42 Kurt Jensen Lars M. Kristensen 42 Coloured Petri Nets Department of Computer Science Two enabled transitions  These bindings elements use different tokens  They are concurrently enabled and can occur concurrently SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, )

43 Kurt Jensen Lars M. Kristensen 43 Coloured Petri Nets Department of Computer Science Three enabled transitions SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, ) RP = (ReceivePacket, ) All other binding elements are concurrently enabled These binding elements are in conflict

44 Kurt Jensen Lars M. Kristensen 44 Coloured Petri Nets Department of Computer Science Three enabled transitions SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, ) TA + = (TransmitAck, ) TA – = (TransmitAck, ) All other binding elements are concurrently enabled 35 different enabled steps

45 Kurt Jensen Lars M. Kristensen 45 Coloured Petri Nets Department of Computer Science Possible marking after 50 steps Receiver is waiting for packet no. 5 Sender is still sending packet no. 4 An acknowledgement requesting packet no. 5 is arriving When it is received, the sender will start sending packet no. 5 This packet will be discarded

46 Kurt Jensen Lars M. Kristensen 46 Coloured Petri Nets Department of Computer Science Dead marking at the end of simulation All packets have been received in the correct order Sender is ready to send packet no. 7 All buffer places are empty Receiver is waiting for packet no. 7 There is no packet no. 7

47 Kurt Jensen Lars M. Kristensen 47 Coloured Petri Nets Department of Computer Science 1 0 SendPacket @ (1:Protocol) - d = "COL" - n = 1 2 0 TransmitPacket @ (1:Protocol) - n = 1 - d = "COL" - success = true 3 0 ReceivePacket @ (1:Protocol) - k = 1 - data = "" - n = 1 - d = "COL" 4 0 TransmitAck @ (1:Protocol) - n = 2 - success = true 5 0 ReceiveAck @ (1:Protocol) - k = 1 - n = 2 6 0 SendPacket @ (1:Protocol) - d = "OUR" - n = 2 Step Time Transition Module Binding of variables  Specifies the occurring transitions and their bindings.  Automatically generated by the CPN Tools simulator. Simulation report

48 Kurt Jensen Lars M. Kristensen 48 Coloured Petri Nets Department of Computer Science  Graphical high-level representation of occurrence sequence.  Automatically generated by the CPN Tools simulator.  Makes it easy to see what happened – also for non-CPN experts. Visualisation by message sequence chart

49 Kurt Jensen Lars M. Kristensen 49 Coloured Petri Nets Department of Computer Science Transitions can have a guard Guard (<> is the Inequality operator) Guard (tests whether n and k are equal)  Boolean expression which must evaluate to true for the binding element to be enabled.  Additional enabling condition. Correct packets Wrong packets

50 Kurt Jensen Lars M. Kristensen 50 Coloured Petri Nets Department of Computer Science 1`"COL" Guard must evaluate to true RN 1 = (ReceiveNext, ) RN 2 = (ReceiveNext, ) false true [n=k]

51 Kurt Jensen Lars M. Kristensen 51 Coloured Petri Nets Department of Computer Science 1`"COL" Guard must evaluate to true DP 1 = (DiscardPacket, <n=1, k=2, d="COL" ) DP 2 = (DiscardPacket, <n=2, k=2, d="OUR") false true [n<>k]

52 Kurt Jensen Lars M. Kristensen 52 Coloured Petri Nets Department of Computer Science Questions


Download ppt "Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Modelling and Validation of Concurrent Systems."

Similar presentations


Ads by Google