190 likes | 387 Views
Direct Link Networks: Reliable Transmission. Sections 2.5. Outline. Stop-and Wait (2.5.1) Sliding Window Algorithm (2.5.2) (will not cover implementation pp. (109-115). Recovering Lost Frames. Protocol must recover from discarded (lost) frames A “lost” frame: a frame that was corrupted
E N D
Direct Link Networks:Reliable Transmission Sections 2.5
Outline • Stop-and Wait (2.5.1) • Sliding Window Algorithm (2.5.2) • (will not cover implementation pp. (109-115)
Recovering Lost Frames • Protocol must recover from discarded (lost) frames • A “lost” frame: a frame that was corrupted • corruption detected by receiver >> frame discarded • Use acknowledgments and timeouts to implement reliable delivery (Automatic Repeat Request, ARQ).
Duplicate Frames • sender sends a frame • receiver acknowledges • acknowledgment lost or delayed • sender times out and retransmits frame • receive think it is the next frame • duplicate copies frame delivered
Dealing with Duplicate Frames • Header includes a 1-bit sequence number • Sequence numbers used for frames alternate • If sender retransmits frame 0 • receiver >> a second copy of frame 0 >> ignore it (still acknowledges it)
Sender Receiver Stop-and-Wait Shortcoming • Problem: keeping the pipe full • Example • 1.5Mbps link ; 45ms RTT; Delay x Bandwidth Product = 67.5Kb • Stop-and Wait max sending rate =BitsPerFrame/TimePerFrame • For 1KB frames, max sending rate = (1024 x 8) / 0.045 = 182 Kbps • link utilization = .182 Mbps/1.5 Mbps = 1/8 • Link capacity = 67.5Kb ~ 8KB • 8 frames could be in the pipe instead of just 1 frame • utilization = (1 frame)/(8 frames) = 1/8th link utilization
Improve Stop-and-Wait For the previous example, optimally • Allow sender to transmit 8 frames before waiting to receive any ACK • Sender transmits the ninth frame at the same time the ACK for the first frame arrives
Sliding Window • Allow multiple outstanding (un-ACKed) frames • Upper bound on un-ACKed frames, called window
< SWS 7 ─ ■ ■ ■ ■ ■ ■ 21 30 31 22 28 29 23 27 32 24 26 25 LAR = 23 LFS = 30 Sliding Window, SW: Sender • Assign sequence number to each frame (SeqNum) • Maintain three state variables: • sender window size (SWS) • last acknowledgment received (LAR) • last frame sent (LFS) • Maintain the relationship: LFS - LAR <= SWS • For example, for a window size, SWS, 7, you could have LFS = 30, LAR = 23 • Buffer a number of frames up to a maximum of SWS frames • After a frame times out, retransmit. Repeat until frame is acknowledged • Advance LAR when ACK arrives
< ─ RWS ■ ■ ■ ■ ■ ■ 7 24 25 30 28 33 34 LFR = 25 LFA = 32 SW: Receiver • Maintain three state variables • receiver window size (RWS) (upper bound on no. of out-of-order frames receiver accepts) • largest frame acceptable (LFA) • last frame received (LFR) • Maintain the relationship: LFA - LFR <= RWS • Frame SeqNum arrives: • if LFR < SeqNum < = LFA ; accept • if SeqNum < = LFR or SeqNum > LFA discarded • Send cumulative ACKs
Cumulative Acknowledgment • SeqNumToAck = the largest sequence number of frames which are received but not yet acknowledged • When all frames with sequence numbers <= SeqNumToAck have been received • Receiver acknowledges receipt of SeqNumToAck frame (even if higher-numbered frames have been received) • Cumulative Acknowledgment • Receiver then sets LFR = SeqNumToAck and adjusts LFA to LFR + RWS
7 7 < < < ─ ─ ─ RWS RWS RWS ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ 26 24 27 24 25 25 28 27 30 30 28 28 36 33 33 34 37 34 LFR = 25 LFR = 25 LFR = 28 LFA = 35 LFA = 32 LFA = 32 30 7 Example • Frame 27 arrives • Frame 26 arrives • SeqNumToAck = 28 • Receiver acknowledges receipt of frame 28 which is a “Cumulative Acknowledgment” • Receiver then sets LFR = 28 and adjusts LFA to LFR + RWS = 28 + 7 = 35
Choosing SWS & RWS • Objective: keep the pipe full • SWS >>> how many frames are outstanding on the link • SWS chosen based on delay x bandwidth • Common RWS settings: 1 & SWS
Sequence Number Space • SeqNum field is finite • Sequence #s: 0, 1, 2, …, MaxSeqNum, 0, 1, 2, ... • Sequence numbers wrap around • Need to distinguish between different incarnations of sequence #s • number of outstanding frames < sequence number space (which is MaxSeqNum +1)
Sequence Number Space • SWS = MaxSeqNum is not sufficient • suppose 3-bit field for SeqNum (8 possible values of SeqNum 0..7) • SWS=RWS=7 {(outstanding frames=7)<(sequence number space=8)} • sender transmit frames 0..6 • frames arrive successfully, but ACKs lost • sender retransmits 0..6 • receiver expecting new frames 7, 0, 1, ...5, but receives old frames with #s 0..5 • receiver cannot distinguish between reincarnations of same frames • For RWS=SWS, correct rule is SWS <= (MaxSeqNum+1)/2 • Intuitively, SeqNum “slides” between two halves of sequence number space
Concurrent Logical Channels • Data Link Protocol used in the ARPANET • keeps the link full without sliding window protocol • Node multiplexes 8 logical channels over a single link • Run stop-and-wait on each logical channel • Maintain three state bits per channel • channel busy • current sequence number out • next sequence number in • When the node has a frame to send, it uses the lowest idle channel • A different frame can be outstanding on each logical channel • sender keeps link full • Header: 3-bit channel num, 1-bit sequence num • This is exactly the number of bits of the SeqNum field for sliding window protocol to support (8 -1= 7) outstanding frames when RWS=SWS