Table of Contents
The Data Link Layer
Let us try and understand the next layer of the OSI model, the Data Link Layer.
If you haven’t read the first part yet, please read it before going through this!
Let’s Dive in!
THE DATA LINK LAYER
As the name suggests, this layer is responsible to bind data given from the layers above and pass it to the physical layer for further actions.
Please note that, data at this layer is typically referred to as a frame; a frame of data. Every layer has data getting generated/manipulated into a form the lower layer understands and thus is uniquely identified.
Roles and Responsibilities of the data-Link layer
- Flow Control:
Flow control, as the name suggests is to control the flow of data. Please look at this logically, a sender needs to send data at a rate the receiver can accept and process this information. It makes no sense to flood the receiver with information; at this point it would mean junk to the receiver; it’s like they say, ‘Don’t bite off more than you can chew’. It is just bad (for both us and the machines) and thus, this layer governs the flow control and governs the rate at which data is being sent into the network.
How is this enforced?
There are several protocols and mechanisms in place that are employed by Layer 2 devices to enforce flow control. A brief of the two commonly used ones will be touched upon
- Feedback-based Flow Control.
- Rate-based Flow Control.
Feedback-based Flow Control
As the name suggests, this technique relies on a feedback mechanism. The receiver sends out an ACK, before the next set of frames can be pushed down to the physical layer. It is important to understand that, this mechanism can be accomplished in different ways and for this very reason there are many protocols to enforce this mechanism. It is up to the Layer 2 device vendor to enforce any one of the protocols available.
The two main protocols are
- Stop and Wait Protocol-> Sends out one Frame-> Receives an ACK-> Sends out the next Frame-> This happens until EOC (End of Connection) Frame.
- Sliding Window -> Supports transmitting multiple frames before waiting for an ACK from the receiver.
Both these protocols have their own Advantages and Disadvantages which is currently not in the scope of this article.
Rate-based Flow Control
Not a commonly used technique, but it is worth mentioning at this point. The rate based flow control is still a topic that is put under the scope and extensive research is on-going; primarily to manage data traffic using this technique.
The concept is to send data at a defined rate not expecting any ACK (acknowledgement) from the user. This rate is configured beforehand on both the senders and receivers end.
Note: The contents of the frame will be different, based on the protocol and technique used. More information on frames and headers can be found below.
2. Framing
The next responsibility of the DLL (data link layer), is to convert the data sent from the layer above into frames.
What is a Frame?
A frame is a collection of data, holding information relevant and useful for the transmission of data. It is imperative that there is a structure to construct this; a generic one that is well understood by the receiver as well.
What constitutes a Frame?
Typically, there is data that is pushed from the layer above and it is the responsibility of the DLL to make a frame out of it . This is to add headers and trailers (this again varies depending on the technology employed at this layer ex; Ethernet, VLAN, Spanning Tree etc.) pack the data and send it below.
Within the header, the source address and the destination address is stored. The data is sent from the layers above; the trailer contains information that helps in Error checking.
In addition to this; the frame also contains a Flag field at the beginning and at the end to indicate the Start of Frame and the End of Frame. This is especially useful when multiple frames are transmitted at a time and the receiver needs to differentiate between one frame and the other.
At this point; it is also worth discussing the two types of framing concepts employed .
- Fixed Frame Size.
- Variable Frame Size.
Both these framing techniques have their advantages, disadvantages and use cases driven decision based on which they need to be chosen. It completely depends on the use case and network data handling that will help us decide one or the other.
Too much theory?… I believe it is..
Let me try and give you a C snippet that takes care of this framing Just to give you an idea on how network device level coding could be done .
Note: This is just an example on what could possibly be the way it is implemented; in no way am I saying; this would definitively be used in L2 devices to do the same!
main()
{
Typedef struct{
Frame_type type;
int header length;
int data_from_network_layer;
int source add;
int dest add;
Bool CRC_FLAG;
} Frame_Parameters;
Frame_parameter.type -> Ethernet_Frame
This is an example of how the frame could be constructed. Please note that; the size of the fields vary depending on the technology employed.
3. Error Handling
The physical layer as discussed is a raw transmission medium that would simply convert these frames into the appropriate bit format and push it into the stream. Having said this, it is up to this layer to add appropriate error check mechanisms to transmit data securely.
What is communication without reliability?
Thus, this layer incorporates certain error check mechanisms, to ensure that the correct data has been received by the intended receiver. We will discuss a few error handling mechanisms in brief.
Errors can be in the form of a single bit error by means of a bit flip or a multi bit error. This can be due to interference or noise in the physical channel. This can even be an intended hack, thus in order to mitigate this, there are checks in place to ensure correctness and accuracy of data.
There are three main error occurrences
- Single Bit Errors
- Multi Bit errors
- Burst Errors
The in depth analysis of each of these error types will not be discussed. To carry on with the rest of the OSI layers; it’s sufficient to know the existence of such problems.
There are plenty of mechanisms in place to mitigate these errors and ensure secure and accurate communication of data. To touch up on what is actually done; there are error correction mechanisms and error detection mechanisms. These two mechanisms help to do a diligent and accurate transmission of data.
4. Access Control
In a network; seldom is the case wherein only two entities are connected to each other via a medium. Hence, there would be more than two devices connected and point to point communication may not be the case at all times.
Numerous devices exchange data in the network and it is the responsibility of a L2 device to ensure a time slot for its data to be pushed into the stream without colliding with other data units already flowing in the stream.
This is thus, another important responsibility of the L2 device.
There are various protocols in place to govern this link access as well and this would be beyond the course of this article as it is a vast topic by itself.
5. Addressing
The physical addressing of the hardware is done at this layer and the layer needs to support that. It is important that in a network, the address of your device is unique and that ensures the correctness in reception and transmission of data. Usually the hardware address is fused in, by the manufacturer. This is the layer that holds the MAC address (Media Access Control) of the device which is a unique address given to the device by the manufacturer. More on this later..
This brings us to the end of the responsibilities withheld by the data link layer in the OSI framework.
You can stop reading at this point; but if you want some additional information and possibly a complete real world take away from the DLL, please read further!
Summary
Roles and Responsibilities of the DLL are
1. Flow Control.
2. Framing.
3. Error Handling.
4. Access Control.
5. Addressing.
MISCELLANEOUS CONTENT
Devices operating at this layer
- Bridges.
- Switches.
Bridges
They are useful Layer2 devices used in the OSI framework. The bridge is slightly more sophisticated in comparison to what a repeater or a booster could do at layer 1. Bridges have the intelligence to route traffic based on MAC addresses (As discussed in addressing), how does this really help?
This helps solve quite a few problems actually. This reduces traffic by a considerable margin and in addition
1. It creates moderate separation of network due to its filtering capacity.
2. It can connect entities having dissimilar network architecture.
3. Interconnect two LANs creating different collision domains.
4. It improves the overall bandwidth utilization in a network.
Ultimately, its primary function would be to filter based on MAC addresses. The device permits broadcast messages; it would create something similar to a look up table called as bridging table to learn the location of the MACs in the network for future reference.
Thus, the frames that we earlier discussed would have the destination MAC embedded in it which would be inspected by the bridge to further route it. If it does not find the destination MAC in its connecting network it will simply drop the packet. In a nutshell this is the functionality of a bridge.
There are two types of bridges
1. Transparent Bridges –> Connects networks with same underlying network protocol.
2. Translating Bridges –> Connects dissimilar network protocols.
More on this in another post.
Switches
Switches are another DLL device that value adds in the framework. It is capable of performing some basic error checking and appropriately routing packets to the right destination based on MAC addresses.
Switches are devices that are used to connect multiple devices together and create a network. It has some intelligence to it and therefore reducing redundant load in the network. Though it may receive inputs from multiple input ports; it decides to push out the data only through the desired output port.
Switches can use hardware such as ASICS (Application Specific Integrated Circuits) for its packet switching and thus it is a combination of hardware and software that achieves the functionality here. This is different in the case of bridges wherein it is strictly a software driven solution.
There are different types of switches again based on the functionality and its usage
1. Unmanaged Switches
2. Managed switches
3. LAN switches
4. POE Switches
A short video on packet tracer demonstrating how you could connect a bridge and a switch together can be found below ; feel free to play around in packet tracer. A good place to build your own network and try things for free!!
A video demonstrating how bridges and switches can be used in packet tracer.
This brings us to the end of this article.
As always feel free to reach out in case of doubts and leave a comment if you liked it 🙂
Thank you for reading!