Computer Network Handwritten Notes
Computer Network Handwritten Notes
Introduction to Networks
What is a Network?
• Example: Your home Wi-Fi connects your phone, laptop, and TV to the internet.
Uses of Networks
Types of Networks
Reference Models
TCP/IP Model
The TCP/IP Model is a framework that describes how data is sent and received over the
internet. It has four layers:
2. Transport Layer: Ensures reliable data delivery (e.g., TCP for reliability, UDP for
speed).
3. Internet Layer: Routes data packets across networks (e.g., IP for addressing).
4. Link Layer: Handles physical connections and data transfer between devices.
OSI Model
The OSI Model (Open Systems Interconnection) is a theoretical model with seven layers to
explain how networks work:
1. Application Layer: Provides services for user applications (e.g., email, web
browsing).
2. Presentation Layer: Formats and encrypts data (e.g., converts text to a displayable
format).
4. Transport Layer: Ensures reliable data transfer (e.g., checks if data is received
correctly).
5. Network Layer: Routes data between networks (e.g., finds the best path for data).
6. Data Link Layer: Handles error-free data transfer between adjacent devices (e.g.,
Ethernet).
Examples Describes all networks Used by the internet (e.g., IP, TCP)
The internet is a global network of networks that connects billions of devices. Its
architecture is based on:
• Layers: Uses the TCP/IP model to handle data from applications to physical
connections.
• Components:
Physical Layer
• Role: Transmits raw bits (0s and 1s) over a medium (like cables or wireless signals).
Guided transmission media are physical cables that carry signals. Common types
include:
2. Coaxial Cable:
Wireless transmission media use electromagnetic waves to send data without cables.
Common types include:
1. Radio Waves:
o Used for Wi-Fi, Bluetooth, and mobile networks (e.g., 4G, 5G).
o Example: Your phone connects to Wi-Fi using radio waves.
2. Microwaves:
3. Infrared:
Switching
Switching is the process of directing data from one device to another in a network. It
happens at the Physical or Data Link Layer. Common types include:
1. Circuit Switching:
2. Packet Switching:
o Breaks data into small packets and sends them independently, reassembling
at the destination.
3. Message Switching:
o Example: Rarely used today but was used in early telegraph systems.
The Data Link Layer is the second layer in the OSI model (or part of the Link Layer in
TCP/IP). It ensures reliable data transfer between two directly connected devices (e.g., two
computers on the same network).
• Role: Takes raw bits from the Physical Layer, organizes them into frames (data
packets), and handles errors, flow control, and access to the shared medium.
• Example: When your laptop sends data over Wi-Fi to a router, the Data Link Layer
makes sure the data arrives correctly.
Design Issues
1. Framing:
o Groups bits into frames (like packets) with a start and end marker.
o Example: Adds headers and trailers to data to mark the frame’s boundaries.
4. Access Control:
o Decides which device can use a shared medium (like a Wi-Fi network) when
multiple devices want to send data.
5. Reliable Delivery:
Errors can occur during transmission (e.g., due to noise). The Data Link Layer detects and
sometimes corrects these errors:
1. Error Detection:
o Parity Check: Adds a parity bit to make the number of 1s even or odd. If the
count is wrong, an error is detected.
o Checksum: Calculates a value based on the data and sends it with the
frame. The receiver recalculates to check for errors.
2. Error Correction:
o Hamming Code: Adds extra bits to detect and correct single-bit errors.
o Retransmission: If errors are detected but not corrected, the sender resends
the frame (used in protocols like ARQ).
2. Stop-and-Wait Protocol:
o Sender sends one frame and waits for an acknowledgment (ACK) before
sending the next.
o Example: Like texting one message and waiting for a reply before sending
another.
1. Go-Back-N (GBN):
o If an error occurs (e.g., frame 3 is lost), the receiver discards frame 3 and all
later frames, and the sender resends from frame 3.
o Example: Like mailing 5 letters but resending all from the 3rd if one is lost.
2. Selective Repeat:
o Only the lost or corrupted frame is resent, not the entire window.
o Example: If frame 3 is lost, only frame 3 is resent, and the receiver keeps
frames 4 and 5.
When multiple devices share the same network medium (like a Wi-Fi channel), Multiple
Access Protocols decide who can send data to avoid collisions (when two devices send at
the same time).
ALOHA
• Pure ALOHA:
o Pros: Simple.
• Slotted ALOHA:
o Time is divided into slots, and devices only send at the start of a slot.
• Cons: Collisions can still happen if two devices start sending at the same time.
CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
• Devices listen before sending and use a handshake (Request to Send/Clear to Send)
to avoid collisions.
Collision-Free Protocols
The Network Layer is the third layer in the OSI model (or Internet Layer in TCP/IP). It is
responsible for moving data packets from one device to another across different networks,
like from your computer to a server on the internet.
• Role: Finds the best path for data to travel, handles addressing, and ensures
packets reach their destination.
• Example: When you visit a website, the Network Layer routes data packets from
your device to the website’s server.
1. Routing: Deciding the best path for packets to travel across networks.
3. Packet Forwarding: Moving packets from one router to the next until they reach the
destination.
• Store and Forward: Routers receive a packet, store it in memory, check for errors,
and then forward it to the next router or destination.
• Example: Like a post office sorting and forwarding a letter to the next office until it
reaches the recipient.
1. Connectionless Networks:
2. Connection-Oriented Networks:
o A connection is established before sending data, and all packets follow the
same path.
Routing Algorithms
Routing algorithms determine the best path for packets to travel from source to
destination. They aim to be efficient, fast, and adaptable to network changes.
Optimality Principle
• States that if a router J is on the optimal path from router I to router K, then the path
from J to K is also optimal.
• Example: If the best route from A to C goes through B, then B to C is also the best
route.
• Finds the path with the least cost (e.g., shortest distance, lowest delay).
Flooding
• Sends a packet to all neighboring routers, which then send it to their neighbors, and
so on.
• Cons: Wastes bandwidth, can overload the network (uses techniques like sequence
numbers to avoid loops).
• Each router maintains a table listing the distance (cost) to every destination and the
next hop.
• A problem in Distance Vector Routing where routers keep increasing the distance to
a failed destination, taking a long time to realize it’s unreachable.
• Example: If a link to Router C breaks, Router A and B may keep updating each other
with higher distances (e.g., 3, 4, 5…) before realizing C is down.
• Solution: Use techniques like split horizon (don’t send routes back to the neighbor
you learned them from) or poison reverse (advertise failed routes as infinite).
• Each router:
• Example: Router A sends, “I’m connected to B (cost 2) and C (cost 5),” and all
routers build a map of the network.
• Similar to Distance Vector, but instead of distances, routers share the full path to a
destination.
• Example: Router A says, “To reach C, go through A-B-C,” instead of just “C is 3 hops
away.”
• Pros: Avoids loops, good for large networks like the internet.
Hierarchical Routing
• Divides the network into regions or areas, and routers only know detailed routes
within their region.
• Example: A router in New York knows all routes in New York but only major routes to
California.
Congestion happens when too many packets overload the network, causing delays or
packet loss. Congestion control algorithms manage traffic to keep the network running
smoothly:
o Limits the rate at which packets are sent, like water dripping from a bucket.
o Example: A router can send a burst of data if it has enough tokens, then
waits for more.
3. Choke Packets:
o When congestion occurs, routers send choke packets to the source to slow
down.
IP Addresses
• Uses a prefix length (e.g., /24) to specify how many bits are for the network part.
• Example: 192.168.1.0/24 means the first 24 bits are the network, and the rest are
for hosts.
Subnetting
• Divides a large network into smaller subnetworks (subnets) for better management.
SuperNetting
IPv4
• IPv4 uses 32-bit addresses (e.g., 192.168.1.1), written as four numbers (0–255)
separated by dots.
Packet Fragmentation
• If a packet is too large for a network’s maximum size (MTU), it’s broken into smaller
fragments.
IPv6 Protocol
• Features:
Since IPv4 and IPv6 are not directly compatible, transitioning requires special methods:
1. Dual Stack:
3. Translation:
• How It Works:
• Example: Your computer uses ARP to find the MAC address of your router.
• Used by devices (e.g., diskless workstations) that know their MAC but need an IP.