sliding window discussion

Upload: ahmed2r

Post on 05-Apr-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Sliding Window Discussion

    1/13

    W A S H I N G T O N U N I V E R S I T Y

    D E P A R T M E N T O F C O M P U T E R S C I E N C E

    C S 4 2 3 C o m p u t e r C o m m u n i c a t i o n s : M o r e E r r o r R e c o v e r y

    F a l l 1 9 9 5

    T h i s i s t h e f o u r t h o f p r o b a b l y 7 l e c t u r e s o n t h e D a t a L i n k L a y e r . I n t h e l a s t l e c t u r e w e s t u d i e d

    t h e s t o p - a n d - w a i t p r o t o c o l f o r e r r o r r e c o v e r y . I n t h i s l e c t u r e , w e w i l l s t u d y m o r e p i p e l i n e d e r r o r

    r e c o v e r y p r o t o c o l s , t h a t a r e c a l l e d s l i d i n g w i n d o w p r o t o c o l s . T h e s e t y p i c a l l y o e r m u c h l a r g e r

    t h r o u g h p u t t h a n t h e a l t e r n a t i n g b i t o r s t o p - a n d - w a i t p r o t o c o l . W e w i l l a l s o l o o k a t s o m e p r o t o c o l

    d e s i g n l e s s o n s , e s p e c i a l l y t h e p r o b l e m o f i n i t i a l i z i n g t h e s l i d i n g w i n d o w p r o t o c o l i n t h e f a c e o f l i n k

    a n d n o d e c r a s h e s .

    1 L a t e n c y a n d T h r o u g h p u t

    W e s t a r t b y i n t r o d u c i n g t w o i m p o r t a n t m e a s u r e s t h a t w e u s e t o c o m p a r e t h e p e r f o r m a n c e o f

    p r o t o c o l s . C o n s i d e r a s y s t e m l i k e a n e t w o r k w h e r e j o b s l i k e m e s s a g e s a r r i v e , a n d a f t e r c o m p l e t i o n

    l e a v e t h e n e t w o r k . T h r o u g h p u t r o u g h l y m e a s u r e s t h e n u m b e r o f j o b s c o m p l e t e d p e r s e c o n d . L a t e n c y

    m e a s u r e s t h e t i m e w o r s t - c a s e o r a v e r a g e , w e w i l l t y p i c a l l y c o n s i d e r w o r s t - c a s e t o c o m p l e t e a j o b .

    T h e o w n e r s o f a s y s t e m w a n t t o m a x i m i z e t h r o u g h p u t t o m a x i m i z e r e v e n u e s , w h i l e u s e r s o f a

    s y s t e m w a n t l o w l a t e n c i e s s o t h e y d o n ' t w a s t e t h e i r t i m e . C o n s i d e r a d o c t o r ' s o c e . O f t e n t h e y

    k e e p y o u w a i t i n g f o r a l o n g t i m e s o t h a t y o u w i l l b e r e a d y w h e n t h e d o c t o r i s r e a d y . T h e y a r e

    o p t i m i z i n g f o r t h r o u g h p u t , n o t t o m i n i m i z e y o u r l a t e n c y . A b u s y t r a c s i g n a l s h o u l d t y p i c a l l y

    m a x i m i z e f o r t h r o u g h p u t b y h a v i n g e a c h s i g n a l d i r e c t i o n s t a y o n f o r a l o n g t i m e ; t h i s m i n i m i z e s t h e

    s t a r t u p o v e r h e a d e v e r y t i m e t h e s i g n a l c h a n g e s . H o w e v e r , t h a t m e a n s t h a t e v e n i f t h e r e i s n o b o d y

    a t t h e i n t e r s e c t i o n , y o u m a y h a v e t o w a i t a l o n g t i m e t i l l t h e s i g n a l l i g h t c h a n g e s i f y o u a r e u n l u c k y

    a n d a r r i v e j u s t a s y o u r l i g h t c h a n g e s t o r e d .

    A n o t h e r i n t e r e s t i n g p o i n t e x e m p l i e d b y t h e t r a c l i g h t e x a m p l e i s t h r o u g h p u t i s m o r e i n -

    t e r e s t i n g f o r b u s y s y s t e m s a n d l a t e n c y i s m o r e i m p o r t a n t f o r i d l e s y s t e m s .

    O n e m i g h t t h i n k t h a t t h r o u g h p u t i s j u s t t h e r e c i p r o c a l o f l a t e n c y . T h a t i s n o t t r u e w h e n t h e

    s y s t e m i s p i p e l i n e d | i . e . , t h e n u m b e r o f u s e r s t h a t m a y b e i n g s e r v i c e d a t t h e s a m e t i m e i n s i d e

    t h e s y s t e m . F o r e x a m p l e , i f t h e s y s t e m c o n s i s t s o f 8 s e r v i c e s t a t i o n s t h a t t a k e 1 u n i t o f t i m e e a c h .

    I f e a c h j o b m u s t g o t h r o u g h e a c h s t a t i o n , t h e t h r o u g h p u t c a n b e 1 j o b p e r u n i t t i m e , w h i l e t h e

    l a t e n c y i s 8 . O n t h e o t h e r h a n d , s u p p o s e e a c h j o b n e e d s o n l y 1 s e r v i c e s t a t i o n a n d a n y s e r v i c e

    s t a t i o n w i l l d o . T h e n t h e t h r o u g h p u t c a n b e 8 j o b s p e r u n i t t i m e , a n d t h e l a t e n c y i s 1 .

    F o r n e t w o r k s , t h e j o b s a r e m e s s a g e s a n d t h e s y s t e m i s a n e t w o r k . T h e s e r v i c e s t a t i o n s c o r r e s p o n d

    t o a s e r i e s o f h o p s . H o w e v e r , i n t h i s l e c t u r e w e w i l l c o n n e o u r s e l v e s t o a s i n g l e h o p .

    T w o o t h e r i m p o r t a n t d e n i t i o n s w e n e e d t o m a k e f o r a D a t a L i n k a r e t r a n s m i s s i o n r a t e a n d

    p r o p a g a t i o n d e l a y . T h e t r a n s m i s s i o n r a t e a t t h e D a t a L i n k i s t h e r a t e a t w h i c h t h e p h y s i c a l

    l a t e r s e n d s b i t s . T h u s a p h y s i c a l l a y e r t h a t s e n d s 1 0 0 0 b i t s a s e c o n d , s e n d s a b i t e v e r y m s e c .

    T h e p r o p a g a t i o n d e l a y i s t h e t i m e i t t a k e s f o r a s i n g l e b i t t h a t i s s e n t t o a r r i v e a t t h e r e c e i v e r .

    P r o p a g a t i o n d e l a y i s l i m i t e d b y t h e s p e e d o f l i g h t t o a t l e a s t 3 u s e c p e r k m . E l e c t r i c a l s i g n a l s t r a v e l

    1

  • 8/2/2019 Sliding Window Discussion

    2/13

    e v e n s l o w e r a n d d e p e n d s o n t h e d i s t a n c e o f t h e l i n k b e t w e e n t h e s e n d e r a n d r e c e i v e r . C o n s i d e r a

    s e n d e r a n d r e c e i v e r t h a t a r e c o n n e c t e d b y a 5 0 k m l i n k . A s s u m e s p e e d o f l i g h t p r o p a g a t i o n , t h a t

    a m o u n t s t o a 0 . 1 5 m s e c p r o p a g a t i o n d e l a y a n d 1 0 0 0 b i t s e c o n d t r a n s m i s s i o n , a 1 0 b i t f r a m e w i l l

    t a k e 1 . 1 5 m s e c t o b e r e c e i v e d c o m p l e t e l y : 1 0 m s e c t o t r a n s m i t a l l t h e b i t s , a n d . 1 5 m s e c f o r t h e

    l a s t b i t t o r e a c h t h e r e c e i v e r .

    T h e t h r o u g h p u t o f a l i n k c a n b e m a d e i n d e p e n d e n t o f i t s l a t e n c y b y p i p e l i n i n g . H o w e v e r , f o r

    o b v i o u s r e a s o n s , t h e t h r o u g h p u t c a n n e v e r e x c e e d t h e t r a n s m i s s i o n r a t e . F i n a l l y , t h e p r o p a g a t i o n

    d e l a y i s a l w a y s a n u n a v o i d a b l e p a r t o f l a t e n c y o n a l i n k .

    F o r u n f o r t u n a t e r e a s o n s , m a n y p e o p l e u s e t h e w o r d b a n d w i d t h t o t a l k o f t h e t r a n s m i s s i o n r a t e

    o n a l i n k . A t t h e p h y s i c a l l a y e r , b a n d w i d t h i s t h e r a n g e o f f r e q u e n c i e s t h a t a r e p a s s e d t h r o u g h . A t

    t h e d a t a l i n k l a y e r , i t i s o f t e n u s e d t o m e a n t h e l i n k t r a n s m i s s i o n r a t e . P l e a s e t r y t o u n d e r s t a n d

    b y c o n t e x t w h i c h m e a n i n g i s b e i n g u s e d . A n o t h e r p h r a s e t h a t i s u s e d o f t e n i s r o u n d - t r i p d e l a y .

    T h i s i s t h e d e l a y t o s e n d a f r a m e f r o m a s e n d e r t o a r e c e i v e r a n d t o r e c e i v e a r e p l y f r a m e f r o m t h e

    r e c e i v e r . I t i n c l u d e s t h e t i m e t o t r a n s m i t b o t h f r a m e s , a s w e l l a s t w o p r o p a g a t i o n d e l a y s .

    2 W h y P i p e l i n e ?

    C o n s i d e r a s a t e l l i t e l i n k t h a t t r a n s m i t s a t a s p e e d o f 1 0 0 K b i t s e c u s i n g 1 0 0 0 b i t d a t a f r a m e s . U s i n g

    a s t o p - a n d - w a i t p r o t o c o l , a n d a s s u m i n g a p r o p a g a t i o n d e l a y o f 2 5 0 m s e c r e m e m b e r a s a t e l l i t e l i n k

    m u s t g o a l l t h e w a y u p t o t h e s a t e l l i t e , a l a r g e d i s t a n c e , w e c a n s e n d o n l y 1 0 0 0 u s e f u l b i t s e v e r y

    5 0 0 m s e c . T h i s l e a d s t o a t h r o u g h p u t o f 2 0 0 0 b i t s e c . T h u s s t o p - a n d - w a i t l i m i t s u s t o u s i n g o n l y

    2 0 0 0 1 0 0 , 0 0 0 o f t h e l i n k b a n d w i d t h n e w s e n s e o f t h e t e r m b a n d w i d t h ! ! w h i c h m e a n s t h a t t h e

    l i n k i s b e i n g u t i l i z e d a t o n l y 2 p e r c e n t . I f t h e s a t e l l i t e l i n k c o s t s s e v e r a l h u n d r e d t h o u s a n d d o l l a r s

    a m o n t h , t h e u s e r s o f t h i s s y s t e m s h o u l d b e u n h a p p y .

    T h e p r o b l e m , o f c o u r s e , i s t h a t s t o p - a n d - w a i t l i m i t s u s t o s e n d i n g o n e f r a m e e v e r y r o u n d - t r i p

    d e l a y . T h i s i s a u s e f u l p o i n t : t h e p e r f o r m a n c e o f a n e t w o r k c a n b e g r e a t l y i n u e n c e d b y t h e c h o i c e

    o f p r o t o c o l .

    T h e s t o p - a n d - w a i t p r o b l e m i s n o t l i m i t e d t o s a t e l l i t e l i n k s . I t r e a l l y a p p l i e s t o a l l l i n k s s u c h

    t h a t t h e l i n k t r a n s m i s s i o n r a t e m u l t i p l i e d b y t h e p r o p a g a t i o n d e l a y i s l a r g e c o m p a r e d t o t h e f r a m e

    s i z e . T h i s i s s o m e t i m e s c a l l e d t h e b a n d w i d t h - d e l a y p r o d u c t o r p i p e s i z e b e c a u s e i t m e a s u r e s t h e

    n u m b e r o f b i t s t h a t c a n p h y s i c a l l y b e s t o r e d o n t h e p h y s i c a l l i n k . S i n c e t h e s p e e d o f l i g h t h a s

    b e e n c o n s t a n t f o r c e n t u r i e s , b u t t r a n s m i s s i o n r a t e s k e e p i m p r o v i n g , t h e b a n d w i d t h - d e l a y p r o d u c t

    k e e p s i n c r e a s i n g . C o n s i d e r a b r e o p t i c l i n k t h a t l i n k s t w o l o c a t i o n s o n t w o c o a s t s . A s s u m i n g a

    c o a s t - t o - c o a s t p r o p a g a t i o n d e l a y o f 2 0 m s e c , a n d a t r a n s m i s s i o n s p e e d o f 1 0 0 M b i t s e c , a n d a f r a m e

    s i z e o f 1 0 0 0 b i t s , w e c a n s t o r e 2 0 0 0 f r a m e s o n t h e p h y s i c a l l i n k ! T h u s s t o p - a n d - w a i t w o u l d r e s t r i c t

    u s t o u s i n g o n l y 1 4 0 0 0 o f t h e l i n k b a n d w i d t h .

    F o r a l l t h e s e r e a s o n s , p i p e l i n e d d a t a l i n k p r o t o c o l s a r e e s s e n t i a l . O f c o u r s e , m o s t h i g h - s p e e d

    d a t a l i n k p r o t o c o l s d o n o t d o e r r o r r e c o v e r y , s o t h i s p r o b l e m d o e s n o t a r i s e . H o w e v e r , t r a n s p o r t

    p r o t o c o l s h a v e t h e s a m e p r o b l e m s e n d - t o - e n d , a n d t h u s i t i s c r u c i a l t h a t t h e y u s e p i p e l i n e d e r r o r

    r e c o v e r y p r o t o c o l s . I n t h e r e s t o f t h e l e c t u r e w e w i l l s t u d y p i p e l i n e d s l i d i n g w i n d o w p r o t o c o l s .

    2

  • 8/2/2019 Sliding Window Discussion

    3/13

    3 S l i d i n g W i n d o w P r o t o c o l s

    I n a s l i d i n g w i n d o w p r o t o c o l , t h e s e n d e r c a n s e n d a w i n d o w o f o u t s t a n d i n g f r a m e s b e f o r e g e t t i n g

    a n y a c k n o w l e d g e m e n t s . T h e w i n d o w s i z e l i m i t s t h e d e g r e e o f p i p e l i n i n g . C o n s i d e r a s l i d i n g w i n d o w

    p r o t o c o l w i t h a w i n d o w s i z e o f w . A s i n t h e s t o p - a n d - w a i t p r o t o c o l , l e t s s t a r t b y u s i n g l a r g e s e q u e n c e

    n u m b e r s r s t . T h e s e n d e r m a i n t a i n s a s i n g l e v a r i a b l e , a a l o w e r w i n d o w e d g e L s o m e t i m e s c a l l e d

    t h e l o w e r w i n d o w w h i c h r e p r e s e n t s t h e l o w e s t s e q u e n c e n u m b e r t h a t t h e s e n d e r h a s n o t r e c e i v e d

    a n a c k f o r . T h e s e n d e r c a n a l s o b e t h o u g h t o f a s m a i n t a i n i n g a n u p p e r w i n d o w e d g e , w h i c h i s e q u a l

    t o L + w , 1 , w h i c h i s t h e m a x i m u m s e q u e n c e n u m b e r i t i s a l l o w e d t o s e n d . T h e r e c e i v e r m a i n t a i n s

    a r e c e i v e s e q u e n c e n u m b e r R t h a t i s t h e n e x t n u m b e r i t e x p e c t s t o s e e j u s t a s i n s t o p - a n d - w a i t .

    L a n d R a r e i n i t i a l l y e q u a l t o 0 .

    I n t h e s t o p - a n d - w a i t p r o t o c o l , t h e s e n d e r k e e p s r e t r a n s m i t t i n g t h e f r a m e w i t h s e q u e n c e n u m b e r

    e q u a l t o t h e s e n d e r s e q u e n c e n u m b e r u n t i l i t g e t s a n a c k . I n s l i d i n g w i n d o w p r o t o c o l s , t h e s e n d e r

    k e e p s r e t r a n s m i t t i n g a l l f r a m e s i n i t s c u r r e n t w i n d o w u n t i l i t g e t s a n a c k . T h e r e c e i p t o f a n a c k

    n u m b e r e d R i m p l i c i t l y a c k s a l l s e q u e n c e n u m b e r s t h a t a r e s t r i c t l y l e s s t h a n R .

    T h e r e a r e t w o i m p o r t a n t v a r i a n t s o f s l i d i n g w i n d o w p r o t o c o l s . I n t h e r s t , c a l l e d g o - b a c k - N , t h e

    r e c e i v e r o n l y a c c e p t s f r a m e s i n o r d e r . S u p p o s e t h e r e c e i v e r i s e x p e c t i n g f r a m e n u m b e r 0 , a n d t h e

    s e n d e r s e n d s f r a m e s 0 a n d 1 . I f f r a m e 0 g e t s l o s t a n d f r a m e 1 a r r i v e s a t t h e r e c e i v e r , a g o - b a c k - N

    r e c e i v e r w i l l d i s c a r d f r a m e 1 b e c a u s e i t a r r i v e d o u t - o f - o r d e r . I t i s o n l y w h e n t h e s e n d e r r e t r a n s m i t s

    0 a n d 1 a n d t h e y b o t h a r r i v e i n o r d e r t h a t t h e r e c e i v e r w i l l a c c e p t b o t h f r a m e s . T h i s v e r s i o n i s

    s i m p l e t o i m p l e m e n t b u t i t i m p l i e s t h a t t h e l o s s o f a s i n g l e f r a m e i n a w i n d o w c a n c a u s e t h e s e n d e r

    t o h a v e t o r e t r a n s m i t t h e e n t i r e w i n d o w h e n c e t h e n a m e , w i t h n r e p r e s e n t i n g t h e w i n d o w s i z e .

    A f a i r l y o b v i o u s x i s t o h a v e t h e r e c e i v e r n o t d i s c a r d f r a m e 1 i n t h e a b o v e e x a m p l e b u t t o

    b u e r i t a t t h e r e c e i v e r u n t i l t h e s e n d e r r e s e n d s f r a m e 0 . W H e n f r a m e 0 a r r i v e s , t h e r e c e i v e r c a n

    t h e n r e l e a s e f r a m e s 0 a n d 1 t o t h e c l i e n t . T h i s a v o i d s t h e s e n d e r f r o m h a v i n g t o u n n e c e s s a r i l y

    r e t r a n s m i t f r a m e 1 . I t h a s a s l i g h t l y m o r e c o m p l i c a t e d i m p l e m e n t a t i o n , h o w e v e r , a n d s o i s a s n o t

    u s e d a s o f t e n a s o n e m i g h t l i k e . T h e d i e r e n c e b e t w e e n t h e t w o i s s l i g h t i f t h e e r r o r r a t e i s l o w

    a n d t h e w i n d o w s i z e i s s m a l l . H o w e v e r , f o r l a r g e p i p e s i z e s c o m m o n i n h i g h s p e e d n e t w o r k s a n d

    f a i r l y l a r g e c h a n c e s o f l o s i n g f r a m e s , s e l e c t i v e r e j e c t i s i m p o r t a n t . I n p a r t i c u l a r , f o r h i g h - s p e e d

    t r a n s p o r t p r o t o c o l s w h e r e m o s t f r a m e s a r e l o s t d u e t o c o n g e s t i o n w h i c h c a n b e q u i t e c o m m o n

    a n d t h e w i n d o w s i z e s a r e l a r g e , s e l e c t i v e r e j e c t i s v e r y d e s i r a b l e .

    4 E x a m p l e

    F i g u r e 1 s h o w s a n e x a m p l e t h a t c o n t r a s t s t h e t w o v a r i a n t s o f s l i d i n g w i n d o w . O n t h e l e f t w e s h o w

    g o - b a c k - n o p e r a t i o n f o r a w i n d o w s i z e o f 3 . W h e n w e u s e a p a i r o f n u m b e r s m ; m + w , 1 n e x t

    t o t h e s e n d e r , i t m e a n s t h a t t h e s e n d e r c a n s e n d f r a m e s i n t h e r a n g e . N o t i c e t h a t a f t e r t h e r s t

    a c k i s r e c e i v e d , t h e w i n d o w s l i d e s t o 1 ; 3 . I f a c k s k e e p c o m i n g b a c k s m o o t h l y a n d t h e w i n d o w i s

    s u c i e n t l y l a r g e , t h e p i p e l i n e c a n k e e p o w i n g s m o o t h l y w i t h t h e a c k f o r t h e r s t f r a m e i n t h e

    w i n d o w b e i n g r e c e i v e d j u s t a f t e r t h e l a s t f r a m e i n t h e w i n d o w i s t r a n s m i t t e d . T h i s w o u l d e n s u r e

    t h a t t h e t r a n s m i t t e r a n d t h e t r a n s m i s s i o n l i n e a r e n e v e r i d l e .

    H o w e v e r , t h e e x a m p l e s h o w s t h a t f r a m e n u m b e r 1 i s l o s t . I n t h e g o - b a c k - 3 v e r s i o n , t h e s e n d e r

    3

  • 8/2/2019 Sliding Window Discussion

    4/13

    u s e l e s s l y t r a n s m i t s 2 a n d 3 . O n l y w h e n a t i m e r e x p i r e s , a n d t h e e n t i r e w i n d o w i s r e t r a n s m i t t e d

    f o r g o - b a c k - n , i t s u c e s t o h a v e a s i n g l e t i m e r t h a t i s r e f r e s h e d w h e n e v e r t h e w i n d o w s l i d e s ; i f

    i t e x p i r e s , t h e e n t i r e w i n d o w i s t r a n s m i t t e d i n o r d e r . I n t h e s e l e c t i v e r e j e c t s c h e m e , o n t h e o t h e r

    h a n d , f r a m e s n u m b e r 2 a n d 3 a r e b u e r e d a t t h e r e c e i v e r u n t i l t h e r e t r a n s m i t t e d 1 a r r i v e s ; a t t h i s

    p o i n t t h e r e c e i v e r n u m b e r j u m p s t o 4 , a n d t h e r e c e i v e r d e l i v e r s f r a m e s 1 , 2 , a n d 3 .

    0

    1D(0)

    A(1)D(1)

    D(2)

    D(3)

    D(1)

    D(2)

    D(3)

    A(4)

    WINDOWSLIDES

    TIMEREXPIRES

    REJECT

    REJECT

    GO BACK 3 SELECTIVEREJECT0

    1D(0)

    A(1)D(1)

    D(2)

    D(3)

    D(1)

    A(4)

    WINDOWSLIDES

    TIMEREXPIRES

    BUFFER

    BUFFER

    0,2

    1,3

    4,6

    4,6

    1,3

    0,2

    F i g u r e 1 : A n e x a m p l e o f G o - B a c k n a n d S e l e c t i v e R e j e c t O p e r a t i o n . N o t e t h a t s e l e c t i v e r e j e c t c a n r e c o v e r f a s t e r f r o m

    e r r o r s a s s e n d e r h a s o n l y t o r e t r a n s m i t l o s t f r a m e s .

    5 S l i d i n g W i n d o w C o d e

    T h e c o d e f o r G o - b a c k - n s l i d i n g w i n d o w p r o t o c o l s i s g i v e n b e l o w . T o m a k e t h e c o d e m o r e g e n e r a l ,

    w e a l l o w t h e r e c e i v e r t o s e n d a c k s w h e n e v e r i t w a n t s t o , n o t j u s t w h e n i t g e t s a d a t a f r a m e , t h o u g h

    t h a t i s t y p i c a l .

    A s s u m e t h a t t h e s e n d e r h a s a l o n g s e q u e n c e o f d a t a p a c k e t s g i v e n t o i t b y i t s c l i e n t , t h a t i t w a n t s

    4

  • 8/2/2019 Sliding Window Discussion

    5/13

    t o s e n d . T h e d a t a p a c k e t s a r e s t o r e d a t t h e s e n d e r . N u m b e r t h e d a t a p a c k e t s f r o m 0 o n w a r d s . W e

    w i l l s e n d t h e s - t h d a t a p a c k e t w i t h s e q u e n c e n u m b e r s a t t a c h e d .

    S e n d e r c o d e f o r G o - b a c k N :

    A s s u m e a l l c o u n t e r s a r e l a r g e i n t e g e r s t h a t n e v e r w r a p .

    T h e s e n d e r k e e p s a l o w e r w i n d o w L , i n i t i a l l y 0 .

    S e n d s , m * s e n d e r s e n d s o r r e s e n d s s - t h d a t a p a c k e t *

    T h e s e n d e r c a n s e n d t h i s f r a m e i f a n d o n l y i f :

    m c o r r e s p o n d s t o d a t a p a c k e t n u m b e r s g i v e n t o s e n d e r b y c l i e n t A N D

    L = s = L + w - 1 * o n l y t r a n s m i t w i t h i n c u r r e n t w i n d o w *

    R e c e i v e r , A c k * s e n d e r a b s o r b s a c k n o w l e d g e m e n t *

    O n r e c e i p t , s e n d e r c h a n g e s s t a t e a s f o l l o w s :

    L : = R

    T h e r e c e i v e r k e e p s a n i n t e g e r R w h i c h r e p r e s e n t s t h e n e x t s e q u e n c e n u m b e r

    i t e x p e c t s , i n i t i a l l y 0 .

    R e c e i v e s , m * r e c e i v e r g e t s a d a t a f r a m e *

    O n r e c e i p t , r e c e i v e r c h a n g e s s t a t e a s f o l l o w s :

    I f s = R t h e n * n e x t f r a m e i n s e q u e n c e *

    R : = s + 1

    d e l i v e r d a t a m t o r e c e i v e r c l i e n t .

    S e n d r , A c k * w e a n a l l o w r e c e i v e r t o s e n d a n a c k a n y t i m e *

    r m u s t b e e q u a l t o r e c e i v e r n u m b e r R a t p o i n t a c k i s s e n t

    m o s t i m p l e m e n t a t i o n s s e n d a n a c k o n l y w h e n a d a t a f r a m e i s r e c e i v e d

    W e a s s u m e t h a t a n y u n a c k n o w l e d g e d f r a m e i n c u r r e n t w i n d o w i s p e r i o d i c a l l y

    r e s e n t . I n p a r t i c u l a r , t h e l o w e s t f r a m e i n t h e c u r r e n t w i n d o w m u s t b e

    p e r i o d i c a l l y s e n t t o a v o i d d e a d l o c k .

    T h e c o d e f o r s e l e c t i v e r e j e c t i s g i v e n b e l o w . T h i s t i m e w e a s s u m e t h a t t h e s e n d e r k e e p s a t a b l e

    t h a t r e c o r d s w h i c h n u m b e r s g r e a t e r t h a n L h a v e b e e n a c k e d w h i l e w e a s s u m e a l a r g e a r r a y i n t h e

    c o d e , i t s u c e s t o k e e p a b i t m a p r e p r e s e n t i n g n u m b e r s f r o m L t o L + w - 1 . S i m i l a r l y , w e a s s u m e

    t h e r e c e i v e r h a s a s i m i l a r t a b l e t h a t s t o r e s b o t h a b i t i n d i c a t i n g r e c e i p t a n d a p o i n t e r t o t h e d a t a

    i f t h e f r a m e h a s b e e n r e c e i v e d .

    I n t h e l a s t e x a m p l e , w e s a w t h a t t h e s e n d e r o n l y n e e d r e t r a n s m i t t h e f r a m e s t h a t a r e a c t u a l l y

    l o s t . I n o r d e r t o p r e v e n t t h e s e n d e r f r o m d o i n g u s e l e s s r e t r a n s m i s s i o n s , t h e r e c e i v e r n e e d s t o s e n d

    5

  • 8/2/2019 Sliding Window Discussion

    6/13

    a n a c k c o n t a i n i n g i t s c u r r e n t n u m b e r R a s w e l l a s a l i s t o f n u m b e r s g r e a t e r t h a n R t h a t h a v e b e e n

    r e c e i v e d o u t o f s e q u e n c e a t t h e r e c e i v e r .

    S e n d e r c o d e f o r s e l e c t i v e - r e j e c t :

    A s s u m e a l l c o u n t e r s a r e l a r g e i n t e g e r s t h a t n e v e r w r a p .

    T h e s e n d e r k e e p s a l o w e r w i n d o w L , i n i t i a l l y 0 a n d a t a b l e t h a t

    i n d i c a t e s w h i c h n u m b e r s h a v e b e e n a c k e d t h i s c a n b e o p t i m i z e d t o s t o r e

    o n l y a w i n d o w s w o r t h o f s u c h s t a t e .

    S e n d s , m * s e n d e r s e n d s o r r e s e n d s s - t h d a t a p a c k e t

    T h e s e n d e r c a n s e n d t h i s f r a m e i f a n d o n l y i f :

    m c o r r e s p o n d s t o d a t a p a c k e t n u m b e r s g i v e n t o s e n d e r b y c l i e n t A N D

    L = s = L + w - 1 * o n l y t r a n s m i t w i t h i n c u r r e n t w i n d o w * A N D

    s h a s n o t b e e n a c k e d .

    R e c e i v e R , L i s t , A c k * s e n d e r a b s o r b s a c k n o w l e d g e m e n t *

    O n r e c e i p t , s e n d e r c h a n g e s s t a t e a s f o l l o w s :

    L = R

    M a r k e v e r y n u m b e r i n L i s t a s b e i n g a c k e d i n t a b l e .

    T h e r e c e i v e r k e e p s a n i n t e g e r R w h i c h r e p r e s e n t s t h e n e x t s e q u e n c e n u m b e r

    i t e x p e c t s , i n i t i a l l y 0 . T h e r e c e i v e r a l s o k e e p s a t a b l e t h a t , f o r

    e a c h s e q u e n c e n u m b e r , s t o r e s a b i t i n d i c a t i n g w h e t h e r i t h a s b e e n r e c e i v e d

    a n d a p o i n t e r t o t h e d a t a , i f a n y , b e i n g b u f f e r e d . O n c e a g a i n , t h i s t a b l e

    c a n b e o p t i m i z e d t o r e d u c e t h e a m o u n t o f s t o r a g e t o b e p r o p o r t i o n a l t o

    a w i n d o w s i z e .

    R e c e i v e s , m * r e c e i v e r g e t s a d a t a f r a m e *

    O n r e c e i p t , r e c e i v e r c h a n g e s s t a t e a s f o l l o w s :

    I f s = R t h e n

    S t o r e m i n t a b l e a t p o s i t i o n s a n d s e t b i t i n p o s i t i o n s

    W h i l e t h e b i t a t p o s i t i o n R i s n o t s e t d o

    D e l i v e r d a t a a t p o s i t i o n R

    R = R + 1

    S e n d R , L i s t , A c k * w e a n a l l o w r e c e i v e r t o s e n d a n a c k a n y t i m e *

    R m u s t b e e q u a l t o r e c e i v e r n u m b e r R a t p o i n t a c k i s s e n t

    L i s t c o n s i s t s o f n u m b e r s g r e a t e r t h a n L t h a t h a v e b e e n r e c e i v e d .

    m o s t i m p l e m e n t a t i o n s s e n d a n a c k o n l y w h e n a d a t a f r a m e i s r e c e i v e d

    W e a s s u m e t h a t a n y u n a c k n o w l e d g e d f r a m e i n c u r r e n t w i n d o w i s p e r i o d i c a l l y

    r e s e n t . I n p a r t i c u l a r , t h e l o w e s t f r a m e i n t h e c u r r e n t w i n d o w m u s t b e

    6

  • 8/2/2019 Sliding Window Discussion

    7/13

    p e r i o d i c a l l y s e n t t o a v o i d d e a d l o c k .

    6 I m p l e m e n t a t i o n D e t a i l s

    T h e c o d e w e h a v e s h o w n d o e s n o t s h o w t i m e r s t h a t a r e u s e d i n a n y r e a l i m p l e m e n t a t i o n . A s w e

    s a i d e a r l i e r , i n g o - b a c k - N i m p l e m e n t a t i o n s , i t s u c e s t o h a v e o n e o u t s t a n d i n g t i m e r . T h e t i m e r

    i s s e t t o s o m e m u l t i p l e o f t h e a v e r a g e r o u n d - t r i p d e l a y . T h e r o u n d - t r i p d e l a y c a n b e c a l c u l a t e d

    b y s e e i n g h o w l o n g i t t a k e s f o r a c k s t o a r r i v e ; w e " l l e x a m i n e t h i s i n m o r e d e t a i l w h e n w e l o o k a t

    t r a n s p o r t p r o t o c o l s . N o t i c e , t h a t a s u s u a l t h e p r o t o c o l w i l l w o r k c o r r e c t l y i f t h e t i m e r v a l u e s a r e

    s e t w r o n g ; i t w i l l o n l y c o s t i n p e r f o r m a n c e . I n s e l e c t i v e r e j e c t , w e h a v e t o s e t a t i m e r f o r e v e r y

    o u t s t a n d i n g f r a m e i n o r d e r t o r e t r a n s m i t a n y o u t s t a n d i n g f r a m e i n t h e w i n d o w .

    T h e a c k l i s t c a n b e r e p r e s e n t e d a s a b i t m a p t o s a v e b i t s . I n o r d e r t o f u r t h e r r e d u c e t h e a c k

    b a n d w i d t h , s o m e i m p l e m e n t a t i o n s o f t e n p i g g y b a c k a c k s o n d a t a o w i n g i n t h e r e v e r s e d i r e c t i o n . I n

    o r d e r t o a l l o w t h i s , t h e d a t a f r a m e s m u s t h a v e e l d s i n t h e i r h e a d e r t h a t c a n b e u s e d t o p u t i n

    r e v e r s e a c k i n f o r m a t i o n . W h i l e t h e s a v i n g i n b i t s c a n b e s m a l l y o u o n l y s a v e t h e r e s t o f t h e h e a d e r

    a n d f r a m i n g i n f o r m a t i o n , i t d o e s r e d u c e t h e n u m b e r o f f r a m e s t h a t t h e s e n d e r h a s t o p r o c e s s . I t

    t u r n s o u t t h a t t h e r e i s a l a r g e x e d c o s t e . g . , i n t e r r u p t p r o c e s s i n g f o r p r o c e s s i n g f r a m e s , a n d i t

    p a y s t o r e d u c e t h e n u m b e r o f f r a m e s .

    7 S e q u e n c e N u m b e r S p a c e f o r S l i d i n g W i n d o w P r o t o c o l s

    F o r t h e s t o p - a n d - w a i t p r o t o c o l , w e s h o w e d t h a t a s e q u e n c e n u m b e r s p a c e o f t w o w a s s u c i e n t .

    I n o t h e r w o r d s , i f w e d i d a l l a r i t h m e t i c m o d n , w h e r e n i s t h e s i z e o f t h e s p a c e , i t a l l w o r k s o u t

    O K . S i m i l a r a r g u m e n t s h o l d f o r s l i d i n g w i n d o w p r o t o c o l s , b u t t h e a r g u m e n t s d i e r f o r t h e d i e r e n t

    v a r i a n t s .

    7 . 1 G o - b a c k - n M o d u l u s

    C o n s i d e r r s t g o - b a c k - n . F i r s t , n o t i c e t h a t i t i s a s t r i c t g e n e r a l i z a t i o n o f s t o p - a n d - w a i t i f w e s e t

    t h e w i n d o w s i z e t o 1 . T h u s i f w e c a n g e t a w a y w i t h a s e q u e n c e n u m b e r s p a c e o f 2 1 + 1 i n s t o p -

    a n d - w a i t , p e r h a p s w e c a n g e t a w a y w i t h a s p a c e o f w + 1 . T h i s i s i n d e e d t r u e b u t t h e a r g u m e n t i s

    m o r e t r i c k y . T h i s i s b e c a u s e i n s l i d i n g w i n d o w p r o t o c o l s w e c a n s h o w t h a t t h e r e c a n b e 2 w d i s t i n c t

    n u m b e r s s i m u l t a n e o u s l y i n t h e s y s t e m i . e . , i n c l u d i n g b o t h l i n k s i n s o m e e x e c u t i o n s t r y t o n d

    t h i s e x a m p l e . F o r w = 1 , t h i s g i v e s u s 2 , w h i c h i s a l s o e q u a l t o w + 1 . H o w e v e r , t h a t s e e m s t o

    i n d i c a t e y o u m a y n e e d a s p a c e o f 2 w .

    F i g u r e 2 s h o w s w h y a s p a c e o f w + 1 i s s u c i e n t f o r g o - b a c k - n . N o t i c e t h a t i n t h e c o d e , t h e

    o n l y c o m p a r i s o n b e t w e e n s e q u e n c e n u m b e r s i s w h e n t h e r e c e i v e r c h e c k s w h e t h e r a n i n c o m i n g f r a m e

    w i t h n u m b e r s h a s n u m b e r s 6= R . S u p p o s e w e c a n s h o w t h a t b o t h s a n d R a r e a l w a y s w i t h i n w

    o f e a c h o t h e r . T h e n a s p a c e o f w + 1 w i l l s u c e .

    T h e p r o o f i s a l i t t l e t r i c k y . W e w i l l n o t u s e a p r o o f t h a t u s e s i n v a r i a n t s t h r o u g h s u c h a p r o o f c a n

    7

  • 8/2/2019 Sliding Window Discussion

    8/13

    b e c o n s t r u c t e d . C o n s i d e r t h e r e c e i p t o f f r a m e n u m b e r s w h e n t h e r e c e i v e r n u m b e r i s R . C o n s i d e r

    t h e s t a t e o f t h e s e n d e r w h e n s w a s s e n t ; c l e a r l y s m u s t b e i n t h e r a n g e L t o L + w , 1 , w h e r e L i s

    t h e l o w e r w i n d o w a t t h e t i m e f r a m e s w a s s e n t . N o w i f t h e s e n d e r n u m b e r i s L a t t h i s e a r l i e r p o i n t

    i n t i m e , i t m u s t b e b e c a u s e i t r e c e i v e d a n a c k f r o m t h e r e c e i v e r w i t h n u m b e r L . T h i s m e a n s t h a t

    t h e r e c e i v e r n u m b e r w a s L s o m e t i m e i n t h e p a s t . B u t s i n c e t h e r e c e i v e r n u m b e r o n l y i n c r e a s e s o r

    s t a y s t h e s a m e , i t m e a n s t h a t t h e r e c e i v e r n u m b e r w h e n f r a m e s i s r e c e i v e d i s a t l e a s t L , w h e r e L

    i s t h e l o w e r w i n d o w a t t h e p o i n t s i s s e n t .

    S i m i l a r l y , i t i s e a s y t o s e e t h a t t h e s e n d e r h a s n e v e r s e n t f r a m e s w i t h n u m b e r s l a r g e r t h a n

    L + w , 1 b e f o r e f r a m e s w a s s e n t b e c a u s e o f t h e w i n d o w s i z e r e s t r i c t i o n . S i n c e t h e l i n k s a r e F I F O

    t h i s i s t h e o n l y p l a c e w e u s e t h e F I F O p r o p e r t y o f t h e p h y s i c a l l i n k , n o d a t a f r a m e w i t h n u m b e r

    g r e a t e r t h a n L + w , 1 c a n h a v e a r r i v e d b e f o r e f r a m e s a r r i v e s . T h u s t h e r e c e i v e r n u m b e r c a n n o t b e

    g r e a t e r t h a n L + w r e c a l l t h a t t h e r e c e i v e r g o e s t o o n e h i g h e r n u m b e r t h a n t h e l a s t f r a m e n u m b e r

    r e c e i v e d i n s e q u e n c e , w h e r e L i s t h e l o w e r w i n d o w a t t h e p o i n t w h e r e f r a m e s w a s s e n t .

    T h u s w e k n o w t h a t L R L + w . B u t w e k n o w b e c a u s e o n l y f r a m e s w i t h i n c u r r e n t w i n d o w

    a r e s e n t t h a t L s L + w , 1 . T h u s t h e a b s o l u t e v a l u e o f R , s i s n o g r e a t e r t h a n w . H e n c e

    w e c a n g e t a w a y w i t h a m o d u l u s o f s i z e w + 1 , b e c a u s e a n y t w o d i s t i n c t i n t e g e r s t h a t d i e r b y a t

    m o s t w w i l l b e a s s i g n e d d i s t i n c t n u m b e r s i n t h e m o d u l u s s p a c e .

    I f w e u s e a s m a l l e r s p a c e , w e c a n e a s i l y c a u s e p r o b l e m s . F o r i n s t a n c e , i f w e u s e a s p a c e o f 0 t o

    7 a n d a w i n d o w s i z e o f 8 . T h e n a f t e r t h e r e c e i v e r r e c e i v e s 0 t o 7 a n d t h e n g e t s a 0 , t h e r e c e i v e r

    c a n n o t t e l l w h e t h e r t h e 0 i s a r e t r a n s m i s s i o n f r o m t h e p r e v i o u s w i n d o w o r a n e w f r a m e f r o m t h e

    n e x t w i n d o w . A c c e p t i n g a r e t r a n s m i s s i o n w i l l c a u s e a d u p l i c a t e t o b e d e l i v e r e d .

    7 . 2 S e l e c t i v e R e j e c t M o d u l u s

    T h e s a m e i n e q u a l i t i e s h o l d f o r s e l e c t i v e r e j e c t . H o w e v e r , r e c a l l f r o m t h e c o d e t h a t s e l e c t i v e r e j e c t

    i n v o l v e s a c o m p a r i s o n o f t h e f o r m s R a s o p p o s e d t o s = R . N o w f r o m t h e p r e v i o u s i n e q u a l i t i e s ,

    w e k n o w t h a t s a n d R l i e w i t h i n a r a n g e w o f e a c h o t h e r . A s l i g h t l y m o r e c a r e f u l a n a l y s i s s h o w s

    t h a t R , w s R + w , 1 . T o n d i f s R , t h e r e c e i v e r n e e d s t o d i s t i n g u i s h t h e p r e v i o u s w

    f r a m e s f r o m t h e n e x t w f r a m e s , w h i c h l e a d s t o a s p a c e o f 2 w n u m b e r s a t l e a s t .

    I f w e u s e a s m a l l e r s p a c e , w e c a n e a s i l y c a u s e p r o b l e m s . F o r i n s t a n c e , i f w e u s e a s p a c e o f 0 t o

    7 a n d a w i n d o w s i z e o f 5 . T h e n a f t e r t h e r e c e i v e r r e c e i v e s 0 t o 5 a n d t h e n g e t s a 0 , t h e r e c e i v e r

    c a n n o t t e l l w h e t h e r t h e 0 i s a r e t r a n s m i s s i o n f r o m t h e p r e v i o u s w i n d o w o r a n e w f r a m e f r o m t h e

    n e x t w i n d o w . A c c e p t i n g a r e t r a n s m i s s i o n w i l l c a u s e a d u p l i c a t e t o b e a c c e p t e d . T h e t e x t g i v e s a

    m o r e d e t a i l e d e x a m p l e o n P a g e 2 3 1 .

    8 F l o w C o n t r o l

    A n o t h e r p r o b l e m t h a t i s o f t e n s o l v e d b y t r a n s p o r t p r o t o c o l s a n d s o m e d a t a l i n k p r o t o c o l s i s t h e

    p r o b l e m o f a v o i d i n g t h e s e n d e r f r o m s e n d i n g a t t o o h i g h a r a t e s o t h a t t h e r e c e i v e r w i l l r u n o u t

    o f b u e r s p a c e . T h i s i s t y p i c a l l y s o l v e d i n s l i d i n g w i n d o w p r o t o c o l s b y h a v i n g t h e r e c e i v e r h a v e

    a t l e a s t w b u e r s . I f t h e r e c e i v e r w a n t s t o d y n a m i c a l l y a d j u s t t h e w i n d o w , t h e r e c e i v e r c a n a d d

    a e l d t o i t s a c k s , i n d i c a t i n g t h a t i t s w i l l i n g t o r e c e i v e s o m a n y f r a m e s b e y o n d R . T h i s i s m o s t

    8

  • 8/2/2019 Sliding Window Discussion

    9/13

    D(s) L

    L

    Sender Receiver

    L

    s

    the same answers. See text for a

    L+w1

    L+w

    L+w

    can be done mod m, m > w and still get

    GO BACK N MODULUS

    R

    |Rs|

  • 8/2/2019 Sliding Window Discussion

    10/13

    D(s)

    Sender Receiver

    SELECTIVE REJECT MODULUS

    Since receiver must buffer n packets

    ahead, simple equality testing is no

    longer enough. Must be able to tell

    Rw

  • 8/2/2019 Sliding Window Discussion

    11/13

    A B

    R(reset)

    RA

    A B

    A(1)

    R

    RAR

    RAR

    NODE CRASH

    D(0)

    A(1)

    D(0)

    D(0)

    F i g u r e 4 : N a i v e P r o c e d u r e t o r e s t a r t a p r o t o c o l a n d w h y i t c a n f a i l a f t e r c r a s h e s

    9 . 1 I m p o s s i b i l i t y R e s u l t

    T h e p r o b l e m i n F i g u r e 4 a r i s e s b e c a u s e n o d e s a r e f o o l e d " b y o l d e r r e s p o n s e s t o t h e i r r e s t a r t

    m e s s a g e s . A n e a s y w a y t o x t h i s i s b y n u m b e r i n g a l l r e s t a r t m e s s a g e s . H o w e v e r , t h a t d o e s n o t

    h e l p i f t h e s e n d e r d o e s n o t k e e p m e m o r y a f t e r a c r a s h i . e . , a d i s k l e s s w o r k s t a t i o n . I n t h a t c a s e , t h e

    s e n d e r c a n n o t r e l i a b l y n u m b e r i t s r e s t a r t m e s s a g e s t o b e d i e r e n t f r o m p r e v i o u s r e s t a r t m e s s a g e s .

    I n g e n e r a l , w e c a n s h o w t h a t t h e r e i s n o d e t e r m i n i s t i c i . e . , t h a t w o r k s a l w a y s w i t h z e r o p r o b a -

    b i l i t y o f f a i l u r e p r o t o c o l t o i n i t i a l i z e a D a t a L i n k a s s u m i n g t h a t t h e p h y s i c a l l i n k s t a k e u n b o u n d e d

    a n d v a r y i n g d e l a y s , a n d t h a t t h e s e n d e r h a s n o m e m o r y a f t e r a c r a s h . T h i s r e s u l t i s d u e t o L y n c h ,

    M a n s o u r , F e k e t e , a n d S p i n e l l i . A m a z i n g l y , i t w a s d i s c o v e r e d o n l y r e c e n t l y . O l d e r p r o t o c o l s l i k e

    H D L C a r e i n d e e d s u s c e p t i b l e t o t h i s p r o b l e m . H o w e v e r , t h e e r r o r s c e n a r i o s a r e e x t r e m e l y u n l i k e l y

    a n d s o n o d a m a g e h a s p r o b a b l y b e e n d o n e . B u t t h e r e i s a w a y t o x t h e p r o b l e m !

    9 . 2 R e l i a b l e R e s t a r t s : x i n g t h e p r o b l e m

    T h e p r o b l e m c a n b e x e d b y c h a n g i n g a n y o f t h e a s s u m p t i o n s i n t h e i m p o s s i b i l i t y r e s u l t :

    N o n - v o l a t i l e m e m o r y : I f w e h a v e n o n - v o l a t i l e m e m o r y a f t e r a c r a s h , t h e s e n d e r c a n k e e p a

    c r a s h - c o u n t o n d i s k t h a t i s i n c r e m e n t e d a f t e r e v e r y c r a s h . R E S T A R T m e s s a g e s a r e l a b e l e d

    w i t h t h i s c o u n t e r , a n d R E S T A R T - A C K S a r e a c c e p t e d o n l y i f t h e y m a t c h t h e c u r r e n t c r a s h

    c o u n t e r .

    P r o b a b i l i s t i c P r o t o c o l : I n s t e a d o f u s i n g a c r a s h c o u n t e r , u s e a r a n d o m n u m b e r t o l a b e l

    R E S T A R T m e s s a g e s . T h i s s h o u l d s u c c e e d w i t h h i g h p r o b a b i l i t y i f t h e n u m b e r o f p o s s i b l e

    r a n d o m n u m b e r s i s m u c h l a r g e r t h a n t h e n u m b e r o f f r a m e s t h a t c a n b e s t o r e d i n t h e l i n k s .

    A s s u m e a t i m e b o u n d : M o s t r e a l p r o t o c o l s c a n a s s u m e t h a t a l l f r a m e s o n t h e l i n k w i l l e i t h e r

    b e l o s t o r d e l i v e r e d i n s o m e m a x i m u m t i m e d e l a y , s a y 2 m i n u t e s . T h i s d e l a y c a n b e s e t

    1 1

  • 8/2/2019 Sliding Window Discussion

    12/13

    c o n s e r v a t i v e l y . T h e n a f t e r a c r a s h t h e s e n d e r m u s t w a i t f o r t h i s t i m e b e f o r e s e n d i n g R E S T A R T

    m e s s a g e s .

    T h e s e t e c h n i q u e s a n d p r o b l e m s a l s o a p p l y t o t r a n s p o r t p r o t o c o l s a s w e w i l l s e e l a t e r .

    1 0 W h a t m a k e s P r o t o c o l s s o H a r d

    S u p p o s e y o u w a n t t o m e e t y o u r f r i e n d a t t h e s t u d e n t c e n t e r i n v e m i n u t e s . J u s t a s y o u t e l l

    y o u r f r i e n d L e t ' s m e e t i n 5 m i n u t e s " , t h e p h o n e g o e s d e a d . Y o u c a n ' t t e l l w h e t h e r y o u r f r i e n d

    h e a r d y o u r l a s t s t a t e m e n t . I f h e d i d , h e m i g h t g o t o m e e t y o u ; i f h e d i d n ' t y o u m i g h t g o a l o n e .

    I t t u r n s o u t t h a t t h e r e i s n o w a y t o a v o i d t h e p r o b l e m , i f c o m m u n i c a t i o n c a n f a i l a t t h e c r u c i a l

    j u n c t u r e . S i n c e o n e s i d e m u s t c h a n g e s t a t e b e f o r e t h e o t h e r , a n d c o m m u n i c a t i o n c a n f a i l a t t h a t

    p o i n t , t h e r e i s n o w a y t o p r e v e n t t h i s p o s s i b i l i t y . I t i s s o m e t i m e s c a l l e d t h e C o o r d i n a t e d A t t a c k o r

    T w o G e n e r a l s p r o b l e m i n w h i c h 2 g e n e r a l s n e e d t o a t t a c k a d i s t a n t f o r t a t t h e s a m e t i m e , a n d t h e y

    c a n c o m m u n i c a t e o n l y b y u n r e l i a b l e m e s s e n g e r s . I t i s a l w a y s p o s s i b l e f o r d i s a s t e r t o o c c u r , w h e r e i n

    o n e g e n e r a l a t t a c k s a l o n e u n l e s s b o t h g e n e r a l a l w a y s d o n ' t a t t a c k , w h i c h i s n o t v e r y u s e f u l .

    F o r n e t w o r k p r o t o c o l s , i t m e a n s t h a t s i n c e l i n k s c a n l o s e m e s s a g e s , i t i s i m p o s s i b l e f o r t w o n o d e s

    i n a p r o t o c o l t o c h a n g e s t a t e a t t h e s a m e t i m e . O n e n o d e m u s t c h a n g e s t a t e b e f o r e t h e o t h e r . S o i f

    w e h a v e t w o b a n k s a n d w e w a n t t o t r a n s f e r 1 0 0 0 d o l l a r s f r o m o n e b a n k t o a n o t h e r , w e h a v e t o b e

    p r e p a r e d f o r a n i n t e r m e d i a t e s t a t e i n w h i c h o n e b a n k h a s w i t h d r a w n m o n e y a n d t h e o t h e r h a s n o t

    r e c e i v e d t h e d e p o s i t . M o r e p r a c t i c a l l y , i f a r o u t e r c h a n g e s o v e r t o a d i e r e n t r o u t e , t h e r e w i l l b e a

    p e r i o d i n w h i c h t h e o t h e r r o u t e r s m a y b e u s i n g t h e o l d r o u t e . O n e h a s t o b e p r e p a r e d f o r p e r i o d s o f

    i n c o n s i s t e n c y a n d p r e v e n t d a m a g e d u r i n g s u c h p e r i o d s . F o r i n s t a n c e , d u r i n g p e r i o d s o f i n c o n s i s t e n t

    r o u t e s , p a c k e t s c a n l o o p , a n d w e n e e d h o p - c o u n t s t o p r e v e n t p a c k e t s f r o m l o o p i n g f o r e v e r .

    A n o t h e r w a y t o s t a t e t h i s l i m i t a t i o n , i s t h a t i t i s i m p o s s i b l e f o r n o d e s i n a n o n - t r i v i a l p r o t o c o l

    t h a t w o r k s o v e r l i n k s t h a t c a n l o s e m e s s a g e s t o r e l i a b l y k n o w t h e s t a t e o f o t h e r n o d e s a t a l l t i m e s .

    T h i s h a p p e n s i n t h e D a t a L i n k p r o t o c o l s . T h e r e i s a l w a y s o n e n o d e t h a t d o e s n o t k n o w t h e s t a t e o f

    t h e o t h e r n o d e . F o r i n s t a n c e , i n S t o p - a n d - W a i t , w h e n t h e s e n d e r g e t s a n a c k , i t k n o w s t h e r e c e i v e r

    n u m b e r ; h o w e v e r , a t t h a t i n s t a n t , t h e r e c e i v e r d o e s n o t k n o w t h e s e n d e r n u m b e r b e c a u s e i t m a y

    o r m a y n o t h a v e r e c e i v e d t h e a c k a s f a r a s t h e r e c e i v e r i s c o n c e r n e d .

    1 1 P r o t o c o l D e s i g n L e s s o n s

    W e e n u m e r a t e t h e f o l l o w i n g p r o t o c o l d e s i g n l e s s o n s :

    I f y o u c a n , d e s i g n p r o t o c o l s w h o s e c o r r e c t n e s s d o e s n o t d e p e n d o n t i m e r s e t t i n g s ; i f y o u h a v e

    t o , m a k e s u r e t h a t t h e t i m e r v a l u e s a r e s e t c o n s e r v a t i v e l y t o h a n d l e d i e r e n t i n s t a l l a t i o n s .

    D o n ' t a d d c o m p l e x i t y u n t i l i t s j u s t i e d . W e w e n t t o s l i d i n g w i n d o w s a n d s e l e c t i v e r e j e c t o n l y

    a f t e r w e g u r e d o u t t h e p e r f o r m a n c e d e g r a d a t i o n o f u s i n g s t o p - a n d - w a i t .

    1 2

  • 8/2/2019 Sliding Window Discussion

    13/13

    D e s i g n S i m p l e P r o t o c o l s r s t a n d t h e n o p t i m i z e l a t e r . S e p a r a t e o u t i m p l e m e n t a t i o n d e t a i l s

    f r o m t h e e s s e n t i a l f e a t u r e s . W e d i d t h i s w h e n d e s i g n i n g t h e s e l e c t i v e r e j e c t a n d g o - b a c k - n

    p r o t o c o l s .

    I t i s i n s u c i e n t t o u n d e r s t a n d p r o t o c o l s w h e n t h e y a r e o p e r a t i n g c o r r e c t l y . Y o u n e e d t o

    u n d e r s t a n d h o w t h e y r e c o v e r a f t e r f a u l t s , i n c l u d i n g n o d e c r a s h e s . C o n s i d e r u s i n g t h e r e s t a r t

    m e t h o d o l o g y w e d e s c r i b e d t o c o m p l e t e l y r e s t a r t t h e s t a t e s o f t h e n o d e s a f t e r a c r a s h , e s p e c i a l l y

    i f i t s a 2 - n o d e p r o t o c o l .

    I m p o s s i b i l i t y R e s u l t s s h o u l d t e a c h u s w h a t w e h a v e t o c h a n g e t o d o o u r j o b s , a n d n o t w h a t

    w e c a n n o t d o . T h u s t h e c r a s h i m p o s s i b i l i t y r e s u l t m o t i v a t e d t h r e e s o l u t i o n s , e a c h o f w h i c h

    w a s a c o n s e q u e n c e o f c h a n g i n g s o m e a s s u m p t i o n i n t h e i m p o s s i b i l i t y r e s u l t .

    1 3