What are TCP/IP or OSI Models?

Ido Magor
7 min readApr 6, 2021

A guide from top to bottom of what is networking and how it works in terms of the TCP/IP and OSI models.

The networking world is quite a fascinating subject if you ask me, it allows connecting every kind of computing device such as smartphones, TVs, computers, IoT, cars, gaming consoles, and many more to each other.

This is actually what the internet is all about, connecting endpoints together and achieving connectivity between each one to give the online experience we have today like watching Netflix, going on a run with Spotify, and again many more…

In the past, I remember that I wanted to understand how all of that works, and I’m still today trying to understand because the world of the internet is so vast and big, so in order to understand every bit of the networking world is sometimes hard to understand even where to start.

Because of that, this post was made to cover the basic understanding of what networking is all about.

We’re going to see what defines networking regarding data flow, communications, routing, applications use cases, and more …

I did make a few posts about networking like TCP vs UDP, and also how the internet works in C/C++, so you can also start there if you wish to but here we will deeply understand the concept of the networking world and its models that define the basic standard of all of it.

A little history

Have you ever asked how the internet came to be?
If you do, the answer is that it started its journey in MIT by J.C.R Licklider, which was a packet switching networking that allowed transmitting electronic data, and that was I think the very major step for the internet as we know it today.

Later on in the 1960s, the ARPANET was invented by the U.S Department of Defense. ARPANET used the packet switching concept to allow multiple computers to communicate on a single network.

After many more events, the World Wide Web which is the world of the web as we know it today also came to be.
Alongside or to be more precise even before came networking communication models like TCP/IP, which described how the networking flow should be done between computers. You can think of those models as best practice rules for the implementation of communications in computers.

Today we have OSI Model and also TCP/IP, which basically sets the standard and describes the flow from top to bottom how computers today communicate.

So what do they do?

Each of them as said before describes how they build the data flow of sending and receiving data over the internet. There are a few differences between them which I don’t wish to get into but I do want to state the fact that TCP/IP is the model being used today, and also I can tell you that TCP/IP is actually a simplified version of the OSI model.

As you see they are very similar but have different layers of format.
The layers of the TCP/IP model define each section what it’s responsible for.

In the Network Access layer, we’re responsible for the physical communication to the cables and also about the first frame of the data, and the most used and popular one is Ethernet. Today there are many more frames that are being used but they are meant for special cases like WAN or serial communications, which we will not cover in this post.

For example, when you’re using WiFi, you’re using IEEE 802.11 protocol standard for the frame of this layer.

If you do wish to further your reading on the subject go read on Carrier Ethernet, HDLC, ATM, LLDP or basically about Data Link layer protocols.

Afterward, we have the Internet layer which is the one that is responsible for routing data from network to network by using the IP(Internet Protocol). This layer is using IP address, usually IPv4 today because there’s also IPv6.

Each computing endpoint(smartphone, laptop, smart TV’s, IoT, more…) has an IP address, and that IP address is being used to route data across the globe.

Afterward again, we have the Transport layer which is responsible to control inside our computer, to which application in the computer that data/packets are going to. This layer does a lot more than that but that’s for the basics for now.

The transport layer allocates a port that signifies a number that an application is listening or sending data to, by that is not all. Today, ports are divided into TCP or UDP ports.

In short, TCP is an expensive connection that is slower than UDP but assures data wouldn’t be lost, while UDP is the opposite. Why use them you ask? Because you have to use a protocol on each layer, but you need to choose wisely for the case that you need for. Also, I highly suggest you read my TCP vs UDP post which is quite detailed about that.

For last and not least, the application layer. This layer is as its name, is used in an application manner way. Today for example, the protocol HTTP is being used to request resources from servers in APIs or web pages.

It’s being also used as a base protocol for other protocols to take place instead like WebSocket for example.

But how does it look?

From the picture, you see an entire packet that is divided into sections. The binary data is the entire packet data, including the layers.

Each layer has its own information that allows an understanding of how to parse the upper layer data and so on…

Each layer of information is stored in headers which are fixed data types in the manner of their value type and size, so TCP/IP knows how to parse them beforehand, and as a result, by reading them he knows how to parse the data itself.

This way, each protocol at each layer allows to understand what is the whole packet is meant for, and by that, the OS knows where to forward the data to be handled.

Can I make my own protocol?

YES WE CAN!

If you wish to create a new application protocol that’s pretty easy.
The reason for that is because you can simply create a UDP/TCP socket and all of the data that is being received in the payload, can be parsed for your own demand.

Do you want an example? Great!
Let’s say that for each payload we define a fixed amount of bytes for our application headers section, and with those headers, we can understand what data is in the payload of the PDU we received from the TCP/UDP connection.

Another is to define a unique string that splits between sections of the binary data in the payload. I personally less like this approach because we’re working with unique values that could sometimes be misunderstood and lead to other problems.

But what about a new TCP/UDP protocol, or maybe even IP or Ethernet?
When we’re reaching those layers we need to add a module that integrates with the OS so the network stack could have the protocol specifications for parsing the binary data properly.

As you understand this is more problematic and harder than a simple application protocol, and I guess by now you understand the meaning of application layer protocols came from.

That name came from the meaning of creating an application that uses the infrastructure in our OS(Ethernet, IP, TCP/UDP) and above that does whatever it wants, or even creates a new protocol that the program defined or uses from a 3rd library or something similar.

In Conclusion

Actually, those are quite the basics and understanding of the TCP/IP model.

I don’t wanna get you mixed up too deep, so I hope you have understood the concept as best as possible.

Today our operating systems come pre-built with protocols inside the kernel which are the standard for world networking as of today, and of course, if a protocol is improved or replaced as a worldwide standard, then the operating system needs to support that as well.

Of course, defining new standards in the world of networking doesn't come or agreed upon that easily because the implications are for multiple endpoints and entities.

I’ve made another post in the past that describes network programming at a high level on the networking part, but the detailed manner on how to develop a networked application in C/C++ so I highly suggest you read that if you wish to further you reading on the manner.

I hope you had a great time reading this piece, and if you have any further questions I would be delighted to answer them.
Also, if you have any opinions or suggestions for improving this piece, I would like to hear :)

Thank you all for your time and I wish you a great journey!

--

--

Ido Magor

My biggest passions are learning and improving each day, in what I do and why I do it.