0% found this document useful (0 votes)
2 views

Topic 4 Midterm Notes

The document discusses the roles of the transport and network layers in IP networks, highlighting that the transport layer is universally applicable while the network layer is relevant mainly in larger networks. It details the functions of routers, including routing, security, and protocol conversion, and explains IP addressing, subnetting, and routing protocols. Additionally, it covers the differences between IPv4 and IPv6, classful and classless addressing, and the significance of network IDs and broadcast addresses.

Uploaded by

2zfkmb88y2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Topic 4 Midterm Notes

The document discusses the roles of the transport and network layers in IP networks, highlighting that the transport layer is universally applicable while the network layer is relevant mainly in larger networks. It details the functions of routers, including routing, security, and protocol conversion, and explains IP addressing, subnetting, and routing protocols. Additionally, it covers the differences between IPv4 and IPv6, classful and classless addressing, and the significance of network IDs and broadcast addresses.

Uploaded by

2zfkmb88y2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Transport Layer Content Applies Everywhere:

 The transport layer (e.g., TCP/UDP) is always relevant in an IP network,


no matter if the network is a LAN, MAN, WAN, or the Internet.
 However, different applications use different transport protocols (e.g.,
VoIP uses UDP, web browsing uses TCP).
Network Layer Content Applies Selectively:
 The network layer (IP addressing, routing) is only relevant in larger
networks such as:
o Metropolitan Area Networks (MANs)
o Wide Area Networks (WANs)
o The Internet
o Core Layer Backbone Networks (BBNs)
 The network layer is NOT applicable at the access and distribution
layers of a network because:
o Devices like switches, access points (APs), and hubs operate at
Layer 2 (Data Link Layer) and use MAC addresses, not IP
addresses, for communication.
When Network Layer Applies:
 If a router is involved in forwarding traffic, then network layer concepts
(IP addressing, routing, packet forwarding) apply.
 In core layer BBNs, traffic often passes through routers, but other
options exist (possibly direct optical switching, MPLS, or software-
defined networking, which will be covered in Chapter 8).

Introduction to Routers
1. Routers: The Most Complex Networking Device in This Course
Routers are critical for managing network traffic in large-scale networks,
ensuring data packets reach the correct destination efficiently. They operate
at Layer 3 (Network Layer) of the OSI model and work with IP addresses to
make forwarding decisions.

2. Types of Routers (Relevance in This Course)


 Wireless routers:
o Not actually routers in a networking sense (they’re multi-function
devices acting as APs, switches, and NAT gateways).
o Not relevant for this course.
 Routers connecting organizational networks to MANs/WANs/Internet:
o Partially relevant (Ch.9) since they help connect local networks to
external ones.
o Used at a company’s edge to connect to an ISP or other
networks.
 Routers used for core layers in large networks:
o Highly relevant (Ch.8).
o Used in backbone networks to move data efficiently between
different parts of the network.
o Typically found in large enterprises and data centers.
 Routers used by ISPs for MANs/WANs/Internet:
o Highly relevant.
o These high-capacity routers build the backbone of the Internet
and telecom provider networks.
o They handle massive amounts of data traffic and use advanced
routing protocols.

3. Key Functions of Relevant Routers


 Routing:
o Finds the best path for data to travel between source and
destination.
o Uses routing tables and routing protocols (e.g., OSPF, BGP, RIP).
 Moving Data at the Core Layer:
o Routers are not involved in local network communication (that’s
the job of switches/APs).
o They operate only in core networks, MANs, WANs, and the
Internet.
 Security & Access Control (ACLs):
o Routers can filter and control which traffic is allowed or denied
using Access Control Lists (ACLs).
o This helps block unauthorized access and improve network
security (covered in Ch.8 & 10).
 Protocol Conversion:
o Converts between different networking protocols when
necessary.
o Useful for migrating from IPv4 to IPv6 or interconnecting different
network architectures.

4. Anatomy of a Router
A router is like a specialized computer with:
 CPU & Memory: Has RAM, ROM, and a special OS (like Cisco IOS or
Juniper JunOS).
 Interfaces/Ports: Each port connects to different networks and has a
specific role:
o WAN interfaces (e.g., Ethernet, Fiber, Serial) for connecting to
ISPs or external networks.
o LAN interfaces (e.g., Gigabit Ethernet) for internal connections.
o Management interfaces (e.g., Console, AUX, USB) for
configuration.
 Routing Logic: Processes data using:
o Routing tables – store known routes to different networks.
o Routing protocols – dynamically update routing tables based on
network conditions.
o ACLs – filter and secure traffic.
Transport Layer: Functions & Protocols
The transport layer (Layer 4 of the OSI model) is responsible for ensuring
reliable (or fast) data transmission between devices by managing
segmentation, delivery, and error handling.

1. Key Functions of the Transport Layer


a. Segmentation & Reassembly
 Sending Computer:
o Breaks messages into Protocol Data Units (PDUs):
 TCP → Segments
 UDP → Datagrams
o Adds header information (like source/destination port numbers)
to ensure correct application handling.
 Receiving Computer:
o Reassembles the PDUs back into the original message.
o Uses sequence numbers (in TCP) to ensure data is in the correct
order.

2. How the Transport Layer Identifies Applications


 Uses source and destination port numbers in the PDU header.
 Example:
o A web request uses port 80 (HTTP) or port 443 (HTTPS).
o An email uses port 25 (SMTP) or port 110 (POP3).
o Online gaming or VoIP often use UDP ports.

3. Transmission Methods: TCP vs. UDP vs. QoS


TCP (Transmission UDP (User Datagram QoS (Quality of
Feature
Control Protocol) Protocol) Service)
Connection-
Type Connection-oriented Connectionless oriented (priority-
based)
Reliabilit Reliable (error-checking, Unreliable (no Guaranteed service
y retransmissions) retransmissions) for selected apps
Faster (minimal Prioritizes time-
Speed Slower (more overhead)
overhead) sensitive traffic
File transfers, web VoIP, video
Use Online gaming, VoIP,
browsing, emails, conferencing,
Cases video streaming, DNS
database access emergency data
Yes (ensures sender Ensures smooth
Flow No (no checks on
doesn't overload real-time
Control speed or delivery)
receiver) performance
a. TCP – Reliable Delivery (Handshake & Flow Control)
 Establishes a connection using a 3-way handshake before sending
data.
 Uses flow control to prevent network congestion (sender slows down if
receiver is overwhelmed).
 Used for most common applications (e.g., web browsing, file
downloads, emails, messaging, etc.).
b. UDP – Fast but Unreliable Delivery
 No handshake, no retransmissions, and no flow control → results in
lower latency.
 Used for real-time communication (VoIP, live streaming, gaming, DNS
queries) where speed is more important than reliability.
c. QoS – Priority-Based Transmission for Critical Applications
 Used when certain applications need guaranteed bandwidth & low
latency.
 Requires QoS-compatible network hardware & software.
 Example: Prioritizing VoIP traffic over regular web browsing to avoid
call disruptions.

4. Who Selects TCP vs. UDP vs. QoS?


Application decides TCP vs. UDP → Developers choose based on needs (not
network designers).
Network Admin configures QoS → Needs specialized configuration on routers,
switches, and network software.

Network Layer: Functions & Protocols


The Network Layer (Layer 3 of the OSI model) is responsible for IP addressing
and routing, ensuring that data can travel across networks from the source
to the destination.

1. Key Functions of the Network Layer


a. IP Addressing – Identifying Networks & Hosts
 Every device (host) in a network is assigned a unique IP address.
 An IP address consists of two parts:
o Network ID: Identifies the network.
o Host ID: Identifies the device within the network.
Types of IP Addressing:
Address
Description
Type
Large networks (1.x.x.x to 126.x.x.x) – Supports 16M hosts per
Class A
network
Medium-sized networks (128.x.x.x to 191.x.x.x) – Supports 65K
Class B
hosts per network
Small networks (192.x.x.x to 223.x.x.x) – Supports 254 hosts per
Class C
network
Public IP Used on the Internet, assigned by ISPs
Used within organizations (10.x.x.x, 172.16.x.x–172.31.x.x,
Private IP
192.168.x.x)
Address
Description
Type
Static IP Manually assigned and does not change
Assigned automatically by DHCP (Dynamic Host Configuration
Dynamic IP
Protocol)

b. Subnetting – Dividing Networks Efficiently


 Subnetting splits a large network into smaller sub-networks to improve
performance and security.
 Example: 192.168.1.0/24 means 254 usable IP addresses in that
subnet.
 Subnet masks determine how many bits are used for the network vs.
the host.
CIDR Hosts per
Subnet Mask
Notation Subnet
255.0.0.0 /8 16.7M
255.255.0.0 /16 65K
255.255.255.0 /24 254
255.255.255.1
/25 126
28

c. Address Resolution – Mapping IPs to MAC Addresses


 The Address Resolution Protocol (ARP) is used to find the MAC address
of a device when given its IP address.
 Example: If a computer wants to send data to 192.168.1.5, ARP helps
find the corresponding MAC address.

2. Routing – Finding the Best Path to the Destination


 The network layer determines the best route for data to reach its
destination.
 Data at this layer is sent in packets, which are forwarded by routers.
a. Static vs. Dynamic Routing
Routing Type Description
Manually configured routes, best for small
Static Routing
networks
Dynamic Routes are updated automatically using routing
Routing protocols
b. Routing Protocols – How Routers Learn the Best Path
Protocol Type Example
Distance RIP,
Chooses the path with the fewest hops
Vector RIPv2
Chooses the fastest path based on network OSPF, IS-
Link-State
conditions IS
Hybrid Uses both methods for better efficiency EIGRP
Who Assigns IP Address Blocks to ISPs?
The Internet Corporation for Assigned Names and Numbers (ICANN) is
responsible for managing and allocating IP address blocks. However, ICANN
does not give IP addresses directly to ISPs. Instead, it delegates this
responsibility to Regional Internet Registries (RIRs).

Regional Internet Registries (RIRs) – Who Manages What?


ICANN allocates large blocks of IP addresses to five RIRs, each responsible for
a specific region:
RIR Region Location
AFRINIC Africa Mauritius
South Brisbane,
APNIC Asia-Pacific
Australia
ARIN North America Virginia, USA
LACNIC Latin America & Caribbean Uruguay
RIPE Europe, Middle East & Central Amsterdam,
NCC Asia Netherlands

How Does an ISP Get an IP Address Block?


1. A new Internet Service Provider (ISP) applies to the appropriate
Regional Internet Registry (RIR) for a block of IP addresses.
2. The RIR allocates a block based on the ISP’s needs and regional
availability.
3. The ISP assigns smaller subnets to its customers.
4. Customers can receive static or dynamic IP addresses depending on
their plan.
💡 Example:
 A Canadian ISP (e.g., Bell or Rogers) would apply to ARIN for IP
addresses.
 ARIN allocates a /16 block (65,536 addresses), which the ISP then
distributes to customers.

IPv4 vs. IPv6 Allocation


 IPv4 is nearly exhausted, so ISPs are encouraged to adopt IPv6, which
has a much larger address space.
 The allocation process for IPv6 is similar, but IPv6 blocks are typically
much larger.

Classful vs. Classless Addressing


IP addresses are divided into network and host portions. The network portion
is called the network prefix and determines which network an address
belongs to.
Classful Addressing (1981–1993)
Classful addressing uses fixed-length prefixes, meaning the number of
networks and hosts per network are predetermined.
Clas Prefix Total Hosts per
Starting Bits Network Format
s Length Networks Network
0xxx xxxx (0- Prefix . Host . Host .
A 8 bits 128 16.7 million
127) Host
10xx xxxx Prefix . Prefix .
B 16 bits 16,384 65,536
(128-191) Host . Host
110x xxxx Prefix . Prefix .
C 24 bits 2.1 million 256
(192-223) Prefix . Host
1110 xxxx Used for
D - - -
(224-239) multicasting
1111 xxxx Reserved
E - - -
(240-255) (experimental)
Drawback:
 Fixed number of networks and hosts → Inefficient allocation of IP
addresses.
 Example: A Class A network could waste millions of addresses if the
organization only needs thousands.

Classless Addressing (1993–Present)


To overcome inefficiencies, Classless Inter-Domain Routing (CIDR) was
introduced.
Instead of fixed prefix lengths, CIDR allows variable-length subnet masks
(VLSM) for efficient IP allocation.
Benefits of Classless Addressing:
✔ More flexible subnetting – A company can use only the IPs it needs.
✔ Reduces wasted addresses – Instead of allocating a full Class A, B, or C
block, networks get only what they require.
✔ Uses CIDR notation – Example:
 192.168.1.0/24 → 256 addresses (Class C style)
 10.0.0.0/8 → 16.7 million addresses (Class A style)

Network ID and Broadcast Address Explained


In IP addressing, every network has two special addresses:
1. Network ID (or Network Address) → Identifies the network itself.
2. Broadcast Address → Used to send messages to all devices in that
network.

1️Network ID (Network Address)


 The first address in an IP subnet.
 Represents the entire network, not a single device.
 All host bits in the address are set to 0.
 Used by routers to forward packets between networks.
Example (Class C Network - /24):
For 192.168.1.0/24 (Subnet Mask: 255.255.255.0)
 Network ID = 192.168.1.0
 This address is not assignable to any device.

2️Broadcast Address
 The last address in an IP subnet.
 Used to send messages to all devices in the network.
 All host bits are set to 1.
 Devices use this to send announcements (e.g., ARP requests).
Example (Class C Network - /24):
For 192.168.1.0/24
 Broadcast Address = 192.168.1.255
 Any packet sent to 192.168.1.255 is received by all devices in
192.168.1.0/24.

Example for a /26 Subnet


If we take 192.168.1.64/26 (Subnet Mask: 255.255.255.192), then:
 Network ID → 192.168.1.64
 Broadcast Address → 192.168.1.127
 Usable Hosts → 192.168.1.65 to 192.168.1.126 (62 addresses)
Step 1: Understanding the /26 Subnet Mask
 You’re given the network 192.168.1.64/26.
 The /26 means that 26 bits are used for the network portion, and the
remaining 6 bits are used for the host portion.
 Subnet mask in binary:
11111111.11111111.11111111.11000000
o The first 26 bits are fixed (network).
o The last 6 bits are for host addresses.

Step 2: Finding the Network ID


The Network ID is always the first address in a subnet, where all host bits are
0.
 Given address: 192.168.1.64
 In binary:
11000000.10101000.00000001.01000000
o The last 6 bits (01000000) are all 0s → confirms it's the Network
ID.

Step 3: Finding the Broadcast Address


The Broadcast Address is always the last address in a subnet, where all host
bits are 1.
 Subnet mask gives us 6 host bits.
 Convert all host bits to 1:
11000000.10101000.00000001.01111111
 In decimal:
192.168.1.127
So, 192.168.1.127 is the Broadcast Address.

Step 4: Usable Host Addresses


 First usable address → Network ID + 1 → 192.168.1.65
 Last usable address → Broadcast Address - 1 → 192.168.1.126

Final Answer
For 192.168.1.64/26:
 Network ID: 192.168.1.64
 Broadcast Address: 192.168.1.127
 Usable Host Range: 192.168.1.65 - 192.168.1.126

1. Network ID (Network Address)


 The Network ID is the first address in a subnet.
 It represents the entire network, not a specific device.
 It cannot be assigned to any host.
 It appears in routing tables so routers know how to forward packets.
 Example: For 192.168.1.64/26, the Network ID is 192.168.1.64.

2. Broadcast Address
 The Broadcast Address is the last address in a subnet.
 It is used for sending messages to all devices in the network.
 When a device sends a packet to the Broadcast Address, all hosts in
that subnet receive it.
 Example: For 192.168.1.64/26, the Broadcast Address is
192.168.1.127.

Public vs. Private IP Addresses: Key Differences


Feature Public IP Address Private IP Address
Unique only within an
Uniqueness Globally unique
organization
Not recognized by public
Recognition Recognized by all routers
routers
Can communicate directly over Cannot be accessed from
Accessibility
the Internet outside without NAT
Example Internal networks, home
Websites, servers, cloud services
Use networks, businesses
More secure due to NAT &
Security More exposed to attacks
firewall rules
Assigned by ISPs (uses Assigned by organizations
Assignment
ICANN/Regional Registries) internally
NAT No, direct communication Yes, needs NAT to access the
Required? possible Internet
What is a Public IP Address?
 Assigned by ISPs and globally unique.
 Can be directly accessed over the Internet.
 Used for websites, email servers, cloud services, etc..
 Examples:
o 8.8.8.8 (Google DNS)
o 142.251.36.46 (Google.com)
o 52.119.148.50 (AWS)

What is a Private IP Address?


 Used only within internal networks (home, office, enterprise).
 Not routable on the public Internet.
 Requires NAT (Network Address Translation) to access the Internet.
 Examples (Reserved by RFC 1918):
o Class A: 10.0.0.0 – 10.255.255.255
o Class B: 172.16.0.0 – 172.31.255.255
o Class C: 192.168.0.0 – 192.168.255.255
Example:
 Your home router might have a public IP (203.0.113.45) but your
computer inside the network has a private IP (192.168.1.100).
 The router uses NAT to allow your private IP to communicate with
public servers.

Why Use Private IPs?


Security – Cannot be attacked directly from the Internet.
Conservation – Reduces public IP usage, extending IPv4 lifespan.
Flexibility – Organizations can structure networks without needing new public
IPs.

Types of Addresses in IP Networks


Each computer in an IP network has multiple addresses, used by different
layers of the TCP/IP model. These addresses serve different purposes, from
human-readable names to low-level hardware identification.

1. Application Layer Address (Domain Names)


 Example: www.yorku.ca instead of 130.63.236.137
 Assigned to servers, not clients (e.g., websites, mail servers).
 Public (Internet-wide) or Private (internal networks only).
 Human-friendly alternative to IP addresses.
 Managed by DNS (Domain Name System).
Example:
Website Domain Name IP Address
York 130.63.236.1
www.yorku.ca
University 37
Website Domain Name IP Address
www.google.co 142.250.72.2
Google
m 38

2. Network Layer Address (IP Address)


 Also known as: IP address or Layer 3 address.
 Assigned to each device in a network for identification and routing.
 Versions: IPv4 (32-bit) and IPv6 (128-bit).
 Two types:
o Public (Globally unique, routable on the Internet).
o Private (Unique within an organization, requires NAT for Internet
access).
IPv4 Addressing
 Dotted decimal notation (e.g., 192.168.1.10).
 Classes:
o Class A: N.h.h.h (e.g., 10.0.0.1)
o Class B: N.N.h.h (e.g., 172.16.5.10)
o Class C: N.N.N.h (e.g., 192.168.1.100)
 Public vs. Private IPs:
o Public: Used on the Internet (8.8.8.8 for Google DNS).
o Private: Used in internal networks (192.168.1.1 for home
routers).
Example:
Device IP Address Type
Home 192.168.1 Privat
Router .1 e
Google
8.8.8.8 Public
DNS

3. Data Link Layer Address (MAC Address)


 Also known as: MAC address, Layer 2 address, or physical address.
 Burned into network adapters (NICs) by manufacturers.
 48-bit hexadecimal format (e.g., 00:1A:2B:3C:4D:5E).
 Used for local network communication, not for Internet routing.
Example MAC Address: 00:1A:2B:3C:4D:5E
Structure:
Bits Usage
First 24 Manufacturer ID (e.g., Intel,
bits Cisco)
Last 24
Unique device ID
bits

Comparison Table
Address Type Layer Example Used For
Application (Domain Layer www.yorku.ca Human-friendly naming
Address Type Layer Example Used For
Name) 7
Layer Device identification,
Network (IP Address) 192.168.1.10
3 routing
Data Link (MAC Layer 00:1A:2B:3C:4D: Local network
Address) 2 5E communication

Key Takeaways
Application Layer → Human-readable (domain names).
Network Layer → Logical addressing (IP addresses for routing).
Data Link Layer → Physical addressing (MAC addresses for direct
communication).

Subnetting Basics: Breaking Down the Key Concepts


1. IPv4 Address Structure: Network ID + Host ID
Every IPv4 address consists of:
Network ID (Net ID) → Identifies the network (same for all devices in a
subnet).
Host ID → Identifies a specific device within that network.
Example: 192.168.1.100/24
 Network ID: 192.168.1.0
 Host Range: 192.168.1.1 to 192.168.1.254
 Broadcast Address: 192.168.1.255

2. Why Subnetting?
Problem:
An organization needs multiple internal networks, but getting multiple Class
A, B, or C addresses from an ISP isn't practical.
Solution: Subnetting
Instead of requesting multiple network addresses, one network address is
subdivided into multiple smaller subnets.
Key Benefits:
✔ Efficient IP allocation → No wasted addresses.
✔ Better traffic management → Routers use Net IDs to direct packets
efficiently.
✔ Greater network control → Security policies and VLANs can be applied per
subnet.

3. Planning a Subnet
When subnetting, you usually start with one of two requirements:
1️Given the number of required subnets, determine hosts per subnet.
2️Given the number of required hosts per subnet, determine the number of
subnets.
Each subnet has:
A unique Network ID
A range of usable Host IDs
A Broadcast Address

4. Subnet Mask and Borrowing Bits


A subnet mask determines which part of an IP address is the Net ID and
which part is the Host ID.
Example: Class C Default Subnet Mask
 255.255.255.0 (/24)
o First 24 bits = Network ID
o Last 8 bits = Hosts
o Supports 1 subnet with 254 hosts
By borrowing bits from the Host ID, we create more subnets while reducing
the number of available hosts per subnet.
Example: Borrowing 2 Bits from Host ID
 New subnet mask: 255.255.255.192 (/26)
o 26 bits for Network ID
o 6 bits for Hosts
o 4 subnets, 62 hosts per subnet

Subnetting Rules & Example (Class C Network)


Step 1: Given Information
 Class C Network Address: (e.g., 192.168.1.0/24)
 Requirement: Each subnet must support at most 20 hosts
 Class C Default Subnet Mask: 255.255.255.0 (/24) → 8 bits for hosts

Subnetting Process
📌 Rule: We "borrow" bits from the Host ID to create a Subnet ID
📌 Formula for Hosts per Subnet:
Max Hosts=(2h)−2\text{Max Hosts} = (2^h) - 2Max Hosts=(2h)−2
(where h = number of bits remaining for Host ID)
📌 Formula for Subnets:
Max Subnets=2s\text{Max Subnets} = 2^sMax Subnets=2s
(where s = number of borrowed bits for Subnet ID)

Answering Questions
Q1: How many bits must remain in the Host ID portion?
We need at least 20 hosts per subnet. Using the host formula:
(2h)−2≥20(2^h) - 2 \geq 20(2h)−2≥20
Testing values:
 h=5⇒(25)−2=30h = 5 \Rightarrow (2^5) - 2 = 30h=5⇒(25)−2=30 ✅
(Enough hosts)
 h=4⇒(24)−2=14h = 4 \Rightarrow (2^4) - 2 = 14h=4⇒(24)−2=14 ❌
(Not enough hosts)
So, at least 5 bits must remain for the Host ID.

Q2: What is the maximum number of hosts per subnet?


With 5 bits for Host ID, the formula gives:
(25)−2=30(2^5) - 2 = 30(25)−2=30
So, each subnet can have up to 30 usable hosts.

Q3: What is the maximum number of subnets possible?


Since 3 bits were borrowed from the Host ID:
23=8 subnets2^3 = 8 \text{ subnets}23=8 subnets
So, the maximum number of subnets is 8.

Q4: What is the subnet mask required?


The default Class C subnet mask is /24 (255.255.255.0). Since we borrowed 3
bits, the new subnet mask is:
/27(or 255.255.255.224)/27 \quad \text{(or
255.255.255.224)}/27(or 255.255.255.224)

Subnet Breakdown (192.168.1.0/27)


Each subnet increases in steps of 32 in the last octet:
Broadcast
Subnet ID Usable Host Range
Address
192.168.1.1 -
192.168.1.0/27 192.168.1.31
192.168.1.30
192.168.1.32/2 192.168.1.33 -
192.168.1.63
7 192.168.1.62
192.168.1.64/2 192.168.1.65 -
192.168.1.95
7 192.168.1.94
192.168.1.96/2 192.168.1.97 -
192.168.1.127
7 192.168.1.126
192.168.1.128/ 192.168.1.129 -
192.168.1.159
27 192.168.1.158
192.168.1.160/ 192.168.1.161 -
192.168.1.191
27 192.168.1.190
192.168.1.192/ 192.168.1.193 -
192.168.1.223
27 192.168.1.222
192.168.1.224/ 192.168.1.225 -
192.168.1.255
27 192.168.1.254
Each subnet has:
 Subnet ID (first address)
 30 usable hosts
 Broadcast address (last address)

Final Answers
1️⃣ At least 5 bits must remain for the Host ID
2️⃣ Each subnet can support up to 30 hosts
3️⃣ A maximum of 8 subnets can be created
4️⃣ The subnet mask required is /27 (255.255.255.224)
Packet Forwarding & Next Hop Selection
Concept of Packet Forwarding
 Routers are responsible for forwarding IP packets across networks.
 A router determines where to send a packet next based on:
1. The destination IP address in the packet.
2. The router’s routing table.

How Does a Router Choose the Next Hop?


📌 Formula:
Next Hop=f(Destination Address,Routing Table)\text{Next Hop} = f(\
text{Destination Address}, \text{Routing
Table})Next Hop=f(Destination Address,Routing Table)
Explanation:
 The function f() refers to a lookup process in the router’s routing table.
 The routing table contains:
o Destination network (Network ID + Subnet Mask)
o Next hop IP address (or an interface if directly connected)
o Metric (Cost of the route)
o Routing protocol information (e.g., OSPF, RIP, BGP)

Step-by-Step: How a Router Forwards a Packet


1️Extract Destination Address
 The router reads the destination IP address from the incoming packet.
2️Compare with Routing Table
 The router checks its routing table for the longest prefix match.
 Example:
o If the destination is 192.168.1.50, the router finds the most
specific match, such as 192.168.1.0/24 instead of a generic
192.168.0.0/16 entry.
3️Determine the Next Hop
 If a match is found, the router forwards the packet to the next hop
router or directly to the destination if it's on the same network.
 If no match is found, the packet is forwarded to the default gateway (if
configured) or dropped.
4️Encapsulate & Forward
 The router updates the Layer 2 (MAC) header.
 It sends the packet to the selected next hop via the corresponding
interface.

Example of Packet Forwarding


Routing Table of Router R
Destination Interfac
Next Hop
Network e
192.168.1.0/24 192.168.2 eth0
Destination Interfac
Next Hop
Network e
.1
10.0.0.0/8 10.1.1.1 eth1
0.0.0.0/0 203.0.113
eth2
(Default) .1
Scenario
 Incoming Packet:
o Source: 10.2.5.100
o Destination: 192.168.1.50
 Router’s Decision:
o Looks for the best match for 192.168.1.50.
o Matches 192.168.1.0/24 → Next hop is 192.168.2.1 via eth0.
o Router forwards the packet out eth0.

Table-Driven Routing
 Uses a static or dynamic routing table to determine the next hop.
 Types:
1. Static Routing → Manually configured routes (used in small
networks).
2. Dynamic Routing → Routes learned automatically via routing
protocols (e.g., OSPF, BGP, RIP).
3. Default Routing → A fallback route for unknown destinations
(0.0.0.0/0).

Summary
Routers forward packets by looking up the destination IP address in their
routing table.
The best match (longest prefix) determines the next hop.
The router updates the Layer 2 header and forwards the packet via the
chosen interface.
If no route exists, the packet is sent to the default gateway or dropped.

Longest Prefix Matching (LPM) in Routing


Longest Prefix Matching (LPM) is a fundamental routing algorithm used by
routers to determine the most specific route for forwarding packets. When a
router receives an IP packet, it searches its routing table to find the longest
matching subnet mask that corresponds to the destination IP address.

How It Works
 The router checks all network prefixes (subnet masks) in the routing
table.
 It selects the route with the most specific (longest) subnet mask that
matches the destination IP address.
Example Routing Table
Destination
Subnet Mask Next Hop
Network
255.255.255.0
192.168.1.0 Router A
(/24)
255.255.255.128
192.168.1.128 Router B
(/25)
255.255.255.192
192.168.1.192 Router C
(/26)
Default
0.0.0.0 0.0.0.0 (/0)
Gateway

Example: Packet Forwarding Using LPM


Case 1: Destination IP = 192.168.1.130
 Convert to binary: 11000000.10101000.00000001.10000010
 Matches both /24 and /25, but /25 (longer) is more specific.
 Next Hop: Router B
Case 2: Destination IP = 192.168.1.200
 Matches /24 and /26, but /26 (longer) is more specific.
 Next Hop: Router C
Case 3: Destination IP = 8.8.8.8
 No specific match found.
 Uses default route (/0).
 Next Hop: Default Gateway

Key Takeaways
1. More specific prefixes take priority (higher subnet mask means a
smaller network, so it's more precise).
2. Routers perform a bitwise comparison to find the best match.
3. Default route (0.0.0.0/0) is the last resort when no other match exists.

Address Resolution & Related Protocols


Address resolution is the process of translating one type of address into
another to enable network communication. There are two main types of
address resolution:

1. Translating Domain Names into IP Addresses (DNS - Domain Name


System)
 When a client wants to communicate with a server (e.g., accessing a
website), it needs to obtain the IP address of that server.
 This is done using the DNS (Domain Name System) protocol.
 Process:
1. The client sends a DNS request to its configured DNS server
(often assigned by the ISP or network administrator).
2. If the DNS server does not have the IP address cached, it
forwards the request to a higher-level DNS server.
3. This process continues, potentially reaching the DNS root
servers, which can direct the query down to the authoritative
DNS server for the domain.
4. Once the IP address is found, the DNS server sends the DNS
response back to the client.
5. The client can now communicate with the target IP address.
📌 Example:
 Request: "What is the IP of www.google.com?"
 Response: "The IP is 142.250.190.78"

2. Translating IP Addresses into MAC Addresses (ARP - Address Resolution


Protocol)
 For communication within a local network, devices use MAC addresses
(Layer 2) instead of IP addresses (Layer 3).
 If a device knows the destination IP address but not the corresponding
MAC address, it uses ARP (Address Resolution Protocol).
 Process:
1. The sender broadcasts an ARP request to all devices on the
subnet:
 "Who has IP 192.168.1.20? Tell me your MAC address!"
2. The device with IP 192.168.1.20 responds with its MAC address.
3. The sender caches this information and uses the MAC address to
forward the packet.
📌 Example:
 Request: "Who has IP 192.168.1.5?"
 Response: "I have that IP, and my MAC is 00:1A:2B:3C:4D:5E"
🔹 Reverse ARP (RARP): Converts a known MAC address into an IP address
(used in older networks).
🔹 Neighbor Discovery Protocol (NDP): IPv6 replacement for ARP, using
ICMPv6 messages.

Summary of Address Resolution Protocols


Protocol Purpose Layer
Resolves domain names to IP Layer 7
DNS
addresses (Application)
Resolves IP addresses to MAC Layer 2 (Data
ARP
addresses Link)
RARP Resolves MAC addresses to IP Layer 2 (Data
(Legacy) addresses Link)
Resolves IP to MAC in IPv6 Layer 3
NDP (IPv6)
networks (Network)
Network Address Translation (NAT) – Overview
1. What is NAT?
Network Address Translation (NAT) is a method that allows multiple devices
on a private network to share a single public IP address when accessing the
internet.

2. Why is NAT Used? (Motivation)


 Saves IP Addresses: Instead of needing a unique public IP for every
device, a single IP can represent the entire network.
 Flexibility: Local device IPs can change without affecting external
communication.
 Easier ISP Switching: The local network remains unchanged even if the
ISP assigns a new public IP.
 Security: Devices on the private network are hidden from direct
external access.

3. Types of NAT
Type Description Common Use Case
One private IP is permanently Hosting a server
Static NAT
mapped to one public IP behind NAT
A private IP is mapped to a Businesses with
Dynamic NAT
public IP from a pool multiple public IPs
PAT (Port Address Multiple private IPs share a
Home networks &
Translation) aka "NAT single public IP using different
Small offices
Overload" port numbers

Advantages & Disadvantages of NAT


Advantages:
✔ Conserves IPv4 addresses by allowing many devices to share a single
public IP.
✔ Enhances security by hiding internal devices from direct internet access.
✔ Simplifies IP management when switching ISPs or restructuring networks.
Disadvantages:
✘ Breaks end-to-end connectivity, making some applications (e.g., VoIP,
peer-to-peer gaming) harder to use.
✘ Increases processing load on the router, especially in large networks.
✘ Alters packet headers, which can interfere with some security protocols
(e.g., IPsec).

NAT and Its Controversy


1. 16-bit Port-Number Field – Why NAT Supports 60,000+ Connections
 The port number field in TCP/UDP is 16 bits, allowing 65,536 possible
values (0–65535).
 Ports below 1024 are reserved (e.g., 80 for HTTP, 443 for HTTPS).
 This leaves about 60,000 available ports for each private IP behind a
NAT-enabled router.
 Meaning: A single LAN-side IP can support 60,000+ simultaneous
connections to the internet.
2. Why NAT Is Controversial?
NAT has been widely adopted but is not universally loved. Two major
criticisms:
1. Breaks Traditional Layer 3 Responsibilities
 NAT operates at Layer 3 (Network Layer) but modifies Layer 4
(Transport Layer) headers (port numbers).
 Routers traditionally only process up to Layer 3, meaning they should
only forward packets based on IP addresses, not change them.
 NAT disrupts end-to-end connectivity, making some protocols (e.g.,
VoIP, P2P apps) harder to use.
2. A Band-Aid for IPv4 Address Exhaustion
 NAT was introduced to extend the life of IPv4, allowing multiple devices
to share a single public IP.
 However, the real solution to address shortages is IPv6, which provides
2^128 addresses—enough for every device to have a unique public IP.
 Critics argue that if everyone adopted IPv6, NAT wouldn’t be needed
anymore.

3. NAT vs. IPv6 – Why NAT Still Exists?


 IPv6 adoption has been slow, especially for home ISPs and legacy
systems.
 Many websites and services still rely on IPv4, forcing ISPs and
businesses to use NAT.
 Network security: Some organizations prefer NAT for security reasons,
as it hides internal devices from external attacks.

Routing Explained
Routing is how a packet gets from source to destination through a network,
guided by routers that use routing tables.

1. Types of Routing
1. Centralized Routing (Obsolete)
 One central computer makes all routing decisions.
 Not used anymore due to scalability issues and single point of failure.
2. Static Routing
 Manually configured by a network admin.
 Routing tables never change unless manually updated.
 Used in small/simple networks where traffic is predictable.
 Pros: Simple, no overhead.
 Cons: Doesn’t adapt to network failures or congestion.
3. Dynamic Routing
 Routers communicate and update routing tables automatically.
 Adjusts routes in real time based on network conditions.
 Used in large networks and the internet.
 Pros: More efficient, adapts to failures/congestion.
 Cons: Adds processing overhead on routers.

2. Metrics Used in Dynamic Routing


Dynamic routing chooses the best path based on a metric. Two main
methods:
1. Distance Vector (Simpler, Less Accurate)
 Measures hop count (number of routers between source and
destination).
 Chooses the path with the fewest hops.
 Example Protocol: RIP (Routing Information Protocol)
 Problem: May not select the fastest/best route since it only considers
hop count.
2. Link State (More Complex, More Accurate)
 Uses multiple factors like:
o Bandwidth
o Latency (response time)
o Packet loss
o Cost (administrative preference)
 More reliable and up-to-date than Distance Vector.
 Example Protocols: OSPF (Open Shortest Path First), IS-IS (Intermediate
System to Intermediate System)
Link State is preferred because it finds better routes using more metrics.

3. Routing Protocols
Routing protocols decide how routers share information.
Interior Routing Protocols (Inside an Autonomous System)
 Used within a single organization’s network (e.g., a company or ISP).
 Examples:
o RIP (Distance Vector, rarely used)
o OSPF (Link State, commonly used)
o EIGRP (Hybrid, used in Cisco networks)
Exterior Routing Protocols (Between Different Organizations/ISPs)
 Used between different ISPs/networks on the internet.
 Example:
o BGP (Border Gateway Protocol) → Used for routing between ISPs
and large networks.

Summary: Why Link State is Better Than Distance Vector?


Feature Distance Vector Link State
Bandwidth, delay, packet
Routing Metric Hop count
loss, etc.
Protocol
RIP OSPF, IS-IS
Example
Lower (only counts
Accuracy Higher (uses multiple factors)
hops)
Speed Slower convergence Faster convergence
Preferred? ❌ No ✅ Yes

Routing Algorithm Classification


Routing algorithms determine how routers find the best path for packets.
There are two main ways to classify them:

1. Based on Information Scope: Global vs. Decentralized


Global Routing (Link State Algorithms)
 Every router has full knowledge of the network topology and link costs.
 Each router computes the best path using a centralized approach.
 Requires LSAs (Link-State Advertisements) to update routing tables.
 Example Protocols:
o OSPF (Open Shortest Path First)
o IS-IS (Intermediate System to Intermediate System)
Analogy: It's like Google Maps knowing all roads and traffic conditions, then
computing the best route for you.

Decentralized Routing (Distance Vector Algorithms)


 Each router only knows its directly connected neighbors and their link
costs.
 Routers share routing information iteratively with neighbors.
 Uses the Bellman-Ford algorithm to find the shortest path.
 Example Protocols:
o RIP (Routing Information Protocol)
o EIGRP (Enhanced Interior Gateway Routing Protocol, Cisco-
specific hybrid)
Analogy: It's like asking for driving directions at each intersection instead of
having a full map.

2. Based on Adaptability: Static vs. Dynamic Routing


Static Routing
 Manually configured by network administrators.
 Routes do not change automatically, even if a link fails.
 Used in small, simple networks with stable traffic patterns.
 Example: A small office network with a fixed route to the internet.
Analogy: A paper map—you have a fixed route, and if a road is closed, you're
stuck.

Dynamic Routing
 Routes update automatically based on network conditions.
 Routers exchange information periodically or in response to link
changes.
 Used in large and changing networks (e.g., the internet).
 Example Protocols:
o OSPF, IS-IS (Link State)
o RIP, EIGRP (Distance Vector/Hybrid)
o BGP (for internet routing between ISPs)
🔹 Analogy: Google Maps updating your route in real time based on traffic
conditions.

Comparison Table
Classification Static Routing Dynamic Routing
Adaptability Manual updates Automatic updates
Small/stable Large/changing
Best for
networks networks
No automatic Automatically finds new
Failure Handling
recovery path
Configuration
High (manual) Low (self-updating)
Effort
Example None (manual
RIP, OSPF, BGP
Protocols routing)

Autonomous System (AS) in Networking


An Autonomous System (AS) is a large network or group of networks under a
single administrative control that follows a common routing policy. Each AS is
identified by a unique Autonomous System Number (ASN) assigned by IANA
(Internet Assigned Numbers Authority).

Why Do We Need Autonomous Systems?


1️.Scalability 📈
 The global Internet consists of hundreds of millions of hosts and
routers.
 Storing, computing, and communicating routing information for every
router in the world would be impossible.
 Issues if we didn’t have AS:
o Memory overload: Every router would need to store routes to
every other router.
o Bandwidth exhaustion: Frequent updates (e.g., in Link-State
Routing) would consume all available bandwidth.
o Slow convergence: A Distance Vector Algorithm wouldn’t be able
to stabilize across millions of routers.
💡 Solution: Divide the global Internet into multiple ASes, each managing its
own routing.

2️.Administrative Autonomy 🏢
 Organizations (e.g., ISPs, corporations, universities) want to manage
their own internal routing policies.
 Each AS can choose its routing protocol (e.g., OSPF, EIGRP for internal
routing) instead of following a global standard.
 Security and privacy: An AS can hide its internal network structure from
the outside world.
Example:
 Google (AS15169) manages its own massive internal network using
custom routing policies.
 ISPs like Bell (AS577) and Rogers (AS812) manage their own routing
policies while connecting to other ISPs.

Autonomous System (AS) Overview 🏢🌐


An Autonomous System (AS) is a group of routers that:
✅ Operates under a single technical administration (e.g., an ISP, a company,
or a university).
✅ Uses an intra-AS routing protocol to route packets within the AS.
✅ Uses an inter-AS routing protocol to route packets to other ASes.

How Routing Works in an AS? 🚦


1️⃣ Intra-AS Routing (Routing Within an AS)
 Inside an AS, routers use an Interior Gateway Protocol (IGP) to
exchange routing information.
 Common IGPs used:
o OSPF (Open Shortest Path First) → Link-state routing (more
accurate, scalable).
o EIGRP (Enhanced Interior Gateway Routing Protocol) → Cisco
proprietary, fast convergence.
o RIP (Routing Information Protocol) → Older, simpler, but
inefficient for large networks.
💡 Example:
If you are using OSPF inside Google's AS (AS15169), Google’s routers will
communicate with each other using OSPF to find the best internal paths.

2️.Inter-AS Routing (Routing Between ASes)


 Different ASes must communicate with each other to send traffic
across the Internet.
 This is done using an Exterior Gateway Protocol (EGP).
 The only widely used EGP today is BGP (Border Gateway Protocol).
Example:
 Google (AS15169) and Bell (AS577) use BGP to exchange routing
information.
 BGP helps determine the best path for sending packets between ASes.

Autonomous System Analogy


Think of an AS as a city, where:
 Intra-AS routing (OSPF, EIGRP) is like the city’s local roads and streets.
 Inter-AS routing (BGP) is like highways connecting different cities.

You might also like