Slide 1

Slide 1 text

The rsync algorithm By Andrew Tridgell and Paul Mackerras Presented by Camilo Aguilar - @c4milo

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Motivation

Slide 4

Slide 4 text

2017

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

South Korea?

Slide 7

Slide 7 text

Designing a remote update algorithm

Slide 8

Slide 8 text

First attempt

Slide 9

Slide 9 text

A B Client Server

Slide 10

Slide 10 text

A B Client Server Sync file…

Slide 11

Slide 11 text

A B Client Server Σ OK Calculating block signatures…

Slide 12

Slide 12 text

A B Client Server Σ Σ Σ Σ Calculating block signatures…

Slide 13

Slide 13 text

A B Client Server Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Calculating block signatures…

Slide 14

Slide 14 text

A B Client Server Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Calculating block signatures…

Slide 15

Slide 15 text

A B Client Server Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Calculating block signatures… Sending block signatures to Client… done

Slide 16

Slide 16 text

A B Client Server Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Calculating block signatures… Sending block signatures to Client… done done

Slide 17

Slide 17 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ

Slide 18

Slide 18 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 19

Slide 19 text

A B Client Server Σ C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 20

Slide 20 text

A B Client Server Σ Lookup C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 21

Slide 21 text

A B Client Server Σ Match! C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 22

Slide 22 text

A B Client Server Σ Match! C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 23

Slide 23 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Finding differences with B…

Slide 24

Slide 24 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 25

Slide 25 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 26

Slide 26 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 27

Slide 27 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 28

Slide 28 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 29

Slide 29 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 30

Slide 30 text

A B Client Server C Σ Lookup Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 31

Slide 31 text

A B Client Server C Σ Not Found! Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 32

Slide 32 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 33

Slide 33 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 34

Slide 34 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 35

Slide 35 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 36

Slide 36 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… Finding differences with B…

Slide 37

Slide 37 text

A B Client Server C Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Reconstructing C… done Finding differences with B… done

Slide 38

Slide 38 text

First attempt is not enough

Slide 39

Slide 39 text

Second Attempt

Slide 40

Slide 40 text

Solution: two signatures

Slide 41

Slide 41 text

Let’s run through an example

Slide 42

Slide 42 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B

Slide 43

Slide 43 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B

Slide 44

Slide 44 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B

Slide 45

Slide 45 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B

Slide 46

Slide 46 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B

Slide 47

Slide 47 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1

Slide 48

Slide 48 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1

Slide 49

Slide 49 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 strong: 1c2fb9a8 index: 2 →

Slide 50

Slide 50 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2

Slide 51

Slide 51 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3

Slide 52

Slide 52 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3

Slide 53

Slide 53 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3

Slide 54

Slide 54 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table

Slide 55

Slide 55 text

Server Block Size Block Match 2 Bytes False Weak 0 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table

Slide 56

Slide 56 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table

Slide 57

Slide 57 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Lookup…

Slide 58

Slide 58 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table ✘

Slide 59

Slide 59 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table ✘

Slide 60

Slide 60 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table

Slide 61

Slide 61 text

Server Block Size Block Match 2 Bytes False Weak 13d00d6 Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table

Slide 62

Slide 62 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 63

Slide 63 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations Lookup…

Slide 64

Slide 64 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✘

Slide 65

Slide 65 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✘

Slide 66

Slide 66 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 67

Slide 67 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 68

Slide 68 text

Server Block Size Block Match 2 Bytes False Weak 406019b Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 69

Slide 69 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 70

Slide 70 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations Lookup…

Slide 71

Slide 71 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 0 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✓

Slide 72

Slide 72 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✓

Slide 73

Slide 73 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✓

Slide 74

Slide 74 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✓ Lookup…

Slide 75

Slide 75 text

Server Block Size Block Match 2 Bytes False Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations ✓ ✓

Slide 76

Slide 76 text

Server Block Size Block Match 2 Bytes True Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations

Slide 77

Slide 77 text

Server Block Size Block Match 2 Bytes True Weak 12e00cb Strong EOF False 5982e9e5 Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1

Slide 78

Slide 78 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 0 0 True

Slide 79

Slide 79 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 0 0 True

Slide 80

Slide 80 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 0 True

Slide 81

Slide 81 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 0 True Lookup…

Slide 82

Slide 82 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 0 True ✓

Slide 83

Slide 83 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 1c2fb9a8 True ✓

Slide 84

Slide 84 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 1c2fb9a8 True ✓ Lookup…

Slide 85

Slide 85 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 1c2fb9a8 True ✓ ✓

Slide 86

Slide 86 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 1c2fb9a8 True

Slide 87

Slide 87 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 13400d3 1c2fb9a8 True 2

Slide 88

Slide 88 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 0 0 True

Slide 89

Slide 89 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 0 0 True

Slide 90

Slide 90 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd 0 True

Slide 91

Slide 91 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd 0 True Lookup…

Slide 92

Slide 92 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd 0 True ✓

Slide 93

Slide 93 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd ab9e1994 True ✓

Slide 94

Slide 94 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd ab9e1994 True ✓ ✓

Slide 95

Slide 95 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd ab9e1994 True ✓ ✓

Slide 96

Slide 96 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd ab9e1994 True

Slide 97

Slide 97 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 13900cd ab9e1994 True 3

Slide 98

Slide 98 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 0 0

Slide 99

Slide 99 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 0 0

Slide 100

Slide 100 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 13d00d6 0

Slide 101

Slide 101 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 13d00d6 0

Slide 102

Slide 102 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 13d00d6 0 Lookup…

Slide 103

Slide 103 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 True 3 13d00d6 0 ✘

Slide 104

Slide 104 text

Server Block Size Block Match 2 Bytes Weak Strong EOF False Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0

Slide 105

Slide 105 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0

Slide 106

Slide 106 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0

Slide 107

Slide 107 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0

Slide 108

Slide 108 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0 C

Slide 109

Slide 109 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0 C

Slide 110

Slide 110 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 12 False 3 13d00d6 0 C

Slide 111

Slide 111 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 2 False 3 13d00d6 0 C

Slide 112

Slide 112 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 1 2 False 3 13d00d6 0 C

Slide 113

Slide 113 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 2 False 3 13d00d6 0 C

Slide 114

Slide 114 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 2 False 3 13d00d6 0 C

Slide 115

Slide 115 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations 2 False 3 13d00d6 0 C

Slide 116

Slide 116 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations False 3 13d00d6 0 C

Slide 117

Slide 117 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations False 3 13d00d6 0 C

Slide 118

Slide 118 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations False 3 13d00d6 0 C

Slide 119

Slide 119 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table Operations False 13d00d6 0 C

Slide 120

Slide 120 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table False 13d00d6 0 C

Slide 121

Slide 121 text

Server Block Size Block Match 2 Bytes Weak Strong EOF True Client A B 12e00cb → strong: 5982e9e5 index: 1 13400d3 → strong: 1c2fb9a8 index: 2 13900cd → strong: ab9e1994 index: 3 Signature table False 13d00d6 0

Slide 122

Slide 122 text

Recap

Slide 123

Slide 123 text

Rolling Checksum

Slide 124

Slide 124 text

Rolling Checksum const ( mod = 1 << 16 ) func rollingHash(block []byte) (uint32, uint32, uint32) { var a, b uint32 l := uint32(len(block)) for index, value := range block { a += uint32(value) b += (l - uint32(index)) * uint32(value) } r1 := a % mod r2 := b % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 125

Slide 125 text

Rolling Checksum const ( mod = 1 << 16 ) func rollingHash(block []byte) (uint32, uint32, uint32) { var a, b uint32 l := uint32(len(block)) for index, value := range block { a += uint32(value) b += (l - uint32(index)) * uint32(value) } r1 := a % mod r2 := b % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 126

Slide 126 text

Rolling Checksum const ( mod = 1 << 16 ) func rollingHash(block []byte) (uint32, uint32, uint32) { var a, b uint32 l := uint32(len(block)) for index, value := range block { a += uint32(value) b += (l - uint32(index)) * uint32(value) } r1 := a % mod r2 := b % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 127

Slide 127 text

Rolling Checksum const ( mod = 1 << 16 ) func rollingHash(block []byte) (uint32, uint32, uint32) { var a, b uint32 l := uint32(len(block)) for index, value := range block { a += uint32(value) b += (l - uint32(index)) * uint32(value) } r1 := a % mod r2 := b % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 128

Slide 128 text

Incremental Rolling Checksum

Slide 129

Slide 129 text

Incremental Rolling Checksum func rollingHash2(l, r1, r2, outgoingValue, incomingValue uint32) (uint32, uint32, uint32) { r1 = (r1 - outgoingValue + incomingValue) % mod r2 = (r2 - (l * outgoingValue) + r1) % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 130

Slide 130 text

Incremental Rolling Checksum func rollingHash2(l, r1, r2, outgoingValue, incomingValue uint32) (uint32, uint32, uint32) { r1 = (r1 - outgoingValue + incomingValue) % mod r2 = (r2 - (l * outgoingValue) + r1) % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 131

Slide 131 text

Incremental Rolling Checksum func rollingHash2(l, r1, r2, outgoingValue, incomingValue uint32) (uint32, uint32, uint32) { r1 = (r1 - outgoingValue + incomingValue) % mod r2 = (r2 - (l * outgoingValue) + r1) % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 132

Slide 132 text

Incremental Rolling Checksum func rollingHash2(l, r1, r2, outgoingValue, incomingValue uint32) (uint32, uint32, uint32) { r1 = (r1 - outgoingValue + incomingValue) % mod r2 = (r2 - (l * outgoingValue) + r1) % mod r := r1 + (mod * r2) return r1, r2, r }

Slide 133

Slide 133 text

The Probability of Failure

Slide 134

Slide 134 text

What could be improved? • Adaptive block size based on file size • Whole file checksum client generation and verification at the server. • Pipelining to sync multiple files in parallel over the same network connection. • Block compression

Slide 135

Slide 135 text

Applications • Online data deduplication • File forensics • Incremental backup systems • Efficient software updates …

Slide 136

Slide 136 text

Main takeaway

Slide 137

Slide 137 text

Thanks! @c4milo Camilo Aguilar

Slide 138

Slide 138 text

Acknowledgments Thanks for all the invaluable feedback on early drafts to: • Catherine Lopez - @lopezcatherine • Elizabeth Ramírez - @eramirem • David Castillo - @castillobgr • Andrew Turley - @casio_juarez • Cameron Yick - @hydrosquall • Juan P. Osorio - @jpoo90

Slide 139

Slide 139 text

Acknowledgments For being so kind with his time answering all my questions about his PhD thesis. Andrew Tridgell

Slide 140

Slide 140 text

References • https://www.samba.org/~tridge/phd_thesis.pdf • https://www.andrew.cmu.edu/course/15-749/READINGS/required/cas/tridgell96.pdf • https://speakerdeck.com/ceejbot/hash-functions-and-you • https://en.wikipedia.org/wiki/Rabin_fingerprint • https://en.wikipedia.org/wiki/Rolling_hash • http://olstrans.sourceforge.net/release/OLS2000-rsync/OLS2000-rsync.html • http://preshing.com/20110504/hash-collision-probabilities/

Slide 141

Slide 141 text

Support Slides

Slide 142

Slide 142 text

Demo • Written in Go • Using gRPC Streaming • LZ4 Compression • Lookup table uses dynamic arrays for chaining • Pipelining possible by using more gRPC streams on the same TCP connection, one per file. • Block size: 6kb • Strong checksum algorithm: xxhash

Slide 143

Slide 143 text

No content

Slide 144

Slide 144 text

Random Collision Probability

Slide 145

Slide 145 text

Random Collision Probability