COMPLETE: Computer Networking
History of INTERNET:
Early Steps (1960s):
- Cold War anxieties and resource sharing: Driven by concerns during the Cold War, the US Department of Defense funded the ARPANET (Advanced Research Projects Agency Network) in the 1960s. Its goal was to create a communication network resilient to outages and attacks.
- Packet switching: Instead of sending entire files, it broke data into smaller “packets” for efficient transmission and reassembly at the destination. This technology proved crucial for the internet’s future.
Standardization and Growth (1970s and 1980s):
- TCP/IP (Transmission Control Protocol/Internet Protocol): Developed in the 1970s, it became the universal language for communication between different networks, laying the foundation for the Internet as we know it.
- ARPANET expands: Universities and research institutions joined ARPANET, fostering collaboration and information sharing beyond military applications.
- Rise of personal computers: With the growing popularity of personal computers, networks like NSFNET (National Science Foundation Network) emerged, further expanding the internet’s reach.
World Wide Web (1990s):
This “www” is nothing but the entire system of interconnected web pages, documents, videos/ links, and resources accessed through the internet all those have URLs, “www” is shorthand for “World Wide Web”.
- This network uses Hypertext Transfer Protocol (HTTP) for communication and relies on hyperlinks to connect information across different servers.
The www allows users to:
- Access a vast amount of information: Text, images, videos, audio, and other multimedia content.
- Interact with different applications and services: Online shopping, social media, email, communication tools, etc.
- Connect and collaborate with others: Share ideas, participate in communities, and build online relationships.
This WWW was the Vision of Berners-Lee:
— a “universal linked information system” where information could be easily accessed and interconnected, regardless of its location or format, he facing problems in sharing and accessing information in one place.
Key Technologies:
- Hypertext Markup Language (HTML): Defined the structure and content of web pages, allowing for text, images, and other elements to be displayed and linked together.
- Hypertext Transfer Protocol (HTTP): Governed how information is transferred between web servers and browsers.
- Uniform Resource Locators (URLs): Essentially, the address of a specific resource on the internet.
Hyperlink: An interactive element that, when clicked, takes you to the resource identified by the URL(link of other document/web pages).
Search engine history in short:
- Archie: Developed in 1990, Archie is considered the first search engine on the internet. It focused on indexing files on anonymous FTP servers, allowing users to search for specific filenames.
- Yahoo: As you mentioned, Yahoo emerged in 1994, initially as a curated directory of websites (“Jerry and David’s Guide to the World Wide Web”). Later, it became Yahoo Directory and ultimately expanded to offer email, search, news, and other services.
- 1998: BackRub, later renamed Google, entered the scene, utilizing link analysis and PageRank algorithm for improved relevance.
Client-Server Architecture
Client-server architecture is like splitting up work between a helper and a manager.
The client-server architecture refers to a system that hosts, delivers, and manages most of the resources and services that the client requests.
The Client:
- Imagine the client as the helper. It’s your device, like a computer or phone, running an application like a web browser or mobile app. This helper asks for specific things, like a website to display or a document to open.
The Server:
- The server is like the manager. It’s a powerful computer with lots of resources (storage, processing power) and information. It waits for requests from the helpers and does the heavy lifting: finding the requested information, processing it, and sending it back.
Another type is called Peer-to-Peer Architecture.
Peer-to-Peer Architecture [P2P]
Peer-to-peer (P2P) architecture is a networking approach where devices or “peers” connect and interact directly with each other, without relying on a central server.
Each peer functions as both a client and a server, sharing resources and services with others in the network.
This differs from the traditional client-server model where dedicated servers provide resources and clients access them.
Key features:
- Decentralized: No single point of control or failure, making the network more resilient.
- Scalable: Can easily grow by adding more peers without impacting performance.
Centralized P2P is also possible to use a central server for discovery and directory services, but not for data transfer.
Disadvantages of P2P:
- Security concerns, especially in unstructured networks
- Performance can be variable depending on participating peers
Network Protocols
Protocols are sets of rules or guidelines that govern how information is exchanged between different entities.
Just think for a second different country have different rules how difficult it get to access America’s data in India things get complicated so to make sure common ground we need and these protocols made by Internet society.
Data transfer protocols:
- TCP (Transmission Control Protocol): The fundamental suite of protocols for communication on the internet, this protocol ensures 100% delivery of data without loss.
- UDP (User Datagram Protocol): A simpler protocol for faster data transfer, but without guarantees of order or delivery of complete data, suited for streaming media or real-time applications.
Security protocols:
- HTTP(Hypertext Transfer Protocol): Defines rules for how data is transferred between web browsers and servers, governs the format and structure of data, and defines error handling and communication.
- HTTPS (Hypertext Transfer Protocol Secure): An extension of HTTP that encrypts communication between web browsers and servers, protecting data privacy and integrity.
- SSH (Secure Shell): Provides secure remote access to computer systems over the internet.
Management protocols:
- DHCP (Dynamic Host Configuration Protocol): Automatically assigns IP addresses to devices on a network. Use by router, provide private IP addresses, your Internet Service Provider(ISP) use it.
Have you ever think how data(e.g. image, message) we send reaches another person's mobile, and how this data is transferred in milliseconds from one place to another?
What is TCP and its need?
TCP: The Reliable Mailman of the Internet
TCP, or Transmission Control Protocol, is a fundamental protocol that governs how data is exchanged over the internet. It plays a crucial role in ensuring reliable and ordered communication between devices, acting like a reliable mailman in the digital world.
Real-world problem being solved:
Imagine you’re sending an important document across the country. You wouldn’t just toss it in a random box and hope for the best, right? You’d likely use a service like registered mail that guarantees delivery and ensures the documents arrive complete and in the correct order.
TCP operates similarly, addressing the following real-world problems:
- Data Loss: Without TCP, data packets could be lost during transmission, just like a package getting lost in the mail. TCP employs error checking and retransmission mechanisms to ensure all data arrives at its destination.
- Data Corruption: Sometimes, data packets get corrupted in transit, similar to a package arriving damaged. TCP uses checksums to verify data integrity and request retransmission of corrupted packets.
- Out-of-Order Delivery: Data packets might arrive out of order, just like your mail sometimes arrives in the wrong order. TCP ensures the data packets are delivered in the correct order, crucial for applications like file transfers or streaming videos.
How TCP solves these problems:
- Connection establishment: Before any data is sent, TCP establishes a connection between the sender and receiver, similar to booking a delivery service. This handshake process sets ground rules and ensures both parties are ready to communicate.
- Packet creation: The data is broken down into smaller packets, like individual pieces of your document.
- Sequencing: Each packet is assigned a sequence number, like page numbers in your document, ensuring they are delivered and reassembled in the correct order.
- Error checking: Each packet includes a checksum, like a document verification code, to detect errors during transmission.
- Acknowledgment and retransmission: The receiver acknowledges receiving packets and requests retransmission of any missing or corrupt ones, ensuring complete and accurate delivery.
- Connection closure: Once finished, the connection is gracefully closed, similar to receiving confirmation of delivery.
Benefits of TCP:
- Reliable data transfer: Guarantees data arrives complete and in the correct order, crucial for applications like web browsing, email, and file transfers.
- Error correction: Detects and fixes errors during transmission, ensuring data integrity.
- Congestion control: Helps manage network traffic efficiently to avoid overwhelming the network with data packets.
Alternatives:
- UDP (User Datagram Protocol): Offers faster but “best-effort” delivery, meaning data might not arrive or might arrive out of order. Used for applications like online gaming where speed is prioritized over absolute reliability.
7 Layers of the OSI Model
- Physical Layer: This is the hardware layer, concerned with the raw transmission of bits (0s and 1s) over the physical medium. It deals with:
- Cables and connectors
- Network cards and physical interfaces
- Electrical signals and voltage levels
2. Data Link Layer: This ensures reliable data transfer between directly connected devices. It’s responsible for:
- Framing: Dividing raw bits into manageable frames of data.
- Error detection: Identifying errors in the received frames.
- Physical addressing: Using MAC addresses to identify devices within a network.
3. Network Layer: This handles routing, addressing, and moving data packets between different networks. It focuses on:
- Logical addressing: Using IP addresses to identify devices across networks.
- Routing: Finding the best path to send packets to their destination.
4. Transport Layer: Provides reliable, end-to-end data delivery and error recovery. It focuses on:
- Flow control: Managing the transmission rate to prevent congestion.
- Segmentation: Breaking larger data into smaller chunks for transmission.
- Ensuring data arrives in order and without errors.
5. Session Layer: It sets up a connection between two applications on different devices, like negotiating the type of communication (full-duplex, half-duplex) and determining how data will be exchanged.
- Once the connection is established, the session layer manages the flow of data between applications
- Establish a session for the video call, negotiating the quality, bandwidth, and data exchange format.
6. Presentation Layer: Translates data into a format applications can understand. It handles:
- Data formatting (e.g., ASCII, JPEG)
- Encryption and decryption for security.
7. Application Layer: This is closest to the user. It includes the applications and protocols that people interact with directly, like web browsers, email clients, and file transfer protocols (FTP).
Why is it helpful?
- Standardization: It provides a common language for networking devices and software.
- Modularity: Dividing into layers makes network systems easier to design and troubleshoot.
- Open system: It promotes interoperability between devices from different vendors.
Layers of the TCP/IP Model
- Application Layer:
- Where network-aware applications live (web browsers, email clients, file-sharing software).
- Handles how data is represented and displayed to the user.
- Protocols used here: HTTP (web browsing), SMTP (email), FTP (file transfer), etc.
2. Transport Layer:
- Manages end-to-end data delivery between applications.
- Break down data into segments for efficient transmission.
- Ensures data arrives in the right order and handles errors.
- Protocols used here: TCP (reliable, connection-oriented) and UDP (fast, connectionless).
3. Network Layer (aka Internet Layer):
- Responsible for routing data packets across networks.
- Handles logical addressing using IP addresses to find the destination device on any network.
- Protocols used here: IP (Internet Protocol), ICMP (ping), etc.
4. Link Layer (aka Network Interface or Data Link Layer):
- Deals with the physical aspects of sending data on a specific network segment.
- Translates data into signals compatible with the physical medium (e.g., electrical pulses or light).
- Handles physical addressing (MAC addresses) of devices on the local network.
- Protocols used here: Ethernet, Wi-Fi, PPP, etc.
How It Works (Simplified):
- An application generates data for another device.
- Data moves down the layers of the TCP/IP model, getting headers and information added at each layer.
- Data is physically transmitted over the network.
- The receiving device’s TCP/IP model works in reverse, peeling off headers and interpreting information layer by layer.
- Data is finally delivered to the appropriate application.
How Data is Transferred?
explain taking an example from your mobile sending data to reaching and returning back to how this work
[after response come back from server it identify your device on router using NAT]
IP address decide which device need to send data, but how we decide which application need to send data in that device
Port Number
Imagine for a second you send a message through WhatsApp and in return your friend also replies back you. You use a router to connect to the internet when the reply comes from your friend your router decides through private/local IP address which device needs this message but inside your phone instead of WhatsApp multiple applications are running inside your phone so how our message will reach to its correct destination.
Here port number comes into the picture, which helps to identify applications, and above we see IP addresses help to identify devices.
Port Numbers: They are the Unique identifiers, that differentiate various services running on a device, ensuring data reaches the correct destination or directing incoming traffic to the right destination within a device.
in short words: identifies a communication endpoint in an IP network.
What they are:
- Numerical identifiers (usually 16-bit, ranging from 0 to 65535) are assigned to specific services or applications on a device.
- 0–1023 Reserved Ports assigned by the Internet Assigned Numbers Authority (IANA), Registered Ports (1024–49151), this range is designated for various applications and services registered with IANA.
- Dynamic or private ports (49152–65535), this range is available for any application or service to use dynamically.
Why they are needed:
- Multiple applications and services can run simultaneously on a single device.
- Port numbers differentiate them, preventing chaos and ensuring data reaches the correct service.
Examples of common ports:
- 80: HTTP (web browsing)
- 443: HTTPS (secure web browsing)
- 25: SMTP (email sending)
- 21: FTP (file transfer)
- 22: SSH (secure remote access)
Explain the Port 80 function.
- When you enter a website address (URL) in your browser, your device sends a request to the server hosting the website. This request travels through your network and the internet, utilizing port 80 by default.
- The server responds through the same port, sending back the requested web page content (text, images, videos, etc.).
- Most web browsers automatically use port 80 when accessing websites unless otherwise specified.
- When a device sees “port 80,” it understands that the incoming or outgoing data is related to basic web traffic. It expects to receive or send information for accessing websites and web pages.
How does this work Internally?
Scenario where a message arrives at a device with a specific port number, several entities work together to ensure it reaches the appropriate application:
1. Router:
- The message first enters your network through the internet connection and reaches your router.
- The router examines the destination IP address included in the message header.
- It then uses its routing table (a map of connected devices and their IP addresses) to determine which device within your network the message should go to.
- Based on the destination port number in the message header, the router consults its port forwarding table (if configured). This table specifies which incoming port numbers should be directed to which internal devices and specific ports.
2. Device and Operating System:
- Once the router identifies the target device, it forwards the message to that device’s network interface card (NIC).
- The operating system on the device receives the message.
- Operating systems maintain a process table that tracks running applications and the ports they use.
- The operating system uses the destination port number to identify the specific application responsible for handling that type of communication.
3. Application:
- If an application is listening on the specified port, the operating system delivers the message to that application.
- The application interprets the message content based on the protocol associated with the port number (e.g., HTTP for web browsing, and email protocols for mail clients).
- The application then processes the message and generates any necessary response, which goes back through the same journey in reverse to reach the sender.
Note:
1mbps/1kpbs means the speed of incoming and outgoing data, data’s bit how fast coming or going.
- 1mbps: 1 Megabit per second (Mbps) measures the amount of data transmitted or received in one second, 1 Megabit is equal to 1,048,576 bits.
- 1kpbs: 1 Kilobit per second (kbps) also measures data transfer rate but in thousands of bits per second. 1 Kilobit is equal to 1,024 bits.
Submarine Cable map
Why do we study this?
To understand an overview take a look from the sky at how things happening so that minute detail you can understand later in the blog.
Please visit this site: https://www.submarinecablemap.com/landing-point/mumbai-india
To see how internet cables are inside the sea, and every country connected to this cable.
Sea cable internet is faster than satellite so we are using it.
Back to school:
1. Local Area Network (LAN):
- Imagine a small space like your home, office, or school. A LAN connects computers, printers, and other devices within this localized area using cables or wireless connections.
- Coverage: Typically spans a few meters to a few kilometers, covering a single building or campus.
- Ownership: Usually private, owned by an individual, organization, or institution.
- Speed: High data transfer rates (think Mbps or Gbps), enabling fast communication and data sharing within the local area.
- Examples: Your home Wi-Fi network, office network connecting computers and printers.
2. Metropolitan Area Network (MAN):
- Think of a larger city or town. A MAN covers a broader area than a LAN, connecting multiple LANs across a geographical expanse like a city or a few neighboring towns.
- Coverage: Spans around 5–50 kilometers, encompassing a larger urban area.
- Ownership: Can be private (owned by a single entity) or public (run by multiple organizations).
- Speed: Offers moderate data transfer rates, typically lower than LANs but sufficient for regional communication.
- Examples: City-wide Wi-Fi network, university network connecting different campuses.
3. Wide Area Network (WAN):
- Picture a vast region or even the entire globe. A WAN spans the largest geographical area, connecting devices and networks across vast distances, even continents.
- Coverage: Expands across large distances, connecting networks across countries or even globally.
- Ownership: This can be private, public, or a combination of both, depending on the specific network.
- Speed: Data transfer rates vary depending on the technology used, but are generally slower than LANs and MANs due to longer distances.
- Examples: The internet, and corporate networks connecting offices in different countries.
nOTE: Internet relies on or utilizes LANs, MANs, and WANs as part of its infrastructure
there is one more network that exists PAN: The smallest network of computers, 10-meter range, your device connects with another device Bluetooth headphone with a smartphone.
SONET (Synchronous Optical Network):
- What it is: A standardized protocol for high-speed, reliable data transmission over fiber optic cables.
Strengths:
- High bandwidth: Offers speeds ranging from 51.84 Mbps to 2.5 Gbps and beyond, Reliable and Scalable.
Weaknesses:
- Complex and expensive, Not cost-effective for low-bandwidth applications and point-to-point connections.
Frame Relay:
- What it is: A packet-switching network protocol that offers efficient data transfer over various media, including fiber optic cables and leased lines.
- Work at the data link layer and used to connect LAN and transmit data across WAN, a better alternative to point-to-point network.
- Typically limited to speeds up to 2 Mbps.
nOTE: a way to connect LANs to WANs for bursty traffic in the past. Frame Relay is being phased out and replaced by newer technologies.
Frame relay has been largely replaced by multiprotocol label switching (MPLS) and IP networks.
Router VS Modem
Modem:
- Function of the modem: The modem acts as a translator. It receives this analog signal from your ISP and converts it into a digital signal that your devices can understand. This digital signal is typically in the form of Ethernet or Wi-Fi signals.
- Think of it as A translator speaking the language of your ISP and translating it for your devices to understand.
- Examples: Cable modem, fiber optic modem.
Let's deep dive into modem internally work:
- Analog signal from ISP: Your ISP delivers an analog signal containing encoded information (websites, emails, etc.).
- The modem receives and demodulates: The modem receives this analog signal and uses demodulation techniques to extract the digital information encoded within.
- Router processes and distributes: The digital signal is then passed to your router. The router analyzes the data packets and directs them to the correct devices on your network based on their IP addresses.
- Wireless adapter translates to radio waves: If a device is connected to the router via Wi-Fi, the router’s wireless adapter takes the digital signal and translates it into radio waves. These radio waves carry the digital information wirelessly to your device.
- Device adapter receives and translates back: The Wi-Fi adapter in your device receives these radio waves and converts them back into a digital signal that your device can understand and process.
initial signal from your ISP is analog, the digital signal used within your home network gets converted into radio waves only for wireless transmission (Wi-Fi).
About Analog signal:
- An analog signal is a continuous representation of information, unlike its counterpart, the digital signal, which uses discrete values. Imagine a smooth, flowing curve as opposed to a series of dots.
- Digital signal means sequence of discrete values — distinct values are just two states, typically represented as 0 and 1.
- An electrical representation of data, like messages, images, sounds, or measurements.
- Microphones, record players, and older TVs all generate analog signals to represent sound and video information.
- These devices convert real-world phenomena like sound or light into electrical signals for transmission or processing.
Router:
- Function: Manages data traffic within your home network. It directs data packets to the correct devices (computers, phones, smart TVs) based on their IP addresses. It can also create a Wi-Fi network for wireless connectivity.
- Think of it as: A traffic controller, directing data to the right “destinations” on your network.
- Examples: Wi-Fi router, wired router.
ISP
An Internet Service Provider (ISP) is a company that provides you with access to the Internet. [JIO, VODAFONE, AIRTEL — ISP]
They act as the middleman between you and the vast network of computers and servers that make up the internet. Think of them as the gateway that allows your devices to communicate and access information online.
What they do:
- ISPs provide different types of internet connections, including cable, fiber optic, DSL, and satellite.
- They manage the infrastructure needed to deliver these connections, such as cables, towers, and satellites.
- They assign IP addresses to your devices, which act like unique identification numbers on the internet.
- They route your internet traffic to the correct destinations and back to your devices.
Tier 1 ISPs:
- Speed: The fastest and most reliable internet access, offering gigabit-per-second (Gbps) speeds or even higher.
Tier 2 ISPs:
- Speed: Offer a wide range of speeds, from Mbps to hundreds of Mbps, catering to various needs.
Tier 3 ISPs:
- Speed: Lower speeds, typically ranging from Mbps to tens of Mbps, are suitable for basic internet usage.
Back to Basic: Network TOPOLOGIES
Bus:
- Description: All devices are connected to a single central cable or “bus” like beads on a string. Any device can communicate with any other device as long as the message reaches the intended recipient.
- Advantages: Easy to set up and expand at low cost.
- Disadvantages: Single point of failure (if the central cable breaks, the entire network is down), limited bandwidth as all devices share the same line.
Bandwidth means maximum amount of data that can be transmitted over a connection in a given amount of time.
Ring:
- Description: Devices are connected in a closed loop, forming a ring. Data packets travel in one direction around the ring, passing through each device until they reach their destination.
- Advantages: More reliable than bus since data can still flow even if one device fails, moderate cost.
- Disadvantages: Can be complex to troubleshoot, adding or removing devices disrupts the network and unnecessary calls are made in between.
Star:
- Description: Each device has a dedicated connection to a central hub or switch. Devices communicate by sending data to the central device, which then forwards it to the intended recipient.
- Advantages: Easy to manage and troubleshoot, failures in one device don’t affect others, scalable by adding more switches.
- Disadvantages: Relies on the central device (if it fails, the entire network is down), higher cost than bus or ring.
Tree:
- Description: Similar to a star, but with multiple layers. Central devices connect to other central devices, forming a hierarchical structure. Branches of the tree can be star or bus topologies.
- Advantages: Highly scalable and manageable, support large networks with different needs in different areas.
- Disadvantages: Complex to set up and maintain, single point of failure at higher levels of the hierarchy.
Mesh:
- Description: Devices are connected to multiple other devices, creating a web-like structure. Data packets can take multiple paths to reach their destination, making the network highly resilient.
- Advantages: Very reliable, self-healing (can bypass failed devices), suitable for wireless networks.
- Disadvantages: Complex to set up and manage, higher cost than other topologies.
Structure of the Network
OSI Model[V.imp]
If you read till here you have noticed one thing everything is made by humans, and as a read you and I are also human — Think about it.
TCP/IP Model vs OSI Model
One main difference between the OSI model and the TCP/IP model lies in their structure and practical use:
- OSI Model: This is a conceptual model with 7 layers. It serves as a theoretical framework for understanding network communication and doesn’t define specific protocols. It’s rarely used in real-world implementations due to its complexity.
- TCP/IP Model: This is a practical model with 4 layers and specifies actual protocols used on the internet. It’s the dominant model in actual network implementations and forms the basis for communication on the Internet.
Therefore, the main difference lies in their approach:
- OSI: Has 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application.
- Provides a conceptual framework for understanding network communication functionalities and how different layers interact.
- TCP/IP: Has 4 layers: Application, Transport, Network, and Link.
- Defines how data is packaged, addressed, transmitted, and received across networks.
Real-world implementation: Unlike the OSI model, which is solely a theoretical framework, the TCP/IP model is used in everyday networking. Its protocols like TCP, IP, and HTTP form the backbone of internet communication. Devices built today, from computers to smartphones, all speak the “language” of the TCP/IP model.
Note:
Ping — A network utility that sends a signal to a target device (like a website or another computer) and measures the time it takes for that signal to return.
Ping Time — The round-trip time it takes for the ping signal to reach the target device and come back, measured in milliseconds (ms). We can’t reduce ping time because we getting the best possible ping time.
Study from here: Hub, Repeater, Bridge, Switch, Router, Gateways, and Brouter [first read OSI model then this]
Protocols
- Define “how to talk”: Think of protocols as languages for devices. They establish rules for formatting data, sending and receiving information, and ensuring everyone “speaks” the same way. Without them, a computer sending 8-bit packets wouldn’t understand one expecting 16-bit!
Let’s talk about different types of protocols:
Network Layer:
- IP (Internet Protocol)
Transport Layer:
- TCP (Transmission Control Protocol)
- UDP (User Datagram Protocol)
Application Layer:
- HTTP (Hypertext Transfer Protocol): The foundation of web browsing, enabling communication between browsers and servers to request and transfer web pages.
- HTTPS (Hypertext Transfer Protocol Secure): Encrypted version of HTTP for secure communication, protecting sensitive data like passwords and credit card information.
- FTP (File Transfer Protocol): Used for transferring files between computers.
- SMTP (Simple Mail Transfer Protocol): Responsible for sending and receiving emails.
Application-Specific Protocols:
- RTP (Real-time Transport Protocol) — for audio/video streaming
- UDP (User Datagram Protocol), is a communication protocol that operates within the internet protocol suite (TCP/IP).
- Think of it as a less strict and faster way to send data compared to its counterpart, TCP (Transmission Control Protocol).
- Telnet: Telnet, short for Teletype Network, was once a prominent protocol for remotely accessing computer systems. It provided a command-line interface to connect to a server and execute commands as if you were sitting directly in front of it. However, due to its inherent security vulnerabilities, Telnet is no longer considered a secure option for remote access, rise of more secure protocols like SSH.
- SSH (Secure Shell): Lets you remotely control another computer securely and establishes a secure encrypted connection between two computers over a network.
- DHCP (Dynamic Host Configuration Protocol): automatically assigning IP addresses and other configuration settings to devices on a network.
Security Protocols:
- SSL/TLS (Secure Sockets Layer/Transport Layer Security):
Link Layer protocols:
- Ethernet, Wi-Fi (IEEE 802.11), PPP (Point-to-Point Protocol), etc.
A disadvantage of SSL:
SSL (Secure Sockets Layer) aimed to solve the problem of unsecured communication over the internet.
Before SSL, data sent between websites and users, like passwords or credit card numbers, traveled in plain text, easily accessible to anyone snooping in on the network.
SSL introduced encryption and authentication tools, scrambling data to make it unreadable and verifying the identity of both sender and receiver, ensuring only authorized parties could access information. However, older versions of SSL (2.0 and 3.0) have known vulnerabilities, making them insecure.
The successor, TLS (Transport Layer Security), addresses these issues with stronger encryption, improved protocols, and active development, offering a more robust solution for secure online communication.
So, while SSL serves as a starting point, it’s crucial to use the enhanced security provided by TLS today.
- POODLE (Padding Oracle On Downgrade Attack): This vulnerability allows attackers to decrypt portions of encrypted data, potentially revealing sensitive information.
- BEAST (Browser Exploit Against SSL/TLS): This vulnerability allows attackers to decrypt entire messages sent over an SSL connection.
- Heartbleed: This vulnerability exposes sensitive memory contents on SSL servers, potentially leaking passwords, private keys, and other confidential data.
DNS (Domain Name System)
DNS is like the address book that tells you how to reach each house. It converts the website names you type in (like www.example.com) into numerical addresses (IP addresses) that computers understand.
Why do we need it?
- Easy to remember: Domain names are much simpler for us humans to remember than strings of numbers.
- IP addresses can change: The IP address of a website might change over time, but the domain name usually stays the same. DNS keeps track of these changes ensuring you’re always directed to the right place.
How DNS Works: A Simplified Analogy
- You type in a website: Let’s say you want to go to www.google.com.
- Your computer asks its friend, the DNS resolver: Your computer doesn’t know the address, so it consults a local DNS server (often provided by your Internet Service Provider) as a starting point.
- The search widens:
- Cache hit: If the DNS resolver has the address stored in its memory (cache), it gives it directly to your computer. Mission accomplished!
- Cache miss: If not, the resolver goes on a wider search:
- Root servers: The resolver contacts top-level “root” DNS servers, which tell it where to find the authoritative servers responsible for domains like “.com”.
- Top-level domain (TLD) servers: The resolver gets in touch with the TLD servers for “.com” domains.
- Authoritative nameservers: These servers hold the specific information about “www.google.com" and finally provide its IP address.
4. The address is delivered: The DNS resolver gives the IP address to your computer.
5. Connection established! Your browser can now use the IP address to contact Google’s server and load its website.
Key Points
- DNS is hierarchical: It’s like a massive tree with branches leading to specific domains. This makes the system efficient and scalable.
- DNS is everywhere: Every internet-connected device relies on DNS.
- Caching: DNS servers store records for a while, meaning lookups can be much faster the next time someone needs the same website.
Process VS. Thread
Process:
- Think of it as An individual program in execution. Each process has its own memory space, resources (like files), and execution context.
- Independence: Processes are isolated from each other. This means that an issue in one process won’t affect another.
- Cost: Creating and managing processes takes more resources than threads.
- Synchronization: Less frequent synchronization is needed between processes, as they don’t directly share resources.
- Examples: Your web browser (multiple tabs as separate processes), word processor, music player.
synchronization refers to the mechanisms used to coordinate the execution of multiple processes or threads that access shared resources to ensure data consistency and prevent interference.
Thread:
- Think of it as A lighter-weight unit of execution within a process. Imagine one process with multiple threads working concurrently.
- Shared resources: Threads within a process share the same memory space and resources, enabling efficient communication and data exchange.
- Concurrency: Multiple threads can execute different tasks simultaneously within the same process, improving responsiveness and performance for certain tasks.
- Overhead: Creating and managing threads is faster and uses less memory than processes.
- Synchronization: Requires careful synchronization to avoid conflicts when multiple threads access shared resources.
- Examples: Downloading multiple files in a browser (each file downloaded as a thread), spell check running while you type in a word processor.
Analogy: Imagine you’re working on a video editing software The entire video editing software can be considered a single process. It has its own memory space to store the editing software code, the video files you’ve imported, and any temporary files generated during editing. It also has access to system resources like your computer’s CPU and GPU for processing the video and displaying it on your screen. Within this video editing software process, several threads can work together to achieve various functionalities: User interface thread, Video decoding thread, Audio decoding thread, Background rendering thread:
Sockets
- What is a socket? A socket is a software endpoint. Imagine it like a telephone jack on the wall. It allows two applications, potentially running on different machines, to establish a connection and talk to each other.
- Real-world Analogy: Think of sockets as the doorways that enable different services to communicate within a network and across the broader internet.
How Sockets Solve Problems
- Device Communication:
- Web browsing: When you type a website address, your browser creates a socket to contact the web server using its IP address and port number (a specific ‘door’ on that server). This socket facilitates sending the request for the webpage and receiving the data back.
- Email: Your email client communicates with mail servers using sockets to send and receive emails.
- Smart home devices: Smart lightbulbs, thermostats, and other devices often communicate over networks using sockets to send commands and receive updates.
- Online games
2. Building Custom Applications:
- Real-time chat: Chat programs use sockets to quickly exchange messages between users without constant page refreshes.
- File sharing: Peer-to-peer sharing applications often depend on sockets for direct communication between users’ computers.
- Internet of Things (IoT): Sockets allow myriad IoT devices to share sensor data, receive commands, and interact with each other.
Core Socket Concepts
- IP address and port number: A socket is uniquely identified by a combination of the device’s IP address and a port number. Think of it as the full address of a specific service/application on that device.
- Protocols (TCP and UDP): Sockets usually rely on communication protocols. TCP provides reliable, ordered data transfer (like a phone call). UDP is faster but less reliable (like sending a postcard).
- Client-Server model: Many network communications use this model, where one device (client) initiates a connection to a socket on a server.Function:
- Create communication channels between applications on different computers or within the same machine.
- Act as endpoints for sending and receiving data over a network.
- Facilitate data exchange using different protocols like TCP (Transmission Control Protocol) for reliable delivery or UDP (User Datagram Protocol) for speed.
Key Features:
- Bound to an address: Similar to your home address, each socket has a unique combination of an IP address and port number, identifying its location on the network.
- Bidirectional communication: Unlike a one-way street, sockets allow data to flow in both directions, enabling two-way conversations between applications.
- Abstraction layer: They simplify network communication by hiding the complex details of underlying protocols, making it easier for developers to build applications.
Types of Sockets:
- Stream sockets: Like a continuous stream of water, these offer reliable, ordered data delivery, ideal for applications like file transfers or web browsing. (Example: TCP)
- Datagram sockets: Similar to quick bursts of water packets, these prioritize speed over order, used for applications like online gaming or streaming media. (Example: UDP)
Ephemeral Ports
- Definition: Ephemeral ports are temporary communication endpoints assigned by a device’s operating system when a client program wants to talk to a server. Think of them as disposable phone numbers for outgoing calls — they exist only for the duration of that specific conversation.
- Range: Typically, operating systems use a range of high-numbered ports (often 49152–65535) for ephemeral ports.
- Why “ephemeral”? They are short-lived. Once a communication session ends, the operating system releases the ephemeral port, making it available again for other connections.
How Ephemeral Ports Solve Problems
- Managing Many Outgoing Connections:
- Imagine your web browser. You likely have multiple tabs open, each loading a website. Each of these outbound connections needs a unique starting point on your device — that’s where ephemeral ports come in.
- The OS can assign different ephemeral ports to each connection, allowing them to run simultaneously without crashing.
2. Security (A Little Bit):
- The randomness of ephemeral port assignments makes it a bit harder for attackers to guess the “source” of network connections, adding a minor layer of security.
3. Compatibility with Servers:
- A server, like a web server, typically listens on a well-known, fixed port (like port 80 for HTTP).
- Clients can initiate connections from any of the available ephemeral ports, ensuring flexibility. Since the server knows where to send its response, this works seamlessly.
Real-World Scenario
You open three browser tabs:
Tab 1: Loads www.example.com
- Your OS assigns ephemeral port 50234 for this connection.
Tab 2: Loads www.newssite.com [invalid URL removed]
- Your OS assigns ephemeral port 55812 for this connection.
Tab 3: Loads your email inbox.
- Your OS assigns ephemeral port 61379 for this connection.
Each website’s server will send responses back to your device addressed to the correct ephemeral port, ensuring the right data reaches the right tab!
HTTP in DETAIL
HHTTP: The Language of the Web
- What is HTTP? HTTP stands for Hypertext Transfer Protocol. It’s a set of rules that defines how web browsers and web servers communicate to exchange information. Think of it as the language they use to understand each other.
The Core Mechanism:
- Request-response model: HTTP is based on a simple model. Your web browser sends a request to a web server (e.g., “Please give me the homepage of www.example.com"). The server processes that request and sends back a response (the website’s code, images, etc.).
Real-World Problems HTTP Solves
- Retrieving and displaying web resources:
- The whole point of the web: HTTP was designed to make it possible to fetch web pages (HTML files), download images, videos, and other resources from servers connected to the internet. Without HTTP, we wouldn’t have the web as we know it!
2. Structuring web communication:
- Standardization: HTTP defines a common language that all web browsers and servers understand. This means developers can build websites and browsers without worrying about compatibility, as long as everyone follows the HTTP rules.
- Data types: HTTP allows for transmitting different kinds of content (text, images, multimedia, etc.) in a structured way.
3. Navigating and interacting with the web:
- Hyperlinks: HTTP provides the framework for how hyperlinks function, allowing us to jump from one web page to another effortlessly.
- Forms: You can fill out forms on websites (like logins, searches, etc.) thanks to the way HTTP handles the submission of that data to the server for processing.
Key Features of HTTP
- Stateless: Each HTTP request-response cycle is independent. The server doesn’t “remember” a client from one request to the next (though additional mechanisms can be used to manage sessions).
- Methods: HTTP defines actions a client can request (“GET” to fetch a resource, “POST” to submit data).
- Status codes: Servers send back status codes (like “200 OK” for success, or “404 Not Found” for errors) which help the browser understand the result of the request.
TCP, on the other hand, ensures reliable data delivery:
- Establishes a connection between client and server before sending data.
- Guarantees ordered and error-free delivery of data packets.
- Uses mechanisms like acknowledgments and retransmissions to ensure complete and accurate data transfer.
Combining HTTP and TCP creates a robust communication system:
- HTTP builds on top of TCP: The browser generates an HTTP request and sends it to the server through the established TCP connection.
- TCP breaks down the HTTP request into packets: These packets are transmitted across the network, ensuring reliable delivery.
- The server processes the request and builds an HTTP response: The response is also divided into packets and sent back through the TCP connection.
- TCP delivers the response packets to the browser: The browser reassembles the packets and interprets the HTTP response for display or further processing.
Error and Status code
Common Status Code Categories:
- 1xx Informational: The request is received and is continuing to be processed. (e.g., 100 Continue)
- 2xx Success: The request was successfully processed and completed. (e.g., 200 OK)
- 3xx Redirection: Further action is needed to complete the request, often involving redirection to another page. (e.g., 301 Moved Permanently)
- 4xx Client Error: The request contains an error or cannot be fulfilled due to something on the client side. (e.g., 404 Not Found, 403 Forbidden)
- 5xx Server Error: The server encountered an error and could not complete the request. (e.g., 500 Internal Server Error)
Cookies
Unique string
- The Server Sends the Cookie:
- While browsing a website, the server might decide to store some information about you as a cookie. This information could be your login credentials, shopping cart contents, preferred language, or browsing history on that specific site.
- The server creates a cookie file with this information, including an expiration date and other attributes.
- It then sends a request to your browser containing the cookie data and tells it to store it locally on your device.
2. Your Browser Accepts or Rejects:
- Your browser checks its cookie settings and preferences:
- If configured to accept cookies, it stores the received cookie on your device, typically associated with the website’s domain.
- If set to block cookies, it rejects the request, and the server won’t store any information about you on your device.
3. Remembering Across Visits:
- When you revisit the same website later:
- Your browser automatically sends all stored cookies for that website’s domain along with your subsequent requests.
- The server recognizes these cookies and retrieves the information stored within them.
- This allows the website to “remember” you and personalize your experience based on the stored data.
4. Different Types, Different Uses:
- Session Cookies: These are temporary cookies that vanish when you close your browser window.
- Persistent Cookies: These cookies stay on your device for a longer duration, even after closing your browser.
- First-Party Cookies: These are placed by the website you’re directly visiting and only accessible by that website.
- Third-Party Cookies: These are placed by other domains embedded in the website you’re visiting, like advertising trackers.
How does E-MAIL work?
The Journey of an Email
1. You Compose and Hit “Send”
- Your Mail Client: You type your message in an email program (like Gmail or Outlook) or a webmail interface.
- Behind the Scenes: When you hit “Send,” your mail client does a few things:
- Format your email with necessary headers (to/from addresses, subject, etc.)
- Contacts your outgoing mail server (SMTP server).
2. The Outgoing Mail Server (SMTP)
- The Post Office: The SMTP server is like your local post office. It handles outgoing mail:
- Determines the recipient’s email address and locates their mail server.
- Break down your email into smaller packets for efficient transmission.
- Sends the email packets onwards, potentially hopping through multiple mail servers in the process.
3. The Recipient’s Incoming Mail Server (IMAP or POP3)
- The Recipient’s Post Office: The email travels across the internet, finally reaching the server responsible for the recipient’s inbox. This could be a POP3 server (older type) or a more common IMAP server.
- Sorting and Storage: This server sorts the email and stores it in the recipient’s mailbox.
4. The Recipient Checks Their Mail
- Mail Client to the Rescue: The recipient uses an email client or webmail to connect to their mail server.
- Download and Display: The email client downloads the email from the server and displays it on their screen.
Real-World Analogy: Sending a Letter
- Writing and Addressing: You write a letter and put it in an envelope with the recipient’s address.
- Local Post Office: You drop the letter in a mailbox. Your local post office sorts and dispatches the letter to the recipient’s region.
- Intermediate Stops: The letter might go through several sorting centers in between, ensuring it follows the most efficient route.
- Recipient’s Post Office: The letter arrives at the post office closest to the recipient’s address and is placed in their mailbox.
- Pick Up: The recipient goes to their mailbox and retrieves the letter.
Key Points
- Protocols: Email relies on a few crucial protocols — SMTP for sending, and POP3 or IMAP for receiving.
- Speed: Emails travel incredibly fast, often taking only a matter of seconds or minutes for delivery.
- Behind the Scenes: A complex network of servers and protocols works continuously to make the seemingly simple email process happen!
POP3 (Post Office Protocol version 3):
This is an older, simpler protocol for accessing email. When you use POP3:
- Your email client connects to the POP3 server and downloads all new emails to your device.
- Once downloaded, the emails are typically deleted from the server.
- This means you can only access your emails from the device where you downloaded them unless you set up manual forwarding or use webmail.
IMAP (Internet Message Access Protocol):
This is a more modern and flexible protocol compared to POP3:
- Your email client connects to the IMAP server and displays a list of your emails.
- You can choose to download only specific emails or keep them on the server for access from any device.
- This allows for unified access to your inbox from different devices, as everything is kept synchronized on the server.
When both parties use the same email provider:
- Internal System: If both the sender and recipient use the same email provider (like Gmail or Outlook), they might not necessarily use POP3 or IMAP for message exchange.
- Direct Delivery: Many email providers like Gmail can directly transfer messages between user accounts on their own servers using internal protocols. This is generally faster and more efficient than using external protocols like POP3/IMAP.
When different email providers are involved:
- POP3/IMAP is more likely to be used: This is because different providers need a standardized way to communicate and transfer messages across their independent systems.
- SMTP is still used: Regardless of whether POP3/IMAP is used for receiving, SMTP (Simple Mail Transfer Protocol) is always used for sending emails. It’s the standard protocol for sending emails between any email servers, regardless of the provider.
DNS(TCP/IP model- application layer)
DNS (Domain Name System) plays a crucial role in translating human-readable domain names (like https://www.google.com) into numerical IP addresses (like 142.250.184.207) that computers can understand and use to communicate.
Here’s how DNS fits into the TCP/IP model:
Layers of the TCP/IP Model:
- Application Layer: This includes applications like web browsers, email clients, and games that initiate communication requests.
- Transport Layer: This layer manages the reliable and efficient transfer of data between applications on different devices. Protocols like TCP and UDP reside here.
- Network Layer: This layer handles the addressing and routing of data packets across the network. The primary protocol here is IP (Internet Protocol), which uses IP addresses to identify devices.
- Data Link Layer: This layer manages physical network communication and transmission of data packets on the specific network media (Ethernet, Wi-Fi).
- Physical Layer: This layer deals with the physical transmission of data bits over the network medium (cables, wires).
DNS and the Application Layer:
- DNS sits at the Application Layer of the TCP/IP model. This is because it interacts directly with applications like web browsers to resolve domain names.
Interaction with Lower Layers:
- Application Requests Domain Name: When you type a website address (like https://www.google.com) in your browser, it sends a request to the DNS resolver on your device.
- DNS Resolver Queries Nameservers: The DNS resolver uses the UDP protocol and sends a query message to one or more DNS nameservers, typically provided by your internet service provider (ISP).
- DNS Response with IP Address: The DNS nameservers search their databases and send a response back containing the corresponding IP address of the website.
- Application Connects using IP Address: The browser receives the IP address and uses the TCP protocol to establish a connection with the web server using the identified IP address.
- Data Exchange: Once connected, the application can exchange data with the web server using established protocols like HTTP for web browsing.
Key Points:
- DNS operates at the Application Layer.
- It interacts with lower layers (Transport and Network) through protocols like UDP for queries and TCP for subsequent communication.
- DNS translates human-readable domain names into IP addresses used by computers for network communication.
How DNS Works:
Resolvers: The intermediaries that translate domain names to IP addresses on your behalf.
DNS also uses UDP
- Initiation: You type a domain name into your web browser (e.g., [invalid URL removed]).
- Recursive Resolver: Your computer contacts its designated resolver, which is usually provided by your internet service provider (ISP). This resolver acts like a phone book directory.
- Root Servers: The resolver starts by querying the root servers, which are the ultimate source of information about the domain name system. These are geographically distributed around the world for redundancy and speed.
- TLD Servers: Based on the domain name extension (e.g., .com, .org), the root server directs the resolver to the appropriate Top-Level Domain (TLD) server.
- Authoritative Name Servers: Finally, the TLD server points the resolver towards the domain’s authoritative name servers. These servers hold the actual IP address associated with the domain name.
- Response: The resolver retrieves the IP address from the authoritative name servers and caches it for future use.
- Connection: Your computer uses the retrieved IP address to connect to the web server hosting the website you requested.
mail.google.com => mail — sub domain, google — second level domain(because top level me .com, .org. io aate hai), com — Top level domain TLD
who is maintaining root DNS server just visit root server. org and see in every continent every country state has this server that is controlled if you visit this website you will see in every direction of a country these servers are installed
The 13 root name servers are operated by 12 independent organizations.
this top-level domain is registered by ICAN
whenever you visit the website for the first time it will store the value of its IP address in your local cache/database if not find the look at local DNS server(Situated within a local network/Home routers often have built-in local DNS servers with basic functionality) many times it is your ISP.
root server act as the initial directory, pointing resolvers to the appropriate Top-Level Domain (TLD) servers for further information.
real look how work
you can’t buy a domain name just rent it
Transport Layer(TCP/IP model)
Data transfer from one network to another is done network layer, but Data from network to the application(within the devices) is done by transport layer, which application I send this arrived data is done by transport layer.
The transport layer in the OSI/TCP-IP model is indeed multiplex, meaning it allows multiple applications on a single device to share a single network connection. This capability is crucial for efficient network use and enables seamless communication between various applications simultaneously.
Here’s how transport layer multiplexing works:
- Data segmentation: The transport layer takes data from different applications and breaks it into smaller segments.
- Port identification: Each segment is tagged with a port number, which identifies the specific application the data belongs to.
- Multiplexing: These segments from different applications are then combined into a single data stream and sent over the network connection.
- Demultiplexing: On the receiving device, the transport layer receives the combined data stream, identifies the destination application for each segment based on its port number, and delivers the segmented data to the corresponding applications.
“single network connection” can refer to a couple of different things, depending on the specific scenario:
1. Physical network connection:
- This could be a single wired connection (e.g., Ethernet cable) or a wireless connection (e.g., Wi-Fi) shared by multiple applications on a single device.
- For example, your laptop might have a single Ethernet connection to your home network, but multiple applications like your web browser, email client, and video streaming service can all use that connection simultaneously thanks to transport layer multiplexing.
2. Logical network connection:
- This refers to the virtual connection established by the transport layer protocol (e.g., TCP or UDP) between a specific application on your device and an application on another device.
- Even if you have multiple physical network connections, each application might establish its own logical connection using the transport layer to communicate with its counterpart.
- For instance, your web browser might have a separate logical TCP connection to each website you visit, even though they all use the same physical connection to the internet.
to refer machine we use IP address, to refer application we use port number.
Checksums: Detecting Data Errors
Use by Transport layer.
A checksum is a small piece of data or random number, typically calculated over a larger block of data, used to detect errors that might have occurred during transmission or storage.
It acts like a quick and efficient way to verify the integrity of the original data.
How it works:
- Calculation: An algorithm applies a mathematical function (e.g., XOR, CRC) to the original data block, generating a checksum value.
- Attachment: The checksum is appended to the data block before transmission or storage.
- Verification: At the receiving end, the same algorithm is applied to the received data block, including the attached checksum.
- Comparison: If the calculated checksum matches the original checksum, it indicates no errors occurred. If they differ, it suggests data corruption.
Timers
Timers are like Watchdogs.
Retransmission Timer:
- Function: Monitors how long it takes for an acknowledgment (ACK) to arrive for a sent segment.
- Action: If the timer expires without an ACK, the segment is assumed lost and retransmitted.
- Adapts: The timer value dynamically adjusts based on network conditions, increasing for potential delays and decreasing for faster connections.
So problem with this if i send packet friend recevie it and he send confirmation but you don’t recevice and timer expeire and retrying to send that packet and because of this 2 duplicate packets now the friend have and because of this sequence number comes in existence.
To every packet/segement value is provided and if 2 packet of same sequence we have so we identify that it is duplicate.
UDP is Transport layer protocol
User Datagram Protocol: In TCP it make sure there is a connection between twos then it send data but in UDP it is connection less but still send/rececive.
UDP uses checksum, in UDP packet — [source port no. + destination port no. + length of datagram + checksum] — header+ DATA are avaialable.
Header is 8 byte and one UDP packet you can send 65,536 byte.
UDP (User Datagram Protocol) sits alongside TCP as one of the fundamental transport layer protocols in the TCP/IP suite. Unlike its more methodical counterpart, UDP prioritizes speed and efficiency over guaranteed delivery and order. Here’s a detailed analysis:
Key Characteristics:
- Connectionless: Doesn’t establish a handshaking process before sending data, offering immediate transmission without the overhead of connection setup.
- Unreliable: Doesn’t guarantee delivery or order of packets, making it suitable for time-sensitive applications like streaming media or online gaming where slight data loss is acceptable.
- Fast: Achieves quicker transmission due to its simpler structure and lack of error-checking procedures.
- Small header: Minimizes overhead with a smaller header compared to TCP.
- Broadcast and Multicast: Can send data to multiple recipients simultaneously, making it useful for real-time communication like video conferencing.
TCP is Transport layer protocol
SMTP, POP3, IMAC these application layer protocol uses which Transport layer protocol — TCP
TCP (Transmission Control Protocol) is a cornerstone protocol in the TCP/IP suite, widely used for reliable and ordered data transfer across networks. Think of it as the meticulous courier ensuring every package arrives at its destination safely and in the correct sequence. Here’s a breakdown of its key features:
Key Characteristics:
- Connection-oriented: Establishes a virtual connection between sender and receiver before data exchange, ensuring both parties are ready and prepared.
- Reliable: Uses mechanisms like acknowledgments (ACKs) and retransmissions to guarantee delivery of all data segments in the correct order.
- Flow control: Adjusts data transmission based on the receiver’s capacity to prevent overwhelming their resources.
- Congestion control: Dynamically adapts to network conditions, avoiding congestion and optimizing data flow.
- Error checking: Employs checksums and sequence numbers to detect and correct transmission errors.
1 TCP connection only between 2 computer means to connect other required another TCP and TCP is full Duplex means data can simolutanously send from one to another.
The 3-Way Handshake: Orchestrating Reliable Communication in TCP
In the bustling world of network communication, the 3-way handshake plays a crucial role in establishing smooth and reliable connections before data transfer. Imagine it as a polite greeting and confirmation process before two friends begin a conversation.
Here’s how this “digital handshake” works in TCP (Transmission Control Protocol):
1. SYN (Synchronize): The client initiates the process by sending a SYN (Synchronize) packet to the server. This packet includes a sequence number that serves as the starting point for the data stream.
2. SYN-ACK (Synchronize Acknowledge): The server acknowledges the client’s request by sending back a SYN-ACK (Synchronize Acknowledge) packet. This packet contains its own sequence number and an acknowledgment number confirming receipt of the client’s sequence number.
3. ACK (Acknowledge): Finally, the client sends an ACK (Acknowledge) packet back to the server, acknowledging the SYN-ACK and completing the handshake.
sequence number are random number because if it is not random then it become easy to guess and anyone would establish connection with server, security purpose is random number
Sequence numbers are 32-bit integers,
Network Layer(TCP model)
in network layer router works
Responsibilities:
- Routing: Determines the best path for data packets to travel through interconnected networks. This involves analyzing network topology, traffic conditions, and various routing protocols.
- Logical addressing: Uses logical addresses like IP addresses to identify devices on the network, allowing them to communicate across different physical segments.
- Packet forwarding: Hands off data packets to the next network device on the chosen route, directing them closer to their destination.
- Congestion control: Manages network traffic to prevent overload and ensure smooth data flow by employing techniques like queueing and congestion avoidance algorithms.
Key protocols:
- IP (Internet Protocol): The dominant protocol for addressing and routing on the internet.
routing table may have multiple path’s information to send data and forwarding table basically data structure only contain one path much more faster — exist inside router, every single router has its own network layer address. Who create the tables — Control plane
IP address: 232.213.32.232 -> 232.213.32 is network address/subnet, 232 is device addresshost id.
So when a router forward a packet it know subnet of the destination.
Control plane:
The control plane is the network’s “conductor,” directing data flow, managing devices, and enforcing policies for efficient and secure communication.
Two type of routing use to create table:
Static routing — adding address manually to go where to where if new added then manually do the changes and dynamic routing automate this.
IP(Internet Protocol)
Internet Protocol (IP) Explained:
The Internet Protocol, often abbreviated as IP, is the foundation of the internet as we know it. It’s a core protocol in the Internet Protocol Suite that acts like the postal service of the internet world. Here’s what it does:
Purpose:
- Enables internetworking: connects different networks and devices across the globe.
- Defines communication: dictates how data travels between devices based on their unique addresses.
- Routes packets: breaks down information into packets and directs them to the correct destination addresses.
Key Features:
- Addressing: assigns unique numeric labels called IP addresses to devices connected to the internet. These addresses act like the “delivery addresses” for data packets.
- Packet structure: packages data into “datagrams” containing header information (source and destination addresses) and the actual data.
- Routing: routers use the IP addresses in the packet headers to determine the best path for the data to reach its destination.
Versions:
- IPv4: the older version with 32-bit addresses, still widely used but running out of space.
- IPv6: the newer version with 128-bit addresses, offering a much larger address space and enhanced security.
IP Host Explained:
An IP host is any device connected to the internet that has its own unique IP address. This includes:
- Computers
- Laptops
- Mobile phones
- Tablets
- Servers
- Smart devices (TVs, refrigerators, etc.)
Each IP host acts as both a sender and receiver of information. It uses its IP address to communicate with other hosts over the internet and exchange data.
a node is any device that can connect to and communicate with other devices on the network.
Subnetting refers to the practice of dividing a single large network into smaller logical subnetworks.
Class of IP address:
- Class A: large networks with many hosts (range: 1.0.0.0–127.0.0.0)
- Class B: medium-sized networks with moderate hosts (range: 128.0.0.0–191.255.0.0)
- Class C: small networks with few hosts (range: 192.0.0.0–223.255.255.0)
- Class D: multicast addresses (range: 224.0.0.0–239.255.255.255)
- Class E: reserved for research and experimentation (range: 240.0.0.0–255.255.255.254)
Subnet masking: Subnet masking is a technique used to divide a single large network into smaller, logical subnetworks. Imagine it like creating neighborhoods within a city, where each neighborhood operates as an independent unit with its own set of addresses and boundaries.
Variable length subnet mask (VLSM), also known as variable lens subnet masking, refers to a technique used in IP network design to create subnets with different subnet masks. Unlike traditional subnetting where all subnets within a network use the same mask, VLSM allows for more flexibility and efficiency in address allocation.
Localhost:
- Refers to an alias (nickname) for a computer’s own IP address within its internal network or operating system.
Loopback Addresses:
- A broader term encompassing IP addresses is reserved for internal communication within a single device.
Packets:
A unit of information sent over a network from one device to another. Contain header, payload and trailer.
Header is of 20 bytes stores IPV, length, identification, flags, protocols, checksum TTL(Time To Live) etc.
TTL: lifespan of a data packet traveling across a network. Think of it like a self-destruct timer attached to the packet, ensuring it doesn’t circulate endlessly and cause network congestion.
- Each time a router forwards the packet, it decrements the TTL value by 1.
- Once the TTL reaches 0, the router discards the packet and sends an error message back to the sender (if applicable).
Network flags: Information embedded in network packets to signal specific conditions or instructions.
Flags are typically found within the header section of a data packet, alongside other essential information like source and destination addresses.
IPV4 vs IPV6
IPV4– 2³² ~ 4.3 billion,
IPV 6— 2¹²⁸ ~ 3.4 * 10³⁸
CONS of IPv6:
- Complexity: IPv6 addresses are longer and more complex than IPv4 addresses, requiring adjustments to network infrastructure and software. This complexity can increase implementation costs and require additional expertise.
- Compatibility: Many older devices and software applications don’t natively support IPv6, necessitating upgrades or workarounds. This can create compatibility issues and slow down migration efforts.
- Cost: Upgrading networks and devices to support IPv6 can be expensive for organizations and individuals, creating a barrier to adoption, ISP have to shift and alot of hardware work.
Middle Boxes
Middleboxes are devices situated within networks that intervene in and manipulate data flow between a source and a destination.
Specific Functions:
- Filtering: Firewalls filter traffic based on rules, blocking unwanted connections or content according to security policies.
- Translation: NATs translate private IP addresses within a network to a single public address for internet access, protecting internal privacy.
- Encryption/Decryption: Some middleboxes encrypt or decrypt data for secure communication across networks.
- Caching: Caching middleboxes store frequently accessed data, reducing server load and improving response times.
A firewall ac control and filter incoming and outgoing network traffic based on predefined security rules, acting as a barrier between your device or network and the outside world, typically the internet.
Function:
- Firewalls monitor incoming and outgoing data packets, which are small units of information traveling across networks.
- They filter packets based on predefined security rules, allowing or blocking them based on specific criteria.
These criteria can include:
- Source and destination addresses: Who is sending the data and who is it intended for?
- Port numbers: Which communication channels are being used?
- Type of data: Is it text, images, software, or something else?
- Content inspection: Some firewalls examine the actual content of packets for suspicious activity.
Type of firewall:
State-less Firewalls:
- Function: Analyze individual data packets based solely on information within the packet header, such as source and destination address, port number, and protocol type.
- Decision: Allow or block traffic based on pre-defined rules applied independently to each packet, without considering context or connection state.
Stateful Firewalls:
- Function: Track the state of network connections by monitoring past traffic and maintaining a dynamic table.
- Decision: Allow or block traffic based on both packet header information and the connection state (e.g., established, ongoing, suspicious).
Firewalls act as the first line of defense against various threats like malware, unauthorized access, and data breaches.
Load Balancer
A load balancer is a network device or software that distributes incoming traffic across multiple servers, often called backends or pool members.
The Process:
- Clients send requests: Users accessing your website or application send requests to a single IP address or hostname associated with the load balancer.
- Load balancer intercepts requests: The load balancer receives the requests and determines how to distribute them based on a chosen algorithm.
- Traffic distribution: The load balancer chooses a backend server from its pool based on the chosen algorithm. Common algorithms include:
- - Round robin: Distributes requests evenly among all available servers.
- - Least connections: Sends requests to the server with the fewest active connections.
- - Weighted: Assigns different weights to servers based on their capacity or performance.
4. Request forwarded: The chosen backend server receives the forwarded request and processes it.
5. Response sent: The server sends its response back to the load balancer, which relays it to the client.
What a Load Balancer Does:
It employs various algorithms to intelligently distribute incoming traffic across a pool of backend servers. These algorithms consider factors like:
- Server health and performance: The load balancer might send requests to the server with the least current load or fastest response time.
- Session persistence: Sometimes, it might direct requests to the same server for a specific user or session to maintain consistency.
- Weighted distribution: Certain servers might be assigned higher weights based on their capacity or priority.
Response Handling:
The server that receives the request processes it and generates a response. The load balancer doesn’t simply return the first response it receives. It typically waits for all responses from the chosen servers and then:
- Selects the best response: This might be based on speed, completeness, or other criteria depending on the configuration.
- Forwards the chosen response to the client: The client only interacts with the load balancer and receives a single response, unaware of the multiple servers involved.
Benefits of Load Balancing:
- Improved performance: Distributing traffic prevents overloading individual servers, leading to faster response times and a smoother user experience.
- Scalability: As traffic increases, adding more servers to the pool allows the load balancer to seamlessly handle growing demands.
- High availability: If a server fails, the load balancer automatically redirects traffic to other available servers, minimizing downtime and ensuring service continuity.
Load balancers operate on the server side of network communication
Network address translation (NAT)
Network Address Translation (NAT): Bridging the Gap Between Private and Public Networks.
Network Address Translation (NAT) acts as a translator between private and public networks, enabling multiple devices on a private network to share a single public IP address for accessing the internet.
Here’s how NAT works:
- Private vs. Public IP Addresses: Devices on a private network (like your home network) use unique private IP addresses for internal communication. These addresses are not routable on the internet and cannot be directly accessed from the outside world.
- Public IP Address: Your network router has a single public IP address assigned by your internet service provider (ISP). This address is unique and identifies your network on the internet.
- Translation Process: When a device on your private network initiates communication with an external device (e.g., accessing a website), the NAT router intercepts the request.
- It translates the private IP address of the requesting device to its own public IP address in the outgoing packet.
- The translated packet travels across the internet to the destination server.
- The server responds, sending the data back to the public IP address of your router.
- The NAT router then translates the public IP address back to the original private IP address of the requesting device and delivers the response.
Data Link Layer(TCP model)
The Data Link Layer, also known as Layer 2 in the TCP/IP model, plays a crucial role in network communication by ensuring reliable data transfer between network devices over a single physical link. Imagine it as the bridge that gets packets (small units of data) from one device to another on the same network segment, like an Ethernet cable or Wi-Fi connection.
Responsibilities:
- Framing: The layer adds header information to each data packet, containing details like source and destination addresses, error detection codes, and packet size. This “frame” allows devices to identify and process the data correctly.
- Addressing: It uses physical addresses (MAC addresses) to uniquely identify devices on the network segment, ensuring packets reach the correct recipient.[data link layer address, also known as a hardware address or MAC address,]
- Error detection and correction: The layer employs mechanisms like Cyclic Redundancy Check (CRC) to detect transmission errors and sometimes even fix them, ensuring data integrity.
- Flow control: It regulates the data flow between devices to prevent overwhelming the receiver and potential data loss.
The Data Link Layer operates on individual network segments, distinct from higher layers like the Network Layer that handle routing across different networks.
Address Resolution Protocol (ARP) cache acts as a temporary “phonebook” for translating Internet Protocol (IP) addresses into corresponding Media Access Control (MAC) addresses.
- When a device needs to communicate with another device on the same network (think browsing a website hosted on another computer), it knows the destination’s IP address but not its physical MAC address.
- The device consults its ARP cache, which stores recently discovered mappings between IP and MAC addresses.
Also you can block devices like this Mac address block
Note: I didn’t discover or write everything in this blog during study of my Computer Networking these materials came into my hand and I love to share with you — Ranjan Mishra