The data link layer is layer 2 of the OSI model. The purpose of the data link layer is to establish a connection between two devices. Unlike the higher layers, the connection that is established is a physical connection, not logical.
As mentioned in the data flow of the OSI model, layer 2 on the transmitting device communicates with the layer 2 of the receiving device. This connection must be established first before the other layers of the OSI model can communicate with each other. If there is a device that operates higher than layer 2 on the OSI model (such as a router) in between the source computer and destination computer, the devices will establish a connection with each other at layer 2. For example, say that you have a home router and have two computers connected to it. The source computer will first establish a connection between itself and the router. After the connection is established, the computer sends a chunk of data from the higher layers to the router. The router then establishes a connection between itself and the destination computer. Once established, the data is sent to the destination computer.
Layer 2 is one of the most overlooked layers of the OSI model, but is very important. The purpose of layer 2 is to provide these key things over a network:
1. Establish a physical connection between devices over the same medium
2. Provide a way to cross data over different medium and topology types
3. Provide a way to identify individual devices over the same medium and communicate directly
4. Ability to check for data errors or collisions and resend if necessary
Layer 2 can be subdivided into two categories: Logical Link Control (LLC) and Media Access Control (MAC). Looking at the list above, LLC is pretty much point 4 while MAC handles 1 – 3. LLC is more software and specifications. There are a lot of protocols that fall into LLC. Examples would be CSMA/CD, wireless encryptions such as WEP and WPA, as well as how to handle tokens in FDDI. I will discuss some of these in later posts.
While layer 1 handles the specifications of wires and connectors, layer 2 handles the devices that interfaces with wires and connectors. MAC consists of rules and circuitry needed to do this. Does MAC sound familiar? It should. Every device that operates at layer 2 or above has a MAC address, also known as a physical or hardware address. A MAC address is a 48 bit, 12 hexadecimal address that is used to identify a device. An example of a MAC address would be A1:24:CD:5F:97:EE. This address is divided in half. The first six identifies the manufacturer. An example would be that all MAC addresses beginning with 13:12:54 is reserved for company X. The other six is used to identify the individual devices. Just like in life, there are rules that need to be followed for MAC addresses:
1. The transmitting device must know the receiving device’s MAC address
2. Every device on a network needs a unique MAC address (if two devices have the same one, there will be problems)
3. If there is a layer 3 device (or above) between the source and destination computers, the device replaces the source computer’s address with its own
I know rule three might be confusing, so consider this scenario. Let’s say that source computer’s MAC address is 11:11:11:11:11:11 and destination computer’s MAC address is 44:44:44:44:44:44. In order to get to the destination, the data needs to first go through a router. The router takes 11:11:11:11:11:11, and replaces it with 22:22:22:22:22:22 (it’s own.) Then the data needs to then go through another router. The second router takes the 22:22:22:22:22:22 MAC address and replaces it with 33:33:33:33:33:33 (it’s MAC address.) The reason for this is because there is a connection established between the source and router, another connection established between the first router and second router, and another connection established between the second router and destination. THE DEVICES CONNECTED DIRECTLY WITH EACH OTHER NEEDS TO ESTABLISH A LINK WITH EACH OTHER, SO THEY NEED THEIR OWN MAC ADDRESS.
Another thing to understand is that layer 2 switches/bridges have their own MAC addresses. However, they ‘switch’ a link between devices. They do not ‘establish’ a link. So, they do not replace source devices’ MAC addresses with their own. They do have their own MAC addresses, but they are mainly used in order to remote into them. I will discuss switches and bridges in more detail in another post.
If a source device does not know the destination’s MAC address, the source sends out a broadcast. The broadcast address is FF:FF:FF:FF:FF:FF. All devices on the medium listen to the broadcast request. The destination device (determined by a higher layer) sends the source device it’s MAC address. All other devices who heard the broadcast will remember source and destination MAC addresses so that they have them for later use.
Layer 2 data (PDU) is called frames. A frame embeds itself in the beginning and ending of data being sent. The beginning of the frame is called a frame header. The ending is called a frame trailer. Frames typically have the source MAC address, destination MAC address, error checking, length and frame type information. This is one of those things I will not go in detail in. If I were to go into detail of every little thing, the OSI model series would probably take about 10,000 posts ;p.
So, what are layer 2 devices? A device is a layer 2 device when either it makes its decisions on layer 2 only or it is used to interface with a medium. I already mentioned switches and bridges being layer 2 devices. Another important device is a Network Interface Card (NIC). A wireless card is a type of a NIC. NICs are also known as a network card. These can either be installed internally in a computer or plugged in a computer externally, usually via USB. Other devices such as routers and servers can have network cards installed in them as well. Usually, a device is only considered to have a network card installed in it if the card is removable. Otherwise, it is not really a card, but integrated in the device.
LAB: Finding your network card’s physical address
As I explained earlier, layer 2 devices have their own MAC address. NICs have MAC addresses as well. In order to find it (in Windows XP,) click on the ‘start’ button and go to the control panel. If in ‘category view,’ switch to ‘classic view.’ Double-click on ‘network connections.’ Next, you should see an icon or icons representing your network connection. If your computer is plugged directly in your network, it should say ‘Network Connection.’ If wireless, it should say ‘Wireless Network Connection.’ Double-click on the connection. Your connection status window should appear. Click on the ‘support’ tab. Next, click on the ‘details’ button. In the network connection details window, you should see ‘Physical Address’ listed.
Resources:
http://www.tcpipguide.com/free/t_DataLinkLayerLayer2.htm
http://compnetworking.about.com/od/networkprotocolsip/l/aa062202a.htm
http://www.dummies.com/how-to/content/how-to-find-your-laptops-mac-address-in-windows-xp.navId-323042.html
Join the forum discussion on this post
