(ELi5) OSI Model and TCP/IP Model in Simple Terms?

53 views
0

I’m not a computer science student. But I want to learn it and grasp these two models in very simple language and terminology.

In: 7

In the absolute simplest terms, the definition of the OSI model is:

Only something you need to know for an IT certification exam.

The OSI model is a fiction that gets taught to students, which then everyone proceeds to mostly forget because it’s not quite accurate to the real world

The underlying idea is that you structure stuff in layers, and the upper layers don’t really care what’s going on below.

* Layer 1 is the physical layer. That determines how data is actually physically communicated. And this can be electrical pulses, or pulses of light (fiber), or electromagnetic radiation (wifi), or smoke signals. Nothing above really needs to care.
* Layer 2 is node to node communication — if you hook up a machine to another directly with a cable. Ethernet goes here.
* Layer 3 is networking — how stuff gets along a chain from A to B to C to D. The IP protocol goes here.
* Layer 4 is Transport — where you have the concept of a transferring arbitrary amounts of data from A to B. TCP goes here.
* Layer 5 is session — where you have the concept of a constant connection. TCP is also here.
* Layer 6 is presentation — concerned with formatting, compressing and encrypting data. For instance SSL.
* Layer 7 is application — which is whatever you run on top of all of this, like HTTP.
* Layer 8 is the user — not an actual layer, but something you might see people jokingly refer to.

In practice the layers that get talked about is 1, 2, 3 and 7:

* It’s a bad cable (layer 1)
* There’s two computers with the same MAC, or they’re not plugged into the same switch (layer 2)
* IP address is misconfigured (layer 3)
* Something is wrong with the application itself (layer 7)

OSI model – when you have two computers in some network (like, say, the internet) communicating with each other, multiple protocols are involved, most of them building off of each other. We organize these protocols into seven “layers”, with each layer serving a specific purpose:

* Layer 1 – physical – how does the computer interpret 1’s and 0’s from electricity or fiber signals?
* Layer 2 – data link – how does the computer know which machine *it is currently connected to* to send a packet to? (Example protocol: ethernet)
* Layer 3 – network – if the computer isn’t connected to the data’s destination, how does it know which machine to send the packet to so that the packet gets closer to its final destination? (Example protocol: IP)
* Layer 4 – transport – once the computer gets the packet, how does it know which process the data is intended for? (Example protocol: TCP)
* Layer 5 – session – maintains connections
* Layer 6 – presentation – ensures the data is in a readable format for whatever application it’s passed to.
* Layer 7 – application – the actual payload, which can have its own protocols based on what application you’re running. (An example is HTTP)

I’ll mention that since layers 5 and 6 don’t have many big example technologies, a lot of places teach the alternate [5-layer internet stack](https://www.educative.io/answers/what-is-the-five-layer-internet-protocol-stack) instead of the 7-layer OSI model.

TCP and IP are the two most common protocols used in the internet today. IP provides routing, pointing data to the right machine, and TCP names which process that data goes to. TCP is common because it also has the excellent benefit of *guaranteed delivery*. This is extremely difficult to write on one’s own, and TCP is a very complex protocol because of this. Though some applications opt to use UDP, which is a faster and simpler protocol, but which doesn’t guarantee delivery so packets are sometimes lost. Most applications that use UDP can handle a few packet drops.

Let’s say you want to play a game of chess with someone by mail. First, you’d write something like “I got your last move for Turn #3. Now I move my pawn from h7 to h5.” Then you’d put that piece of paper in an envelope with your opponent’s name and address on it. Then you’d take the envelope outside and put it in a mailbox. The postal worker would take it to a sorting facility, then to your opponent’s house, then your opponent would open it rather than another member of his family, and then he’d move the piece on his copy of the chessboard after reading your letter.

The postal worker is the physical layer, actually moving the data from one computing device to another. The sealed envelope itself represents the networking layer with information like the city, state, and postal code to guide the postman in where it should go. The information about the turn number and acknowledgement are the session layer, letting the person who opens the envelope know where this information fits into the overall series of messages, and whether a lost message needs to be re-sent. The text of the chess move is part of the presentation layer, representing a physical piece with a predetermined code for the locations on the board that needs to be interpreted by the reader. Finally, the piece is actually moved, doing something useful to the human player, which is the application layer.

TCP is represented by acknowledging the prior communication and numbering the present communication, so that if any packet is dropped, it will be noticed and re-transmitted. IP is just a means of transmitting packets to a particular destination, regardless of what their contents are, just like an envelope is in the mail system.

A computer is like a whole city of people and everyone has a job to do and relies on the others doing their job. So to get the internet on your screen, computers need to talk a lot to make sure everyone knows what needs to be done and when they should do it etc. But all that talking is very confusing if everyone is in the same room, so some smart people told everyone to go to a separate room, so those who need to talk to each other can do so without being distracted and confused by all the other things going on in the city.

So for OSI they decided to make 7 rooms but for TCP/IP they said 5 rooms are enough. (If you want to make a boomer OSI joke, say something like “I seem to have layer 8 issues, nothing gets done on my computer”, because the user in front of the screen is sometimes called layer 8)

As I said before it’s about getting the internet to your computer.
So you start with the lowest layer (1), being the actual cable. So all the cable people go to room 1.
Like the car mail gets delivered in.

That cable goes to your router. That connection is layer 2. So all the people who deliver mail only in your neighborhood but not further go to room 2. It could be enough to tell them to bring the mail to house number 7 and they wouldn’t need more to know where to deliver it. (MAC addresses)

Layer 3 is for delivering outside of the neighborhood. Now you need to write down the exact address, with zip code etc, because otherwise the mail service wouldn’t really know where to go with the letter. In room 3 people just talk about where things are and how to get there. They are really good at that. (IP)

In room 4 people start talking about how to deliver the mail. Is it important that you get a letter back once your letters arrived, so you can be sure they all arrived in good condition, or is it enough to just send it and hope for the best? (TCP/UDP)

The 5th room talks about the letter itself. What should we put in there? What language should the letter be written in so the recipient understands it as well? Should we use abbreviations, so we can fit more of what we want to say and show? Should we introduce ourselves first? Maybe we should ask if they can send us their favorite poem back, because we got told by the boss (you) that we need to get poems from the person we send our letters to.

In OSI they split up the 5th room/layer in 3 separate rooms.

Here you can see the names of those rooms (might be helpful to read more about specific layers that caught your interest): https://1.bp.blogspot.com/-brz99Xq77EY/WIi6f-eklDI/AAAAAAAAD_g/V1_zENy22dkofjfoYAyaKvj6Z5gYJxDOACLcB/s1600/tcp-ip-vs-osi.png

So next time you have no internet connection (no letters are arriving), you can take one of the models and use them for troubleshooting. You could start with layer 1 for example and check if the cable is actually plugged in. Then you could try to ping your router to see if that connection works, or open the settings page of the router in your browser. And so on.. (it’s probably the DNS server, if it’s not DHCP.. it’s always one of those two in room 5/7, so you might just start there if you don’t regularly unplug your computer)

If anyone finds mistakes, outdated knowledge or anything alike, let me know please, it’s been some time since I learned about those models. Learned that TCP/IP now has 5 layers while looking for pictures for example.