Lecture 6
Point-to-Point
 Architecture
   1 March 2010



                  1
Point-to-Point Architecture



                Role of clients
                Notify clients
                Resolve confl...
Latency
  Robustness
Conflict/Cheating
  Consistency
  Accounting
   Scalability
  Complexity

                   3
Lower Latency
No Single Point of Failure
Low Infrastructure Cost




                             4
Collect    Collect

Game     Simulate              Game
                    Simulate
States                         States...
6
MiMaze from INRIA, France

                            7
Age of Empire Series
http://compactiongames.about.com/library/games/screenshots/blscreens-ageofkings.htm
                 ...
How to order events?




                       9
Does received-order delivery work?



  Player A


  Player B


 Player C



                                     10
Does sending order delivery work?



  Player A


  Player B


  Player C



                                    11
idea: wait for messages
from all players to arrive
    before executing


                             12
Bucket Synchronization



                         13
The game is divided into rounds (e.g. 25
rounds per second).


  Player A


  Player B


  Player C



                   ...
Players are expected to send an event in each
round (e.g. 25 updates per second).


  Player A


  Player B


 Player C


...
Players are expected to send an event in each
round (e.g. 25 updates per second).


  Player A


  Player B


 Player C


...
Every round has a “bucket” that collects the
events.


  Player A


  Player B


  Player C



                           ...
Events generated in the same round go into the same
bucket of a future round. We know which round an event
is generated in...
Events generated in the same round go into the same
bucket of a future round. We know which round an event
is generated in...
In each round, the events in the bucket are
processed (in order of time-stamp).




  Player A


  Player B


  Player C

...
Two parameters needed : round length and lag. Lag
depends on maximum network latency among the
players; round length depen...
Players periodically ping among themselves and
exchange latency information. They also measure the
average time taken to r...
If events from another player is lost (or late), we can
predict its update (e.g. using dead reckoning) when possible.




...
Alternative is to ensure every event is received
before executing the bucket. What are the
drawbacks?



  Player A


  Pl...
Stop-and-Wait Protocol



                         24
Synchronized
 Simulations


               25
Every player sees
exactly the same states
(but maybe at different time)



                                26
Getting all clients to simulate the exact same
 thing is tricky: must use same number of
 random calls with same seeds, sa...
Clients may periodically exchange hash of
  game states to detect if a player has gone out-
  of-sync.
            Compare...
Cheating



           29
Look-Ahead Cheat



                   30
Player C (or a bot) can peek at A’s and B’s
actions first, before deciding his/her moves.




Player A


Player B


Player ...
Player C (or a bot) can peek at A’s and B’s
actions first, before deciding his/her moves.




Player A


Player B


Player ...
Player C (or a bot) can peek at A’s and B’s
actions first, before deciding his/her moves.




Player A


Player B


Player ...
Dealing with cheaters:

1. Prevent cheats (hard)
2. Detect cheats (easier)

                            32
Detecting Look-
 Ahead Cheats


                  33
“Mmm... player C
 always the last one
that makes its move.”


                        34
Time-stamp Cheat



                   35
Player C (or a bot) can put in an earlier time-
            stamp in its messages.




  Player A


  Player B


 Player C...
Suppress-Update Cheat



                        37
If dead reckoning is used, Player C can stop sending update
and let others predict its position. C then sends an update at...
A   C




        39
C stops sending update.
A predicts C’s position.



 A




                           40
C stops sending update.
A predicts C’s position.



 A




                           41
C stops sending update.
A predicts C’s position.



 A




                           42
C sends an update and shoots A.




     A




                                  43
Not my fault! My
Cheater!   packets were dropped..




                                    44
Inconsistent Cheat



                     45
Player C can send different events
          to different players.




Player A


Player B


Player C


                  ...
With synchronous simulations,
we can compare periodically the
     game states to detect
      inconsistency cheats



   ...
Cheat-Proof Protocol



                       48
Lock Step Protocol



                     49
One-Way Function f:
Given x, we can compute f(x)
easily. Given f(x) it’s hard to
find out x if x is random.


             ...
Lock Step Protocol



                     51
Stage 1 (Commit): Everyone decide on its
move x, and send f(x) to each other.


 Player A


 Player B


 Player C


      ...
Stage 2 (Reveal): After f(x)s from all other
players are received, sends x to each other.



 Player A


 Player B


 Play...
f(x) is known as commitment
to x.

A player, once committed to
its move, can’t change it.


                              ...
How does lock-step prevent:

look ahead cheat?
timestamp cheat?
suppress-update cheat?



                              55
Problem: Lock-step
  protocol is slow.




                      56
lmax = maximum latency
rmax = maximum frame (round) rate

Lockstep Protocol

     1/r = max{2lmax, 1/rmax}


             ...
Idea: Use Interest Management

Players only engaged in lock-step protocol
when they influence each other. Otherwise
    the...
This is known as
Asynchronous Synchronization
 or Asynchronous Lock-step



                               59
We may also stagger these two stages to improve
frame rate. Multiple commitments can be sent
out before we reveal the acti...
A player can reveal its action in round i once it receives
all commitment of round i from other players.



     Player A
...
A player can make p moves (send p commitments)
without engaging in lockstep.



    Player A




    Player C


          ...
This is known as
Pipelined Lock-step




                      63
lmax = maximum latency
rmax = maximum frame (round) rate

Lockstep Protocol

     1/r = max{2lmax, 1/rmax}


             ...
lmax = maximum latency
rmax = maximum frame (round) rate

Pipelined Lockstep Protocol

     1/r = max{2lmax/p, 1/rmax}


 ...
lmax = maximum latency
rmax = maximum frame (round) rate

We can pick optimal p as

           p = 2 lmax rmax


         ...
Cheating in Pipelined Lock-step




                                  67
C makes its 4-th move after seeing the first p moves
from A. A’s first six moves are not based on C’s move.



     Player A...
C makes its 4-th move after seeing the first p moves
from A. A’s first six moves are not based on C’s move.



     Player A...
Fair if everyone do the same thing.
             But frame rate suffers.



Player A




Player C


                      ...
Fair if everyone do the same thing.
             But frame rate suffers.



Player A




Player C


                      ...
We can enforce commit to arrive within a period of
time (T < RTT) and treat late arrivals as cheaters.
What are some drawb...
We can enforce commit to arrive within a period of
time (T < RTT) and treat late arrivals as cheaters.
What are some drawb...
lmax = maximum latency
rmax = maximum frame (round) rate

Pipeline Lockstep Protocol
(without late commit)

     1/r = max...
Upcoming SlideShare
Loading in …5
×

CS4344 09/10 Lecture 6: P2P Synchronization

9,723 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,723
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
56
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

CS4344 09/10 Lecture 6: P2P Synchronization

  1. 1. Lecture 6 Point-to-Point Architecture 1 March 2010 1
  2. 2. Point-to-Point Architecture Role of clients Notify clients Resolve conflicts Maintain states Simulate games 2
  3. 3. Latency Robustness Conflict/Cheating Consistency Accounting Scalability Complexity 3
  4. 4. Lower Latency No Single Point of Failure Low Infrastructure Cost 4
  5. 5. Collect Collect Game Simulate Game Simulate States States Render Render Wait Wait 5
  6. 6. 6
  7. 7. MiMaze from INRIA, France 7
  8. 8. Age of Empire Series http://compactiongames.about.com/library/games/screenshots/blscreens-ageofkings.htm 8
  9. 9. How to order events? 9
  10. 10. Does received-order delivery work? Player A Player B Player C 10
  11. 11. Does sending order delivery work? Player A Player B Player C 11
  12. 12. idea: wait for messages from all players to arrive before executing 12
  13. 13. Bucket Synchronization 13
  14. 14. The game is divided into rounds (e.g. 25 rounds per second). Player A Player B Player C 14
  15. 15. Players are expected to send an event in each round (e.g. 25 updates per second). Player A Player B Player C 15
  16. 16. Players are expected to send an event in each round (e.g. 25 updates per second). Player A Player B Player C 16
  17. 17. Every round has a “bucket” that collects the events. Player A Player B Player C 17
  18. 18. Events generated in the same round go into the same bucket of a future round. We know which round an event is generated in, based on time-stamp. Player A Player B Player C 18
  19. 19. Events generated in the same round go into the same bucket of a future round. We know which round an event is generated in, based on time-stamp. Player A Player B Player C 18
  20. 20. In each round, the events in the bucket are processed (in order of time-stamp). Player A Player B Player C 19
  21. 21. Two parameters needed : round length and lag. Lag depends on maximum network latency among the players; round length depends on rendering speed. lag Player A round length Player B Player C 20
  22. 22. Players periodically ping among themselves and exchange latency information. They also measure the average time taken to render a frame and exchange that information to estimate lag and round length. lag Player A round length Player B Player C 21
  23. 23. If events from another player is lost (or late), we can predict its update (e.g. using dead reckoning) when possible. Player A Player B Player C 22
  24. 24. Alternative is to ensure every event is received before executing the bucket. What are the drawbacks? Player A Player B Player C 23
  25. 25. Stop-and-Wait Protocol 24
  26. 26. Synchronized Simulations 25
  27. 27. Every player sees exactly the same states (but maybe at different time) 26
  28. 28. Getting all clients to simulate the exact same thing is tricky: must use same number of random calls with same seeds, same precision of floating point calculation etc. Collect Collect Game Simulate Game Simulate States States Render Render Wait Wait 27
  29. 29. Clients may periodically exchange hash of game states to detect if a player has gone out- of-sync. Compare Compare Collect Collect Game Simulate Game Simulate States States Render Render Wait Wait 28
  30. 30. Cheating 29
  31. 31. Look-Ahead Cheat 30
  32. 32. Player C (or a bot) can peek at A’s and B’s actions first, before deciding his/her moves. Player A Player B Player C 31
  33. 33. Player C (or a bot) can peek at A’s and B’s actions first, before deciding his/her moves. Player A Player B Player C 31
  34. 34. Player C (or a bot) can peek at A’s and B’s actions first, before deciding his/her moves. Player A Player B Player C 31
  35. 35. Dealing with cheaters: 1. Prevent cheats (hard) 2. Detect cheats (easier) 32
  36. 36. Detecting Look- Ahead Cheats 33
  37. 37. “Mmm... player C always the last one that makes its move.” 34
  38. 38. Time-stamp Cheat 35
  39. 39. Player C (or a bot) can put in an earlier time- stamp in its messages. Player A Player B Player C 36
  40. 40. Suppress-Update Cheat 37
  41. 41. If dead reckoning is used, Player C can stop sending update and let others predict its position. C then sends an update at appropriate time to “surprise” other players. Player A Player B Player C 38
  42. 42. A C 39
  43. 43. C stops sending update. A predicts C’s position. A 40
  44. 44. C stops sending update. A predicts C’s position. A 41
  45. 45. C stops sending update. A predicts C’s position. A 42
  46. 46. C sends an update and shoots A. A 43
  47. 47. Not my fault! My Cheater! packets were dropped.. 44
  48. 48. Inconsistent Cheat 45
  49. 49. Player C can send different events to different players. Player A Player B Player C 46
  50. 50. With synchronous simulations, we can compare periodically the game states to detect inconsistency cheats 47
  51. 51. Cheat-Proof Protocol 48
  52. 52. Lock Step Protocol 49
  53. 53. One-Way Function f: Given x, we can compute f(x) easily. Given f(x) it’s hard to find out x if x is random. 50
  54. 54. Lock Step Protocol 51
  55. 55. Stage 1 (Commit): Everyone decide on its move x, and send f(x) to each other. Player A Player B Player C 52
  56. 56. Stage 2 (Reveal): After f(x)s from all other players are received, sends x to each other. Player A Player B Player C 53
  57. 57. f(x) is known as commitment to x. A player, once committed to its move, can’t change it. 54
  58. 58. How does lock-step prevent: look ahead cheat? timestamp cheat? suppress-update cheat? 55
  59. 59. Problem: Lock-step protocol is slow. 56
  60. 60. lmax = maximum latency rmax = maximum frame (round) rate Lockstep Protocol 1/r = max{2lmax, 1/rmax} 57
  61. 61. Idea: Use Interest Management Players only engaged in lock-step protocol when they influence each other. Otherwise their games proceed independently. 58
  62. 62. This is known as Asynchronous Synchronization or Asynchronous Lock-step 59
  63. 63. We may also stagger these two stages to improve frame rate. Multiple commitments can be sent out before we reveal the actions. Player A Player C 60
  64. 64. A player can reveal its action in round i once it receives all commitment of round i from other players. Player A Player C 61
  65. 65. A player can make p moves (send p commitments) without engaging in lockstep. Player A Player C 62
  66. 66. This is known as Pipelined Lock-step 63
  67. 67. lmax = maximum latency rmax = maximum frame (round) rate Lockstep Protocol 1/r = max{2lmax, 1/rmax} 64
  68. 68. lmax = maximum latency rmax = maximum frame (round) rate Pipelined Lockstep Protocol 1/r = max{2lmax/p, 1/rmax} 65
  69. 69. lmax = maximum latency rmax = maximum frame (round) rate We can pick optimal p as p = 2 lmax rmax 66
  70. 70. Cheating in Pipelined Lock-step 67
  71. 71. C makes its 4-th move after seeing the first p moves from A. A’s first six moves are not based on C’s move. Player A Player C 68
  72. 72. C makes its 4-th move after seeing the first p moves from A. A’s first six moves are not based on C’s move. Player A Player C 68
  73. 73. Fair if everyone do the same thing. But frame rate suffers. Player A Player C 69
  74. 74. Fair if everyone do the same thing. But frame rate suffers. Player A Player C 69
  75. 75. We can enforce commit to arrive within a period of time (T < RTT) and treat late arrivals as cheaters. What are some drawback of this scheme? T Player A Player C 70
  76. 76. We can enforce commit to arrive within a period of time (T < RTT) and treat late arrivals as cheaters. What are some drawback of this scheme? T Player A Player C 70
  77. 77. lmax = maximum latency rmax = maximum frame (round) rate Pipeline Lockstep Protocol (without late commit) 1/r = max{lmax/p, 1/rmax} p = lmax rmax 71

×