cmpe 150 – winter 2009 lecture 6 january 22, 2009 p.e. mantey

54
CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Post on 21-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

CMPE 150 – Winter 2009

Lecture 6

January 22, 2009

P.E. Mantey

Page 2: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

CMPE 150 -- Introduction to Computer Networks

Instructor: Patrick Mantey [email protected] http://www.soe.ucsc.edu/~mantey/

Office: Engr. 2 Room 595J Office hours: Tuesday 3-5 PM TA: Anselm Kia [email protected] Web site: http://www.soe.ucsc.edu/classes/cmpe150/Winter09/

Text: Tannenbaum: Computer Networks (4th edition – available in bookstore, etc. )

Page 3: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Syllabus

Page 4: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Assignment #3

Available on the web site:http://www.soe.ucsc.edu/classes/cmpe150/Winter09/

Due Thursday, January 29, 2009

Page 5: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Today’s Agenda Link Layer

Services Framing

kind, seq, ack, info Error Control (CRC) Flow Control

Protocols Standards

Page 6: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Data Link Layer Design Issues

Provide Services to Network Layer1.Framing2.Error Control3.Flow Control

Page 7: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Cyclic Redundancy Check

Page 8: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Cyclic Redundancy Check

Page 9: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Cyclic Redundancy Check

At Transmitter, with M = 1 1 1 0 1 1, compute

2rM= 1 1 1 0 1 1 0 0 0 with G = 1 1 0 1

T = 2rM + R [note G starts and ends with “1” ]

R = 1 1 1 Transmit T= 1 1 1 0 1 1 1 1 1

Page 10: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Cyclic Redundancy Check

At the Receiver, compute:

Note remainder = 0 no errors detected

Page 11: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Polynomial Code

M = 1 1 1 0 1 1 x5 + x4 + x3 + x + 1 = M(x)

G = 1 1 0 1 x3 + x3 + 1 = G(x)R(x) = remainder of [2 3 M(x)/G(x)]

(recall r = 3)

T(x) = 23 M(x) + R(x)

Page 12: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Error-Detecting Codes

Calculation of the polynomial code

checksum.

Ref: Tannenbaum, Fig. 3-8

Page 13: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

CRC Codes

CRC-12 G(x) = x12 + x11 + x3 + x2 + x + 1

CRC-15 G(x) = x16 + x15 + x2 + 1

CRC-CCITT G(x) = x16 + x12 + x5 + 1

CRC-32 G(x) = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x +

1

Page 14: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

CRC Performance Errors go through undetected only if divisible by G(x) With “suitably chosen” G(x) CRC code detects:

All single-bit errors All double-bit errors, as long as G(x) has at least three

“1s” Any odd number of error, as long as G(x) has a factor

(x+1) Any burst error for which the length of the burst is less

than the length of the G(x) (i.e. “r”) Most larger burst errors For equally-probable errors, with burst of length r+1,

probability of an undetected error is 1/2r-1

For longer burst, probability of undetected error is 1/2r

[adapted from Stallings, Chapter 7, page 205]

Page 15: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Logic implementation of Polynomial Encoder / Decoder

Ref: Stallings, Fig. 7.6

Page 16: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Ref: Stallings, Fig. 7.6

Page 17: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Data Link

Connects to (adjacent) computers(connected by a wire or equivalent)

Serial -- Bits delivered in order sent

Page 18: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Data Link Layer - Functions Provide service interface to the

network layer Dealing with transmission errors Regulating data flow

Slow receivers not swamped by fast senders

Page 19: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Data Link Layer - Functions

Relationship between packets and frames.

Page 20: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Services Provided to Network Layer

(a) Virtual communication. (b) Actual communication.

Page 21: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service

Acknowledged Connectionless Service

Acknowledged Connection-oriented Service

Page 22: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service Sender just sends, no acknowledgments No attempt to resend lost frames

Acknowledged Connectionless Service

Acknowledged Connection-oriented Service

Page 23: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service Sender just sends, no acknowledgments No attempt to resend lost frames Used for

Real-time traffic (voice, video) Highly reliable LANS When error control is done at higher layers (e.g.

TCP) Acknowledged Connectionless Service

Acknowledged Connection-oriented Service

Page 24: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service Sender just sends, no acknowledgments

Acknowledged Connectionless Service No logical connection Frames individually acknowledged Tannenbaum says “an option, not a

requirement” BUT:

Acknowledged Connection-oriented Service

Page 25: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service Sender just sends, no acknowledgments

Acknowledged Connectionless Service No logical connection Frames individually acknowledged Tannenbaum says “an option, not a

requirement” BUT: large packets become multiple (fixed size) frames Some frames get through, others lost, then resend of

packet is very inefficient vs. resend of lost frames

Acknowledged Connection-oriented Service

Page 26: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Services

Unacknowledged Connectionless Service Acknowledged Connectionless Service Acknowledged Connection-oriented Service

Connection established before data sent Each frame numbered Data link guarantees error-free delivery

Each frame received once and only once(vs. connectionless, where a packet can be received

several time – if errors or timeouts occur

Provides reliable bit stream to Network Layer

Page 27: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Connection-Oriented Service

Protocol steps 1. establish connection 2. reliably deliver data stream

Number frames Acknowledgments

3. free the connection

Page 28: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Link Layer Connection of Routers in WAN Using Connection-

Oriented Service

Ref: Tannenbaum, Fig. 3-3

Page 29: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Framing

(a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after

stuffing.

Ref: Tannenbaum, Fig. 3-5

Page 30: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Framing: Bit Stuffing

Bit stuffing (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in receiver’s memory

after destuffing.Ref: Tannenbaum, Fig. 3-6

Page 31: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Elementary Data Link Protocols

Manage data flow at Link Layer An Unrestricted Simplex Protocol

A Simplex Stop-and-Wait Protocol

A Simplex Protocol for a Noisy Channel

Page 32: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Protocol Definitions

Continued

Some definitions needed in the protocols to follow. These are located in the file protocol.h.

Page 33: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Protocol Definitions

(ctd.)

Some definitions needed in the

protocols to follow. These are located in the file protocol.h.

Page 34: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Unrestricted Simplex Protocol

Page 35: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

From Stallings: Data and Computer Communications

Page 36: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Stop-and-Wait

• Simplest form of flow control.– Transmitter sends frame and waits.– Receiver receives frame and sends ACK.– Transmitter gets ACK, sends other frame, and waits,

until no more frames to send.

• Good when few frames.

• Problem: inefficient link utilization.– In the case of high data rates or long propagation

delays.

Page 37: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Simplex Stop-and-

Wait Protocol

Page 38: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Animations

• http://media.pearsoncmg.com/aw/aw_kurose_network_2/applets/go-back-n/go-back-n.html

http://www.humboldt.edu/%7Eaeb3/telecom/SlidingWindow.html

• http://netbook.cs.purdue.edu/othrpags/page15.htm

Page 39: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

From Stallings: Data and Computer Communications

Page 40: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

A Simplex Protocol for a Noisy Channel

A positive acknowledgement

with retransmission protocol.

Continued

Page 41: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

A Simplex Protocol for a Noisy Channel (ctd.)

A positive acknowledgement with retransmission protocol.

Page 42: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window Protocols

Page 43: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window Protocols Supports bi-directional data transfer

Full-duplex “piggy backing” of acks

Page 44: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window Protocols A One-Bit Sliding Window Protocol

A Protocol Using Go Back N A Protocol Using Selective Repeat

Page 45: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window Protocols (2)

• 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.

Tannenbaum Figure 3-13

Page 46: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window 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.

Page 47: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window

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.

Page 48: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Sliding Window Sender maintains sequence numbers it’s

allowed to send; receiver maintains sequence number it can receive.

These lists are sender and receiver windows. Sequence numbers are bounded; if frame

reserves k-bit field for sequence numbers, then they can range from 0 … 2k -1 , modulo 2k.

Transmission window shrinks each time frame is sent, and grows each time an ACK is received.

Page 49: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Example: 3-bit sequence number and window size 7

• A (sender) (receiver) B• 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

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 4RR3

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

RR40 1 2 3 4 5 6 7 0 1 2 3 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 4Stallings Figure 7-4

Page 50: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

A One-Bit Sliding Window Protocol

Continued

Page 51: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

A One-Bit Sliding Window Protocol (ctd.)

Page 52: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

1-bit Sequence Number• Distinguish between “original” transmission and “retransmission”• Sequence number will do this• Extra long sequence field wasteful of header / channel • Minimum size = 1 bit !• Need to distinguish between frame m and frame m+1• Sender keeps trying to send frame m until it is acknowledged• Sender won’t send m+1 until m is acknowledged • (Sender won’t send m+2 until m+1 is acknowledged – which means

m was correctly received and acknowledged )• Receiver knows what sequence number to expect next• Arriving frame with wrong sequence number is rejected as a

duplicate• Correctly received frame – with right sequence number – sent to

network layer and expected sequence number incremented by 1 modulo 2.

Page 53: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

One-Bit Sliding Window Protocol

Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet. Tannenbaum Figure 3-15

Page 54: CMPE 150 – Winter 2009 Lecture 6 January 22, 2009 P.E. Mantey

Bit Length of a Link• Assume link is fully occupied

• 1st bit is just arriving at the receiver

• sender has sent continuously

• R = data rate (bps)

• d = distance (length of link) (meters)

• V = propagation velocity (meters / second)

• (~ 2 - 3 x 108 meters/second)

• Bit length = Rd / V bits