The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer...

74
The Data Link Layer Chapter 3

Transcript of The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer...

Page 1: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

The Data Link Layer

Chapter 3

Page 2: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Hybrid Reference Model - REMINDER

Application Layer

Transport Layer

Network Layer

Data Link Layer

Physical Layer

Page 3: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Data Link Layer• “Virtual communication” takes place in the

data link layer (in additional to the other layers).

• Provides services to the network layer– Framing (sending machine breaks input data into

input frames). Need to recognize framing boundaries.

– Error control - noise burst can ruin a transmission.

Page 4: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Data Link Layer

• Provides svcs to the network layer (contd)– Flow control - how to stop a fast transmitter

from overwhelming a slow one.

Page 5: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Data Link Layer

• Services Provided to Network Layer– Transfer data from network layer on source

machine to network layer on destination machine through “virtual communication.”

– Actual path is through all lower layers.– Services are 1) Unacknowledged

connectionless service 2) Acknowledged connectionless service 3) Ack. Connection-oriented service

Page 6: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Data Link Layer

Page 7: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Unacknowledged connectionless service

• Source machine sends frames to destination machine. Destination machine does not ack.

• No connection estd. before hand

• Frame loss due to noise is not recovered in data link layer but maybe above.

• Appropriate for – Low error rate systems– real time traffic (speech) - bad data is worse

than late data.

Page 8: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Acknowledged connectionless service

• Each frame sent is acknowledged but no connections are set up.

• If frame does not arrive, sender can wait and retransmit.

• Can be used over unreliable channels.

Page 9: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Acknowledged connection-oriented service

• Connection estd. Before any data are transferred.• Each frame sent is numbered and the data link

layer guarantees that each frame sent is indeed received.

• Each frame is recd. Only once (guaranteed) and that order is maintained (guaranteed) (is frame receivable multiple times in connectionless service?)

Page 10: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Connection-oriented service

• Three phases to transfer: – Connection is established by initializing

counters for received/unreceived frames– One or more frames are transmitted– Connection is released freeing up resources

(variables, buffers)

• Example - next slide

Page 11: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Placement of data link protocol• WAN subnet consisting of routers

connected by point-to-point leased tel. Lines.

• Frame arrives at router - it is checksummed and is passed to data link layer software.

• DLL soft. Checks to see if frame was expected. If so gives packet in payload field to routing software.

• Routing software chooses appropriate outgoing line and passes the packet to DLL software which transmits it.

Page 12: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Placement of data link protocol

Page 13: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Routing Code (box 3, prev. slide)

• Routing code wants reliable sequenced connections on each of the Pt-to-Pt lines.

• Data link protocol must make unreliable lines look good (good for wireless links).

Page 14: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Framing

• In order to provide service to the network layer, DLL must use services provided by the physical layer.

• Bit stream delivered by physical layer may not be error free.

• DLL must correct for errors

• DLL breaks bit stream into discrete frames and creates checksum for each frame.

Page 15: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Framing (cont’d)

• Transmission is tricky. One possibility is to insert gaps between frames but there is no guarantee about timing from the network.

• Start and end of frame marked by– Character count– Starting and ending chars with char stuffing– Starting & ending flags with bit stuffing– Physical layer coding violations

Page 16: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Character count

Even if checksum is incorrect, the destination does notknow where the bad frame starts.

Page 17: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Starting and ending chars w/ character stuffing

• Use ASCII chars DLE STX (Data Link Escape, Start TeXt) and DLE ETX (End TeXt). If receiver loses frame boundaries it should look for DLE STX and DLE ETX

• Problem: Binary data. DLE STX/ETX could occur and ruin framing.

• Stuffing: Add an ASCII DLE before each DLE in the binary data.

Page 18: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Starting and ending chars w/ character stuffing

Data from Network Layer

Data after stuffing

Data after de-stuffing that is passed to networklayer on destination end

DISADVANTAGE: Reliance on 8 bits per character

Page 19: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Start & end flags w/ bit stuffing• Frame begins and ends with 01111110 called

flag byte.• When senders DLL senses 5 consecutive 1’s

it “stuffs” a 0 into the bit stream.• Receiver sees the 5 consecutive 1’s followed

by a 0 and destuffs it (i.e., deletes the 0).• Bit stuffing unambiguously locates frame

boundaries.

Page 20: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Start & end flags w/ bit stuffing

Page 21: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Physical Layer Coding Violations

Read on your own

Page 22: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error Control

• How to ensure that all frames are sent to network layer at dest. in proper order?

• This is important for reliable connection-oriented service.

• Receiver sends back responses (positive or negative) to incoming frames. Positive means frame OK, negative means retransmit.

Page 23: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error Control

• Question: What happens when an error burst destroys a whole frame?

• Answer: Receiver knows not that an error has occurred. It wouldn’t send and acknowledgement. Sender would hang forever in such a case.

• To solve above, DLL’s have timers. On sending frame a timer is set off ….

Page 24: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error Control

• … if acknowledgement is not received (or lost) before timer goes off, sender is alerted to retransmit frame.

• Problem: What to do if frames are submitted multiple times?

• Answer: Assign a sequence number to frame. Therefore receiver will be able to distinguish original and retransmitted frame.

Page 25: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Flow control

• Problem: What to do when sender sends frames faster than receiver can accept them?

• Solution: Have rules as to when a sender can send the next frame. The rule could say “send n frames now but do not send any more after that until I ask for them.”

• More on flow control later.

Page 26: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error detection and correction

• Two strategies– Include enough redundant information to

deduce what the error was - error correcting codes

– Use redundant info. So that the receiver knows that an error occurred but not which error. In any case it can request a retransmission - error detecting codes

Page 27: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• Terminology:

– Frame consists of m message bits + r redundant or checkbits. n = r + m

– n bit unit consisting of data + checkbits is called a codeword

– Hamming distance - 0010 XOR 1101 = 1111, i.e., the number of bit positions at which two codewords differ is called the Hamming distance.

– If two codewords are a Hamming distance d apart, it takes d single bit errors to convert one to another.

Page 28: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• 2^m possible data messages are legal but

2^n possible codewords are not. This is because of how check bits are calculated.

• Having an algo. to calculate legal codewords we can compute exhaustive list of them. From this list two codewords whose Hamming Distance is minimum can be calculated.

• This distance is called the Hamming Distance of the Complete Code.

Page 29: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• To detect d bit errors we need a distance

d+1 code because there is no way d single bit errors can change one valid code word into another valid code word.

• To correct d errors we need a distance 2d+1 code because legal codewords are so far apart so that with even d changes - the original codeword and the modified codeword are still closest.

Page 30: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• Parity Bit: is appended to the data and is

chosen so that the number of 1 bits in the code word is even (or odd).– Example (even parity): 10110101 ->

101101011 and 10110001 -> 101100010

• A code with a single parity bit has a distance 2 since any single bit error produces a word with the wrong parity. It is used to detect single errors.

Page 31: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• Example: Code consisting of 4 code words

– 0000000000, 0000011111, 1111100000, 1111111111

– Code has distance 5. Therefore double errors can be corrected

– If 0000000111 arrives, the receiver knows that the original must have been 0000011111.

– If triple error changes 0000000000 into 0000000111 then by a minimum distance approach we will not correct the code word.

Page 32: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes• Given m message bits and r checkbits.

Design a code that will allow all single bit errors to be corrected.– Each of the 2^m legal messages has n illegal

codewords at a distance 1 from it (just invert each of the n bits in the n-bit codeword)

– Thus each 2^m legal messages requires (n+1) bit patterns dedicated to it

– (n+1)2^m <= 2^n but n = m + r so (m+r+1) <= 2^r. Given m we get a lower limit on r (number of check bits) to correct single bit errors.

Page 33: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes- Hamming• Bits of codeword are numbered from L-R

starting with 1.

• Bits that are powers of 2 (1, 2, 4, 8 etc) are check bits. The rest (3,5,6,7,9, etc) are filled with the m data bits.

• Each check bit forces the parity of some collection of bits (including itself) to be even (or odd).

• A bit may be included in several parity computations ...

Page 34: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes- Hamming• To see which check bits the data bit in

position k contributes to, rewrite k as a sum of powers of 2. k = 15 = 1 + 2 + 4 + 8 or k = 29 = 1 + 4 + 8 = 16.

• A bit is checked by only those check bits occurring in its power of two expansion.

• On codeword receipt, receiver initializes counter to 0. It checks each check bit (k = 1, 2, 4, 8, …) to see if it has the correct parity (even or odd). If not, it adds k to the counter.

Page 35: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error correcting codes- Hamming• If counter is non zero, it contains the

number of the incorrect bit. E.g. if check bits 1, 2, 8 are in error, the bit in error is 11

Page 36: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes• Let the block size be 1000 bits. To provide

error correction for such blocks 10 check bits are needed.

• Why? (m+r+1) <= 2^r.

• 1Mbit requires 10^4 checkbits.

• To detect a block with a single bit error one parity bit per block will suffice.

• Once every 1000 blocks an extra block is reqd.

Page 37: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes• With a single parity bit, if a block is garbled

by a burst error, what is the probability that the error will be detected?

• Solution:Take a block and break into an nxm matrix. Compute parity bit for each column and place at the bottom of matrix. Matrix is transmitted one row at a time. Receiver checks parity bits, if any one is wrong it requests transmission again.

Page 38: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes• Burst Error: In a number of bits of length l,

at least the first bit and the last bit are wrong.

• In the n (cols) x m (rows) matrix method a single burst of length n (in any row) can be fixed since the parity will be violated.

• However if a burst of length of n+1 occurs (where the error is in the first bit and the n+1th bit) then the error will be undected.

• Another way is Cyclic Redundancy Code

Page 39: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Bit strings represented as polynomials

– 110001 = 1x^5 + 1x^4 + 0x^3 + 0x^2 +0x^1 + 1x^0

– Highest order bit (of k bits) is the coefficient of x^(k-1).

– The polynomial is said to be of degree k-1– Polynomial addition and subtraction is done

modulo 2• 10011011 + 11001010 = 01010001

– Division is same as binary but subtraction is done modulo 2.

Page 40: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Sender and receiver use an agreed upon

generator polynomial G(x). The high and low order bits of G(x) are 1.

• To compute a checksum for a frame with m bits (whose polynomial is M(x)), the frame must be longer than the generator poly.

• Take the checksum and place it at the end of the frame so that the poly represented by the new frame (with checksums at the end of it) is divisible by G(x)

Page 41: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• When receiver gets checksummed frame, it

divides by G(x). If remainder exists, then error occurred.

• Algorithm– r = degree of G(x). Append r zero bits to the

lower-end of frame. Now we have m+r bits and this corresponds to the polynomial x^rM(x).

– Divide bit string corresponding to G(x) into the bit string corresponding to x^rM(x) using modulo 2 division.

Page 42: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)

• Algorithm (contd)– Subtract the remainder (always r or fewer bits)

from the bit string corresponding to x^rM(x) using modulo 2 subtraction.

– Result of above operation is the checksummed frame to be transmitted. Call its polynomial T(x).

– T(x) is divisible by G(x).

Page 43: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

G(x) = x^4 +x + 1

Page 44: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Suppose error occurs i.e., T(x) + E(x). Each

1 bit in E(x) is an error.

• A single burst error is indicated by 1xxxxx1 where xxxx could be any combination of 0’s and 1’s.

• Receiver does [T(x) + E(x)]/G(x). What is left is E(x)/G(x).

• If E(x) = x^i, i shows which bit is in error then if G(x) has >= 2 terms it will never divide E(x) so single bit errors are detected.

Page 45: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Two isolated single bit errors: E(x) = x^i +

x^j = x^j(x^(i - j) + 1), i > j. – Assume that G(x) is not divisible by x, a

sufficient condition for double errors to be detected is that G(x) does not divide x^k+1 upto the maximum of i-j.

• Odd number of bits in error: Make x+1 a factor of G(x) & we can catch all errors consisting of an odd number of inverted bits.

• READ PARA starting bottom of p189 on own.

Page 46: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Burst errors of length <= r: r is the

number of checkbits.– Burst error of length k < r represented by x^i

(x^(k-1) + … + 1); i determines how far from the right hand of the frame the burst is located.

– If G(x) has an x^0 term it will not have x^i as a factor so if degree of (x^(k-1) + … 1) is less than the degree of G(x), the remainder can never be 0.

• Burst length of length = r+1: Pr(Accept) = 1/2^(r-1)

Page 47: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Error-Detecting Codes (CRC)• Burst length of length > r+1 then then

Pr(Accept) = 1/2^r

• Example Polynomials– CRC-12: x^12 + x^11 + x^3 + x^2 + x^1 + 1 – CRC-16: x^16 + x^15 + x^2 + 1– CRC-CCITT: x^16 + x^12 + x^5 + 1

• CRC 12 used for 6 bit chars. CRC-16 and CCITT used for 8 bit characters.

Page 48: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols• Assumptions:

– Physical, data link layer and network layer engage in “peer to peer” communication, i.e., each layer has physically independent proc.

– Machine A sends data to machine B using a reliable connection oriented service. Also we will consider the case where B wants to send to A simultaneously.

– A has ‘infinite bit bucket’, i.e., no waiting for data production by Network Layer - i.e., data is always available.

Page 49: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols• Assumptions:

– The DLL on source machine A assumes that data from Network layer (on A) is all data every bit of which is to be passed to the network layer on destination machine B.

– When DLL accepts a packet it creates a frame by putting a data link header and trailer to it. SEE FIGURE ON NEXT SLIDE.

Page 50: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols

Page 51: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elem. Data link protocols

• DLL Interaction with the Physical Layer– to_physical_layer to transmit frame– from_physical_layer to receive frame

• DLL Interaction with the Network Layer– to_network_layer to pass packet upwards– from_network_layer: get pkt from network layer

• wait-for-event(&event) This procedure only returns when something has happened, for example a frame arrives. event says what happened (e.g., event = cksum_err).

Page 52: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols• Frame contents - kind, seq_no, ack, info

– First 3 contain control info and the last contains actual data.

– kind lets us know if frame contains only control info. or if it contains control info. + data.

– seq_no is used to number frames to tell them apart

– ack is used for acknowledgements– info field of data frame contains a single packet.

For a control frame info field is not used.

Page 53: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols• Packet and Frame:

– Network layer constructs a packet by taking a message from the transport layer and adds the network layer header to it.

– Packet is then passed to DLL and put into the info field of the outgoing frame.

– The destination DLL extracts the packet from the frame and sends packet to network layer (above it).

Page 54: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Elementary data link protocols• Some Listed Procedures + more:

– wait_for_event waits in a loop for events to occur. For example when a frame is sent by DLL, it starts a timer (in order to account for lost frames/replies). wait_for_event returns event = timeout.

– to_network_layer, from_network_layer used to pass packets between network layer and DLL

– to_physical_layer, from_physical_layer used to pass frames between DLL and physical layer.

– Frame number is counted from 0 - MAX_SEQ

Page 55: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Unrestricted simplex protocol• Assumptions:

– Data transfer is unidirectional (MAX_SEQ is not used).

– Transmitting and receiving network layers are always ready

– Processing time of frames can be ignored– Buffer space is infinite– The communication channel between DLL’s is

always noiseless

Page 56: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Unrestricted simplex protocol• Protocol has two procedures - sender1 (runs

in DLL of source machine) and receiver1 (runs in DLL of destination machine).– sender1 - fetch packet from network layer,

create a frame and send frame to physical layer.– receiver1- Await arrival of frame (assumed

undamaged). Take frame from physical layer and send data portion to network layer.

Page 57: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Simplex stop-and-wait protocol• Eliminates the assumption that there is an

infinite buffer space in the DLL in which to store all incoming frames.

• Assume communication channel is error free and data traffic is one way (more later).

• Therefore we only have to worry about how not to flood the receiver.

• If the receiver requires Δt (seconds, microseconds etc) from_physical_layer and to_network_layer then sender must send less than one frame per Δt.

Page 58: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Simplex stop-and-wait protocol• Assuming no automatic buffering and

queuing are done in hardware, sender must never send a new frame until receiver has completely taken old one through the use of from_physical_layer.

• Delay is not feasible if the receiver has several lines to attend to.

• Accounting for worst case behavior of the receiver is too conservative.

• Thus it is preferable to have receiver send feedback to sender.

Page 59: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Simplex stop-and-wait protocol• After sending a packet to network layer,

receiver sends a dummy frame back to sender - which effectively tells sender to send next frame.

• Thus sender is required by protocol to wait for some time - i.e., until dummy frame is received. This is known as stop-and-wait.

• Data traffic is simplex but frame traffic is duplex. Since strict alternation is followed, half-duplex is permissible.

Page 60: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Simplex protocol for noisy channel

• Assume-if frame damaged, CRC catches it.

• SCENARIO (receiver = A, sender = B)– Network layer on A gives packet to its DLL. B

receives packet correctly and is sent to its Network layer. B sends ack frame back to A.

– Ack frame gets lost.– DLL on A times out. A takes lost ack to mean

that frame never made it to B. Sends frame containing packet 1 again.

– B receives packet 1 twice and may process it twice. Protocol fails.

Page 61: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Simplex protocol for noisy channel

• Solution: Mechanism to distinguish between a first- time and a retransmitted frame.– Place sequence numbers in header of each

frame.

• Max number of bits needed for sequence numbers? ANSWER: 1 (0 or 1).

• This kind of protocol is called ARQ (Automatic Repeat reQuest)

• Read code on own. Exam??

Page 62: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• Full duplex communication, i.e., same ckt is

used to send data/ack in both directions.

• Piggybacking: When data frame arrives, receiver (B) instead of sending an ack to A immediately, waits till it has a packet to send to (A) from its network layer. The ack is put in the frame header. Advantage: Better bandwidth utilization. Disadvantage: Waiting for packet could take for ever. Compromise wait a fixed time for packet to send otherwise send separate ack.

Page 63: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• Outbound frame has a sequence number

from 0 - 2^n -1 (therefore n bits suffice)

• Sender maintains a list of numbers in sequence corresponding to frames it is permitted to send. This set of frames falls within the so-called sending window.

• Receiver maintains a similar list of frames it is permitted to accept called a receiving window.

• Sending & receiving window can have diff sizes, upper/lower limits & can grow/shrink

Page 64: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols

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

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

Frames sent but not acknowledged

When new pkt arrives from NLit is given next highest seq. # andwindow advanced by 1.

When acknowledgementarrives trailing edge is advanced by p. (next slide)

Sender

Receiver

Frames receiver may accept

Frames outside window are discarded without ack

Last frame acked

Page 65: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• SENDER:

– Sender maintains a list of consecutive sequence numbers corresponding to frames it is permitted to send. This list, termed the sending window, represents frames sent but not yet ack’d.

– When an ack arrives, the lower edge of the window is advanced to the corresponding sequence number, thereby allowing the sender to transmit new frames. (Note: When receiver sends an ack for frame s, this is understood to mean that all frames up to and including s have been received.)

Page 66: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• SENDER (continued):

– Let SWS be the maximum sender window size.– Let LAR be the sequence number of the last

acknowledgment received.– Let LFS be the sequence number of the last

frame sent.– Therefore LFS - LAR + 1 <= SWS.– The sender must have a buffer large enough to

hold as many frames as there are in its window.– sender records the time at which every packet is

sent

Page 67: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• SENDER (continued):

– If sender does not receive ack for packet before timeout elapses, it retransmits original frame

• RECEIVER:– The receiver also maintains a receiving

window, corresponding to the number of out-of-order frames it can accept. Frames falling outside the window are discarded without ack

– Let RWS be the maximum receiver window size; HFA be the highest-numbered frame that will be accepted & NFE be the next frame expected

Page 68: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• RECEIVER:

– HFA - NFE + 1 <= RWS.– When frame with sequence number s arrives,

the receiver takes the following action. If s < NFE or s > HFA, then the frame is outside the receiver's window and so it is discarded. If NFE <= s <= HFA, then the frame is accepted.

– An acknowledgment for s is sent if the following conditions are met:

• s has not yet been acknowledged.

• all frames in the range from NFE to s have been received.

Page 69: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Sliding Window Protocols• RECEIVER:

– Thus the acknowledgments are cumulative. When the acknowledgment is sent, the receiver sets NFE = s + 1 and HFA = s + RWS.

Page 70: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Go back n• Pipelining:

– Assumption was that trans. time is negligible– Eg. 50Kbps channel, 500ms round trip

propagation delay. Send 1000bit frames. t=0 ms the first fame is sent. t=270ms is when frame fully arrives at receiver and only at t = 520ms has the ack arrived back at the sender.

– Sender was blocked 500/520 or 96% of time.– Solution: Choose w frames before blocking. In

example above, w = 26, i.e, by the time it has sent 26 frames (t=520) the ack for 0 will have arrived. This is known as pipelining.

Page 71: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Go back n/selective repeat• Pipelining: (continued)

– If channel capacity is b bps, frame size l bits & the round trip propagation time R sec, the time required to send a single frame is l/b sec.

– There will be a total channel delay of R sec– In stop-and-wait line is busy for l/b and idle for

R sec giving a line utilization for l/(l+bR). – Thus pipelining can be used to keep the line

busy in the interval.– What to do if errors occur during pipelining?– Answer: go back n, or selective repeat

Page 72: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Go back n/selective repeat• go back n :

– What to do when a frame in the middle of a long stream is bad? Large # of succeeding frames may come to receiver before sender is told of error.

– On discovering error, a solution is go back n. Here receiver discards all subsequent frames (upto n) & sends no ack for the discarded frames. Therefore the receiver DLL refuses all frames but the next one it must give to the NL.

– Eventually sender will retransmit all frames including lost/damaged one.

Page 73: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.

Go back n/selective repeat• Selective repeat :

– Store all frames following the bad one.– When sender notices that something is wrong it

only retransmits the bad frame.– This is like having a receiver window larger

than 1– Thus any frame within the window may be

accepted and buffered until all the preceding ones have been passed to the network layer.

– Could need large amounts of memory in DLL

Page 74: The Data Link Layer Chapter 3. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer.