cmpe 150 – winter 2009 lecture 6 january 22, 2009 p.e. mantey
Post on 21-Dec-2015
216 views
TRANSCRIPT
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. )
Syllabus
Assignment #3
Available on the web site:http://www.soe.ucsc.edu/classes/cmpe150/Winter09/
Due Thursday, January 29, 2009
Today’s Agenda Link Layer
Services Framing
kind, seq, ack, info Error Control (CRC) Flow Control
Protocols Standards
Data Link Layer Design Issues
Provide Services to Network Layer1.Framing2.Error Control3.Flow Control
Cyclic Redundancy Check
Cyclic Redundancy Check
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
Cyclic Redundancy Check
At the Receiver, compute:
Note remainder = 0 no errors detected
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)
Error-Detecting Codes
Calculation of the polynomial code
checksum.
Ref: Tannenbaum, Fig. 3-8
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
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]
Logic implementation of Polynomial Encoder / Decoder
Ref: Stallings, Fig. 7.6
Ref: Stallings, Fig. 7.6
Data Link
Connects to (adjacent) computers(connected by a wire or equivalent)
Serial -- Bits delivered in order sent
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
Data Link Layer - Functions
Relationship between packets and frames.
Services Provided to Network Layer
(a) Virtual communication. (b) Actual communication.
Link Layer Services
Unacknowledged Connectionless Service
Acknowledged Connectionless Service
Acknowledged Connection-oriented Service
Link Layer Services
Unacknowledged Connectionless Service Sender just sends, no acknowledgments No attempt to resend lost frames
Acknowledged Connectionless Service
Acknowledged Connection-oriented Service
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
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
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
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
Connection-Oriented Service
Protocol steps 1. establish connection 2. reliably deliver data stream
Number frames Acknowledgments
3. free the connection
Link Layer Connection of Routers in WAN Using Connection-
Oriented Service
Ref: Tannenbaum, Fig. 3-3
Framing
(a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after
stuffing.
Ref: Tannenbaum, Fig. 3-5
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
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
Protocol Definitions
Continued
Some definitions needed in the protocols to follow. These are located in the file protocol.h.
Protocol Definitions
(ctd.)
Some definitions needed in the
protocols to follow. These are located in the file protocol.h.
Unrestricted Simplex Protocol
From Stallings: Data and Computer Communications
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.
Simplex Stop-and-
Wait Protocol
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
From Stallings: Data and Computer Communications
A Simplex Protocol for a Noisy Channel
A positive acknowledgement
with retransmission protocol.
Continued
A Simplex Protocol for a Noisy Channel (ctd.)
A positive acknowledgement with retransmission protocol.
Sliding Window Protocols
Sliding Window Protocols Supports bi-directional data transfer
Full-duplex “piggy backing” of acks
Sliding Window Protocols A One-Bit Sliding Window Protocol
A Protocol Using Go Back N A Protocol Using Selective Repeat
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
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.
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.
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.
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
A One-Bit Sliding Window Protocol
Continued
A One-Bit Sliding Window Protocol (ctd.)
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.
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
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