Exploring the OSI Model and Network Structure
https://rahulsblogg.hashnode.dev/exploring-the-world-of-computer-networking
Check out my computer networks part 1 if you haven't visited yet.
Let's begin→
OSI stands for open systems interconnection model
why its developed - structured way or conceptual framework for communicating with servers and computers.
There are 7 layers in this model:
1. Application Layer
2. Presentation Layer
3.Session Layer
4.Transport Layer
5.Network Layer
6.Data Link Layer
7. Physical Layer
- Each and every layer will be having own protocols rules etc.
Application Layer:
The top layer where the clients or people use it , ex: web browser , email etc.
The application layer will give data to next layer which is Presentation Layer.
The data maybe anything words , characters , numbers etc.
Presentation Layer:
Where the data from above layer will be converted into binary form or intermediate machine language form which we all know it!
This layer handles encryption, encoding, translation etc of the data received by the application layer.
Data compression will also be done in this layer.
Every layer after completion assumes that my work is over and it will taken care by the below layers.
Session Layer:
- This layer focuses on setting up the connections and managing it and then enabling processing of data followed by termination of the connected sessions.
Transport Layer:
This layer divides the data into segments which have a sequence number attached to them to align them sequentially in the received side.
This layer has flow control which manages the upload speed of the sending device according to the receiving device so we do not lose any data packet during the data sending process.
Also adds checksum for error detection , it has connection oriented transmission like TCP which 100% of data will be sended and also receives acknowledgement that data been received , also with connectionless oriented like UDP where it don’t bother whether 100% data being transmitted where some data packets will be losted here like gaming , video conference.
Network Layer:
This layer takes data segments from the transport layer and moves them from the sending device to the receiving device.
Router lives over here and it’s a part of network layer.
The function of this layer is Logical addressing where it assigns receiver and sender Ip address for every data segment making into a packet to reach its destination.
uses some nice algorithms like dijkstra to find best paths to send packets.
Data Link Layer:
This takes data packet from network layer and does logical address and physical addressing.
MAC Address is used for physical addressing (network layer does logical addressing which means it goes till router of receiving side and mac address used so that it know which system should it transfer the data to )
MAC address is a 12 digit alphanumeric number which uniquely identifies a system in a network.(note:for one computer or device can have various MAC addreses)
Adds MAC Address to frames or data segments received from network layer.
A frame is the data unit that is has the MAC Address to it added by the data link layer.
After creating these data frames, all the above layers can access these frames and control how they are placed and received.
Physical Layer:
The hardware section where it works with cables , wires etc.
on the receivers side of the physical layer routers , where it converts the incoming analog or digital signals into binary form and into data frames in the data link layer and moves upper till application.
TCP/IP model:
known as Internet Protocol Suite.
This model has 5 layers: - Application Layer - Transport Layer - Network Layer - Data Link Layer - Physical Layer
The working of the layers is same as OSI Model but with few exceptions.
OSI model's Application, Presentation, Session are merged together into Application.
This is used practically and OSI is used for theory and concepts.
Diving deep onto each layer:
1.Application layer:
Two main architectures:
1.Client - server architecture
2.peer - peer architecture
Client server architecture →
We know that client send a request to server and server responds back.
What is server : server basically a system which controls your website or application you are hosting!
The application layer we are talking about has two parts:
1.client part 2. Server part
This is known as process where one process will be running on client side and another process takes place simultaneously on server side.
You can make your own server by having reliable IP address ,and high availability (where you don't want to be server down)
Collection of servers in a big company called as Data centers.
Peer to peer architecture :
This is one more way of connecting applications to the end systems.
Where every computer can be termed as a client also a server.
Applications running on various devices get connected with eachother and there is no single sever or data center.
Ex: BitTorrent
protocols used on application layer : TCP/IP
Why TCP/IP : To send 100% data reliably without loosing data packets in between network.
Protocols used in TCP/IP:
HTTP : hypertext transfer protocol
SMTP: simple mail transfer protocol
FTP : file transfer protocol
DHCP: dynamic host configuration protocol
SSH : secure shell protocol (used if you want to login in
to another terminal of someone remotely) etc.
HTTP IN DETAILED →
This protocol basically tells how the client send request for data and how the server responds back to client.
HTTP uses some methods in it to get and send data.
It is a stateless protocol - which means the server will not store data by default.
HTTP METHODS:
GET - requesting server for data
POST - give some data to server
PUT - puts data on specific location of server
DELETE - delete special data from server
Status codes → The codes server will reply back with.
100 → which means informational category.
200 →success code which means data reached successfully.
400 →client error when entered wrong url.
500 →server problem or error.
Etc.
What are COOKIE'S :
Ex: we experienced this for example someone log into a particular website like Amazon and we give some credintals like password email id etc , the next time you visit that website it don't ask again for your credentials, and we know that HTTP is a stateless protocol but how it's storing our data.
The answer is cookies : it's a unique string stored in our browser. On very first time you logged into application it sets a cookie internally and second time when we go into website the request from client to server is sent with cookie and server notices cookie and server like oops it's a cookie and we already have this information and server like takes this!
It do have some expiration dates.
DNS : Domain name system
Why DNS → suppose you type Google.com on browser how does it connect to Google server.
Answer : Each domain names are mapped to particular IP ADDRESSES and people use it DNS as a service to look up into DNS databases.
Why - it's hard to remember each IP addresses of a application .
Now , http takes url and it will find the IP ADDRESS and after been found it reaches particular server for requesting data.
Now question , how did it find the IP address:
DNS has its own servers where all the IP ADDRESSES will be stored.
If we look further more into deep:
DNS don't have one server it makes very tedious and difficult or traffic to request one server from many computer or devices for addresses.
Note: it's not like everytime you look up DNS servers for the IP ADDRESSES. For the first time you get the IP addresses from server and it will be stored onto your local device database or cache.
Databases are divided into various classes domains:
Ex: google.com
.com is a TOP LEVEL DOMAIN
Google is second level domain.
The top level domains has root DNS servers.
Ex: .com for community purpose, .org for organizational purpose, .edu for education purposes
Where addresses of each particular domain stores in that root DNS server.
root-servers.org is the organisation who maintain root DNS servers. And the top level domains are maintained by ICANN.org(organization to register for top level domains).
This end up the application layer.
2.TRANSPORT LAYER :
Now data reaches network layer.
Transportation of data from one computer to another computer is done by NETWORK LAYER.
we can cover how does it transport data in network layer.
The role of transport layer is to collect data from network layer and reach it to the application.
SOCKET → software Interface between application and transport layer which connects two layers.
let us consider above figure and there are three fields included which is a message, a file ,and a video and all this data undergoes multiplexing at sender device and de-multiplexing at receiving side. Why because data travels in packets and every packet has segment headers with the socket port numbers , sender and destination IP ADRRESSES and that reaches to the destination transport layer in sequence.
Multiplexing –
Gathering data from multiple application processes of the sender, enveloping that data with a header, and sending them as a whole to the intended receiver is called multiplexing.
Demultiplexing –
Delivering received segments at the receiver side to the correct app layer processes is called demultiplexing.
- Transport layer take cares of the CONGESTION CONTROL - normally in a device the packets sends rapidly to network layer so this can lead to packet loss , that is why transport layer takes care of by reducing traffic.
Also sends checksum along with the data , checksum main purpose is to figure out whether the data received accurately or data been corrupted in between.
Lets talk about UDP:
UDP stands for USER DATAGRAM PROTOCOL.
another protocol like HTTP inside TCP/IP.
But unlike HTTP it doesn’t take care about 100% data been reached or not where packet losses are common in this protocol.
data may or may not be delivered , may change and not be in order.
connectionless oriented protocol.
It also has checksums but it don’t care if there is error in checksum calculation.
UDP PACKET:
HEADER consist of 8 bytes and DATA of 2^16 - 8 .
advantages can be like very fast
examples including like GAMING and VIDEO CONFERENCE.
IN TCP /IP:
3 - WAY HANDSHAKE PROCESS→
It is a process that establishes a reliable connection between two devices over a TCP/IP network.
Step 1 (SYN) : first step is on the client side where it sends request to get connect with server.
It sends a synchronization flag (Synchronize Sequence Number which informs the server that the client is likely to start communication)along with the sequence number(random sequence number so systems can’t be compromised by the hackers)
Step 2 (SYN + ACK): After the client sends the server responds like ok and in response it sends the ACKNOWLEDGEMENT FLAG (that client request been approved)along it does some calculation and generate another sequence number from server side , signifies with what sequence number it is likely to start the segments with.
**Step 3 (ACK):**In the final part client acknowledges the response of the server and they both establish a reliable connection with which they will start the actual data transfer.
THIS COMPLETES TRANSPORT LAYER!
3.NETWORK LAYER:
Let’s learn now how the data will be transported.
NETWORK LAYER uses INTERNET PROTOCOL.
Till now all the data came upto the network layer where it gone under each layer steps and it is now ready to complete network layer steps and fly over the network and reach its destination.
Here we work with the routers.
we know that A Router is a networking device that forwards data packets between computer networks.
Every router will be having the NETWORK ADDRESS.
This is the example figure how routers will cover network from senders to destination:
every router will check whether this data is for that particular router if yes it passes.
If not the packets will be forwarded using forward table in the router tables.
what are router tables and forward tables:
These are the tables builted on the routers internally.
A routing table lists all networks for which routes are known. Each router’s routing table is unique and stored in the RAM of the device.
A routing table contains the information necessary to forward a packet along the best path toward its destination. Each packet contains information about its origin and destination. Routing Table provides the device with instructions for sending the packet to the next hop on its route across the network.
It’s not like where every router will have addresses of every device in the world.
The router tables will be having only the information in certain range of its network.
If the packet received is out of range it's just forward using forward table - A forward table is a data structure that helps router to decide the best path for forwarding further.
Packets of network layer:
Header of 20 bytes , IP address, flags, checksum, address,TTL(Time to live is a number like for example: 60 , if the packets doesn't reach after that number of hops then it will just leave that it's not reached)
lets talk about IP ADDRESS:
- we know that IP ADDRESS which uniquely identifies the devices. lets know more about them.
This IP address is just a string of numbers written in a certain format:
ex: X.X.X.X
where each number or X in this example range from 0-255.
ex:192.155.12.1
There are two types :
IPv4
IPv6
IPv4 → IP version 4
4byte word - 2⁴ (32 bits)
And 2³² - Around 4.3 billion devices can hold different IP addresses.
blocks of IP addresses will be assigned to the ISP(intenet service providers) this is known as subnetting.
classes of IP ADDRESSES:
IPv6 - future version of IP address where because of devices increasing simultaneously arround globe we may need the IPv6 version where we can significantly assign ip addresses
4times larger than IPv4.
Disadvantages can be like it cannot be compatible with present IPv4 addresses , Internet service providers have to shift and lot of hardware work.
4.DATALINK LAYER:
Here all the packets received from network layer.
These packets will be added with datalink address i.e mac addresses and sent over physical link.
Here data packets will be called as frames
Frames consist of data link layer address and ip address.
5.PHYSICAL LAYER :
All the data will be traveling through the real Physical cables like ethernet etc arround the outer network like LAN , MAN , WAN until it reaches it’s destination.
The data packets converted into digital signals or analog signals or signals into binary digits and digits into real data packets reach till application layer of the destination device.
Subscribe to my newsletter
Read articles from Rahul Poluru directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by