Module 03 CN
Module 03 CN
1. Internet Structure:
Internet = interconnected LANs and WANs using routers and switches.
2. Network Layer Role:
At the source, it creates datagrams.
At the destination, it extracts packets from datagrams.
Routers forward datagrams between networks.
3. Layers Used:
Hosts use all 5 TCP/IP layers.
Routers use 3 layers (Network, Data-link, Physical).
18.1.1 Packetizing
1. Error Control:
Network layer doesn’t directly handle error detection for data due to
inefficiency caused by fragmentation.
Includes a checksum field to detect corruption in the packet header.
ICMP Protocol assists in error reporting for discarded or malformed packets.
2. Flow Control:
Network layer doesn’t provide flow control.
Reasons:
a. Simplicity of receiver tasks (no error control).
b. Upper layers can buffer data.
c. Flow control is managed by upper-layer protocols.
3. Congestion Control:
Deals with excessive datagrams in the network causing router overload.
Dropped packets lead to retransmissions, worsening congestion.
Not implemented in the Internet but discussed conceptually.
4. Quality of Service (QoS):
Critical for multimedia (real-time audio/video).
QoS provisions are implemented at upper layers, leaving the network layer
unchanged.
5. Security:
Initially ignored as the Internet was limited to trusted users.
Modern networks require IPSec, which provides security by adding a virtual
layer for connection-oriented service.
In IPv4 addressing, the address space is determined by the number of bits used to define
an address. Since IPv4 uses 32-bit addresses, the address space is 232, which equals
4,294,967,296 unique addresses. This theoretically allows over 4 billion devices to be
connected to the Internet.
There are three common ways to represent an IPv4 address:
a. Binary Notation: An IPv4 address is represented as a 32-bit binary number. For
readability, spaces are often inserted between each octet (8 bits).
b. Dotted-Decimal Notation: This is the most common way to write an IPv4 address.
It represents the 32-bit address as four decimal numbers, each ranging from 0 to 255
(each corresponding to one octet), separated by periods. For example, 192.168.1.1.
c. Hexadecimal Notation: In this format, the 32-bit address is split into 8 hexadecimal
digits. Each hexadecimal digit represents 4 bits, so an IPv4 address is expressed
using 8 hexadecimal characters.
Hierarchical Addressing:
IPv4 addresses are hierarchical, similar to postal or telephone addresses. An IPv4 address
is divided into two parts:
Prefix: This part defines the network to which the device is connected.
Suffix: This part identifies the device (or node) within that network.
The length of the prefix is n bits, and the suffix length is (32−n) bits.
When IPv4 was designed, a fixed-length prefix scheme was used, which divided the
address space into five classes: A, B, C, D, and E. This structure was intended to
accommodate networks of various sizes but later became inefficient, leading to the
abandonment of classful addressing in favor of classless addressing.
IPv4 Classes:
Class A: The first 8 bits (n = 8 bits) are for the network identifier. This allows
for 128 networks (since the first bit is reserved for the class, leaving 7 bits for the
network). Each class A network can support up to 16,777,216 nodes. This was
intended for large organizations but often led to wasted addresses since most
organizations didn’t need such a large number of addresses.
Class B: The first 16 bits (n = 16 bits) are for the network identifier. This allows
for 16,384 networks and up to 65,536 nodes per network. Class B was designed for
medium-sized organizations but still led to inefficient usage as many addresses
remained unused.
Class C: The first 24 bits (n = 24 bits) are for the network identifier. This class
allows for over 2 million networks, but each network is limited to 256 addresses.
This small number of addresses often led to inefficiencies for organizations that
needed more addresses, even though they could easily have multiple networks.
Class D: Class D is reserved for multicast addresses. These addresses do not
have a network and node division and are used for sending data to multiple devices
simultaneously.
Class E: Reserved for future use, typically not allocated for general use.
Address Depletion
The inefficiencies of classful addressing became evident as the Internet grew. Large
organizations were allocated Class A addresses (which they rarely used fully), while
small networks often struggled with the limited address space of Class C addresses.
This imbalance contributed to the depletion of available IPv4 addresses.
For example:
Class A addresses were given to only 128 organizations worldwide, but each
organization could have up to 16 million addresses. This left many of these
addresses underutilized.
Class B provided 16,384 networks but was inefficient because of the large number
of addresses available to each network, which weren’t always fully used.
Class C had a limit of 256 addresses per network, which became inadequate for
many organizations that needed more.
3. Prefix Length:
The prefix length (e.g., /27) refers to how many bits are used for the network
portion of the IP address.
The larger the prefix length, the smaller the subnet. A smaller prefix length
(e.g., /8) means a larger network.
4. Network Block Division:
The IPv4 address space is divided into blocks, with each block containing a
certain number of addresses based on the prefix length.
The block size is calculated by the number of host bits (32 - prefix length).
5. Information Extraction:
The number of addresses in a block is given by the formula N=2 32−n, where n
is the prefix length.
The first address in the block has the network bits set and the host bits set to
0.
The last address in the block has the network bits set and the host bits set to
1.
6. Subnet Mask:
The subnet mask is used to extract the network portion of an IP address. It is
a 32-bit number with the first n bits set to 1 and the remaining bits set to 0.
The subnet mask helps determine which part of the address refers to the
network and which part refers to the host.
7. Network Address:
The network address is the first address of a block and is used to route
packets to the correct network.
It is the address that represents the entire network, and it cannot be assigned
to a specific host.
8. Block Allocation:
CIDR allows the Internet Corporation for Assigned Names and Numbers
(ICANN) to allocate large blocks of IP addresses to ISPs.
The size of the allocated block must be a power of 2 (e.g., 256, 512, 1024).
The first address in a block must be divisible by the number of addresses in
the block. This ensures address alignment.
9. Subnetting:
Subnetting divides a large network into smaller, more manageable subnets.
Subnetting in CIDR allows ISPs to divide the allocated address blocks into
smaller subnets to serve different regions or departments within an
organization.
If needed, these subnets can be further divided into even smaller subnets,
allowing for more efficient address utilization.
18.4.4 DHCP
Overview:
DHCP: A network management protocol used to automate the assignment of IP
addresses, subnet masks, gateways, and DNS servers to devices in a network.
How DHCP Works:
1. DHCP Discover: The client broadcasts a DHCPDISCOVER message to find a
DHCP server.
2. DHCP Offer: The server responds with a DHCPOFFER message, offering an
IP address.
3. DHCP Request: The client sends a DHCPREQUEST message to the server to
request the offered IP.
4. DHCP Acknowledge: The server responds with a DHCPACK message,
confirming the IP assignment.
5. DHCP Nack: If the client’s request is invalid (e.g., no IP available), the server
sends a DHCPNACK.
Important Fields in DHCP Packets:
Transaction ID: Unique identifier for the DHCP transaction.
Options Field: Includes configuration parameters like lease time, DNS servers,
router addresses, etc.
Magic Cookie: Value (99.130.83.99) used to identify the start of the options
field.
DHCP States (State Machine):
1. INIT: The client starts the process with DHCPDISCOVER.
2. SELECTING: The client waits for a response from a DHCP server.
3. REQUESTING: The client has selected an offer and requests the IP.
4. BOUND: The client has successfully obtained an IP address.
5. RENEWING: The client tries to renew its lease at 50% lease time.
6. REBINDING: The client tries to renew the lease with another server at 87.5%
lease time.
7. EXPIRED: The lease expires, and the client must restart the process.
DHCP Message Format:
Fields:
a. Op Code: Defines if the message is a request or response (1 for request, 2
for response).
b. Hardware Type: Type of hardware (Ethernet, Wi-Fi, etc.).
c. Transaction ID: Used to match requests with replies.
d. Client IP Address: The IP address of the client (usually 0.0.0.0 during the
discover phase).
e. Server IP Address: The IP address of the DHCP server.
f. Options: Contains vendor-specific options and IP configuration data.
DHCP Ports:
Port 67: Server port.
Port 68: Client port.
Lease Time:
DHCP assigns an IP address for a specific period, called the lease time. After
expiration, the client must renew or request a new IP.
18.4.5 NAT
Overview:
NAT is used to translate private IP addresses to public IP addresses and vice versa,
enabling devices in a local network to communicate with the internet using a single
public IP address.
Why NAT?
IP Address Conservation: IPv4 addresses are limited, and NAT allows multiple
devices on a private network to share a single public IP address.
Security: Hides internal network structures and devices from the external world.
Types of NAT:
1. Static NAT (One-to-One Mapping):
One private IP address is mapped to one public IP address. Common for web
servers.
2. Dynamic NAT (Many-to-One Mapping):
A pool of public IP addresses is used to map multiple private IP addresses to
public ones dynamically. This is more flexible but still requires public IP
addresses.
3. PAT (Port Address Translation):
Also known as NAT overload, this allows many private IP addresses to share
a single public IP address by differentiating the connections using port
numbers. Most commonly used NAT type in home routers.
NAT Process:
When a device in the private network wants to access the internet:
1. The router changes the source IP address of the outgoing packet from a
private IP to a public IP.
2. The router tracks this mapping in a translation table.
3. When the response returns to the public IP, the router uses the translation
table to send it to the correct private IP address.
NAT Table:
The router maintains a NAT translation table that maps:
a. Private IP addresses to public IP addresses.
b. Private port numbers to public port numbers.
Limitations of NAT:
1. Performance: Processing NAT for each packet can add delay.
2. Complicates Peer-to-Peer Communication: Some protocols (e.g., VoIP, FTP) rely
on direct address communication and can have issues with NAT.
3. IP Fragmentation: NAT can interfere with the transmission of fragmented packets.
NAT and Security:
Firewalling: NAT acts as a basic firewall by hiding internal addresses from the
public internet, providing a layer of security.
Packet Filtering: Routers with NAT often also provide basic packet filtering,
allowing only certain traffic to enter or leave the private network.
NAT Overload (PAT):
NAT Overload allows multiple internal devices to share a single public IP address.
It does this by assigning unique port numbers to each connection.
For example, two devices using the same public IP can be differentiated by
using port numbers 5000 and 5001.
NAT Traversal:
NAT Traversal refers to techniques used to enable devices behind NAT (like those
on private networks) to communicate with external servers, especially for peer-to-
peer applications (e.g., VoIP, online games).
Extension Headers:
Hop-by-Hop Option: Used for passing information to all routers visited by the
datagram, including options like Pad1 (alignment) and Jumbo Payload (for payloads
larger than 65,535 bytes).
Destination Option: Used to pass information to the destination only, with Pad1
and PadN options defined.
Source Routing: Combines strict and loose source route options from IPv4.
Fragmentation: Fragmentation occurs only at the source, not by routers. The
source must ensure that the datagram size is appropriate for the smallest MTU along
the path or fragment to 1280 bytes.
Authentication: Validates the message sender and ensures data integrity.
Encrypted Security Payload (ESP): Provides confidentiality and guards against
eavesdropping.
Flow and Priority in IPv6:
Flow Label: Helps IPv6 function as a connection-oriented protocol. Routers use a
flow label table to provide required services for a given flow.
Connection-oriented Protocol: The flow label table can speed up processing by
bypassing routing algorithms.
Unicast routing in the Internet requires hierarchical routing due to the large
number of routers and hosts.
Hierarchical routing involves multiple steps with different routing algorithms.
Routing Concept: Unicast routing in an internet (internetwork) involves networks
connected by routers.
After understanding routing concepts and algorithms, we can apply them to the
Internet using hierarchical routing.
An Internet as a Graph
Graph Representation: An internet can be modeled as a graph, where:
Each router is a node.
Each network between two routers is an edge.
A weighted graph is used where each edge has an associated cost.
The cost could represent different factors like distance, bandwidth, or delay.
If no edge exists between nodes, the cost is infinite.
3. Distance Vectors:
A distance vector is a one-dimensional array representing a least-cost tree. The
vector holds the minimum cost to reach each destination from the node.
Distance vectors are created initially with minimal information, just the
distances to immediate neighbors.
Nodes send their distance vectors to immediate neighbors. After receiving
vectors, each node updates its own vector using the Bellman-Ford equation.
Distance_Vector_Routing ()
{
// Initialize (create initial vectors for the node)
D[myself] = 0 // Set distance to self as 0
for each neighbor (C, D, B, A, E, F, G)
{
if (neighbor is a direct connection)
D[neighbor] = c[myself][neighbor] // Set distance to neighbors
based on the direct cost
else
D[neighbor] = ∞ // Set distance to other nodes as infinity
}
// Update (improve the vector with the vector received from a neighbor)
repeat (forever)
{
wait (for a vector Dw from a neighbor w or any change in the link)
for (y = 1 to N)
{
D[y] = min[D[y], (c[myself][w] + Dw[y])] // Bellman-Ford
equation to update the vector
}
if (any change in the vector)
{
send vector {D[1], D[2], ..., D[N]} to all neighbors
}
}
}
// Calculation
repeat {
find a node w with D[w] minimum among all nodes not in the Tree
Tree = Tree ∪ {w} // Add w to the tree
Path_Vector_Routing()
{
// Initialization
for (y = 1 to N)
{
if (y is myself)
Path[y] = myself;
else if (y is a neighbor)
Path[y] = myself + neighbor node;
else
Path[y] = empty;
}
Send vector {Path[1], Path[2], ..., Path[y]} to all neighbors;
// Update
repeat (forever)
{
wait (for a vector Pathw from a neighbor w);
for (y = 1 to N)
{
if (Pathw includes myself)
discard the path; // Avoid any loop
else
Path[y] = best {Path[y], (myself + Pathw[y])};
}
if (there is a change in the vector)
Send vector {Path[1], Path[2], ..., Path[y]} to all neighbors;
}
}
Unicast routing protocols govern how data packets are routed in the Internet. Unlike
simple algorithms, protocols define a broader operational framework, including
message exchanges, inter-router communication, and interactions across domains.
Three key unicast routing protocols used today are:
1. Routing Information Protocol (RIP)
Based on the distance-vector algorithm.
Simpler and suited for smaller networks.
2. Open Shortest Path First (OSPF)
Based on the link-state algorithm.
Designed for efficient, scalable routing in larger networks.
3. Border Gateway Protocol (BGP)
Based on the path-vector algorithm.
Manages routing between autonomous systems in the global Internet.
Internet Structure
Modern Internet architecture has evolved from a single-backbone tree-like structure to
a multi-backbone system managed by private corporations.
Backbones: Global networks managed by major providers, interconnected at
peering points.
Provider Networks: Regional or local networks that utilize backbones for
connectivity and serve customers.
Customer Networks: End-user networks relying on provider networks for
Internet access.
These entities, collectively known as Internet Service Providers (ISPs), operate at
various levels and are critical to the Internet's hierarchical structure.
Hierarchical Routing
Given the Internet's vast scale, routing requires multiple protocols:
1. Intradomain Routing Protocols (IGPs):
o Operate within an autonomous system (AS).
o Examples: RIP, OSPF.
2. Interdomain Routing Protocol (EGP):
o Governs routing between ASs.
o Example: BGP.
Hierarchical routing divides the Internet into autonomous systems to ensure scalability
and administrative control, enabling each AS to manage its policies and routing
requirements.
1. Historical Context
RIP was first introduced in the Xerox Network System (XNS) protocol suite as
part of the Gateway Information Protocol (GIP).
Gained widespread use through BSD UNIX, where it became an integral part of
network systems.
Played a significant role in early IP-based networks as one of the first standardized
interior gateway protocols (IGPs).
2. General Features
Routing Algorithm: Based on the distance-vector algorithm, which periodically
shares routing information between neighbors.
Metric: Routes are evaluated using a simple metric: hop count.
Hop count directly reflects the number of routers a packet must traverse to
reach its destination.
Hop Count Limit: Capped at 15 to prevent routing loops and ensure quick
error detection.
Network Scale: Designed for small to medium-sized networks, often unsuitable for
large, complex topologies.
3. Functionality
RIP is specifically an intra-domain protocol, meaning it is used within a single
autonomous system (AS).
Operates on the application layer and communicates via UDP using port 520.
Regularly exchanges routing information between directly connected routers to
ensure consistent updates.
5. RIP Messages
RIP uses two core message types for communication:
Request Message: Queries routing information from other routers.
Response Message: Shares the sender’s routing table.
Messages are sent regularly (every 30 seconds) or triggered by significant changes
in topology.
Data packets use a defined packet format, including fields for version, command,
and address.
6. Timers in RIP
RIP’s operation is governed by multiple timers to ensure stability and consistency:
Periodic Timer: Ensures routing updates are sent every 25–35 seconds to
neighbors.
Expiration Timer: A route is declared invalid if no updates are received
within 180 seconds.
Garbage Collection Timer: After being marked invalid, a route is retained
for an additional 120 seconds before removal, allowing for consistency.
9. RIP Implementation
Typically runs as the routed or quagga daemon in UNIX-based systems.
Simple to configure but lacks advanced features for large-scale deployments.
Still found in legacy systems and environments where simplicity is prioritized over
performance.
10. Robustness
Although simple, RIP is prone to errors in:
Incorrect Information Propagation: A single misconfigured router can
impact the entire routing table.
Network Instability: The periodic update mechanism may inadvertently
create temporary inconsistencies.
Comparatively less robust than link-state protocols, which have more precise
network-state awareness.
20.3.3 OPEN SOURCE SHORTEST PATH
1. OSPF Overview
OSPF (Open Shortest Path First) is an intradomain routing protocol based on
the link-state routing protocol.
It is an open protocol, meaning its specification is public.
2. Metric in OSPF
OSPF calculates the cost to reach a destination from the source router to the
destination network.
Each link can be assigned a weight based on throughput, round-trip time,
reliability, etc.
Different service types (TOSs) can have different weights as the cost.
The cost values are based on various factors and can differ between routers in
the network.
3. Forwarding Tables
OSPF routers create a forwarding table after finding the shortest-path tree
using Dijkstra’s algorithm.
Forwarding tables are similar to RIP in structure but differ in cost values.
If OSPF uses hop count, the forwarding tables will be identical to RIP's.
4. Areas in OSPF
OSPF handles routing for both small and large autonomous systems (AS).
To reduce traffic, the AS is divided into smaller sections called areas.
A backbone area (Area 0) connects all areas within the AS.
Routers in the backbone area pass information between areas.
5. Link-State Advertisement (LSA)
OSPF uses five types of LSAs:
1. Router Link: Advertises the existence of a router as a node and its link
to other routers.
2. Network Link: Advertises a network as a node, with a designated router
sending the announcement.
3. Summary Link to Network: Area border routers advertise a summary of
links to other areas.
4. Summary Link to AS: AS routers advertise summary links to the
backbone area.
5. External Link: AS routers announce networks outside the AS to the
backbone area.
6. OSPF Implementation
OSPF operates at the network layer, using IP for message propagation
(protocol field set to 89).
It exists in two versions: version 1 and version 2, with version 2 being more
commonly used.
7. OSPF Messages
OSPF uses five types of messages:
1. Hello Message (Type 1): Used for router introduction and neighbor
announcement.
2. Database Description Message (Type 2): Sent to acquire the full LSDB.
3. Link-State Request Message (Type 3): Sent to request specific link-
state information.
4. Link-State Update Message (Type 4): Main message for building the
LSDB, carrying router, network, summary, and external links.
5. Link-State Acknowledgment Message (Type 5): Used for
acknowledging link-state update messages.
8. Authentication in OSPF
OSPF includes provisions for authenticating message senders to prevent
malicious entities from disrupting the network.
9. OSPF Algorithm
After creating the shortest-path tree, OSPF uses the tree to form the routing
algorithm.
The algorithm is designed to handle sending and receiving all five message
types.
10. Performance Considerations
Update Messages: Link-state messages have a complex format and are
flooded throughout the area, which can consume bandwidth in larger areas.
Convergence of Forwarding Tables: After LSP flooding is completed,
convergence occurs relatively quickly as each router computes its shortest-
path tree using Dijkstra's algorithm.
Robustness: OSPF is more robust than RIP, as each router is independent
once the LSDB is received, meaning router failures don't severely affect
other routers in the area.
20.3.4 BORDER GATEWAY PROTOCOL 4 [BGP4]
Introduction
BGP4 is the interdomain routing protocol used across the Internet today. It is based on the
path-vector algorithm and designed to communicate network reachability information
between autonomous systems (ASs).
MOSPF is an extension of OSPF that allows for multicast routing. It uses the source-based
tree approach for multicasting and extends unicast routing concepts:
1. Dijkstra’s Algorithm is used to create a source-specific shortest-path tree with the
source as the root.
2. The router finds itself within the shortest-path tree and constructs a multicast
subtree.
3. The multicast tree is pruned to ensure that multicast packets only reach networks
with active group members using IGMP.
4. The router then forwards the multicast packet only through interfaces corresponding
to the multicast tree.
MOSPF enhances OSPF by adding a new type of link-state update packet to propagate
membership information, allowing routers to prune the broadcast tree and create multicast
trees.
PIM operates in two modes: Dense Mode (PIM-DM) and Sparse Mode (PIM-SM), and
can work with any unicast routing protocol (distance-vector or link-state).
PIM-Dense Mode (PIM-DM) is used when there are many active members in the
multicast group. It is based on a source-based tree and uses Reverse Path
Forwarding (RPF) and Reverse Path Multicast (RPM) for efficient packet
delivery:
1. The router uses RPF to check if the multicast packet is coming from the
expected direction.
2. If the packet is valid, it is forwarded to all interfaces except the one it came
from. Unwanted packets are pruned through prune messages.
o Figure 21.14 shows the broadcast to multicast transition after prune messages
are received.
PIM-Sparse Mode (PIM-SM) is used when there are fewer active members. PIM-
SM uses a shared tree rooted at a Rendezvous Point (RP). Multicast
communication occurs in two phases:
1. Multicast packets are first sent to the RP via unicast tunneling. The RP
decapsulates and sends the multicast packets to their destination.
2. Join and Prune messages are used to build and manage the multicast tree,
ensuring that packets are only forwarded to routers with active members.
o Figure 21.15 shows how join and prune messages form and adjust the
multicast tree in PIM-SM.
PIM-SM provides an efficient mechanism to multicast packets in environments where
group members are dispersed, and minimizes unnecessary traffic by only forwarding
multicast packets to interested routers.