Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Framing

To provide service to the network layer, the data link layer must use the service provided to it by the physical layer.

OSI model layers

As seen in the image above, the data link layer uses the services of the physical layer.

In following steps data link layer received bits from the physical layer.

  1. Physical layer accept raw bit stream and transfer to the destination.
  2. Channel may be noisy whether it is Wireless or wired medium.
  3. Physical layer will add some redundancy to its signals to reduce the bit error rate to a tolerable level. 
  4. When data link layer received bit stream, it is not guaranteed to be error free.
  5. It is up to the data link layer to detect error and, if necessary, correct errors.

Now its necessary to know about frame in data link layer.

A frame contains (see the image below),

  1. A frame header contains control information
  2. A payload field for holding the packet
  3. A frame trailer

Data transmitted on a physical link are packed in units of frames.
Control information in frame header means the destination address, the upper-layer protocol in use, the error detection code, etc.

How data link layer know there is error in bit stream received?

  1. Data link layer to break up the bit stream into discrete frames, and for each frame computes a short token called a checksum.
  2. When frame is transmitted checksum is included in it.
  3. When a frame arrives at the destination, the checksum is recomputed.
  4. If the newly computed checksum is different from the one contained in the frame, the data link layer knows that an error has occurred and takes steps to deal with it

This was an usual approach which we discuss above.

Since data are transmitted as raw bit streams in the physical layer, the link layer must identify the beginning and the end of each frame when receiving a bit stream. On the other hand, it must also turn frames into a raw bit stream for physical transmission. This function is called framing. 
For this there are some framing methods too.

  1. Byte count. 
  2. Flag bytes with byte stuffing. 
  3. Flag bits with bit stuffing. 
  4. Physical layer coding violations.

1. Byte count framing method:

The byte count framing method uses a field in the header to specify the number of bytes in the frame.

  1. Data link layer at sender sends the byte count.
  2. Data link layer at receiver counts the byte count. send by sender.
  3. If there is difference between  bytes counts of sender and receiver. There is error in data received.
  4. Else received data is correct.
  5. Above points are shown in diagram below.

2. Flag bytes with byte stuffing framing method:

  1. In this method a flag byte, is used as both the starting and ending of a frame. See in the  figure below.
  2. Two consecutive flag bytes indicate the end of one frame and the start of the next frame.
  3.  If the receiver ever loses synchronization it can just search for two flag bytes to find the end of the current frame and the start of the next frame.

What if accidental unwanted flag bytes occur in the data?

To prevent from wrong flag bytes, escape byte (ESC) is inserted just before each ‘‘accidental’’ flag byte in the data. As shown in the figure below.

The data link layer on the receiving end removes the ESC before giving the data to the network layer.

This technique is called byte stuffing.

What if accidental unwanted ESC occur in the data?

This unwanted ESC is also stuffed with an escape byte (ESC). As shown in the figure below.

3. Flag bits with bit stuffing framing method:

  1. In this method bit stuffing is used.
  2. When sender’s data link layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit.
  3. At receiver end this stuffed 0 bit automatically deleted. As shown in the figure below.

4. Physical layer coding violations framing method:

  1. In this method some reserved signals are used to indicate the start and end of frames.
  2. As they are reserved signals, it is easy to find the start and end of frames.
  3. Here we are using ‘‘coding violations’’ by  putting reserved signals in original data.

Error Control in Data Link Layer:

With positive and negative acknowledgement about a frame.

  1. If the sender receives a positive acknowledgement about a frame, the frame has received safely. 
  2. A negative acknowledgement means that something has gone wrong and the frame must be transmitted again.

What if frame not received by receiver?

  1. Here timer concept is used.
  2. When the sender transmits a frame, it also starts a timer. 
  3. Before expiry of this timer acknowledgement from receiver must reach to the sender.
  4. In absent of acknowledgement sender will again transmit the frame.

What is acknowledgement sent by receiver not reached to sender?

  1. In this case may possible sender sent multiple frames.
  2. To prevent from receiving same frames by receiver sender assign a sequence number to the frame. 
  3. By seeing sequence number receiver identifies that its duplicate frame.

Flow Control in data link layer:

A situation arise when sender wants to transmit frames faster than the receiver can accept them.For example when a slow speed smart phone requests a Web page from very powerful server.Even if the transmission is error free, the receiver phone may be unable to handle the frames as fast as they arrive and will lose some.In such situations two approaches are commonly used:

  1. Feedback-based flow control
  2. Rate-based flow control

1. Feedback-based flow control: In this the receiver sends back information to the sender giving it permission to send more data.

2. Rate-based flow control: In this a built-in mechanism is used that limits the rate at which senders may transmit data, without using feedback from the receiver.