A dive into the OSI Model and more!
The connection of computers connecting with computers on a global scale - Internet
Context & Build up:
Earlier, the US and Soviet Union were looking for ways to write their names in history each before the other. In pursuit of this, the US set up APRA (Advanced Project Research Agency). They had offices across the US, and needed some way to communicate at the time. They then setup ARPA who created ARPANET. They setup 4 computers at MIT, Stanford, UCLA, Utah and were connected to each other through computers. This communication channel used the TCP protocol.
What are protocols? Rules for how data is sent from one device to another is known as protocols.
But there was a problem with this system. For eg: if MIT sent a page to Stanford which had a link to another page, that wasn’t possible. They needed to send the file for that link too to have that file. This entire process was extremely manual.
Then came the world wide web.
The world wide web is essentially an information system where documents and other resources are accessible via URLs, which may be interlinked by hyperlinks, and can be accessed over the Internet.
Q) Why do protocols exist?
If every application made had different ways of communicating with each other, communicatiuon beteween applications wouldnt be possible. Hence, protocols were designed to bring uniformity, all of which were developed and are updated by The Internet Society.
Client-Server Architecture:
When you write google.com as a url, a request is sent to the google server, and the google server sends back a response.
When you make full-stack apps by yourself, your computer locally acts as the server and client.
TCP protocol: TCP ensures that the data sent reaches its destination without any form of corruption.
UDP protocol: UDP is a protocol used when you’re fine with not 100% of data reaches. (Video)
HTTP protocol: Used by the WWW, helps define the format for data transferred between client and servers.
WorldWideWeb:
The World Wide Web (WWW), commonly known as the Web, is an information system enabling information to be shared over the Internet as well as documents and other web resources to be accessed over the Internet according to specific rules, the Hypertext Transfer Protocol (HTTP).
Let’s just say you type google.com, to know what server the request hits, all of this and all servers and computers are identified using an IP Address.
Every Device that can talk to each other on the internet, has an IP address.
The format of an IP address: X X X X, where each X can have a value 0-255.
Even when you type www.google.com, this request gets resolved to a server with an IP address of format X X X X.
How the Internet Works?
You, when working on the internet in your house are associated with an Internet Service Provider (Eg: Airtel, Vodaphone, Etisalat, Xfinity etc). Each of these provide you with a modem/router kept in your house, which consists of a global IP address.
All devices connected to this wifi from this router, all go through to the ISP which sends a request to the actual server with a global IP address. It is this modem/router that gives out a local IP address to each device connected on the Internet. This is done using Dynamic Host Configuration Protocol.
On sending a request from a local device like www.google.com, the router sends this request to the ISP, which connects to the server, comes back to the router, and based on the local IP address, goes to the designated device. This sending the response to the designated device is done via the router the Network Access Translation (NAT).
Now we’ve figured out how the designated device gets the data, what about which application on the designated device? As in how do we find out whether the response sent back for example the response when www.google.com as a request is sent, should be sent to firefox or safari. This is done using a PORT.
Each user running an application on a device would have a Port Number and an IP address.
Ports are essentially 16 Bit Numbers.
16 bit no.s essentially mean that you can have 16 numbers, with each number being either 0 or 1. Hence, the total number of Port Numbers you can create is 2^16 ~ 65k port numbers.
What do we mean by “download/upload speeds”?
Download speeds are often measured in mbps, gbps etc.
MBPS - Mega Bits Per Second ie 10^6 Bits / second can be transferred over the internet
GBPS - Giga Bits Per Second ie 10^9 Bits / second
KBPS - Kilo Bits Per Second ie 10^3 Bits / Second
Now we understood that when we for example want to make a request www.google.com, the router sends our request to the ISP, which connects to the server. How does this happen on an extremely large scale across countries? How do our requests get go from an ISP to the server which send back some data across continents? This is done using submarine cables, which are connected from under the ground. These are optic fibre cables.
Types of Networks:
LAN: Local Area Network - Used to connect computers to each other in a small area.
Example: Ethernet cables, WI-FI
MAN: Metropolitan Area Network - Used to connect computers across a city
WAN: Wide Area Network - Used to connect computers across countries. (Eg: Optical Fibre Cables are used)
SONET (Synchronous Optical Networking): SONET is a technology primarily used in WANs to transmit data over optical fiber cables. It's often used to establish high-speed, reliable, and scalable connections between various network nodes across a wide area.
Frame Relay: Frame Relay is a communication protocol used to connect LANs and MANs to a WAN.
Internet is essentially a collection of these types of networks. Several LANs connected using MANs connected to each other using WANs
What is a Modem and Router Used For?
A modem is used to convert Digital Signals to Analog Signals and vice versa.
For example: An image sent to another user across the globe is converted into analog signals that can be trasmitted, and then back into digital to be converted into an image.
A Router is used to give route to each of these signals based on their IP addresses.
What does an ISP do?
An ISP is essentially to connect users to the internet. There’s usually a very few number of Tier-1 ISPs like Tata in India, with Airtel, Vodaphone etc being Tier 2, which connect to Tier 1 which further connect to the Internet.
OSI Model & Structure Of Network: (Open Systems Interconnection Model)
Essentially defines a structure for how users and servers on the backend interact with each other.
There are 7 Layers in the OSI model.
1) Application Layer
2) Presentation Layer
3) Transport Layer
4) Network Layer
5) Data Link Layer
6) Physical Layer
Let’s just say you’re on imessage, you send a message. The part that the user is interacting with ie imessage is the Application Layer. Lies on your devices.
The next layer, presentation layer, situated within the OSI model, plays a pivotal role in ensuring seamless communication between disparate systems. Its primary objective is to facilitate data exchange by handling the translation, encryption, and compression of data to ensure that information transmitted is both meaningful and secure. This layer is responsible for converting data from its native format into a format that can be easily understood by the receiving system. Additionally, it manages the encryption and decryption of data to guarantee confidentiality and integrity during transmission, safeguarding it from unauthorized access. Furthermore, the presentation layer can apply compression techniques to optimize data transmission, reducing bandwidth usage and latency. By performing these functions, the presentation layer contributes to the efficient and secure exchange of data across networks and systems.
The data is then sent to the Session Layer. The session layer is responsible for establishing, managing, and terminating communication sessions in applications. It ensures that data is transmitted reliably and efficiently between devices or systems. It also provides services such as synchronization, checkpointing, and recovery. It ensures that data is properly organized into sessions and can be reliably transmitted between devices. It also involves maintaining and managing the session throughout the communication, including dealing with issues like data loss, out-of-order delivery, and more. The session layer is like the operator who sets up the call, keeps track of the conversation, and ends the call when you're finished.
This data is then sent to the Transport Layer.
The Transport Layer, situated within the OSI model, serves as a pivotal bridge between the higher layers responsible for user data and the lower layers responsible for physical data transmission. Its essential role includes segmenting data into manageable units, each encapsulating crucial information such as source and destination port numbers, sequence numbers, and more. These segments ensure proper routing and delivery. Moreover, the Transport Layer exercises control over data flow, maintaining a balanced pace of transmission to prevent congestion and optimize performance. It also encompasses error control, implementing techniques like checksums to confirm data integrity and facilitating retransmissions in case of corruption. Through protocols like TCP and UDP, the Transport Layer offers distinct approaches—TCP ensures reliable data delivery, while UDP focuses on speed and efficiency, for instance, in media streaming.
The next layer is the Network Layer.
The Network Layer orchestrates the efficient movement of data across networks. Operating through routers, the network layer assigns logical IP addresses to data packets, ensuring accurate sender and receiver identification. It embarks on the critical task of routing, guiding packets through the intricate web of interconnected devices toward their intended destinations. Employing algorithms such as Dijkstra's, the network layer determines optimal routes, minimizing delays and maximizing efficiency. Analogous to a postal system's sorting and delivery process, it seamlessly navigates the data through various nodes, each akin to courier companies, until it reaches its final destination.
The next layer is the DataLink Layer.
After functions performed at the network layer, the datalink layer does the physical addressing unlike the network layer which does the logical addressing. Physical Addressing consists of Mac Addresses to form a frame to form a Data Unit. Mac Address is a 12 digit alpha-numeric number. There can be several mac addresses on a computer (diff from bluetooth, wifi, etc), and the frame formed can be accessed by all the other layers.
The last layer is the Physical Layer.
Here, all signals and data recieved is sent to the reciever’s physical layer (could be in the form of light in the case of optic fibre cables sending data, could be in the form of radio signals if done over WI-FI, etc).
End to End example:
Application Layer (Layer 7):
- You start by typing a message in a messaging application on your computer.
Presentation Layer (Layer 6):
- The message you typed might undergo character encoding or encryption at this layer, ensuring the data is properly formatted and secure.
Session Layer (Layer 5):
- The session layer establishes a connection between your system and the underlying software’s servers being used
Transport Layer (Layer 4):
The transport layer segments your message into smaller packets.
TCP handshake occurs between client sending message and application youre running’s servers’ transport layers.
Network Layer (Layer 3): The router makes a routing decision based on the destination IP address, determining where the packet needs to be sent next in terms of routers or network segments.
Data Link Layer (Layer 2): Once the router knows where to send the packet, it determines the specific MAC address of the next router's interface that will receive the packet on that segment. It then encapsulates the packet in a frame and adds the source and destination MAC addresses.
Physical Layer (Layer 1):
The frame is transformed into physical signals (electrical voltages, light pulses, radio waves) appropriate for the transmission medium.
These signals travel through the physical medium to the next router.
Then, a backward process of the 7-layer OSI model begins.