The Data Link Layer 2 Chapter 3 CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice...

Preview:

Citation preview

The Data Link Layer 2Chapter 3

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

• Data Link Layer Design Issues• Error Detection and Correction• Elementary Data Link Protocols• Sliding Window Protocols• Example Data Link Protocols

Revised: August 2011

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

The Data Link Layer

Responsible for delivering frames of information over a single link• Handles transmission errors and

regulates the flow of dataPhysical

Link

Network

Transport

Application

Computer Networks 1

3TUNALI

Assumptions

Source and destination are directly connected to each other

There can be an error during the transmission

The channel has finite data rate

There is a nonzero propagation delay

PurposeDevelop algorithms for reliable and efficient communication between the source and the destination

Computer Networks 1

4TUNALI

Protocol Definitions

Continued

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

Link layer environment (2)

Link layer protocol implementations use library functions• See code (protocol.h) for more details

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Group Library Function Description

Network layer

from_network_layer(&packet)to_network_layer(&packet)enable_network_layer()disable_network_layer()

Take a packet from network layer to sendDeliver a received packet to network layerLet network cause “ready” eventsPrevent network “ready” events

Physical layer

from_physical_layer(&frame)to_physical_layer(&frame)

Get an incoming frame from physical layerPass an outgoing frame to physical layer

Events & timers

wait_for_event(&event)start_timer(seq_nr)stop_timer(seq_nr)start_ack_timer()stop_ack_timer()

Wait for a packet / frame / timer eventStart a countdown timer runningStop a countdown timer from runningStart the ACK countdown timerStop the ACK countdown timer

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Sliding Window Protocols

• Sliding Window concept »• One-bit Sliding Window »• Go-Back-N »• Selective Repeat »

Sliding Window concept (1)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Sender maintains window of frames it can send• Needs to buffer them for possible retransmission• Window advances with next acknowledgements

Receiver maintains window of frames it can receive• Needs to keep buffer space for arrivals• Window advances with in-order arrivals

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Sliding Window concept (2)

A sliding window advancing at the sender and receiver• Ex: window size is 1, with a 3-bit sequence number.

At the start First frame is sent

First frame is received

Sender gets first ack

Sender

Receiver

Sliding Window concept (3)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Larger windows enable pipelining for efficient link use• Stop-and-wait (w=1) is inefficient for long links• Best window (w) depends on bandwidth-delay (BD)• Want w ≥ 2BD+1 to ensure high link utilization

Pipelining leads to different choices for errors/buffering• We will consider Go-Back-N and Selective Repeat

Computer Networks 1

10TUNALI

Sliding Window ProtocolsPrevious protocols involved transmission of data frames in only one direction

In practice, two way data communication is necessary

One way to achieve this is to have two lines each having forward and backward channels each implementing Protocol 2• This will waste bandwidth

Better way is to use the same circuit for data in both directions• There will be data and ack frames in each direction

Computer Networks 1

11TUNALI

PiggybackingThe performance is further improved by attaching ack to an outgoing data frame instead of sending a separate ack frame. (piggybacking)• Unnecessary overhead of sending a separate frame for

ack is avoided

Question: How long should data link layer wait for a packet onto which to piggyback the ack?

Answer: It starts an ack timer. If a data frame is received from the network layer in the mean time, ack is piggybacked,. if not, a separate ack frame is sent

Computer Networks 1

12TUNALI

Sliding Window Parameters

Sequence numbers of frames range from 0 to 2n–1 where n will be specified later for each protocol

Sending Window• A set of sequence numbers of frames the sender

is permitted to send

Receiving Window• A set of sequence numbers of frames the

receiver is permitted to accept

Computer Networks 1

13TUNALI

Sliding Window AssumptionsThe protocol must deliver packets to the destination network layer in the same order that they were passed to the data link layer on the sending machine

Physical communication channel must deliver all frames in the order sent

The senders window contains frames sent but not ack’ed yet

When a packet from network layer is received, the upper edge of the window is advanced

When ack is received, lower edge of the window is advanced

Computer Networks 1

14TUNALI

Receiver Window

Any frame falling outside the window is discarded

When a frame whose sequence number is equal to the lower edge of the window is received, • it is passed to the network layer• An ack is generated• Window is rotated by one

The receiver window always remains at its initial size

Computer Networks 1

15TUNALI

A One Bit Sliding Window Protocol

Sender and receiver window size is 1

Frame sequence numbers are 0 and 1

The ack field contains the number of the last frame received without error

No combination of lost frames or premature timeouts can cause the protocol to deliver duplicate packets to either network layer, or to skip a packet, or o get into a deadlock.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

One-Bit Sliding Window (1)

Transfers data in both directions with stop-and-wait• Piggybacks acks on reverse data frames for efficiency• Handles transmission errors, flow control, early timers

. . .

{

Each node is sender and receiver (p4):

Prepare first frame

Launch it, and set timer

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

One-Bit Sliding Window (2). . .

If a frame with new data then deliver it

Wait for frame or timeout

(Otherwise it was a timeout)

If an ack for last send then prepare for next data frame

Send next data frame or retransmit old one; ack the last data we received

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Two scenarios show subtle interactions exist in p4:− Simultaneous start [right] causes correct but slow operation

compared to normal [left] due to duplicate transmissions.

Time

Normal case Correct, but poor performance

One-Bit Sliding Window (3)

Notation is (seq, ack, frame number). Asterisk indicates frame accepted by network layer .

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Go-Back-N (1)

Receiver only accepts/acks frames that arrive in order:• Discards frames that follow a missing/errored frame• Sender times out and resends all outstanding frames

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Go-Back-N (2)

Tradeoff made for Go-Back-N:• Simple strategy for receiver; needs only 1 frame• Wastes link bandwidth for errors with large

windows; entire window is retransmitted

Implemented as p5 (see code in book)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Selective Repeat (1)

Receiver accepts frames anywhere in receive window• Cumulative ack indicates highest in-order frame• NAK (negative ack) causes sender retransmission of

a missing frame before a timeout resends window

Selective Repeat (2)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Tradeoff made for Selective Repeat:• More complex than Go-Back-N due to buffering

at receiver and multiple timers at sender• More efficient use of link bandwidth as only lost

frames are resent (with low error rates)

Implemented as p6 (see code in book)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Selective Repeat (3)

For correctness, we require:• Sequence numbers (s) at least twice the window (w)

Originals OriginalsRetransmits Retransmits

Error case (s=8, w=7) – too few sequence numbers

Correct (s=8, w=4) – enough sequence numbers

New receive window overlaps old – retransmits ambiguous

New and old receive window don’t overlap – no ambiguity

Computer Networks 1

24TUNALI

Receiver Window

Any frame falling outside the window is discarded

When a frame whose sequence number is equal to the lower edge of the window is received, • it is passed to the network layer• An ack is generated• Window is rotated by one

The receiver window always remains at its initial size

Computer Networks 1

25TUNALI

A One Bit Sliding Window Protocol

Sender and receiver window size is 1

Frame sequence numbers are 0 and 1

The ack field contains the number of the last frame received without error

No combination of lost frames or premature timeouts can cause the protocol to deliver duplicate packets to either network layer, or to skip a packet, or o get into a deadlock.

Computer Networks 1

26TUNALI

A One-Bit Sliding Window Protocol

Continued

Computer Networks 1

27TUNALI

A One-Bit Sliding Window Protocol (ctd.)

Computer Networks 1

28TUNALI

Peculiar Scenarios for Protocol 4

If both sides simultaneously send an initial packet, half of the frames contain duplicates but there is no transmission error

Same situation may happen with premature timeouts

Computer Networks 1

29TUNALI

A Protocol Using Go Back n

In protocol 4, sender is required to wait for an ack before the next frame is transmitted

If the propagation delay is high, this causes waist of bandwidth.

The solution is to allow the sender to transmit more than one frame before receiving any ack.

To maximize throughput, the sender is expected to send w frames to keep the line busy, called pipelining.

Computer Networks 1

30TUNALI

ExampleIf

Channel capacity: 50 kbps

Round trip propagation delay: 500 msec

Frame length: 1000 bit

Then

Frame transmission time is 20 msec

t=0 frame sent, t=520 msec ack received

Protocol 4 uses 20/520 of the bandwidth

To fully utilize bandwidth, w=520/20=26

Computer Networks 1

31TUNALI

Pipelining Receiver PoliciesQuestion• What happens to the frames received after receiving an

in correct frame?

Answer• Either discard all the frames proceeding the garbled

one, (called go back n, receiver window size 1)• Or accept those frames, but not forward the to the

network layer until the garbled one is retransmitted correctly (called selective repeat, receiver window size greater than 1)

Computer Networks 1

32TUNALI

Receiver Policies

Computer Networks 1

33TUNALI

Sliding Window Protocol Using Go Back

N

Continued

Computer Networks 1

34TUNALI

Sliding Window Protocol Using Go Back N

Continued

Computer Networks 1

35TUNALI

Sliding Window Protocol Using Go Back N

Continued

Computer Networks 1

36TUNALI

Sliding Window Protocol Using Go Back N

Computer Networks 1

37TUNALI

Protocol 5 Assumptions 1Network layer may not always have a packet to send• When it has a packet to send it causes

network_layer_ready event

Data link layer may not send frames as fast as the network layer wants• enable_network_layer

− Allow network layer to pass packets to data link layer

• disable_network_layer− Disallow network layer from passing packets to data link layer

Computer Networks 1

38TUNALI

Protocol 5 Assumptions 2

Sequence numbers range from 0 to MAX_SEQ

When an acknowledgement comes in for frame n, frames n-1, n-2, and so on are also automatically acknowledged

The window size is MAX_SEQ

Computer Networks 1

39TUNALI

Protocol 5 Assumptions 3There are at most MAX_SEQ many frames outstanding at any instant• If it were MAX_SEQ+1, then the protocol fails with the

following scenario− The sender sends frames 0 to MAX_SEQ− It receives ack for MAX_SEQ− The sender sends another batch of frames from 0 to MAX_SEQ− All of the last batch is lost− The receiver sends ack for the last correctly received frame

which is MAX_SEQ− The sender will think that all the frames of the last batch are

correctly received and the protocol will fail

Computer Networks 1

40TUNALI

Multiple timer management

Computer Networks 1

41TUNALI

A Protocol Using Selective Repeat Protocol 5 has poor performance if the error rate of the channel is high

An alternative receiver strategy is to accept frames proceeding a garbled one

Frame sequence numbers start from 0 and grow to some predefined maximum MAX_SEQ

The receiver window is always fixed and has a buffer reserved for each frame number in its window

Computer Networks 1

42TUNALI

A Sliding Window Protocol Using Selective Repeat

Continued

Computer Networks 1

43TUNALIContinued

A Sliding Window Protocol Using Selective Repeat (2)

Computer Networks 1

44TUNALI

A Sliding Window Protocol Using Selective Repeat (3)

Continued

Computer Networks 1

45TUNALI

A Sliding Window Protocol Using Selective Repeat (4)

Computer Networks 1

46TUNALI

Protocol 6 Mechanisms 1

Function between• Checks if the arriving frame sequence number

falls within the window

The window size is (MAX_SEQ+1)/2

Computer Networks 1

47TUNALI

Protocol 6 Mechanisms 2

The following scenario shows that the protocol fails when window size is MAX_SEQ• The sender transmits frames 0 to MAX_SEQ-1• At the receiver, all frames are received correctly• The receiver sends MAX_SEQ acks to sender

and slides the window to MAX_SEQ-MAX_SEQ-2

• All the acks are lost • Sender times out and retransmits all the

MAX_SEQ frames• The receiver accepts frames 0 to MAX_SEQ-2

as new frames and the protocol fails

Computer Networks 1

48TUNALI

Failure Scenario

Computer Networks 1

49TUNALI

Protocol 6 Mechanisms 3

The number buffers needed is the size of the window

There is a timer associated with each buffer

Protocol 5 assumes that there is always reverse traffic to piggyback acks and it blocks if there is no reverse traffic

Protocol 6 implements start_ack_timer • When a data frame arrives, a timer is started• If no data frame to send back, timer runs off and

a special ack frame is sent

Computer Networks 1

50TUNALI

Protocol 6 Mechanisms 4

If the receiver suspects that a frame is garbled or lost, it sends a NAK frame to the sender requesting retransmission

To prevent duplicate NAKs, variable no_nak is used.

If the standard deviation of ack interval is small, NAK is not that useful

Else, NAKs speedup the communication considerably

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Example Data Link Protocols

• Packet over SONET »• PPP (Point-to-Point Protocol) »• ADSL (Asymmetric Digital Subscriber Loop) »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Packet over SONET

Packet over SONET is the method used to carry IP packets over SONET optical fiber links• Uses PPP (Point-to-Point Protocol) for framing

Protocol stacks PPP frames may be split over SONET payloads

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

PPP (1)

PPP (Point-to-Point Protocol) is a general method for delivering packets across links• Framing uses a flag (0x7E) and byte stuffing• “Unnumbered mode” (connectionless unacknow-

ledged service) is used to carry IP packets• Errors are detected with a checksum

IP packet0x21 for IPv4

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

PPP (2)

A link control protocol brings the PPP link up/down

State machine for link control

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

ADSL (1)

Widely used for broadband Internet over local loops• ADSL runs from modem (customer) to DSLAM (ISP)• IP packets are sent over PPP and AAL5/ATM (over)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

ADSL (2)

PPP data is sent in AAL5 frames over ATM cells:• ATM is a link layer that uses short, fixed-size cells

(53 bytes); each cell has a virtual circuit identifier• AAL5 is a format to send packets over ATM• PPP frame is converted to a AAL5 frame (PPPoA)

AAL5 frame is divided into 48 byte pieces, each of which goes into one ATM cell with 5 header bytes

Computer Networks 1

57TUNALI

Required Reading

Tanenbaum Sections• 3.4• 3.5• 3.6

Computer Networks 1

58TUNALI

Homework 2Chapter 3• 21 (23)• 27 (30)• 29 (32)• 30 (34)

End

Chapter 3

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

Recommended