CSE 331 Introduction to Networks and Security Lecture

  • Slides: 32
Download presentation
CSE 331: Introduction to Networks and Security Lecture 4 Fall 2002

CSE 331: Introduction to Networks and Security Lecture 4 Fall 2002

Announcements • HW 1 is due today • HW 2 on the web site

Announcements • HW 1 is due today • HW 2 on the web site – due next Friday • Project 1 will be handed out next Friday – Form groups of two or three – Mail group members to Aditya achadha@gradient. cis. upenn. edu – If you can’t find a partner, mail Aditya – Groups should be formed before project is handed out CSE 331 Fall 2002 2

Recap • Link-layer protocols – Frame transmission – Error detection (CRC) CSE 331 Fall

Recap • Link-layer protocols – Frame transmission – Error detection (CRC) CSE 331 Fall 2002 3

Today: Reliable Transmission • Now we can detect errors… • What do we do

Today: Reliable Transmission • Now we can detect errors… • What do we do when we find one? • Corrupt frames must be discarded. • Need to recover these lost frames. CSE 331 Fall 2002 4

Fundamental mechanisms • Acknowledgments (ACK) – Small control frame (little data) – When sender

Fundamental mechanisms • Acknowledgments (ACK) – Small control frame (little data) – When sender gets an ACK, recipient has successfully gotten a frame • Timeouts – If sender doesn’t get an ACK after “reasonable” time it retransmits the original • General strategy called Automatic Repeat Request (ARQ) CSE 331 Fall 2002 5

Stop-and-Wait • Simplest scheme – After transmitting one frame, sender waits for an ACK

Stop-and-Wait • Simplest scheme – After transmitting one frame, sender waits for an ACK – If the ACK doesn’t arrive, sender retransmits CSE 331 Fall 2002 6

Stop-and-Wait scenario 1 Receiver frame ACK Timeout Sender Everything works CSE 331 Fall 2002

Stop-and-Wait scenario 1 Receiver frame ACK Timeout Sender Everything works CSE 331 Fall 2002 7

Stop-and-Wait scenario 2 Timeout Receiver frame Timeout Time Sender frame ACK CSE 331 Fall

Stop-and-Wait scenario 2 Timeout Receiver frame Timeout Time Sender frame ACK CSE 331 Fall 2002 Original frame Lost & Resent 8

Stop-and-Wait scenario 3 Timeout Sender Receiver frame ACK CSE 331 Fall 2002 ACK Lost

Stop-and-Wait scenario 3 Timeout Sender Receiver frame ACK CSE 331 Fall 2002 ACK Lost 9

Stop-and-Wait scenario 4 Timeout Sender Receiver frame ACK CSE 331 Fall 2002 Timeout too

Stop-and-Wait scenario 4 Timeout Sender Receiver frame ACK CSE 331 Fall 2002 Timeout too short 10

Sequence numbers Timeout Sender Receiver frame 0 ACK frame 00 Add a 1 -bit

Sequence numbers Timeout Sender Receiver frame 0 ACK frame 00 Add a 1 -bit sequence number so receiver can detect repeated frames. ACK 0 CSE 331 Fall 2002 11

Stop-and-Wait • Inefficient use of link’s capacity • Sends 1 frame per RTT •

Stop-and-Wait • Inefficient use of link’s capacity • Sends 1 frame per RTT • Example: – – 10 Mbs Link 16 ms RTT Delay x Bandwidth product is about 20 KB Frame size of 1 K yields about 5% link capacity CSE 331 Fall 2002 12

More efficient solution Sender Receiver Time N= delay x bandwidth frame size Sender ready

More efficient solution Sender Receiver Time N= delay x bandwidth frame size Sender ready to transmit N+1 st frame just as 1 st ACK arrives. CSE 331 Fall 2002 13

Sliding Window Algorithm • Sender assigns a sequence number to each frame: Seq. Num

Sliding Window Algorithm • Sender assigns a sequence number to each frame: Seq. Num – For now, assume Seq. Num can grow infinitely • Send Window Size (SWS) – Upper bound on # of unacknowledged frames sender can transmit • Last ACK Received (LAR) – Sequence number of last ACK • Last Frame Sent (LFS) CSE 331 Fall 2002 14

Sender Invariant Sender’s frames SWS Seq. Num LAR LFS • LFS – LAR SWS

Sender Invariant Sender’s frames SWS Seq. Num LAR LFS • LFS – LAR SWS • Associates timeout with each frame sent – Retransmits if no ACK received before timout • When ACK arrives, increase LAR – Means another frame can be sent CSE 331 Fall 2002 15

Receiver’s frames RWS Seq. Num LFR LAF • Receive Window Size (RWS) – Number

Receiver’s frames RWS Seq. Num LFR LAF • Receive Window Size (RWS) – Number of out-of-order frames it will accept • Largest Acceptable Frame (LAF) • Largest Frame Received (LFR) • LAF – LFR RWS CSE 331 Fall 2002 16

Receiver Algorithm • When packet numbered Seq. Num arrives – If (Seq. Num LFR)

Receiver Algorithm • When packet numbered Seq. Num arrives – If (Seq. Num LFR) or (Seq. Num > LAF) discard – Else accept the packet • Define: Seq. Num. To. Ack – Largest un. ACK’ed sequence # s. t. all earlier frames have been accepted • Receiver sends ACK(Seq. Num. To. Ack) • LFR = Seq. Num. To. Ack • Laf = LFR + RWS CSE 331 Fall 2002 17

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR 1 LFR 2 3 Sender begins sending frames 1, 2, 3 with appropriate timers. Sender CSE 331 Fall 2002 Receiver 18

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR LFRLFR 1 2 3 1 Receiver gets frame 1 Seq. Num. To. Ack = 1 Receiver sends ACK(1) LFR = 1 LAF = LFR + RWS Sender CSE 331 Fall 2002 Receiver 19

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR 1 LFR 2 3 1 Sender CSE 331 Fall 2002 While ACK(1) is in transit, frame 2 is lost and frame 3 is accepted. Receiver 20

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR LFR 1 2 3 1 1 Sender CSE 331 Fall 2002 Seq. Num. To. Ack = 1 Receiver sends another Ack(1) message. Receiver 21

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR 1 LFR 2 3 1 1 Sender gets ACK(1). Sets LAR = 1 Increases LFS to 4 Sender CSE 331 Fall 2002 Receiver 22

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR Sender transmits frame 4 and then the timer for frame 2 expires, so it resends. 1 2 3 1 1 2 Sender LFR 4 CSE 331 Fall 2002 Receiver 23

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 LAR Sender gets ACK(1) again—ignores it. LFR 1 2 3 Receiver gets frame 4 Seq. Num. To. Ack = 1 Receiver sends ACK(1) 1 1 2 4 1 Sender CSE 331 Fall 2002 Receiver 24

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 5

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 5 6 7 LAR LFR 1 2 3 Receiver gets frame 2 Seq. Num. To. Ack = 4 Receiver sends ACK(4) 1 1 4 2 1 Sender LFR = 4 LAF = LFR + RWS 4 CSE 331 Fall 2002 Receiver 25

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 5

Example Sliding Window Protocol SWS = RWS = 3 1 2 3 4 5 6 7 LAR Sender gets ACK(1) again—ignores it. Sender gets ACK(4) Sets LAR = 4 Increases LFS LFR 1 2 3 1 1 2 4 1 4 Sender CSE 331 Fall 2002 Receiver 26

Variants on Sliding Window • Receiver doesn’t transmit redundant ACKs • Receiver transmits selective

Variants on Sliding Window • Receiver doesn’t transmit redundant ACKs • Receiver transmits selective ACKS – ACK indicates exactly which frames have been accepted CSE 331 Fall 2002 27

Window Sizes • If RTT x Bandwidth product is known then SWS = RTT

Window Sizes • If RTT x Bandwidth product is known then SWS = RTT x Bandwidth / Framesize • Receive window size: – 1 = no buffering of out-of-order frames – RWS = SWS buffers as many as can be in flight – Note that RWS > SWS is not sensible CSE 331 Fall 2002 28

Finite Sequence Numbers • Recall that for Stop-and-Wait we needed two sequence numbers. •

Finite Sequence Numbers • Recall that for Stop-and-Wait we needed two sequence numbers. • How many do we need for Sliding Window? • Suppose SWS=RWS – How many sequence numbers should there be? – Is SWS + 1 sufficient? CSE 331 Fall 2002 29

Sufficient Max. Seq. Num • Frame i’s sequence num is i%Max. Seq. Num •

Sufficient Max. Seq. Num • Frame i’s sequence num is i%Max. Seq. Num • Assuming SWS = RWS • SWS < (Max. Seq. Num + 1)/2 • Why? – Consider case where all the ACKS are lost. – Suppose SWS = RWS = 3 – Max. Seq. Num = 5 (sequence numbers = 0, 1, 2, 3, 4) is insufficient CSE 331 Fall 2002 30

Roles of Sliding Window Algorithm • Reliable delivery – It provides an efficient retransmission

Roles of Sliding Window Algorithm • Reliable delivery – It provides an efficient retransmission protocol for dealing with errors • In-order delivery – The receiver buffers frames and delivers them in sequence number order • Flow control – It sends ACKs back to give hints to sender – More sophisticate version could give # of frames the receiver has room for—throttles the sender. CSE 331 Fall 2002 31

Sliding window in practice • TCP (Transmission Control Protocol) – Transportation layer protocol –

Sliding window in practice • TCP (Transmission Control Protocol) – Transportation layer protocol – Uses sliding window algorithm – More complex because it’s used in an Internetwork – not over a direct link – Bandwidth x delay not known – Dynamically changes timeouts – Larger buffers for in-order delivery CSE 331 Fall 2002 32