27
1 CMPE 150- Introduction to Computer Networks CMPE 150 Fall 2005 Lecture 13 Introduction to Computer Networks

CMPE 150- Introduction to Computer Networks 1 CMPE 150 Fall 2005 Lecture 13 Introduction to Computer Networks

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

1CMPE 150- Introduction to Computer Networks

CMPE 150

Fall 2005Lecture 13

Introduction to Computer Networks

2CMPE 150- Introduction to Computer Networks

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.

3CMPE 150- Introduction to Computer Networks

Hamming Code (Revisited)

4CMPE 150- Introduction to Computer Networks

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.

5CMPE 150- Introduction to Computer Networks

Hamming Code (Cont’d)

• Parity computations:– 11: 1, 2, 8 - 6: 2, 4

– 10: 2, 8 - 5: 1, 4

– 9: 1, 8 - 3: 1, 2

– 7: 1, 2, 4

6CMPE 150- Introduction to Computer Networks

Hamming Code: Example 1

11 10 9 8 7 6 5 4 3 2 1

1 0 0 1 0 0 00

1: 1, 3, 5, 7, 9, 11

Data: 1001000 using even parity (counting from right to left).

7CMPE 150- Introduction to Computer Networks

Hamming Code: Example 1 (Cont’d)

11 10 9 8 7 6 5 4 3 2 1

1: 1, 3, 5, 7, 9, 11

Data: 1001101 using even parity (counting from right to left).

11 10 9 8 7 6 5 4 3 2 1

2: 3, 6, 7, 10, 11

1 0 0 1 1 0 1 1

1 0 0 1 1 0 1 1001

8CMPE 150- Introduction to Computer Networks

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?

. 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

11 10 9 8 7 6 5 4 3 2 1

0 1 1 1

Result: Bit in position 0 1 1 1 is wrong!

9CMPE 150- Introduction to Computer Networks

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.

10CMPE 150- Introduction to Computer Networks

Hamming Code: Example7-bit

. Hamming codes can only correct single errors.

. But, to correct bursts of errors, send column by column.

11CMPE 150- Introduction to Computer Networks

Flow + Error Control

• Frame revisited.– Layer 2 encapsulation/decapsulation.

– Flags.

– Trailer: checksum.

– Header: type, sequence number, ack.

12CMPE 150- Introduction to Computer Networks

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.

13CMPE 150- Introduction to Computer Networks

Stop-and-Wait: Pros and Cons

• Very simple!• But, poor link utilization.– High data rates.

– Long propagation delay.

14CMPE 150- Introduction to Computer Networks

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?

15CMPE 150- Introduction to Computer Networks

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.

16CMPE 150- Introduction to Computer Networks

ARQ Protocols

• Sender:– Send frame 0.

– Start timer.

– If ACK 0, arrives, send frame 1.

– If timeout, re-send frame 0.

• Receiver:– **Waits for frame.

– If frame arrives, check if correct sequence number.

– Then send ACK for that frame.

– Go to (**)

17CMPE 150- Introduction to Computer Networks

Simplex versus Duplex Transmission

• Simplex: – Send data in one channel and control in

another channel.

• Duplex:– Send data and control on the same chanel.

18CMPE 150- Introduction to Computer Networks

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!

19CMPE 150- Introduction to Computer Networks

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.

20CMPE 150- Introduction to Computer Networks

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.

21CMPE 150- Introduction to Computer Networks

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.

22CMPE 150- Introduction to Computer Networks

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.

23CMPE 150- Introduction to Computer Networks

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.

24CMPE 150- Introduction to Computer Networks

Example: 3-bit sequence number and window size 7

01

20 1 2 3 4 5 6 7 0 1 2 3 4

0 1 2 3 4 5 6 7 0 1 2 3 4ACK 3

0 1 2 3 4 5 6 7 0 1 2 3 4

3456ACK 40 1 2 3 4 5 6 7 0 1 2 3 4

0 1 2 3 4 5 6 7 0 1 2 3 4

0 1 2 3 4 5 6 7 0 1 2 3 4

0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4

A (Sender) B (Receiver)

0 1 2 3 4 5 6 7 0 1 2 3 4… 0 1 2 3 4 5 6 7 0 1 2 3 4

25CMPE 150- Introduction to Computer Networks

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.

26CMPE 150- Introduction to Computer Networks

Bandwidth-Delay Product

• How large should the sender’s window be?• Function of how “fat” is the pipe?

S R

RTT

BW

W = BW*RTT/data size

27CMPE 150- Introduction to Computer Networks

Pipelining

• Pipelining and error recovery. Effect on error when (a) Receiver’s window size is 1. (b) Receiver’s window size is large.

Receiver’swindow sizeis 1: discard frames after errorwith no ACK.

Receiver’swindow sizeis large: buffersall frames until errorrecovered.

Selective Repeat

Go Back N