0% found this document useful (0 votes)
6 views42 pages

Module 03 CN

The document outlines the functions and services of the network layer, including packetizing, routing, and forwarding, as well as error control and security measures. It discusses IPv4 addressing, its structure, and the transition from classful to classless addressing to address address depletion issues. Additionally, it explains packet switching techniques, including the datagram and virtual-circuit approaches, highlighting their characteristics and advantages.

Uploaded by

ajayshenoy15
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)
6 views42 pages

Module 03 CN

The document outlines the functions and services of the network layer, including packetizing, routing, and forwarding, as well as error control and security measures. It discusses IPv4 addressing, its structure, and the transition from classful to classless addressing to address address depletion issues. Additionally, it explains packet switching techniques, including the datagram and virtual-circuit approaches, highlighting their characteristics and advantages.

Uploaded by

ajayshenoy15
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/ 42

Module 03

Network Layer & Unicast Routing Protocols

18.1 Network Layer Services

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. Packetizing (Main Duty):


 Source Host: Encapsulates data into a network-layer packet (adds headers
with source and destination addresses).
 Destination Host: Decapsulates the packet and delivers the payload to the
upper layer.
2. Payload Handling:
 The payload is carried unchanged unless it is too large, requiring
fragmentation.
3. Fragmentation and Reassembly:
 Source/Router: Fragments large packets if needed.
 Destination: Reassembles fragments before delivering to the upper layer.
4. Router Role:
 Forwards packets without changing source/destination addresses.
 Fragments packets if necessary, copying headers to all fragments.

18.1.2 Routing and Forwarding

Other Duties of the Network Layer:


 Routing: Finds the best path for packets from source to destination using routing
protocols.
 Forwarding: Moves packets between networks based on router tables.
1. Routing Details:
 Determines the best route among multiple possible routes.
 Uses routing protocols to build consistent routing tables before
communication starts.
2. Forwarding Details:
 Action performed by routers when packets arrive at interfaces.
 Uses the forwarding table (or routing table) to determine the output interface.
 Decisions are based on information like destination address or labels in the
packet header.
3. Unicast vs. Multicast Forwarding:
 Unicast: Sends the packet to one specific network.
 Multicast: Sends the packet to multiple networks.
18.1.3 Other Services

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.

18.2 Packet Switching


1. Switching at the Network Layer:
 A router acts as a switch, connecting input and output ports to allow data
flow.
 Only packet switching is used at the network layer since the unit of data is a
packet.
2. Comparison of Switching Types:
 Circuit Switching:
 Used at the physical layer (e.g., electrical switches).
 Not applicable at the network layer.
 Packet Switching:
 Divides messages into packets.
 Packets are sent and received one by one.
3. Routing in Packet-Switched Networks:
 Devices decide how to route packets to their destination.
 Two approaches are used:
 Datagram Approach.
 Virtual Circuit Approach.
These approaches are discussed in detail in later sections.

18.2.1 Datagram Approach (Connectionless Service)


1. Concept:
 The network layer offers a connectionless service.
 Each packet is treated independently, with no relationship to other packets in
the same message.
2. Routing of Packets:
 Packets may take different paths to the destination.
 Routing decisions are made per packet based on the destination address in the
header.
3. Role of Source and Destination Addresses:
 Destination Address: Determines where the packet is routed.
 Source Address: Used for sending error messages if the packet is discarded.
4. Characteristics:
 Packets may follow packets from the same or different sources.
 Routers (switches in this type of network) handle packets individually.
5. Example:
 Packets belonging to the same message can arrive at the destination in any
order due to varying paths.
This approach prioritizes simplicity but lacks reliability guarantees for ordered
delivery.
18.2.1 Virtual-Circuit Approach (Connection-Oriented Service)
1. Concept:
 Establishes a relationship between all packets of a message through a virtual
connection.
 All packets follow the same path after the virtual connection is set up.
2. Packet Information:
 Packets contain source and destination addresses along with a flow label or
virtual circuit identifier (VCI), which defines the virtual path.
3. Phases of Virtual Circuit:
 Setup Phase:
 A virtual circuit is established by exchanging request and
acknowledgment packets.
 Routers create entries in their forwarding tables. These entries include
the incoming port, incoming label, outgoing port, and outgoing label.
 Data-Transfer Phase:
 Packets use the established labels in the forwarding tables.
 Routers update the label at each hop to ensure packets follow the
predefined path.
 All packets arrive in order at the destination.
 Teardown Phase:
 After the message is delivered, a teardown packet is sent to release the
resources and delete table entries.
4. Setup Process:
 A request packet (with source and destination addresses) is sent from the
sender to the receiver through routers.
 Each router assigns an incoming label, an outgoing port, and partially fills the
table.
 The destination assigns the final label (e.g., 77) and sends an
acknowledgment packet back through the same path, completing the labels at
each router.
5. Data Forwarding:
 Each packet is forwarded based on its label.
 Routers modify the label at each hop, as per the forwarding table entries.
 The process ensures in-order delivery of packets.
6. Advantages:
 Guarantees ordered delivery and predictable paths.
 Efficient for applications requiring consistent performance.
7. Teardown Process:
 A teardown packet signals the end of communication.
 Routers delete all related entries in their tables, freeing up resources.
18.4 IPv4 Addresses
The IPv4 address is a 32-bit identifier used in the TCP/IP protocol suite to uniquely
define a connection between a device (host or router) and the Internet. This address
identifies the device's connection rather than the device itself. For example, if a device
moves to a different network, it may receive a new IP address, because the IP address is
tied to the specific network connection, not the device's hardware.
IPv4 addresses are globally unique, meaning each address specifies a unique connection
to the Internet. If a device has multiple connections (for instance, through two different
networks), it will have a separate IPv4 address for each connection. The system for IPv4
addressing is universal, meaning that any host connected to the Internet must adhere to
this addressing standard for communication to occur across different networks.

18.4.1 Address Space

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.

Classful vs. Classless Addressing:


 Classful Addressing: The early method of IPv4 addressing, where the network portion
(prefix) of the address had a fixed length. The address space was divided into different
classes (Class A, Class B, and Class C), each with a predefined number of bits for the
network and node portions.
 Classless Addressing: The more modern and flexible approach, where the prefix
length can vary (using variable-length subnet masks or VLSM), allowing for more
efficient use of the available address space. This is the system currently in use.
The classless approach makes it possible to allocate addresses more effectively, based
on the actual needs of networks, rather than being restricted to the rigid class-based
divisions.

18.4.2 Classful Addressing

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 Space Allocation


 Class A: 0 to 127 (binary starting with 0)
 Class B: 128 to 191 (binary starting with 10)
 Class C: 192 to 223 (binary starting with 110)
 Class D: 224 to 239 (binary starting with 1110) for multicast addresses
 Class E: 240 to 255 (binary starting with 1111) reserved for future 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.

Subnetting and Supernetting


To mitigate address depletion, two techniques were proposed:
 Subnetting: Dividing a large Class A or Class B network into smaller subnets. Each
subnet has a longer prefix and can be used by smaller organizations. However, this
system was not ideal, as large organizations were often reluctant to divide their
blocks of addresses.
 Supernetting: Combining several smaller Class C networks into a larger block.
While this approach could provide larger address blocks, it created challenges in
routing, making the network more complex and less efficient.

Advantages of Classful Addressing


Despite its drawbacks, classful addressing had a clear advantage: it was
straightforward. Given an IPv4 address, it was easy to determine the class (A, B, C,
D, or E), and since the prefix length was fixed for each class, no extra information
was needed to identify the network and host portions of the address. This
simplicity was beneficial in the early days of the Internet when the address space was
more manageable. However, as the number of devices grew, classful addressing was
replaced by classless addressing (CIDR), which offers more flexibility and efficient use
of the available address space.

18.4.3 Classless Addressing

1. Classless Addressing (CIDR - Classless Inter-Domain Routing):


 Classless addressing was introduced to solve the problem of address depletion
in IPv4 by using variable-length subnet masks (VLSM) instead of fixed class-
based addressing (Class A, B, C).
 CIDR allows for more efficient IP address allocation, offering flexibility and
reducing wastage of addresses.
 The traditional class-based system (Class A, B, C) was inefficient and led to
rapid address depletion, particularly with the growing number of ISPs and
network devices.
 CIDR addresses this by allowing for a more precise allocation of IP
addresses.
2. Slash Notation (CIDR Notation):
 In classless addressing, an IP address is followed by a slash (/) and a number,
indicating the number of bits used for the network portion of the address.
 For example, 167.199.170.82/27 means that the first 27 bits represent the
network, and the remaining bits are for the host portion.

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).

22.2 THE IPv6 PROTOCOL

IPv6 Changes Overview:


1. Better Header Format: IPv6 uses a new header format where options are separated
from the base header and inserted when needed, improving routing speed and
simplifying the process by eliminating unnecessary checks by routers.
2. New Options: IPv6 introduces new options for additional functionality.
3. Allowance for Extension: IPv6 allows the protocol to be extended for new
technologies or applications.
4. Support for Resource Allocation: The type-of-service field in IPv6 is replaced
with traffic class and flow label fields that allow the source to request special
handling of the packet, supporting applications like real-time audio and video.
5. Support for More Security: IPv6 introduces encryption and authentication options
to provide confidentiality and integrity of the packet.

IPv6 Packet Format:


 Base Header and Payload:
 The base header occupies 40 bytes, with the payload having up to 65,535
bytes of information.
1. Version: 4-bit field defining the version number of the IP (value for IPv6 is 6).
2. Traffic Class: 8-bit field used to distinguish payloads with different delivery
requirements (replaces the type-of-service field in IPv4).
3. Flow Label: 20-bit field used to provide special handling for a flow of data.
4. Payload Length: 2-byte field indicating the length of the IP datagram excluding the
header (fixed 40-byte header).
5. Next Header: 8-bit field defining the type of the first extension header (if present) or
the type of data following the base header.
6. Hop Limit: 8-bit field serving the same purpose as the TTL field in IPv4.
7. Source and Destination Addresses: 16-byte (128-bit) Internet addresses for the
source and destination of the datagram.
8. Payload: In IPv6, the payload may include extension headers (such as UDP, TCP,
ICMPv6, etc.) followed by data from other protocols.

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.

Fragmentation and Reassembly:


 Fragmentation: In IPv6, only the source can fragment packets, and reassembly takes
place at the destination.
 Packet Too Big: If a router encounters a packet that exceeds the MTU, it drops the
packet and sends an ICMPv6 error message to inform the source.

Comparison of IPv4 and IPv6 Options:


1. Pad1 and PadN replace the no-operation and end-of-option options in IPv4.
2. Source Route: The source route extension header replaces the source route option
from IPv4.
3. Fragmentation: The fragmentation fields in IPv4 are moved to the fragmentation
extension header in IPv6.
4. Authentication and ESP: These are new extension headers in IPv6.

20.1 INTRODUCTION (ROUTING)

 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.

20.1.1 LEAST COST ROUTING

Finding the Best Route:


 In a weighted graph, the best route from the source router to the destination
router is the one with the least total cost.
 The source router selects a path that minimizes the total cost to the
destination router.
 For example, in Figure 20.1, the best route from A to E is A → B → E with a
cost of 6.
 Each router needs to determine the least-cost route to all other routers.
Least-Cost Trees
 Least-Cost Paths:
 For an internet with N routers, there are (N - 1) least-cost paths from each
router to all other routers.
 The total number of least-cost paths for the entire internet is N × (N - 1).
 Efficient Representation:
 A least-cost tree for a router is a tree rooted at that router, covering all other
routers with the shortest paths.
 Each router has a least-cost tree, and there are N least-cost trees for the entire
internet.
Properties of Least-Cost Trees
1. Bidirectional Paths:
 The least-cost route from X to Y in X’s tree is the reverse of the least-cost
route from Y to X in Y’s tree.
 Example: In Figure 20.2, the route from A to F in A’s tree is A → B → E
→ F, and the route from F to A in F’s tree is F → E → B → A. Both
routes have a cost of 8.
2. Combining Routes:
 You can combine routes from two least-cost trees to reach a destination.
 Example: In Figure 20.2, travel from A to G using A’s tree: A → B → E
→ F → G.
 Alternatively, travel from A to E in A’s tree (A → B → E) and then from
E to G in E’s tree (E → F → G). The total cost in both cases is 9 (6 + 3).

20.2 ROUTING ALGORITHMS

20.2.1 DISTANCE VECTOR ROUTING

1. Overview of Distance-Vector Routing:


 Each node creates its own least-cost tree based on the information it knows
about its immediate neighbors.
 The trees are exchanged between neighbors, gradually making them more
complete.
 A node continuously shares what it knows about the network with its neighbors,
although this knowledge may be incomplete.
2. Bellman-Ford Equation:
 Central to distance-vector routing, this equation helps find the shortest path from
a source node to a destination node via intermediary nodes.

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.

4. Updating Distance Vectors:


 When a node receives a distance vector from a neighbor, it updates its vector by
checking if a new route is shorter.
 Nodes send their updated vectors to all neighbors, and this process continues
asynchronously.
 The vectors eventually stabilize, allowing nodes to determine the best route to all
other nodes.
5. Distance-Vector Routing Algorithm:

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
}

send vector {D[1], D[2], ..., D[N]} to all neighbors

// 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
}
}
}

Initialization: Each node creates an initial vector with distances to immediate



neighbors and infinity for others.
 Vector Updates: Nodes send their vectors to neighbors and update their own
vectors when they receive new ones. This happens asynchronously.
 The algorithm involves:
 Initialization: Setting the distance to immediate neighbors and infinity for
others.
 Updating: After receiving a vector, the node updates its own distance
vector using the Bellman-Ford equation and sends the updated vector to
neighbors.
6. Count to Infinity Problem:
 Issue: When a link fails, the update of the broken link's cost takes time to
propagate through the network.
 This results in a delay in the system's stability as nodes slowly recognize the cost
of the failed link as infinity.
 The count to infinity problem occurs when a link failure leads to a loop where
the cost to reach a node increases gradually until it reaches infinity.
7. Two-Node Loop Problem:
 Scenario: In the case of a failed link, two nodes might mistakenly believe they
can still reach a destination via each other, leading to gradual cost increases
(counting to infinity) until both nodes realize the destination is unreachable.
 This creates an unstable period where routing information is not accurate.

20.2.2 LINK STATE ROUTING

Link-State Database (LSDB) Creation:


1. Each node needs a complete map of the network, called the Link-State Database
(LSDB). It contains the cost of each link in the network.
2. Flooding is used to create this LSDB. Each node sends a greeting message (Link-
State Packet - LSP) to all its neighbors, collecting:
 The identity of the node
 The cost of the link
3. The node compares the newly received LSP with the stored one. If the new LSP is
more recent (based on sequence number), it is kept; otherwise, the old one is
discarded.
4. The node sends the LSP out of all interfaces except the one from which it was
received, ensuring the flooding process stops when the node has only one interface.

Dijkstra's Algorithm for Least-Cost Tree


1. Initialization:
 The node considers itself the root of the tree and starts with only itself in the
tree. The cost of all other nodes is set based on the information in the LSDB.
2. Select Closest Node:
 The node selects the node that is closest to the root and adds it to the tree.
This is based on the minimum cost from the root.
3. Repeat Until All Nodes Are Added:
 After adding a node to the tree, the cost of all other nodes is updated as their
paths may have changed. This process continues until all nodes are added to
the tree.
Dijkstra’s Algorithm ()
{
// Initialization
Tree = {root} // Tree is made only of the root
for each node y in the network {
if y is the root
D[y] = 0 // D[y] is the shortest distance from root to node y
else if y is a neighbor
D[y] = c[root][y] // c[x][y] is the cost between nodes x and y in
LSDB
else
D[y] = ∞
}

// 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

// Update distances for all neighbors of w


for each node x that is a neighbor of w and not in the Tree {
D[x] = min{D[x], (D[w] + c[w][x])}
}
} until all nodes are included in the Tree
}

20.2.3 PATH VECTOR ROUTING

1. Limitations of LS and DV Routing:


 LS (Link-State) and DV (Distance-Vector) routing are based on the least-cost
goal, which may not always be the priority.
 For example, a sender may want to avoid passing through certain routers, such as
those with security concerns or commercial rivals.
 LS and DV do not allow for the imposition of specific routing policies (e.g.,
avoiding certain routers) because they prioritize cost.
2. Path-Vector (PV) Routing:
 Path-Vector routing addresses the limitations of LS and DV by allowing the
source to define the routing path based on policies, not just cost.
 Best route selection: The source controls the path by applying its policies, such
as avoiding certain nodes or using the minimum number of nodes.
 Spanning Trees: In PV routing, the path from a source to a destination is
determined by a spanning tree that is not based on least-cost but on the policies
defined by the source.
3. Policy-Driven Routing:
 The source can apply multiple policies to route a packet, such as minimizing the
number of hops or avoiding certain nodes.
 Example: Source A may avoid passing through node D, while source B may
avoid node C.
4. Creating Spanning Trees in PV Routing:
 Path-Vector routing is asynchronous and distributed, with each node gradually
creating its own spanning tree based on its policies.
 The process begins when a node boots and creates a path vector based on its
immediate neighbors. These path vectors are shared with neighbors.
5. Path Vector Update Process:
 When a node receives a path vector from a neighbor, it updates its own vector
using an equation similar to Bellman-Ford but applying its own policies (not just
cost).
 Equation: Path(x, y) = best {Path(x, y), [(x + Path(v, y))]} for all v in the
network.
 This equation ensures that nodes select the best route according to their policy,
and paths that would lead to loops are discarded.
6. Path-Vector Algorithm:

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;
}
}

 Initialization: Each node initializes its path vector, setting distances to


immediate neighbors and ∞ for other nodes.
 Update Process: Nodes update their path vectors based on the information
received from neighbors, applying their policies.
 The process continues indefinitely as nodes exchange updated vectors.
7. Example of Path-Vector Updates:
 When node C receives path vectors from nodes B and D, it updates its own
vector accordingly, improving its knowledge of routes and stabilizing its
forwarding table.
 The vector updates are shown through events in which a node improves its
knowledge of the path after receiving vectors from neighbors.

20.3 UNICAST ROUTING PROTOCOLS

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.

Autonomous Systems (AS)


Each AS is identified by a unique 16-bit Autonomous System Number (ASN)
assigned by ICANN. ASs are categorized based on their connections:
 Stub AS:
o Connects to only one other AS.
o Data cannot transit through it.
o Example: Customer networks.
 Multihomed AS:
o Connects to multiple ASs.
o Does not allow transit traffic due to policy constraints.
 Transient AS:
o Connects to multiple ASs and allows transit traffic.
o Examples: Provider networks, backbones.
This classification influences interdomain routing protocols like BGP, ensuring
efficient communication across the global Internet.

20.3.2 ROUTING INFORMATION PROTOCOL

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.

4. RIP Routing Tables


 RIP routers maintain dynamic routing tables, which are updated in real-time based
on exchanged messages.
 Each table consists of:
 Destination Network: Specifies reachable subnets or networks.
 Next Router: Indicates the next hop along the path to the destination.
 Cost (Metric): Measured in hop count, with 16 hops indicating
unreachable routes.
 Tables are recalculated based on periodic updates or triggered 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.

7. RIP Algorithm Enhancements


 To overcome the limitations of the basic distance-vector approach, RIP employs:
 Split Horizon: Prevents routers from advertising routes back to the origin.
 Poison Reverse: Advertises failed routes with a metric of 16, indicating they
are unreachable.
 Holddown Timers: Temporarily suppresses updates for a route to avoid
oscillations during network convergence.

8. Challenges and Limitations


 Count-to-Infinity Problem:
o In a network with loops, hop count increments slowly, potentially
destabilizing the network.
o Mitigated through split horizon and poison reverse, but not completely
eliminated.
 Scalability:
o With a hop limit of 15, RIP cannot handle large networks or complex
topologies.
o Modern networks often require advanced routing protocols like OSPF or
EIGRP.
 Slow Convergence:
o Changes in topology require time to propagate, leaving the network in an
inconsistent state during updates.

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).

Operation of External BGP (eBGP)


 Connection Establishment: eBGP operates over TCP, typically using port 179. It
establishes a connection between border routers of different ASs, forming eBGP
peers (speakers).
 Message Exchange: The primary message type exchanged is the update message,
announcing network reachability. Each border router shares this information with its
eBGP peers, allowing them to update their forwarding tables with networks
reachable through the respective ASs.
 Example: In a network with multiple ASs, eBGP sessions help routers like R1, R5,
and others learn about networks in different ASs and update their tables for routing
packets accordingly.
Issues with eBGP
 Routing Gaps: While eBGP helps establish initial reachability information between
neighboring ASs, non-border routers within an AS may still lack the full routing
information to reach networks in other ASs.
 Solution: To address this, internal BGP (iBGP) is used to propagate reachability
information within an AS, ensuring that all routers within the AS have the necessary
data to route packets correctly.
Operation of Internal BGP (iBGP)
 Intradomain Communication: iBGP allows routers within an AS to exchange
reachability information. However, it requires a fully connected mesh of sessions
between routers to avoid routing loops.
 Session Setup: Each router in an AS sets up an iBGP session with every other
router. For an AS with n routers, the number of sessions required is calculated as [n
× (n − 1) / 2].
 Information Propagation: Routers exchange information about network
reachability, which is then used to update forwarding tables.

Combining eBGP and iBGP


 BGP Path Tables: Once information from eBGP and iBGP is combined, routers
create path tables that are used to select the best route for packet forwarding. This
combination ensures that routers have complete and up-to-date routing information.

Injection of Information into Intradomain Routing


 Enhancing Intradomain Routing: BGP’s role is not limited to interdomain routing; it
also helps populate the forwarding tables used by intradomain routing protocols like
RIP or OSPF. This process allows routers to make informed routing decisions both
within and between ASs.
 Default Routing for Stub ASs: In cases where an AS only has one connection to
another AS, such as a stub AS, border routers define a default route that points to
the eBGP peer for all external destinations.
Example of BGP Path Tables
The following are sample path tables after the BGP process has propagated reachability
information across multiple routers:
 R1 Path Table: Includes networks reachable via AS1, AS2, and AS4.
 R4 Path Table: Shows routes for networks in AS3 and AS4, with the next hop
defined.
 R5 Path Table: Contains information for networks reachable via AS2, AS1, and
AS3.

21.3.2 MULTICAST OPEN SOURCE SHORTEST PATH

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.

21.3.3 PROTOCOL INDEPENDENT MULTICAST

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.

You might also like