Layer 2 of the OSI model — the data link layer — governs how data frames are addressed and transmitted within a local area network, covering key protocols such as Ethernet, wireless LAN, and point-to-point protocol. This content explores LAN fundamentals, layer 2 addressing, the relationship between OSI layers 1, 2, and 3, and the IEEE 802 standards framework.
Layer 2 Basics
From an OSI standpoint, we find layer 2 snuggled right in here between layer 1 and layer 3. We call this the data link layer. Some examples of layer 2 protocols would be Ethernet, ATM, and frame relay. The information that's sent across is sent across in what we call a frame, so the protocol data unit is called a frame. In most of these cases, or at least in an Ethernet case, we have both a frame header and a frame trailer, and there's different information in both that header and that trailer. But here is layer 2, the data link layer.
A LAN is a local area network. So it is a network. It's a network of machines, it's a network of nodes, and the key to this is it's local. But what is local? For instance, let's just say you're inside a room and you shout out and say, "Hey, Andrew." Now, whoever's going to hear you is going to be local. It's going to be somebody nearby. It's going to be the people within that room. And so when this message, "Hey, Andrew," goes out, everybody hears that. It gets sent out to everybody. And so that's local.
Now, from a computer's perspective, local doesn't necessarily mean that it's all geographically in one location. Local could be clear across the United States. But the key to this is what is communicating at a layer 2. So a local area network is the network which communicates with the same protocol at layer 2, and that layer 2 doesn't go beyond the outside of that network. So in this example right here, everything on this side of the router is the layer 2 network, or everything on this side of the router is the LAN. Now generally speaking a LAN is local even geographically, and it is, but when it comes to your ISPs they have much larger LANs. But the key to it is, once again, if a device speaks or talks that layer 2 language, the devices that can get to that layer 2, that can get to that communication, that can get to them — that is the layer 2 network, or the LAN.
Now, let's talk about addressing, because when we send this information out, somebody needs to be able to receive that. But how do we get information to that receiver? Well, we're going to have to have some sort of address. Now, in this example right here, I'm using MAC addresses, because we're going to get more into MAC addresses, but MAC addresses don't apply to every single protocol that's out there. In fact, a lot of the protocols aren't going to use MAC addresses at all.
So in this example right here, rather than saying "Hey, Andrew" and all the Andrews in the room recognizing that's to them, in this case right here this machine right here is trying to talk to this server over here. And so when it sends out this information, it's going to be sent to the address of a a bbC. And so that information leaves this computer destined with this address in mind. And one of two things could happen: this could be a switch, and then it could forward on to this direct address right here and then that computer gets it, or possibly it's sent out to all machines. But the key is, if it is sent out to all machines, then each machine is going to take a look at that address and say, is this for me, and determine yes or no. And only this machine is going to see that the address in the destination of this frame is itself. And so only this machine right here is going to listen to that and then take that frame in and start unraveling what that message is and what that message means.
There's quite a few layer 2 protocols. We're going to be talking a lot about Ethernet, or IEEE 802.3. But just because we're going to spend a lot of time on that, realize that there's still other common protocols out there. Point-to-point protocol is still a very commonly used protocol out there that's used largely in conjunction with other protocols. But we also largely use wireless LAN. We will be talking about wireless LAN technology, or IEEE 802.11. There's also wireless PAN, and so the wireless personal area network is a common protocol that's out there. We also have HDLC, which is high-level data link control, and then we have frame relay, which is not used as much nowadays as it used to be used. But there are lots of layer 2 protocols. So even though we're going to focus largely on Ethernet, and we'll talk some about wireless LANs as well, just realize that there's lots of layer 2 protocols that are out there, and they each look a little different, or could possibly look quite a bit different.
We're going to get a little more into some of these protocols, specifically the IEEE 802. IEEE is the organization that sets up a lot of these different standards, and the 802 is the specific standards that come along with LAN technology. So IEEE 802 defines what a LAN looks like, and there's several protocols that fall into this. I've listed out the three most common ones here. So that would be 802.3, which defines Ethernet. There's a lot of sub-standards to this as well, so there's a lot of categories underneath this, but the 802.3 defines what Ethernet looks like. 802.11 defines what a wireless LAN looks like. So when it comes to wireless technologies, a lot of this falls into this wireless LAN here. Um, and then we have 802.15. And the 802.15 defines what the wireless PAN networks look like. And there's once again lots of different protocols in here. One example of this would be Bluetooth. Bluetooth is defined within this 802.15 and it's a wireless personal area network. So here are a few different LAN protocols that are used and defined by IEEE 802.
The fact that these lines could be different media along the way really gives us a lot of option worth with this communication, and it allows these networks to be much more dynamic. One of the keys to this: layer 2 and layer 3 behave very differently. They both have addresses and they both have destinations where they're trying to reach to. From a layer 3, the source, which is this computer right here, and the destination use a layer 3 address to get that information from one point to another. So, for the most part, when that communication — when you're asking for a web page, or it's going out to some server to get some sort of service — what's happening as it traverses these networks is that layer 3 essentially stays the same throughout that journey. There are exceptions to that, but essentially that layer 3 remains the same to go from point A to point B. But that layer 2, something interesting happens, because we've got different media along the way: that layer 2 will change as it goes.
And so in this example right here, this computer, as it's talking, it's talking on this — let's say this is an Ethernet LAN right here. And so how it's going to get to its end destination is it's going to use a MAC address to get to this router. That router is going to see the MAC address and realize that that is the MAC address that's assigned to that router. And so the router is going to recognize this frame was meant for me. And then it's going to determine, okay, since that frame is meant for me, I no longer need my layer 1, layer 2, so I'm going to throw that away. I don't need that anymore. I'm going to take a look at the layer 3 packet and determine what I need to do with that layer 3 packet. So, it's going to process that layer 3 packet. And then it's going to realize, oh, I need to send this to another router, and I have a point-to-point connection with this other router. And so what I'm going to do is I'm going to now read a different address to it that's going to be destined to this router right here. I'm going to repackage it to go across whatever media this connection happens right here. And so it's going to put a new layer 2 and a new layer 1 on there and send it across this link to get to this router.
That router is going to do the same thing. It's going to take a look at it and take a look at the layer 2 address and realize that this layer 2 address is destined for itself. And so it's going to need to take that packet in, or that frame in. It's going to get rid of layer 1 and layer 2 because it no longer needs that information. And then what it's going to do is it's going to process the layer 3 and realize, okay, I need to send this to this router, that's the next hop along the way. And so I'm going to then repackage, put a new layer 2 and a new layer 1 with a new layer 2 address that's going to be destined for this router. And I'm going to send it out this interface towards that router. So it sends it along this way. This router gets it, takes a look at it, and says, "Oh, I'm going to take a look at that layer 2 address. That layer 2 address is destined for this router right here. So, I no longer need that layer 1 and layer 2, so I'll rip those off." And now it's going to process that layer 3, realize that it needs to go within this network right here to this machine right there. And so it's going to add a new layer 2 address of this machine right here, and a layer 1 as it goes across into the media, and send it to this end destination. So the layer 2 is going to be changing all along every single network along the way, versus the layer 3 is going to remain the same.
One thing to note about this too is there could be lots of different layer 2 devices within these, just like this switch exists within this Ethernet realm right here, this Ethernet LAN right here, and it gets information to multiple devices. There could be lots of different devices on these networks as well. Probably are lots of different networks along these different layer 2 networks within here. And so there is some switching that could be happening in these layer 2 networks that are in between these routers.
In the OSI model, we have seven different layers. And so a lot of our protocols fall into this. They have a physical layer and a data link layer that operates separate from each other. Within that layer 2, or that data link layer, it has some sort of address which gets sent off to the next hop, and then the physical layer is then assembled so it can go across that media. Now when it comes to 802, or IEEE 802, that defines LAN technologies, a lot of our more modern protocols that are defined under this LAN technology operate a little different, and because of that our TCP/IP model simplifies this model to only four layers. Specifically, the network access layer takes the place of these two, the data link layer and the physical layer, and so it's broken down a little differently.
Diving further into layer 2 versus layer 1: here on the left hand side, we see our different OSI layers. We've got the network layer, which we know this is the layer 3 right here. And we have a lot of different protocols that will operate within there. The main one that we're using is IP. Then we have our data link layer, so this is layer 2 right here. And then we have our physical layer. So these are the first layers, layer 1, 2 and 3 here. But our data link layer is actually broken into two different sub-layers. We got the LLC and we got the MAC sub-layer. So we've got these two different sub-layers to it.
Now the key to this is, once again, we have the IEEE 802 which defines what a LAN looks like. And in here we have 8 IEEE 802 that defines what the LLC sub — and then it further gets broken down into 802.3, which defines the Ethernet protocols. We've got the wireless LAN protocols, which are defined by 802.11. And we've got the wireless PAN protocols that are defined by 802.15.
Now as we get a little even deeper, then 802.15.1 is the standard for Bluetooth and how Bluetooth operates. 802.15.4 is the ZigBee and how the ZigBee protocol operates within wireless LANs. We have lots of different ones. I've just outlined a few here, but this includes 802.11b/g, or 802.11n, or 802.11ac. So they're just variations of the 802.11 wireless LAN protocol. And then we've got Ethernet, which is defined by a ton of different sub-protocols to this. So I've got listed out here 802.3I, 3U, 3AB, 3AE, 3B Q. So a lot of these different ones that will define how information is transferred across this. And so this 802.2 and this 802.3 will work together to define how Ethernet operates, or this 802.2 and 802.11 will define how wireless LANs operate. So this 802.2 and 802.15 define how wireless PAN is going to operate. So this is how the LAN technologies are broken out, or how the IEEE 802 different LAN protocols operate both on that layer 1 and layer 2.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →