1 / 35

Model and Verify a Distributed Algorithm in a Tree Network using jSpin

Model and Verify a Distributed Algorithm in a Tree Network using jSpin. Presented by Xinghao Xu. Outline. 1. Spin History and jSpin 2. Goal and Expected results of Project 3 . Introduction to Algorithm 4. Verification 5. Programming Code and Experiment Result 6. Conclusion.

nolen
Download Presentation

Model and Verify a Distributed Algorithm in a Tree Network using jSpin

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Model and Verify a Distributed Algorithmin a Tree Network using jSpin Presented by XinghaoXu

  2. Outline • 1. Spin History and jSpin • 2. Goal and Expected results of Project • 3. Introduction to Algorithm • 4. Verification • 5. Programming Code and Experiment Result • 6. Conclusion

  3. Spin • Spin is a popular open-source software tool, used by thousands of people worldwide, that can be used for the formal verification of distributed software systems. • The tool was developed at Bell Labs in the original Unix group of the Computing Sciences Research Center, starting in 1980. The software has been available freely since 1991, and continues to evolve to keep pace with new developments in the field.

  4. jSpin • jSpin is a graphical user interface for Spin. • jSpin is slightly easier to use thanks to the simpler GUI (one window, one-click buttons)

  5. Installing jSpin

  6. Starting jSpin Menu Toolbar Input Output

  7. Starting jSpin Promela Promela Result Command Line Option

  8. Running jSpin How do you actually run jSpin? • Check: generate a verifier for your specification • Random: view the path of a random walk • Interactive: manually select each decision that the model checker can make • Guided : view the results of an error trace • Verify:perform a guided verification of the model (ie, find errors, if they exist)

  9. Goal and Expected results of Project • Model and verify a distributed algorithm with jSpin tool. • Obviously, the final output result will display what we find by executing the algorithm and the jSpin tool can also present us the work flow of the executing process and maybe show some flaws or warnings of the algorithm.

  10. Introduction to Algorithm • The distributed algorithm is used to find “center” in a tree topology. • We can consider “center” as a place from which it costs less time and resource to broadcast some information to all other places in the network.

  11. Center Node • Definition: A center node is a node which has the shortest distance to the farthest node in the tree network. • Feature: Max_Distance- Second_Max_Distance= 0 or 1 • Max_Distance: the distance to the farthest node • Second_Max_Distance: the distance to the second farthest node • (they should be with different links to the center node)

  12. Center Node Max_Distance=4 Second_Max_Distance=2

  13. Center Node Max_Distance- Second_Max_Distance=2 If the result is greater than 1, it means we can find another node whose shortest distance to the farthest node is shorter than the center node. Contradiction

  14. Algorithm • Each node has 4 states: • Idle Available Processing Done • Each node only knows who is its neighbor and if it is a leaf node or internal node. It doesn’t know the relationship of parent and child.

  15. Algorithm • At the beginning, all nodes are in the Idle state. Each initiator sends a message called M1 (ACT) to all neighbors and enter Available state. M1 message is to wake up other idle nodes. Nodes at Idle state receives M1 message will also send M1 message to its neighbors except sender and enter Available state. Within finite time, all nodes will enter Available state.

  16. Algorithm • Leaf node sends a message called M2(SAT and dist+1) to its only neighbor, referred now as its “parent,” and enter Processing state. The function of M2 is to find the saturated nodes and pass distance information. • An internal node waits until it has received an M2 message from all its neighbors but one, sends a M2 message to that neighbor that now will be considered as its “parent,” and goes to Processing state.

  17. Algorithm

  18. Algorithm • If a Processing state node receives a M2 message from its parent, it becomes SATURATED node. • SATURATED node: A Processing state node which receives message from its parent. • Exactly two Processing nodes will become SATURATED nodes. Furthermore, these two nodes are neighbors and are each other’s parent.

  19. Algorithm

  20. Algorithm • SATURATED nodes send M3 message (CEN, Max_dist+1) to its other child nodes. Child nodes also calculate the Max Distance and send M3 message to its children…… • Each node locally check: If (Max_Distance - Second_Max_Distance)==0 or (Max_Distance - Second_Max_Distance)==1 Then it is the Center and goes to Done state Else it is not the Center and goes to Done state

  21. Algorithm

  22. Verification • Deadlock • Only 2 SATURATED nodes • All nodes terminate in Done state in finite time • At last, there will be 1 or 2 Center in the tree network

  23. Model Set up model for arbitrary tree topology.

  24. Programming Code(IDLE) IDLE: do ::chancel_34 ? msg_type; { if ::(msg_type==ACT) -> {chancel_47 ! ACT; chancel_48 ! ACT-> goto ACTIVE;} ::(msg_type!=ACT) -> goto IDLE fi } od;

  25. Programming Code(ACTIVE) ACTIVE: do ::chancel_34 ? msg_type, msg_dist; { if ::(msg_type==SAT) -> { if ::(msg_dist>=Max_dist) -> {SecMax_dist=Max_dist; Max_dist=msg_dist;} ::(msg_dist>=SecMax_dist && msg_dist<Max_dist) -> SecMax_dist=msg_dist; ::else -> msg_dist=0; fi; neighbour=neighbour-1; r34=1;

  26. Programming Code(ACTIVE) if ::(neighbour==1) -> { if ::(r74==0) -> chancel_47 ! SAT, Max_dist+1; goto PROCESSING; ::(r84==0) -> chancel_48 ! SAT, Max_dist+1; goto PROCESSING; fi } ::else -> goto ACTIVE; } ::else -> goto ACTIVE; fi }

  27. Programming Code(PROCESSING) PROCESSING: do ::chancel_34 ? msg_type, msg_dist; { if ::(msg_type==SAT) -> { printf("4--SATURATED NODE"); if ::(msg_dist>=Max_dist) -> {SecMax_dist=Max_dist; Max_dist=msg_dist;} ::(msg_dist>=SecMax_dist && msg_dist<Max_dist) -> SecMax_dist=msg_dist; ::else -> msg_dist=0; fi; chancel_47 ! CEN, Max_dist+1; chancel_48 ! CEN, Max_dist+1 -> goto DONE; }

  28. Programming Code(PROCESSING) ::(msg_type==CEN) -> { if ::(msg_dist>=Max_dist) -> {SecMax_dist=Max_dist; Max_dist=msg_dist;} ::(msg_dist>=SecMax_dist && msg_dist<Max_dist) -> SecMax_dist=msg_dist; ::else -> msg_dist=0; fi; chancel_47 ! CEN, Max_dist+1; chancel_48 ! CEN, Max_dist+1 -> goto DONE; } ::else -> goto PROCESSING; fi; }

  29. Programming Code(DONE) DONE: if :: ((Max_dist-SecMax_dist)<2) -> {printf("4--Center");printf("4--terminate");} :: else printf("4--terminate"); fi }

  30. Verify

  31. Verify Terminating

  32. Verify Saturated Node and Center

  33. Verify Saturated Node and Center

  34. Conclusion • In this project, we successfully model a distributed algorithm and verify some features of the algorithm with jSpin tool. • The final result shows that the distributed algorithm is correct and can be applied to large network topology. Tips: 1. The requirement of installing jSpin needs 32bit computer. Actually, I found if you install jdk1.6 instead of jdk1.7, we can also run jSpin on 64bit computer. 2. It is better to install jSpin in the default path. Otherwise, you have to set environment variables more complicated.

  35. Thank you ! Questions?

More Related