Data link layer has several functions to perform they are providing a well defined service to the network layer, determining how the bits of the physical layer are grouped into frames, dealing with transmission errors, regulating the flow of frames so that slow receivers are not swamped by fast senders, and general link management.
Services provided to the network layer:
The principal service provided by the data link layer to the network layer is the transmission of data from the source network layer to destination network layer. This can be accompolished in 3 ways:
Unacknowledged connectionless service consists of having the source machine send independent frames to the destination machine without having the destination machine acknowledge them. This is used where the re is a very low chance of transmission errors.
In Acknowledged connectionless service the source machine send the frames indepenedently to the destination machine, but with acknowlegement to each and every frame from the destination machine.
In connectin oriented service a connection is established between the source and the destination until all the data is transfered.
Framing:
In order to provide service to the network layer data link layer must use the service provided by the physical layer. Physical layer deal with transmission of raw bit streams from the source machine to the destination machine. The number of bits recieved by the destination machine may be less, more or equal it is upto the data link layer to deal with. The usual approach is to break the bit stream into discrete frames and compute the check sum for each frame. When the frame arrives the destination machine, it computes the check sum again if the newly computed checksum is different from the old one an error has been occured and the data link layer takes necessary steps to deal with it.
The following methods are commonly used for calculating the check sum:
Error control:
Data link layer also deals with the delivery of all frames to the network layer at the destination. The usual approach is thats the destination giving a positive or negative acknowledgement after the delivery of each frame. If the sender recieves a positive acknowledgement it assumes that the frames has arrived correctly at the destination, a negative acknowledgement means that something has gone wrong, and the frame must be transmitted again.
An additional complication comes when a hardware touble may cause a frame to vanish completely. In that case the reciever will not react. This case is dealt with by using timers. When a frame was sent a timer will be started for each frame, if the acknowledgement was not recieved before the timer turn off, sender assumes that there was some problem, and retransmits the frame. When the frame or acknowledgement was lost it will alert the sender to retransmit the frame, which will cause a potential problem of sending the same frame multiple times. This can be dealt with by using sequence number to each frame.
Flow control:
Another potential problem is how to deal when a sender transmits the frames faster than the reciever accepts them. The usual solution is to introduce the flowcontrol to throttle the sender into sending no faster than the receiver can handle the traffic. The throttle generally requires some kind of feedback mechanism, so the sender can be made aware of whether or not the receiver is able to handle the frame.
Physical layer
Network layer
Transport layer
Session layer
Presentation layer
Application layer