Data Link Layer Protocols Flow Control in Data

  • Slides: 50
Download presentation
Data Link Layer Protocols Flow Control in Data Link Layer

Data Link Layer Protocols Flow Control in Data Link Layer

Flow Control: Initial Assumptions • • Simplex Channel Infinite buffer capacity with the receiver

Flow Control: Initial Assumptions • • Simplex Channel Infinite buffer capacity with the receiver Error free transmission Network layer at the senders end is always ready with data • No need for flow control

Protocol Definitions Continued Some definitions needed in the protocols to follow. These are located

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

Protocol Definitions (ctd. ) Some definitions needed in the protocols to follow. These are located in the file protocol. h.

Unrestricted Simplex Protocol

Unrestricted Simplex Protocol

Some assumptions dropped • Infinite capacity in the buffer of the receiver. • Need

Some assumptions dropped • Infinite capacity in the buffer of the receiver. • Need for “flow control” • Stop-n-Wait protocol – Sender sends a frame – And waits for a signal in the form of a dummy frame – No seq no. is required since the line is still error free

Simplex Stop-and. Wait Protocol

Simplex Stop-and. Wait Protocol

Further assumptions dropped • The channel is noisy, frames may be damaged or lost

Further assumptions dropped • The channel is noisy, frames may be damaged or lost • Good scene : data frame reaches intact, ack sent back and received, next frame sent • Bad scene : – Data frame damaged or lost. . hence no ack – sender times out and resends. . No problems – Data frame reaches intact but Ack lost. . Times out. . resends. . Receiver receives duplicate frames. . Problem

Problem of Duplicate frames • Solution : – Keep a sequence number for each

Problem of Duplicate frames • Solution : – Keep a sequence number for each frame to distinguish between the new frame and a duplicate frame. • How large should be the sequence number? Or • What should be minimum number of bits required for the sequence number? – The only ambiguity at the receiver is between two successive frames. . Say m and m+1 and never between m-1 and m +1. . Its only after the ack for m-1 reaches back intact mth frame is sent. . And once mth frame reaches intact at the receiver’s end. . Story of m-1 th frame is over. . However depending upon whether ack of mth frame reaches back intact or not either mth or m+1 th frame is sent. . hence only 1 bit is sufficient

A Simplex Protocol for a Noisy Channel A positive acknowledgement with retransmission protocol. Continued

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

A Simplex Protocol for a Noisy Channel (ctd. ) A positive acknowledgement with retransmission protocol.

Further assumption dropped • Channel is simplex. . • So, Now communication is two

Further assumption dropped • Channel is simplex. . • So, Now communication is two way. . I. e. Duplex channel – Interleave data and ack. . So. . a kind field is required to specify whether the frame contains data or ack. – Piggyback on data frame

Sliding Window Protocol(Duplex) • At any instant of time, the sender maintains a set

Sliding Window Protocol(Duplex) • At any instant of time, the sender maintains a set of sequence numbers corresponding to frames it is permitted to send – this includes – frames not yet sent – Frames sent but not yet acknowledged. . May have to be sent again This corresponds to the sender’s window. When a packet comes from the NL. . it is appended in the window and when an ack arrives for a frame. . it is deleted from the buffer(and from the window)

Sliding Window Protocol(Duplex) • Similarly, the receiver also maintains a set of sequence numbers

Sliding Window Protocol(Duplex) • Similarly, the receiver also maintains a set of sequence numbers corresponding to frames it is permitted to accept. – When a frame arrives, its seq number is checked. . if it falls in the window it is accepted else discarded. . Once an ack is sent for a frame it is deleted from the window so that duplicate frames are not accepted. • Sliding window gives the DLL the flexibility to accept the frames in any order but they must be handed over to the NL in order.

Sliding Window Protocols (2) A sliding window of size 1, with a 3 -bit

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.

Sliding Window Protocols • A One-Bit Sliding Window Protocol • A Protocol Using Go

Sliding Window Protocols • A One-Bit Sliding Window Protocol • A Protocol Using Go Back N • A Protocol Using Selective Repeat

A One-Bit Sliding Window Protocol Continued

A One-Bit Sliding Window Protocol Continued

A One-Bit Sliding Window Protocol (ctd. )

A One-Bit Sliding Window Protocol (ctd. )

How does it handle duplicate frames… Say when an Ack is lost …A times

How does it handle duplicate frames… Say when an Ack is lost …A times out and resends. . Both A and B are wanting to send a packet numbered 0, or one can imagine they have both sent out packets with seq no. 1 and are waiting for its ack.

 • A sends A 0, seq = 0, ack = 1, B sends

• A sends A 0, seq = 0, ack = 1, B sends B 0, seq=0, ack = 1, but B 0 is lost. • B gets the packet A 0 but ack is not the one required. . It resends B 0 with the ack of A 0… I. e. A 0, seq = 0 and ack =0, (This is a duplicate of the ack that was lost) also it increments the FE. I. e FE becomes 1. • Duplicates of A 0, 0, 1 are rejected since their seq number (0) don’t match the FE(1). However B sends the duplicate of the above again. • If this is also lost. . A duplicates and then B duplicates and so on.

 • Eventually one of the duplicates of B reaches A. . I. e.

• Eventually one of the duplicates of B reaches A. . I. e. the ack required by A (remember both are waiting for ack of packet 0 in the beginning) and A sends another packet. . A 1 with seq =1 and ack =0 that for B 0 it just received. • This was a good scene : problem was only due to noisy channel. . Ack were being lost

Bad scene : duplicates without transmission error • When B sends before receiving a

Bad scene : duplicates without transmission error • When B sends before receiving a frame from A.

A One-Bit Sliding Window Protocol (2) Two scenarios for protocol 4. (a) Normal case.

A One-Bit Sliding Window Protocol (2) 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.

Further assumption dropped • So far, implicitly, we have assumed that the time of

Further assumption dropped • So far, implicitly, we have assumed that the time of transmission is negligible. I. e. the time frame takes to reach the receiver and the ack to travel back is negligible.

Long propagation delays • Consider a 50 kbps satellite channel with a round trip

Long propagation delays • Consider a 50 kbps satellite channel with a round trip delay of 500 msec (10^-3 sec). • To send a frame of size 1000 bits. . it takes = 1000/50 kbps = 20 msec. • At t=0, the sender sends the first bit and at t = 20 msec (1000/50, 000 sec= 1/50 sec= 1000/50 msec = 20 msec), it sends the last bit. • At t= 270 msec, the frame completely reaches the receiver. • Not before t= 520 msec , the ack arrives back at the receiver ( it will be later than this). This means that the sender was blocked for 500 msec out of 520 msec.

Contd. . • That means – Long propagation delays – High bandwidth – And,

Contd. . • That means – Long propagation delays – High bandwidth – And, short frame length Is bad in terms of channel efficiency. A large window size is needed at the sender’s end whenever the bandwidth * round trip delay is large.

Pipelining • Imagine in the above example, if the sender could send more frames

Pipelining • Imagine in the above example, if the sender could send more frames without waiting for the ack for the first one, the channel could have been utilized more efficiently. This technique is called pipelining.

Pipelining • Imagine the scenario, when the sender always has something to send until

Pipelining • Imagine the scenario, when the sender always has something to send until the ack for the first frame arrives. . Best scenario, right? • Clearly this is not Stop-n Wait.

Pipelining contd… Let • Channel capacity is b bits/sec • Frame size l bits,

Pipelining contd… Let • Channel capacity is b bits/sec • Frame size l bits, • Round trip propagation time is R • The time required to transmit a single frame is l/b. • So, in stop n wait, the line is busy for l/b time and idle for R time, thus the line utilization is = l/b divided by l/b + R = l/(l + b. R). If l < b. R, the efficiency will be less than 50%.

Pipelining over noisy channels • What if one or more frames is errored. •

Pipelining over noisy channels • What if one or more frames is errored. • Two options : – Throw away all the subsequent frames and go back and start resending from the damaged frame. This corresponds to size 1 window in the receiver. - Go back N Protocol – Buffer the subsequent frames and wait for the damaged frame to be resent, once that comes handover the frames in proper order to the NL-Selective Repeat Protocol

Comparison • Trade off between the bandwidth utilization and the buffer space in the

Comparison • Trade off between the bandwidth utilization and the buffer space in the receiver.

A Protocol Using Go Back N Pipelining and error recovery. Effect on an error

A Protocol Using Go Back N Pipelining and error recovery. Effect on an error when (a) Receiver’s window size is 1. (b) Receiver’s window size is large.

Issues • For a maxseq = 7, Number of outstanding frames can only be

Issues • For a maxseq = 7, Number of outstanding frames can only be 7 and not 8. To see why, let us consider what happens when 8 frames are allowed to be outstanding. . That is the scene is • Sender has sent out 8 frames • The piggybacked ack for frame 7 finally comes to the sender. • Now suppose the sender has 8 outstanding frames, 0… 7 • Now sender sends next frame 0, if it is lost, if B has a frame to send, B will send the piggybacked ack for 7.

 • Next, the sender sends the next frame 1 without waiting for the

• Next, the sender sends the next frame 1 without waiting for the ack for 0, now suppose this is also lost, again B has a frame to send, then B will again send ack for 7. • And so on. . Sender sends all the outstanding frames, 0… 7 • Suppose all of them are lost, the receiver will still send the ack of the last frame received I. e. 7. • Now sender has no way of knowing, whether all the frames were lost or since it has received ack for 7. . all the frames reached intact.

Solution • The problem is solved by keeping at most 7 instead of 8

Solution • The problem is solved by keeping at most 7 instead of 8 outstanding frames, say – 0 -6 in the first batch, and – 7, 0 -5 in the second • If all the frames in the second batch are lost, sender may keep on receiving ack for frame 6 which is not in sender’s window and hence it will know that frames were lost.

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N Continued

Sliding Window Protocol Using Go Back N

Sliding Window Protocol Using Go Back N

Sliding Window Protocol Using Go Back N (2) Simulation of multiple timers in software.

Sliding Window Protocol Using Go Back N (2) Simulation of multiple timers in software.

A Sliding Window Protocol Using Selective Repeat Continued

A Sliding Window Protocol Using Selective Repeat Continued

A Sliding Window Protocol Using Selective Repeat (2) Continued

A Sliding Window Protocol Using Selective Repeat (2) Continued

A Sliding Window Protocol Using Selective Repeat (3) Continued

A Sliding Window Protocol Using Selective Repeat (3) Continued

A Sliding Window Protocol Using Selective Repeat (4)

A Sliding Window Protocol Using Selective Repeat (4)

Issues in “Selective Repeat” • 7 frames 0 -6 are sent, • Received, ack-ed,

Issues in “Selective Repeat” • 7 frames 0 -6 are sent, • Received, ack-ed, and window of the receiver advanced to 7, 0 -5 • All ack lost • Sender times out and resends frame 0 -6 • At receiver, 0 -5 accepted, buffered(since next frame it is expecting is 7) as new frames and acked (Ack 6) and 6 discarded and acked as a duplicate • Sender advances its window to 7, 0 -5 • Sends packets 7, 0 -5

 • 7 is accepted and passed onto the NL • 0 and others

• 7 is accepted and passed onto the NL • 0 and others are rejected as duplicate and the previous buffered frames are passed on to the NL - wrong packets!!!! • Order in which packets are sent: • P 0…p 6, p 7, p 0(new)…p 5(new) • Order in which packets are handed over to NL of the receiver: • P 0…p 6, p 7, p 0…p 5(duplicate) and rest are discarded including the new frames

Solution • Keep the window size 4 • That is half the range of

Solution • Keep the window size 4 • That is half the range of permitted sequence numbers.

A Sliding Window Protocol Using Selective Repeat (5) (a) Initial situation with a window

A Sliding Window Protocol Using Selective Repeat (5) (a) Initial situation with a window size seven. (b) After seven frames sent and received, but not acknowledged. (c) Initial situation with a window size of four. (d) After four frames sent and received, but not

Programming Assignments • Make Groups of two and, • Implement – Sliding window protocol

Programming Assignments • Make Groups of two and, • Implement – Sliding window protocol with CRC on a duplex channel – Go Back N protocol with Hamming Code on a duplex channel • Implementation of the channel must be clearly defined. • There must be two copies of the same program running simultaneously, ( For example, on time sharing basis on the same machine, say in two different windows. ) if required some synchronization may be added between the two processes. Alternatively, threads could be used. • Will tell you more about the points on which your programs will be evaluated. Few are: – Acks incorporated or not, piggybacked or not, channel is truly duplex or not etc

I Acknowledge Help from the following site http: //www. cs. vu. nl/~ast/ In preparing

I Acknowledge Help from the following site http: //www. cs. vu. nl/~ast/ In preparing this lecture.