Computer Networks:
Computers aren’t standalone. All are connected by internet.
Data = any kind of information that needs to be sent from one device to another.
This can include:
A web page you requested
An image
A file you're downloading
A message you're sending
Internally, data is just a stream of binary digits (bits) → 0s and 1s.
IP (Internet Protocol) is the principal communications protocol in the Internet protocol suite for relaying
packets of data across network boundaries. Its job is to address and route data so it can travel across
networks and arrive at the correct destination.
Version Description
IPv4 The most widely used version. Uses 32-bit addresses (e.g., 192.168.1.1). Limited to
~4.3 billion unique addresses.
IPv6 Newer version. Uses 128-bit addresses (e.g., 2001:0db8:85a3::8a2e:0370:7334).
Supports vastly more devices.
✅The 5 Layers of the TCP/IP Model with Example
1 ⃣ Physical Layer
What it does:
Transmits raw bits (0s and 1s) over a physical medium (like cables or radio waves).
Deals with electrical signals, light pulses, or wireless transmission.
Example:
Your Wi-Fi antenna or Ethernet cable sends electrical signals from your laptop to your
router.
Analogy:
Like the road that a truck drives on.
2 ⃣ Data Link Layer
What it does:
Responsible for MAC addressing, framing, error detection, and direct delivery
between two devices on the same network.
Example:
Your laptop sends a frame with its MAC address and the router’s MAC address via Wi-
Fi.
Protocols:
Ethernet, ARP, Wi-Fi (IEEE 802.11)
Analogy:
Like the driver of the delivery truck ensuring it gets from your house to the city gate.
3 ⃣ Network Layer
What it does:
Responsible for routing, IP addressing, and sending packets across different networks.
Example:
Your data packet goes from your router to an ISP router to Google’s data center using IP
routing.
Protocols:
IP (Internet Protocol), ICMP (used in ping), IGMP
Analogy:
Like choosing the best route across cities to reach the destination.
4 ⃣ Transport Layer
What it does:
Ensures reliable delivery, error checking, and retransmission if needed.
Supports:
o TCP (reliable, ordered)
o
TCP (Transmission Control Protocol) is one of the core protocols of the Internet
protocol suite (often referred to as TCP/IP). It is used for reliable, ordered, and error-
checked delivery of data between applications running on hosts communicating over an
IP network.
o UDP (faster, no guarantees)
UDP (User Datagram Protocol) is a lightweight, connectionless transport protocol used
for sending short messages, called datagrams, between devices on an IP network. It is
part of the TCP/IP suite, but unlike TCP, it does not guarantee reliability, order, or error
checking (beyond basic checksums).
Example:
TCP ensures all parts of the website (text, images, CSS) are received completely and in
the correct order.
Protocols:
TCP (used in websites), UDP (used in streaming)
Analogy:
Like making sure each box in a shipment is intact and arrives in order.
Feature TCP UDP
Connection Connection-oriented Connectionless
Reliability Guarantees delivery and order No guarantees
Speed Slower due to overhead Faster, minimal overhead
Use Cases File transfer, web, email Video, gaming, voice calls
5 ⃣ Application Layer
What it does:
Provides services for user applications to communicate over the network.
Example:
Your browser uses HTTP to request the webpage.
It also uses DNS to resolve www.google.com to an IP address.
Protocols:
HTTP, HTTPS, FTP, DNS, SMTP, POP3, Telnet
Analogy:
Like the shop interface you interact with — you click a product (Google search), and
everything else happens behind the scenes.
How IP and TCP Work Together:
TCP ensures reliable data transfer.
IP ensures the data finds its way across networks to the correct device.
Together, they form the TCP/IP model, which is the foundation of the internet.
Summary Table
Layer Function Example Action in Web Protocols
Browsing
5.Application User-level communication Browser sends HTTP request HTTP, DNS, FTP
4. Transport Reliable data delivery TCP breaks data into segments TCP, UDP
3. Network Routing between networks IP routes packets across the IP, ICMP
internet
2. Data Link Local delivery between Frame sent from laptop to Wi- Ethernet, ARP,
devices Fi router Wi-Fi
1. Physical Physical transmission of Wi-Fi radio sends 1s and 0s as Cables, Fiber,
bits signals Radio
Real-Life Flow: "Opening Google in Your Browser"
1. You type www.google.com and hit Enter.
2. Application Layer: Sends HTTP request and does DNS lookup.
3. Transport Layer: TCP breaks the request into packets.
4. Network Layer: IP routes packets to Google’s server.
5. Data Link + Physical Layer: Packets travel through your Wi-Fi/Ethernet.
What is Data in Networking?
In the context of networking:
Data = any kind of information that needs to be sent from one device to another.
This can include:
A web page you requested
An image
A file you're downloading
A message you're sending
Internally, data is just a stream of binary digits (bits) → 0s and 1s.
How is Data Transmitted?
In networks, data is not sent all at once. It’s transmitted in structured units at different layers
of the TCP/IP (or OSI) model. Each layer wraps the data in its own format — this process is
called encapsulation.
Here’s how it flows top-down:
1. Application Layer → Data
Raw user data (e.g., HTTP request, email message)
2. Transport Layer → Segment
The application data is broken into segments
Adds source & destination port numbers
If using TCP, it also adds sequencing and error checks
3. Network Layer → Packet
The segment is placed inside a packet
Adds source & destination IP addresses
Routing happens based on this
4. Data Link Layer → Frame
The packet is put inside a frame
Adds MAC addresses (hardware addresses of sender & receiver on the local network)
5. Physical Layer → Bits
The frame is finally converted into bits (0s and 1s) and sent over the wire, fiber, or air
(Wi-Fi) as electrical, light, or radio signals
Real-Life Example: Visiting a Website
1. You request www.google.com in your browser.
2. Your request becomes data.
3. It's segmented, packed into packets, framed, and turned into bits.
4. These bits travel over Wi-Fi to your router, then to your ISP, then to Google.
Summary of Units at Each Layer
Layer Data Unit What's Added
Name
Application Data Raw info (HTTP, FTP, etc.)
Transport Segment Port numbers, TCP/UDP headers
Network Packet IP addresses
Data Link Frame MAC addresses, error checks
(CRC)
Physical Bits Transmitted as
electrical/light/wireless signals
Analogy:
Think of it like mailing a letter:
Data → The letter content
Segment → Fold the letter and put in a message envelope
Packet → Put it in a delivery box with address
Frame → Add shipping label for the local delivery truck
Bits → Delivery trucks on the road (moving the actual box)
Unit Layer Wraps/Contains
Segment Transport Application Data (e.g., HTTP, FTP)
(L4)
Packet Network Segment + IP Header
(L3)
Frame Data Link Packet + MAC Address Info
(L2)
Bits Physical Frame as electrical signals(smallest representation of data
(L1) that a computer can understand: It’s either a 0 or 1
The basics of Networking devices:
1. Hub – The Dumb Repeater
What It Does:
A hub connects multiple devices in a network and broadcasts data to all connected
devices.
It does not check where the data should go.
Example:
If Device A sends data to Device B, the hub sends it to all devices (A, B, C, D), and only
B picks it up. Waste of bandwidth.
❌Drawback:
No traffic control = more collisions.
Very old and rarely used today.
2. Switch – The Smart Hub
What It Does:
A switch connects devices like a hub but is intelligent.
It knows the MAC address of each connected device and sends data only to the
intended recipient.
Example:
If Device A sends data to Device B, the switch only sends it to B — not to everyone.
✅Advantages:
Reduces collisions, improves performance
Used in almost all modern LANs
3. Router – The Network Connector
What It Does:
A router connects different networks together (e.g., your home LAN to the Internet).
It routes data based on IP addresses, not MAC addresses.
Example:
When your phone visits google.com, the router figures out how to get the data from the
internet to your device.
Also:
Most home routers include a built-in switch, Wi-Fi access point, and sometimes a
firewall.
4. Wires and Cables – The Physical Medium
What They Do:
Carry data as electrical signals or light pulses.
Used to physically connect devices like routers, switches, and PCs.
Common Types:
Type Description
Ethernet (RJ-45) Common in LAN; twisted pair copper cable
Fiber Optic High speed; uses light, not electricity
Coaxial Used in older networks and TV signals
Twisted pair cables are the most common type of cables used in networking, especially for
Ethernet LAN connections.
They are called "twisted pair" because they contain pairs of insulated copper wires twisted
around each other — this helps reduce electromagnetic interference (EMI) from other devices
or cables.
Types of Twisted Pair Cables
1. Unshielded Twisted Pair (UTP)
Most commonly used in homes and offices
No extra shielding → lighter, cheaper
Good for short-distance communication
2. Shielded Twisted Pair (STP)
Has an extra layer of metal shielding
Protects better against EMI
Used in factories or high-interference environments
Common Categories of UTP Ethernet Cables
Category Speed Support Max Distance Use Case
Cat 5 Up to 100 Mbps 100 meters Old standard, rarely used now
Cat 5e Up to 1 Gbps 100 meters Most common in homes today
Cat 6 Up to 10 Gbps (short runs) 55–100 meters Used in offices and faster LAN
Cat 6a True 10 Gbps up to 100m 100 meters For high-speed data centers
Cat 7/8 Up to 40–100 Gbps Short ranges Expensive, shielded, data centers
Why Are Wires Twisted?
Twisting helps cancel out electromagnetic interference (EMI).
Each pair carries signal and return current — twisting them ensures both are exposed
equally to noise, which cancels it out.
Summary Table
Device Layer Uses Smart? Function
(OSI) MAC/IP?
Hub Layer 1 None ❌No Broadcasts to all; no filtering
Switch Layer 2 MAC ✅Yes Sends data to correct device in LAN
Router Layer 3 IP ✅Yes Connects networks (LAN ↔
WAN/Internet)
Cable Layer 1 N/A ❌N/A Medium to carry data as signals
Visual Flow in a Home Network
[PC] --Ethernet--> [Switch] --Ethernet--> [Router] --Fiber--> [Internet]
↑
[Wi-Fi Hub built-in]
Sure! Let’s explain this network flow step-by-step:
Diagram Breakdown
[PC] --Ethernet--> [Switch] --Ethernet--> [Router] --Fiber--> [Internet]
↑
[Wi-Fi Hub built-in]
This represents a typical home or office network setup with both wired and wireless
connectivity.
[PC] --Ethernet--> [Switch]
Your PC (computer) is connected to a switch using an Ethernet cable.
Ethernet provides high-speed, stable wired communication.
The switch knows the MAC address of each connected device and forwards data only
to the intended recipient, making it efficient.
[Switch] --Ethernet--> [Router]
The switch is connected to a router via Ethernet.
The switch handles local device communication (LAN), but it can’t access the internet
directly — that’s where the router comes in.
The router connects the internal (private) network to the external (public) internet.
[Router] --Fiber--> [Internet]
The router connects to the internet using a fiber optic line (or it could be DSL, cable,
etc., depending on your ISP).
It uses an IP address to communicate with websites, online services, etc.
The router uses NAT (Network Address Translation) to allow multiple devices in your
LAN to share one public IP address.
Wi-Fi Hub Built-in ↑
Most modern routers have a Wi-Fi hub (Access Point) built-in.
Devices like laptops, phones, smart TVs, etc., connect wirelessly to the router using
Wi-Fi instead of Ethernet.
These wireless devices still communicate through the router to access both local devices
and the internet.
Summary
Component Function
PC Sends/receives data over Ethernet
Switch Forwards data to correct LAN devices (based on MAC)
Router Routes data between LAN and Internet (based on IP)
Fiber High-speed connection to the ISP/internet
Wi-Fi Hub Provides wireless connectivity for devices without Ethernet ports
What is Duplex in Networking?
Duplex refers to how data flows between two devices on a network — whether it’s one-way at
a time, or both ways at once.
1. Half Duplex
Meaning:
Data can travel in both directions, but only one direction at a time.
Devices take turns sending and receiving.
Example:
Walkie-talkie
o You push to talk, release to listen.
o Both users can communicate, but not simultaneously.
Real Network Example:
Old Ethernet hubs
Wireless (Wi-Fi) under some conditions (e.g., collisions)
❌Limitation:
If both devices send at the same time → collision
Less efficient, slower communication
2. Full Duplex
Meaning:
Data can travel in both directions at the same time.
No waiting; simultaneous send and receive.
Example:
Telephone
o You can talk and listen at the same time.
Real Network Example:
Modern Ethernet switches
Fiber optic networks
Most LANs today use full duplex
✅Advantage:
No collisions
More efficient and faster communication
Quick Comparison Table
Feature Half Duplex Full Duplex
Direction Both, but one at a time Both at the same time
Simultaneous Tx/Rx ❌No ✅Yes
Collision risk High (on shared media) None (separate paths)
Speed/Efficiency Lower Higher
Example Device Hub, Walkie-talkie Switch, Telephone
Real-Life Use in Networking
Device Duplex Mode Supported
Hub Half Duplex only
Switch Full Duplex
Router Full Duplex
Wi-Fi Can be half or full (varies by standard and setup)
What is a MAC Address?
A MAC address (Media Access Control address) is a unique hardware identifier assigned to a
network interface card (NIC) of a device.
It’s used at the Data Link Layer (Layer 2) of the OSI model to ensure local network
communication.
Format of a MAC Address
A MAC address is 48 bits, typically shown in 6 pairs of hexadecimal digits:
Example: 00:1A:2B:3C:4D:5E
(or)00-1A-2B-3C-4D-5E
The first 3 pairs (e.g., 00:1A:2B) identify the manufacturer (called the OUI –
Organizationally Unique Identifier).
The last 3 pairs are unique to the device.
Key Features
Feature Details
Layer Data Link Layer (OSI Layer 2)
Length 48 bits (6 bytes)
Uniqueness Globally unique for each network interface
Assigned By The NIC hardware manufacturer
Unchangeable? Usually fixed in hardware (but can be spoofed in software)
Where is MAC Address Used?
Switches use MAC addresses to forward data to the correct device.
Devices use MAC addresses to communicate within the same local network (LAN).
ARP (Address Resolution Protocol) maps IP addresses to MAC addresses.
Real-World Example:
Imagine your laptop connected to Wi-Fi:
It has a MAC address like A0:B1:C2:D3:E4:F5
Your router uses that MAC to know where to send data (e.g., a web page response)
If your phone connects too, it has a different MAC like F2:11:8A:9B:7C:01
IP Address vs MAC Address — Different Purposes at
Different Layers
Feature IP Address MAC Address
Used At Network Layer (Layer 3) Data Link Layer (Layer 2)
Assigned By Software (DHCP or manually) Hardware (NIC manufacturer)
Changes? Can change (dynamic) Usually permanent (static)
Purpose Identifies location on network Identifies device on local link
Why We Need Both
Why This Mapping Exists
IP addresses are used at Layer 3 (Network Layer).
MAC addresses are used at Layer 2 (Data Link Layer).
For a device on an Ethernet network to receive multicast packets, the IP multicast
address must be translated into a MAC address — so that the Ethernet frame can be
properly delivered.
1. MAC addresses are needed for LAN delivery (local network)
IP is for identifying the logical location on the network (e.g., 192.168.1.10)
But inside a local network (LAN), data is actually delivered using MAC addresses
Devices don’t forward packets based on IP at Layer 2 — they forward based on MAC
Example:
When your PC sends data to the router:
It knows the router’s IP, but doesn’t know its MAC.
It uses ARP (Address Resolution Protocol) to find the MAC address for that IP
Then it sends the Ethernet frame with the router’s MAC address as the destination
2. MAC ensures device-to-device communication on the same network
Switches don't understand IP addresses
They build a table of MAC addresses to know which port to forward frames to
Without MAC addresses, switches wouldn’t know where to send data on the LAN
3. IP handles routing between networks — MAC handles delivery within a
network
Think of IP as the postal address (for long-distance delivery)
Think of MAC as the house number or name tag (used to find the right person once
inside)
Flow: When You Access a Website
1. You enter www.google.com → DNS gives IP address (e.g., 142.250.190.36)
2. Your device prepares the IP packet
3. It uses ARP to resolve the MAC address of your router
4. It sends the frame with:
o Destination IP: 142.250.190.36
o Destination MAC: your router’s MAC address
5. The router forwards it based on the IP
6. At each hop, IP addresses stay the same (until NAT), but MAC addresses change hop-
by-hop
✅TL;DR
Why We Need MAC If We Have IP
IP is for logical addressing across networks
MAC is for physical delivery within a local network
Devices need MAC addresses to actually send/receive frames
Switches and NICs don’t understand IP — they use MAC
If the least significant bit in the first octet of a destination address is set to 0(zero), It means
that Ethernet frame is intended for only the destination address.
In Ethernet networks, FF:FF:FF:FF:FF:FF is the broadcast MAC address. This address is
used to send a frame to all devices on the local network segment.
1. What is Unicast Transmission?
Unicast = One-to-One communication
Meaning:
Data is sent from one sender to one specific receiver.
Most internet traffic (like browsing, downloading, emails) is unicast.
Example:
You open www.google.com on your laptop → Google sends the webpage only to your
device, not to others.
IP Example:
Sender: 192.168.1.10
Receiver: 192.168.1.20
IP packet is delivered only to 192.168.1.20
✅Pros:
Efficient when communication is private or 1-to-1
Guaranteed delivery (if TCP is used)
2. What is Multicast Transmission?
Multicast = One-to-Many (selected) communication
Meaning:
Data is sent from one sender to multiple specific receivers who have joined a multicast
group.
Saves bandwidth by sending a single copy of data that multiple receivers can use.
Example:
A live video lecture streamed to selected students.
Instead of sending the video separately to each one, the server sends it once to a
multicast group, and all members receive it.
IP Example:
Multicast IP addresses range from 224.0.0.0 to 239.255.255.255
Example multicast address: 239.1.1.1
All devices that have joined group 239.1.1.1 will receive the stream
✅Pros:
Saves bandwidth when sending to multiple devices
Common in video conferencing, IPTV, online gaming
Unicast vs Multicast – Quick Comparison
Feature Unicast Multicast
Direction One-to-One One-to-Many (group)
IP Address Type Unique IP (e.g. 192.168.1.5) Group IP (e.g. 239.1.1.1)
Used In Web browsing, file transfer Live streaming, webinars, IPTV
Bandwidth Usage High (duplicate data per user) Low (one data copy for multiple users)
Protocols TCP, UDP Mostly UDP + IGMP (group management)
Visual Example (in mind):
Unicast:
[Server] ---> [Client A]
---> [Client B]
---> [Client C] // Sends 3 separate copies
Multicast:
[Server] ---> [Multicast Group 239.1.1.1]
↓ ↓ ↓
[Client A] [Client B] [Client C]
3. Broadcast (One-to-All)
Definition:
Data is sent to all devices on the local Ethernet segment.
How it works in Ethernet:
Destination MAC address is always:
FF:FF:FF:FF:FF:FF (all 1s = broadcast)
Every device on the LAN receives and processes the frame.
✅Example:
[MAC A] → Broadcast → All devices B, C, D, E
Used in:
ARP requests (to find MAC for a given IP)
DHCP (discovering a server)
Initial network discovery
Summary Table
Type Destination MAC Who Receives Use Case Example
Unicast A single device's MAC One specific device Sending a file, HTTP
request
Multicast 01:00:5E:xx:xx:xx Subscribed group IPTV, webinars, gaming
(group) devices
Broadcast FF:FF:FF:FF:FF:FF All devices on LAN ARP, DHCP, network
discovery
Quick Visual
Unicast: A → B
Multicast: A → [Group of B & C]
Broadcast: A → Everyone (B, C, D, E)
Ethernet Frame Structure (IEEE 802.3)
Here's the high-level layout of a standard Ethernet II frame:
| Preamble | SFD | Dest MAC | Src MAC | VLAN (optional) | EtherType | Payload
| FCS |
1. Preamble (7 bytes)
Purpose: Helps the receiving device synchronize with the incoming data stream.
It's a pattern of alternating 1s and 0s:
10101010 10101010 ... (7 bytes = 56 bits)
Analogy:
Think of it like ringing a doorbell — it tells the receiver, “Get ready, data is coming!”
2. SFD (Start Frame Delimiter) (1 byte)
Purpose: Marks the end of the preamble and start of the actual frame.
Value: 10101011
3. Destination MAC Address (6 bytes)
Purpose: MAC address of the receiver
Used by switches to determine which port to forward the frame to.
4. Source MAC Address (6 bytes)
Purpose: MAC address of the sender
Used for return communication and MAC learning in switches.
5. VLAN Tag (Optional – 4 bytes)
Part of IEEE 802.1Q
Used in VLAN-aware networks to indicate VLAN ID and priority
Structure:
o 2 bytes: TPID (Tag Protocol ID, typically 0x8100)
o 2 bytes: TCI (Tag Control Info – VLAN ID, priority bits)
6. EtherType / Length (2 bytes)
Indicates what kind of payload is inside the frame.
o 0x0800 = IPv4
o 0x86DD = IPv6
o 0x0806 = ARP
Can also represent payload length in older 802.3 frames (if value < 1500)
7. Payload / Data (46 to 1500 bytes)
The actual data being carried (IP packet, ARP, etc.)
Minimum is 46 bytes (padded if needed)
Maximum without jumbo frames = 1500 bytes
✅8. FCS (Frame Check Sequence) (4 bytes)
Used for error checking
Sender calculates a CRC (Cyclic Redundancy Check); the receiver recalculates and
compares.
If it doesn’t match, the frame is discarded.
Complete Ethernet II Frame Layout:
Field Size (Bytes) Description
Preamble 7 Clock sync for receiver
SFD 1 Marks start of actual frame
Destination MAC 6 Receiver MAC address
Source MAC 6 Sender MAC address
VLAN Tag 4 (optional) VLAN ID and priority
EtherType 2 Type of payload (IPv4, ARP, etc.)
Payload 46–1500 Actual data being transmitted
FCS 4 Error checking using CRC
Visual (Simplified):
[ Preamble ][ SFD ][ Dest MAC ][ Src MAC ][ VLAN ][ EtherType ][ Payload ][
FCS ]
7B 1B 6B 6B 4B(opt) 2B 46–1500B
4B