160 likes | 190 Views
Data Link Control. We want to minimize the amount of error correcting and detecting we need to do. Framing. The primary purpose of the data link layer is to ensure data moves from one end of a link to the other accurately.
E N D
Data Link Control We want to minimize the amount of error correcting and detecting we need to do
Framing • The primary purpose of the data link layer is to ensure data moves from one end of a link to the other accurately. • One issue is how to separate different information being sent over the link. The way this is done is through framing. • Framing adds addresses for the sender and receiver to facilitate communication between mutiple devices sharing a physical link. • It also provides a way of dividing up large transmissions to reduce the quantity of material that needs to be resent in case of an error.
Two types of framing • Fixed-size: Pretty self explanatory • Wastes resources if we are sending lots of half-empty frames. • Variable-size: • Frames can be sized to match data segments, so no wasted resources • More overhead to mark beginning and end of frame.
Character-oriented framing: • Frame length is in multiples of bytes. • Headers and trailers also in multiples of bytes. • Use special 1 byte flags at beginning and end of frame. • Fine if all you’re sending is text, but if you’re sending other data, some might match the flag. • Byte stuffing inserts a special byte (usually ESC) into the data section before a byte that matches the flag.
Bit-oriented framing: • Mostly use pattern 0111110 as the flag. • If that pattern appears in the data segment, we use bit stuffing to insert an extra 0 after an sequence that looks like 011111.
Data rate control • What if the two ends of a given link cannot communicate at the same speed? • Flow control is the process by which the sender and receiver negotiate how much data can be sent before the receiver needs to send an acknowledgement. • Error control is the process by which the receiver informs the sender about lost/damaged frames and arranges to have those frames resent.
Protocols • These negotiations are not left entirely up to the devices on either side of a link. Rather, they agree on a system to decide these things. This system is called a protocol.
Noiseless channels • If we can presume the channel is noiseless (which we never can), the protocols are very simple: • Simplest protocol has no flow or error control. • Event driven • Frames are simply sent and assumed to be received and processsed • Stop-and-Wait has maximal flow control; no error control • Sender sends a frame • Sender won’t send another frame until it receives an ACK from the receiver.
Noisy channels Of course, most channels are noisy, so we need to have some level of error control. • Stop-and-Wait Automatic Repeat Request (ARQ) • If a damaged frame arrives at the receiver, no ACK is sent. • If a certain time passes without receiving an ACK, the frame is re-sent. • In order to know which frames are being sent, frames need to be numbered.
Go-Back-N ARQ • Stop-and-wait is inefficient. The link spends a lot of time idle. • Pipelining is where we start a new task before a previous task is done. So the sender can start sending further frames before receiving an ACK about one already sent. • A sliding window is the range of frames (sequence numbers) that the sender and receiver are concerned with. • For the sender, the window is frames sent for which it hasn’t received an ACK and the frames that it is waiting to send.
For the receiver the window is always 1 frame - the next one it is expecting to receive. • When the receiver gets a frame, it sends an ACK and moves its window over one. • If the frame is damaged, no ACK is sent and the window doesn’t move. • Frames that aren’t in the window that arrive are discarded. • After the minimal time to wait for an ACK passes, the sender resends all the already sent frames in its window.
Selective Repeat ARQ • Go-Back-N is inefficient in that lots of otherwise valid frames get discarded because the receiver’s window only has size 1. • Why not make the receiver’s window the same size as the sender’s window? • The primary restriction is that the start of the sender’s window must always be the earliest non-ACKed frame. • If a frame is lost, it is re-sent after the timer expires. • If a frame is corrupted, the receiver sends a NAK to the sender, and the frame is resent.
Piggybacking • All of the protocols we’ve just discussed apply specifically to communication in one direction. • Most communication, of course, is bi-directional. • Piggybacking is the process by which ACK and NAK signals are attached to normal data frames that are sent back and forth, to maximize the amount of data being sent.