Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Introduction to Computer Networks CMPE 150 Fall 2005 Lecture 13 CMPE 150- Introduction to Computer Networks 1 Announcements • Midterm postponed! – Instead of 10.28, it will be on 11.04! • Lab next week: – Discussion sessions on protocol pseudo-code (from Tanenbaum Chapter 3). – Also, checksum calculation practice! • Homework 2 due on Monday, 10.24. CMPE 150- Introduction to Computer Networks 2 Hamming Code (Revisited) CMPE 150- Introduction to Computer Networks 3 Hamming Code • Check bits in power-of-two positions. • Each check bit verifies a set of data bits. • A data bit is checked by multiple check bits. CMPE 150- Introduction to Computer Networks 4 Hamming Code (Cont’d) • Parity computations: – – – – 11: 1, 2, 8 10: 2, 8 9: 1, 8 7: 1, 2, 4 - 6: 2, 4 - 5: 1, 4 - 3: 1, 2 CMPE 150- Introduction to Computer Networks 5 Hamming Code: Example 1 Data: 1001000 using even parity (counting from right to left). 0 1 11 10 9 0 8 0 7 6 1 0 0 0 5 4 3 2 1 1: 1, 3, 5, 7, 9, 11 CMPE 150- Introduction to Computer Networks 6 Hamming Code: Example 1 (Cont’d) Data: 1001101 using even parity (counting from right to left). 1 0 0 11 10 1 9 8 7 1 0 1 6 5 4 1 3 2 1 1: 1, 3, 5, 7, 9, 11 1 0 0 1 1 1 0 0 1 0 1 11 10 9 8 7 6 5 4 2 1 2: 3, 6, 7, 10, 11 CMPE 150- Introduction to Computer Networks 3 7 Hamming Code: Example 2 What if instead of 1 0 0 1 1 1 0 0 10 1, receiver gets 1 0 0 1 0 1 0 0 1 0 1? 11 10 9 8 7 6 5 4 3 2 1 . Receiver takes frame received and re-computes check bits. . 1, 3, 5, 7, 9, 11: 1, 1, 0, 0, 1 => 1 . 2, 3, 6, 7, 10, 11: 0, 1, 1, 0, 0, 1 => 1 . 4, 5, 6, 7 : 0, 0, 1, 0 => 1 . 8, 9, 10, 11: 1, 0, 0, 1 => 0 0 1 1 1 Result: Bit in position 0 1 1 1 is wrong! CMPE 150- Introduction to Computer Networks 8 How much code redundancy? • How many check bits needed, i.e., given m data bits, how many more bits (r) are needed to allow all single-bit errors to be corrected? – – – – Resulting frame is m + r. (m+r+1) <= 2r. Given m, then find r. Example: If m = 7 (ASCII 7 code), minimum r is 4. CMPE 150- Introduction to Computer Networks 9 Hamming Code: Example 7-bit . Hamming codes can only correct single errors. . But, to correct bursts of errors, send column by column. CMPE 150- Introduction to Computer Networks 10 Flow + Error Control • Frame revisited. – – – – Layer 2 encapsulation/decapsulation. Flags. Trailer: checksum. Header: type, sequence number, ack. CMPE 150- Introduction to Computer Networks 11 Stop-and-Wait • Simplest form of flow control. • How does it work? (assume error-free channel) – (1) Send 1 frame; – (2) Wait for ACK. – (3) Go to 1. CMPE 150- Introduction to Computer Networks 12 Stop-and-Wait: Pros and Cons • Very simple! • But, poor link utilization. – High data rates. – Long propagation delay. CMPE 150- Introduction to Computer Networks 13 Stop-and-Wait in Noisy Channels • Need timers, retransmissions, and duplicate detection. • Use sequence numbers. – Why? – Distinguish frames. – How large (e.g., in number of bits) are sequence numbers? CMPE 150- Introduction to Computer Networks 14 ARQ Protocols • Automatic Repeat Request. – Protocols that wait for ACK before sending more data. • ACKs now are used for flow AND error control. • What can happen? – At receiver: frame arrives correctly, frame arrives damaged, or frame does not arrive. – At sender: ACK arrives correctly, ACK arrives damaged, or ACK does not arrive. CMPE 150- Introduction to Computer Networks 15 ARQ Protocols • Sender: – Send frame 0. – Start timer. – If ACK 0, arrives, send frame 1. – If timeout, re-send frame 0. CMPE 150- Introduction to Computer Networks • Receiver: – **Waits for frame. – If frame arrives, check if correct sequence number. – Then send ACK for that frame. – Go to (**) 16 Simplex versus Duplex Transmission • Simplex: – Send data in one channel and control in another channel. • Duplex: – Send data and control on the same chanel. CMPE 150- Introduction to Computer Networks 17 Can we do better? • Can we do better? – Piggybacking. – Bi-directional transmission. – Wait for data packet and use that to piggyback the ACK. – Use ACK field: only a few additional bits in the header. • But, how long should Layer 2 wait to send an ACK? – ACK timers! CMPE 150- Introduction to Computer Networks 18 Sliding Window Protocols • Window: number of “outstanding” frames at any given point in time. – So what’s the window size of Stop and Wait? • Every ACK received, window slides. CMPE 150- Introduction to Computer Networks 19 Sliding Window: Example • A sliding window of size 1, with a 3-bit sequence number.(a) Initially; (b) After the first frame has been sent; (c) After the first frame has been received;(d) After the first acknowledgement has been received. CMPE 150- Introduction to Computer Networks 20 Sliding Window: Basics • Allows multiple frames to be in transit at the same time. • Receiver allocates buffer space for n frames. • Transmitter is allowed to send n (window size) frames without receiving ACK. • Frame sequence number: labels frames. CMPE 150- Introduction to Computer Networks 21 Sliding Window: Receiver • Receiver ack’s frame by including sequence number of next expected frame. – Cumulative ACK: ack’s multiple frames. • Example: if receiver receives frames 2,3, and 4, it sends an ACK with sequence number 5, which ack’s receipt of 2, 3, and 4. CMPE 150- Introduction to Computer Networks 22 More Sliding Window … • Sender maintains sequence numbers it’s allowed to send; receiver maintains sequence number it can receive. • Sequence numbers are bounded; if frame reserves k-bit field for sequence numbers, then they can range from 0 … 2k -1k. • Transmission window shrinks each time frame is sent, and grows each time an ACK is received. CMPE 150- Introduction to Computer Networks 23 Example: 3-bit sequence number and window size 7 A (Sender) B (Receiver) 0 1 2 3 4 5 6 7 0 1 2 3 4… 0123456701234 0 1 0123456701234 2 ACK 3 0123456701234 0123456701234 0123456701234 0123456701234 ACK 4 0123456701234 CMPE 150- Introduction to Computer Networks 3 45 0 1 2 3 4 5 6 7 0 1 2 3 4 6 0123456701234 24 One-Bit Sliding Window Protocol Two scenarios: (a) Normal case. (b) Abnormal case. Notation is (seq, ack, packet number). An * indicates where a network layer accepts packet. ACK indicates last sequence number received. CMPE 150- Introduction to Computer Networks 25 Bandwidth-Delay Product • How large should the sender’s window be? • Function of how “fat” is the pipe? BW S R RTT W = BW*RTT/data size CMPE 150- Introduction to Computer Networks 26 Pipelining Receiver’s window size is 1: discard frames after error with no ACK. Go Back N Receiver’s window size is large: buffers all frames until error Selective Repeat recovered. • Pipelining and error recovery. Effect on error when (a) Receiver’s window size is 1. (b) Receiver’s window size is large. CMPE 150- Introduction to Computer Networks 27