DEV Community

Quame Jnr
Quame Jnr

Posted on • Edited on

Computer Networking - 4-Layer Internet Model

Introduction

Computer network is made up of nodes connected by a link with the nodes being the devices that can receive and share data and the links being the conduit by which these data are being transmitted. The largest network is the internet.

The internet is pretty ubiquitous these days. Matter of fact, if you’re reading this, it is because of the internet. When you type in google.com or dev.to you are communicating with another computer out there. So how exactly are you doing that?

To help us understand, let’s use the 4 layer internet model. This is basically different layers of abstractions with protocols that helps us to communicate with other computers. Protocols in this sense is set a rules that governs our communication, it guides how we communicate, what we communicate and when we communicate.

The 4 internet layer model is an abridged version of the former Open Systems Interconnection (OSI) model. You can read more on that but some of the layers have been fused into one to create the 4 layer model which is made up of the application layer, transport layer, internet layer and the network layer.

Image description

Bottom-Up Approach

Let’s look at this from the bottom up, starting with the lowest abstraction which is the network layer.

Network Layer

The network layer is only responsible for carrying your request from one node to another until it reaches its location. The network layer does not know where the request is going or coming from, all it does is to move the data it is given through the network.

💡To observe this, you can type in traceroute [google.com](http://google.com) on your computer terminal and you will see the IP addresses of all the nodes your packets hops to and from before it gets to the node google.com exist. This will show you the pathway of your IP packets.

So the question then arises, how then does the data know if it has reached its destination. This is where the internet layer comes in

Internet Layer

The internet layer uses a protocol know as Internet Protocol (IP). It breaks the request down to small parts knowns as packets so it can be easily transferred then it adds the destination address and source address which are IP addresses to the packets before handing it over to the network layer to transport. IP address is a unique identifier of a node in a computer network. So anytime the network layer transports a packet from one node to another, it hands the packet to the internet layer of that node to check if the destination address is the same as the IP of the computer, if it is, the file being requested is then sent back, if not the packet is handed back to the network layer to be transferred to the next computer. This is great, our request is being transferred except there is a problem. IP breaks down our request to packets and hands them down to the network layer to be sent, it des its best to send the packets. However, if something happens and a packet falls off, IP is not going to do anything about it. Imagine being sent an email but some packets fell off and now you receive an incomprehensible message. This is where the transport layer comes in.

💡 One of the IP addresses of google.com is 216.58.223.238 by the way. You can type in the IP address in your browser and it should open google.com.

Transport Layer

The transport layer is mainly of two protocols, User Datagram Protocol (UDP) and Transmission Control Protocol (TCP). UDP doesn’t resolve our problem at hand so we’ll focus on TCP instead. TCP is a protocol built upon IP to ensure that the requests being sent out by the IP get to their destination without losing their integrity. IP ensures that the request being sent out gets to their destination. TCP ensures that the request gets to its destination without losing its integrity during transport. TCP does this by a set of processes.

3-Way Handshake

One is the 3 way handshake, what happens in the 3 way handshake is that before we even start transmitting data, we first establish a connection with the server we want to talk to. So we make a request known as SYN with a random number, let’s call x when the server receives our request, it generates a random number of its own, let’s call it y then adds 1 to our random number x then sends an acknowledgement ACK while sending his own number to us to SYN. Our client on receiving the acknowledgement will add 1 to the number y generated by the server, then send an ACK. This is synonymous to what is done when we call someone on phone. We say “Hello” and wait for a response from the other side before we continue to actually pass our message. If we don’t get any response, we try a couple of hellos and then hang up if there is still no response or in computer networking lingo, we timeout.

Image description

Checksum

Once this is done, a connection is established and data transmission is initiated. During data transfer, TCP breaks down the request into segments then adds numbers to the segments then labels the segments like 1, 2, 3, 4. Thus, when a request reaches the server, the server uses an algorithm known as checksum to check if all the segments have been received, if all have been received, the segments are then pieced together in the right format and an acknowledgement is sent to the client. If the segments are not complete, the server rejects the packet. The client will then try to resend the data again if it doesn’t receive an acknowledgement after a while. This is how TCP ensures the integrity of the requests being sent.

Application Layer

Application layer works with a couple of protocols like HTTP, SMTP, FTP, etc. If you remember how IP ensures that data being transmitted get to their right destination, it does that by adding the IP address of its destination to the packets being sent but you likely didn’t make your request with an IP address. So it turns out when you type in google.com in your browser, you’re making a GET request for a page on google.com but for computers to communicate with other computers, they use an IP address which means to get the page you want we have to figure out the IP address of the computer that page is on. That is what Domain Name System (DNS) lookup does.

What is DNS?

Look at it this way, when you want to call someone, you call them via their number right? However, storing numbers in your mind is quite difficult, so you save the number on your phone in the phonebook with the alias of the person. So you can save John’s number on your phonebook with John as the alias. Now when you want to call John, all you have to do is go to your phonebook and search for John then proceed to call him. This is essentially what DNS does, well another reason it is termed as the phonebook of the internet. But unlike our phonebook where we can save the number under an alias of our own discretion, DNS has a universal contact name with their numbers. So when we make a request to google.com, a DNS lookup is activated by the application layer to get the IP address of google.com. This IP address is what is eventually handed over to the Internet Protocol to add to the packets being sent out.

Top-Down Approach

  1. When you type google.com into your browser, the protocol for the application layer, which in this case is HTTP activates a DNS lookup to get the IP address of google.com.

  2. The transport layer breaks down the request into segments, tags them and hands over the request and IP addresses of the source device and destination device to the internet layer.

  3. The internet layer breaks down the segments into packets then attaches the IP address of the client as source address and that of google.com as destination address to the packets and hands it over to the network layer.

  4. The network layer then moves the request from one node of the network to another until it finally reaches its destination which is google.com. A response is then sent back to our source address and voila we see the page below.

Image description

Top comments (0)