# Sliding window protocol The sender continues the send action without receiving the acknowledgements of at most w messages (w > 0), w is called the window.

## Presentation on theme: "Sliding window protocol The sender continues the send action without receiving the acknowledgements of at most w messages (w > 0), w is called the window."— Presentation transcript:

Sliding window protocol The sender continues the send action without receiving the acknowledgements of at most w messages (w > 0), w is called the window size.

Sliding window protocol {program for process S} define next, last, w : integer ; initially next = 0, last = -1, w > 0 do last+1 ≤ next ≤ last + w  send (m[next], next); next := next + 1 ÿ (ack, j) is received  if j > last  last := j  j ≤ last  skip fi ÿ timeout (R,S)  next := last+1 {retransmission begins} od {program for process R} define j : integer ; initially j = 0; do (m[next], next) is received  if j = next  accept the message; send (ack, j); j:= j+1  j ≠ next  send (ack, j-1) fi ; od

Why does it work? Show that Every message is accepted exactly once M[k] is accepted before m[k+1] Required unbounded sequence number. This is bad. Can we avoid it?

Why unbounded sequence no? (m[k],k) ( m’, k) ( m’ ’,k) Retransmitted version of m New message using the same seq number k

Theorem If the communication channels are non-FIFO, and the message propagation delays are arbitrarily large, then using bounded sequence numbers it is impossible to design a window protocol that can withstand the (1) loss, (2) duplication, and (3) reordering of messages.

Alternating Bit Protocol SR Link layer protocol. Works on FIFO channels only. Guarantees reliable message delivery with a 1-bit seq. One message at a time, so window size = 1. Study how this works. m[0], 0 ack, 0

Alternating Bit Protocol program ABP; {program for process S} define sent, b : 0 or 1 ; next : integer ; initially next = 0, sent = 1, b = 0, and channels are empty ; do sent ≠b  send (m[next], b); next := next +1; sent := b  (ack, j) is received  if j = b  b := 1-b  j ≠ b  skip fi timeout (R,S)  send (m[next-1], b) od {program for process R} define j : 0 or 1; {initially j = 0}; do(m[next], b) is received  if j = b  accept the message; send (ack, j); j:= 1 - j  j ≠ b  send (ack, 1-j) fi od S R

How TCP works Supports end-to-end logical connection between any two computers on the Internet. Basic idea is the same as those of sliding window protocols When is it safe to re-use a sequence number seq? If it is unique. With a high probability, a random 32 or 64-bit number is unique. Also, current seq numbers are flushed out of the system after a time = 2  where  is the round trip delay.

How TCP works

Three way handshake. Why is the knowledge of roundtrip delay important? Sequence numbers are unique with high probability. What if the window is small/large? What if the timeout period is small/large? Adaptive retransmission: receiver can throttle sender and control the window size to save its buffer space.

Distributed Consensus Reaching agreement. Fundamental problem in distributed computing. Many examples Leader election / Mutual Exclusion Commit or Abort in distributed transactions Reaching agreement about which process has failed

Distributed Consensus No failure - trivial Consensus in presence of failures can be surprisingly complex.

Problem Specification u3 u2 u1 u0 v v v v Here, v equals the input value at some input line. All outputs must be identical. input output p0 p1 p2 p3

Problem Specification Termination. Every non-faulty process must eventually decide. Agreement. The final decision of every non-faulty process must be identical. Validity. If every non-faulty process begins with the same initial value v, then their final decision must be v.

Asynchronous Consensus Seven members of a busy household decided to hire a cook, since they do not have time to prepare their own food. Each member of the household separately interviewed every applicant for the cook’s position. Depending on how it went, each member formed his or her independent opinion "yes" (means “hire”) or "no" (means “don't hire”). These members will now have to communicate with one another to reach a uniform final decision about whether the applicant will be hired. The process will be repeated with the next applicant, until someone is hired.

Asynchronous Consensus Consider various modes of communication. If there is no failure, then collect all inputs and apply a decision function on the bag of inputs. Easy!

Asynchronous Consensus In a purely asynchronous distributed system consensus problem is impossible to solve if even a single process crashes Famous result due to Fischer, Lynch, Patterson (commonly known as FLP 85)

Download ppt "Sliding window protocol The sender continues the send action without receiving the acknowledgements of at most w messages (w > 0), w is called the window."

Similar presentations