The OSI model defines how data is packaged, addressed, and transmitted across networks — from application-layer requests down through transport, network, and data link layers to physical signals. Each layer adds or removes specific information as data moves between devices on different network segments.
OSI Model in Action
I created a little network in Legos to help illustrate the point of the OSI model and how it's used.
Here's our network all laid out. On one side we have a local area network — all of these laptops that are communicating on this local area network, as well as this router that is on the edge of it. So this is one local area network over here. Over on the other side we have another local area network. Both these local area networks speak Ethernet, by the way.
This one right here is a laptop, and I'm going to host a website off of this laptop. So I install Apache on it, and Apache is what I use to host this website. Now we have a machine that actually wants to access this website over here. What needs to happen is that this machine needs to communicate across these routers — we've got router 1, router 2, and router 3 — to this local area network on this side.
So it's going to go through the process of resolving and figuring out what the IP address of this machine is. The IP address is 1 192.168.57, so we have that IP address over here. We need to route information from this machine, which is requesting those web resources, from this machine, which is hosting those web resources.
We have data that needs to be requested. The data is going to be sent from this laptop over here, across the routers, to this laptop, and then there's going to be a response, and so a different set of data is then going to be sent back. Of course we have to make a connection here, and when this data gets over to this server it's going to need to be routed to the proper program, which is Apache. The program over here, Apache, is tied to port 80. So there's some information that we need to get over here, and we need to address that specific service right there.
What we need to do is put a TCP header on this. This TCP header is going to be additional information that's going to be carried over here so that it can get to the proper service, which is port 80. So we've got that information in here — that it needs to hit port 80 — as well as quite a bit of other information in this TCP. We're going to encapsulate the data with this TCP header, that additional information.
The other thing that needs to happen is this needs to be routed from router to router, because there could be many networks in between. So it needs to be able to route to this IP address. What we need to do is also attach the IP address to this. This is the IP header, and there is additional information in this header, but for now we're just mainly concerned with this IP address. So we're going to encapsulate the data and the TCP with this IP header here, and that's going to be the information that's needed to route to this final destination.
But the first step is that this laptop needs to send the information to this router. That's the first thing that needs to happen, and it needs to have some local addressing here to be able to get it to the router. The local addressing is the MAC address. The MAC address of this router is AB 2C1244 F112.
So we've got that information that needs to be sent there. What we do is we have the Ethernet frame right here that needs to be added to it — the Ethernet header needs to be added to this, we need to encapsulate it with the Ethernet information. The Ethernet information actually spans multiple layers, so we've got layer 1 and layer 2 all wrapped up into this. By the way, this is layer 3 and layer 4: layer 3 is the IP and layer 4 is the TCP.
So we've got this additional information, and the information is the MAC address, so it can be delivered locally to this router, as well as the layer 1. Layer 1 has some signaling to get the communication started, and it starts out with a bunch of ones and zeros. I represented this by some ones and zeros here. This is kind of like a wakeup signal to get devices on this network listening. So I've got this layer 2 and layer 1, and I'm going to attach this to my data as well, so it can be sent over.
Now this laptop can send this information over on the local area network to this router. This router receives this information and it can take a look — once again, the preamble here is like the little wakeup signal — and it says, is this my MAC address? And it says, yep, that matches up, that's my MAC address. So now this layer 1 and layer 2 has done its job, it's no longer needed, so it takes this information and gets rid of it.
Next what it needs to do is take this IP address and figure out what the next hop is. So it goes through the process of figuring out where it needs to route this traffic, and it figures out it needs to go to router 2.
With router 2, the connection between these is a little different type of connection that we've set up between router 1 and router 2 — not an Ethernet connection, but a point-to-point connection. We're using point-to-point protocol. This is a protocol that is many times used between routers like this. It's just point-to-point, so there are just two devices on this network. It just needs to send out essentially a broadcast to the other side, so this other device receives it, which is all ones in the case of point-to-point protocol.
So we're going to attach this point-to-point protocol to this. This is the layer 2 header, so that when it gets over to this other destination, router 2, then it will be able to see where it's come from and be able to process that packet.
But it's going across this link right here, which is physically set up as an ISDN line. I don't want to get into the specifics of what an ISDN line is, but that's the layer 1 technology going between these two devices. The layer 1, the ISDN, starts out with a series of ones, so I've got this represented here, and that's the preamble, kind of the wakeup signal. So it attaches this now to this, and now we've got our new layer 2 and layer 1 here. Then it can be sent over to this router right here.
That router is going to take a look at the layer 1 and say, is this for me? This is being sent over, and it's woken up, and so yes, it gets this and it says, I need to process this. It takes away the layer 1. The layer 2 now, right here, the point-to-point protocol, says, is this for me? It says, yeah, this is for me. So now it no longer needs this.
Next it needs to take a look at the IP address and see where it needs to be routed next, and it determines it needs to be routed to router 3 here. The connection that we've set up between router 2 and router 3 is an HDLC connection, so now we've got this HDLC protocol that's set up between these two routers. It's a much different protocol. Here's the address to it — we've got some sort of address marking on here — and it needs to address this router 3 right here. So we're going to take that HDLC and encapsulate our packet with it.
But we also have that layer 1 connection across there, which is an RS-232. So we've got the RS-232, and what starts the RS-232 connection, and we're going to attach that here and send it across. It's going to physically send that across now to router 3.
Router 3 has this now. It takes a look at the RS-232 and does whatever it needs to do with that, and does away with that because it's no longer needed. It's got the HDLC; it makes sure that it's addressed to router 3, and sure enough, it is. It sees the 192.168.57, realizes that that is a directly connected network and needs to send it to this device.
This LAN over here is using Ethernet, so it needs to form a new Ethernet frame right here. We've got the Ethernet information; this operates on both layer 1 and layer 2. It needs to determine a MAC address, and the MAC address of this laptop over here is 34 1 F 7 A 61 BB 4B. So there's the MAC address of this machine over here, and it needs to put that MAC address in this Ethernet frame. Of course it's got the preamble as well, the little wakeup signal. It attaches this to this packet right here — in fact, I'm going to flip that around — and then it sends it into this network to be delivered.
The switch then delivers it to that MAC address, so it gets here. This computer will take a look at this and say, okay, I need to process this. It says, oh yeah, this is destined for me. It no longer needs that layer 2 information. It takes a look at the IP, processes the IP, which does several different things, but the main one is, hey, is this my IP address? Sure enough, it is. It takes a look at the TCP right here; with the TCP it looks at the port and says, I know which port this is associated with, this is associated with Apache. So now I'm going to send my data to Apache so that Apache can process it. The Apache program processes this data, realizes it's a request for some web services, and starts forming the reply back, and then the reply happens so that the information can get back to this laptop.
So that's how the different layers are. We've got layers 5 through 7, the application layer. We've got the TCP, which is layer 4. We've got the IP, which is layer 3. And then we've got layer 1 and layer 2, which could be Ethernet, or it could be these other protocols that I showed here — HDLC with RS-232, or ISDN and point-to-point protocol — or perhaps we could have any one of a number of these different configurations. Once again, these layers can work together to provide all this communication back and forth, and we would choose which protocols we would use based off of what's available to us, and what technologies, and what we're trying to accomplish.
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 →