So only the first layer is physical. The rest are software (generally).
To keep it simple, the idea is to break up all the complexities of communicating across wires into smaller building blocks that can be stacked up on each other until you get “I type in google, and google appears”.
So maybe think of it like how we speak to each other.
Layer one is, we make physical sounds. Then we can code some of those sounds into words. Then we can take those words and form sentences, and then we can take those sentences and make paragraphs.
The OSI reference model describes how communication in a network can be encoded in a way where each layer builds on top of the previous layer.
The layers are not physical, they all refer to different kinds of encoding, that are stacked on top of each other. Even the first layer, the physical layer, doesn’t describe what physical medium to use to transport signals, but rather how signals can be encoded such that we can send 1s and 0s despite the actual medium sending analog signals.
The OSI reference model doesn’t describe a specific technology or encoding standard, it only describes an idea of how encodings can be built on top of each other and what purpose each layer should fulfil.
Roughly, it says that the job of layer 1 (physical) is go make sure you can transport 1s and 0s in a way that the receiver can read it. Layer 2 (data link layer) says to structure 1s and 0s into small units (so called Frames), put an address on them so we know which physical network device it is for, and make sure the recipient can error check it (via a checksum). Layer 3 (Network Layer) says to then combine frames into larger units called (called Packets), and put a more organized address on them such that it is clear which logical network device should be the recipient. Layer 4 (Transport layer) deals with methods to ensure packets are transported efficiently and reliably, for example by numbering packages to make sure they arrived in the same order as they were sent..
Layers 5-7 are very high level and deal with what kind of content is stored in these packets and how they should be first assigned to a Session (layer 5), how the actual data should be presented (layer 6), and then finally on top are the actual protocols programmers will write programs for (layer 7).
A metaphor for the OSI framework is to imagine you’re writing an essay
First layer – physical – using a blue ink pen and white paper
Second layer – characters will be written left to right then top to bottom using a 1/4 inch line spacing and 1 inch margins
Third layer – the words will be written using the Roman alphabet, in cursive style
Fourth layer – the language used for the words will be English spelling
Fifth layer – the format will be using sentences and paragraphs using English grammar and syntax
Sixth layer – the essay structure will have a title, introduction, main content and conclusion
Each layer except for the first is an abstraction.
It is just a way of organizing the needed parts of a network connection in a way that makes sense to a broad swath of IT professionals. Of course, if you opened up the hardware you would not find anything called a ‘data link’ layer. That is what we use to describe say…the ARP and deliver to a MAC address. So, above physical (actually plugging the thing in) and below the ‘network’ layer, or the ability to send traffic outside of our local network.
If I am dealing with a developer, they typically don’t care about the first 4 layers, those will be handled by the operating system(s). They need to know about layers 5-7, or session through application. What the user actually touches and the underlying softwares that enable to happen, which are all dependant on the layers below. It is why we use the term ‘layering’, you can’t worry about the session layer if the physical layer is unplugged.
Your other question is a terminology one, all switches work on layer 2, or I should say all *switching* works on layer two. We determine the tool by its function, so if I have a box full of ports that has software that can do routing and I configure it as such, it is a router. The spray paint on the box doesn’t matter, it matters how it is used. Saying ‘layer 2 switch’ is just shorthand I might use to tell another engineer that the switch’s sole purpose is to switch packets, it doesn’t do any routing or anything even if it is capable of it.
On one end, you have some sort of wire or radio signal that is used to give you internet. On the other end, you have webpages, streaming music and videos and other things. In between is a whole lot of complexity of how those webpages, music and videos are requested, controlled and how they get to your computer. The OSI model divides that complexity up into different layers. For example, if you’re listening to Spotify, one of those layers is responsible for making sure that when you listen to “White Christmas” by Bing Crosby, that you hear “I’m dreaming of a” before you hear “white Christmas.” Another layer is responsible for making sure that the music gets to your home network and then, inside that network, another layer is responsible for making sure that the music gets to your computer. And, on top of it all, yet another layer lets you send commands like “stop” and “rewind” back to Spotify.
I am going to go off-model here, but layers are meant as a way of breaking the problem down into different things, and each of the parties doing their thing doesn’t need to care or know about how everyone else is doing theirs.
Layer 1 is generally the physical layer, the actual transport of signals – we’re talking about whether it’s going to be radio waves (WiFi), different kind of radio waves (GSM and all the newer stuff in cellular networks), electrical signals (ethernet over twisted pair), electrical signals (ethernet over coax), electrical signals, but phone lines, visible light (fiber optics, ronja, other stuff still) or even more exotic things.
Layer 2 doesn’t need to care about any of that, layer 2 is about “I need to send some data to a specific thing that is on my network”. That’s where we find MAC addresses – those are identities of devices that are on this network.
A layer 2 switch basically receives a message from one of the devices connected to it that says “this is for device with MAC address such and such”, and all it does is check if it already knows where that device is (on which *port* it is connected), and if not, quickly asks every device it can reach “hey, is anyone here MAC address such and such?”. At that point it doesn’t care about any layer 1 shenanigans, like “oh that one is connected over ethernet, I’ll send some electrical signals ” or “this one talks fiber, better start blinking”.
Layer 3 is the communications both within and outside the network, this is where IP addresses are most commonly used. Again, don’t care about layer 1 or 2 at all – the command is “send this to IP address such and such”, that is handed over to something that finds out the MAC address (and doesn’t care about the information at all) and then issues the L2 command “send this to MAC address such and such” and eventually that becomes “send this data to a specific port”.
Some switches have layer 3 functionality and allow routing between networks, especially VLANs – virtual networks, basically the switch can be configured to treat some ports as one network and others as another – and then do IP routing between those.
Usually it is actual routers that do the layer 3 stuff, though. There’s something called a routing table – a list of IP addresses (more like ranges) and a default address to send anything else to.
Suppose your computer is on a network, with IP addresses in the 192.168.0.X range, with the router having the one that ends in .1, your computer .2 and a printer on .3. Your router would have a table stating anything that doesn’t match 192.168.0.1 has to go elsewhere – that means the “internet” cable going some way out to the internet provider. So if your computer asks to send something to 192.168.0.3, it knows (because the router told it about its routing table) to just find out the MAC address and tell the switch to send it to the printer, but if it wants 8.8.8.8, then it knows it needs to give this to the router sitting at 192.168.0.1 (which is called the default gateway), find out the router’s MAC and tell the switch to send it. The router then will send that out to “the internet” which basically means more routers passing it along until it ends up where it needs to be.
Layer 4 is TCP and UDP (and a bunch of others), which means “I want to talk to a specific program on a specific computer” (specific computer IP and a specific TCP/UDP port (different from switch ports) which corresponds to a program).
For example, port 80 is http 443 is https. So when you ask for a page at http://666.777.11.22/, what is happening is that your computer asks to talk to port 80 on a computer at that address. Once the computer receives this request, it will tell the program “listening” (“subscribing to messages”) on port 80 about your message.
The layers above are concerned with things like how to actually display the data, how to login and other things – that’s firmly between the applications on your computer and the one yours is talking to.
To recap, what you do is (layer 4 and above) tell your computer to access a webpage on a specific address. Your computer requests the page and displays it to you. Neither you nor your browser care much about any details of how that happens, while what happens is (very simplified):
Your browser tells the computer to send a message with your request to an IP address and a specific port (443 for https), as well as a port number it will use to receive the response. Layer 4
The computer finds out that the IP address is not on your network, so it knows it needs to send this message to the gateway (router). Layer 3
The computer finds out the MAC address of the router and decides to send it there. Layer 2.
The computer tells its network interface to send data to that MAC address, which it does (it is an ethernet network card, so it sends a bunch of electric impulses down the cable).
The signals arrive at the switch, which then receives the message to “send this to MAC address such and such”, so it sends a command to the appropriate network interface to do so – at which point it goes down another cable or something else, which reaches the router. The router then reads the layer 3 data (IP address) and sends it outwards towards the “Internet”.
Eventually, your message reaches the target IP address, goes through all those steps many times over and eventually the computer that has the IP address receives the message – and now reads the Layer 4 data (the TCP port) and lets the program (the webserver) that listens to port 443 know there’s a message from an IP address requesting something. The program then simply responds to that message, telling the computer to send a message to the sender’s IP address (and a port number, that the sender agreed to receive the response on). This happens in reverse until eventually your computer receives a message from server’s IP address with the port number that the browser specified it wanted the response on. The computer tells the browser (because that’s what listens to the port at the time) that a message from an IP address has arrived, and the browser then reads it and displays the page you requested.
Other people have expanded on the OSI 7 layer model, but i dont see an answer about the layer 2 switch part, so i will expand on that:
a layer 2 swtich is the “normal” type of switch. the name refers to the way in which it routes incoming packets of data: by using the layer 2 (data link) addresses. This means it looks at the MAC address of the destination devices physical network card, and then tries to send it that way. if it doesnt know where a device is, if “floods” it out of every other port in order to find it, then remembers which way it is when the response comes back though the device.
This works well with a smaller number of directly or nearly- directly connected devices, and is pretty quick in terms of of routing the message, but if you have a big network of devices with lots of devices, it can get unmanageable or slow, or you end up with a switching loop where several switches can send traffic in a endless loop between themselves, never reaching the destination and slowing down the network.
The best way to avoid this problem is to “break up” the network with devices that route off the IP address (layer 3), like routers, which don’t pass on these broadcast messages.
However, their is such a thing as a layer 3 switch, which uses the simpler switching protocols, but with the IP address instead of MAC address. these might be used in certian network configurations for various reasons
Latest Answers