After physical layer which is the first layer in OSI model, the second layer is the Data link layer. This layer takes data from lower layer (Physical) and gives a logical structure to it. This structure includes information about the source/destination address and the validity of the bytes.
This layer has two sub-layers, the Media Access Control (MAC) and the Logical Link Control (LLC). In the next paragraphs we’ll take a deeper look into the details.
Data link layer concepts
Data link layer has several responsibilities, including adding layer 2 headers to the data, transmitting and receiving data frames. Also, this layer is responsible for adding the physical address (MAC) to the packets. Additionally, creating logical topology and controlling media access is another process which happens in this layer.
The Hardware (MAC) address
Every network interface card (NIC) has a unique and predefined address which is assigned by the manufacturing companies and cannot be modified. Media Access control (MAC) is the name of this (Layer 2) address.
The MAC address is 48 bits (6 Bytes) long which is in the format of 12- digits Hexadecimal number. A Hexadecimal uses all digits from 0 through 9 and A to F. Each two digits in a MAC address is separated by colons. Below is a sample of a MAC address:
Different parts of a MAC address
MAC address is composed from two parts. The first 24 bits is uniquely defined to show the manufacturing company and it’s called Organization Unique Identifier (OUI).
The second part is Vendor-Assigned address which is different for each NIC card that is produced. Look at the illustration on the right side.
The Data Link layer can also dictate the logical topology of a network, or the way the packets traverse the media in a network. A logical topology differs from a physical topology. In fact, physical topology is the way the cables are laid out but, the logical topology dictates the way the information flows.
Finally, in Ethernet networks, when two computers use the same media for transmitting, a phenomena called Data Collision might occur. Data link layer provides Token Passing mechanism to eliminate the collision. Token passing uses a special data packet called Token which works as an license card.
Only the station which has this license (Token) in its possession, can transmit data to another device in the network. Otherwise, the station is not allowed to make any transmission and has to wait until the Token is released.