what is the OSI model?

491 viewsEngineeringOther

Something that has to do with the internet, I get this part. But what are those layers? Are they physical?

I also heard the term: layer 2 switch. What is that, is there a difference between this and a normal switch?

What can be achieved using the OSI model?

In: Engineering

7 Answers

Anonymous 0 Comments

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.

You are viewing 1 out of 7 answers, click here to view all answers.