CN BCS502 Module3 Notes
CN BCS502 Module3 Notes
MODULE – 3
NETWORK LAYER
Network Layer: Network layer Services, Packet Switching, IPv4 Address, IPv4 Datagram, IPv6
Datagram, Introduction to Routing Algorithms, Unicast Routing Protocols: DVR, LSR, PVR,
Unicast Routing protocols: RIP, OSPF, BGP, Multicasting Routing-MOSPF
1. NETWORK-LAYER
1.1 Network Layer Services
1.2 Packet Switching
1.3 IPv4 Addresses
1.4 IPv4 Datagram
1.5 IPv6 Datagram
2. INTRODUCTION TO ROUTING ALGORITHMS
2.1 Introduction
2.2 Routing Algorithms
2.3 Unicast Routing Protocols:DVR, LSR, PVR
2.4 Unicast Routing Protocols:RIP, OSPF,BGP
2.5 Multicast Routing:MOSPF
1. NETWORK-LAYER
The network layer in the TCP/IP protocol suite plays a crucial role in ensuring host-to-host
delivery of data. It operates between the data-link layer and the transport layer, providing
services to the latter while receiving services from the former. It is responsible for routing and
delivering packets across various networks, encapsulating data into packets, and decapsulating
them at the destination.
1.1 Network Layer Services
The Internet, a combination of LANs and WANs, consists of many networks connected through
routers and switches. The network layer is involved in:
• Source Host (e.g., Alice): It encapsulates the transport layer packet into a datagram and
hands it over to the data-link layer for transmission.
• Destination Host (e.g., Bob): It decapsulates the received datagram to retrieve the packet
and deliver it to the transport layer.
• Routers (R2, R4, R5, R7): They forward the datagrams across multiple networks until
they reach the destination.
o The network layer encapsulates data from the transport layer into packets
(datagrams) at the source and decapsulates them at the destination.
o The source adds necessary headers, including source and destination addresses,
to the packet.
2. Routing:
o The network layer selects the best route for packets to travel across multiple
networks (LANs, WANs).
o Routers use algorithms to determine the most efficient path from source to
destination.
3. Forwarding:
o Forwarding refers to how routers handle packets upon arrival. Routers look up
the forwarding table or routing table to determine which network interface to send
the packet through.
o Although the network layer itself doesn’t handle errors directly, the ICMP
protocol helps detect errors, such as when a packet cannot be delivered.
• Flow Control:
o The network layer helps prevent the receiver from becoming overwhelmed with
data by ensuring the sender doesn't send more data than the receiver can process.
• Congestion Control:
o The network layer helps in managing and avoiding congestion in the network by
controlling the flow of packets, especially in high-traffic conditions.
o QoS ensures the network layer delivers data with a certain performance level,
managing delays, throughput, and packet loss.
Today, a packet-switched network can use two different approaches to route the packets: the
datagram approach and the virtual circuit approach.
1. Setup Phase
• Goal: Establish a virtual circuit between Source A and Destination B using request and
acknowledgment packets.
• Steps in Setup:
o Request Packet:
1. Source A sends a request packet to Router R1.
2. Router R1:
▪ Identifies the outgoing port for packets to B (Port 3).
▪ Assigns:
▪ Incoming Port: 1
▪ Incoming Label: 14
▪ Outgoing Port: 3
▪ Forwards the packet to Router R3.
3. Router R3:
▪ Fills its routing table with:
▪ Incoming Port: 1
▪ Incoming Label: 66
▪ Outgoing Port: 3
▪ Forwards the packet to Router R4.
4. Router R4:
▪ Assigns:
▪ Incoming Port: 1
▪ Incoming Label: 22
▪ Outgoing Port: 4
▪ Sends the request packet to Destination B.
5. Destination B assigns Label 77 to incoming packets from A.
o Acknowledgment Packet:
1. Destination B sends an acknowledgment packet back to Router R4:
▪ Router R4 fills the outgoing label as 77.
2. Router R4 sends the acknowledgment to Router R3, which fills its
outgoing label as 22.
3. Router R3 sends an acknowledgment to Router R1, which fills its
outgoing label as 66.
4. Router R1 sends the acknowledgment to Source A, which fills its
outgoing label as 14 for future packets.
• Goal: Transfer data between Source A and Destination B once the virtual circuit is
established.
• Steps:
1. Source A labels the packets with Label 14 (from R1).
2. Router R1:
▪ Receives packets with Label 14.
▪ Changes the label to 66 and forwards to Router R3.
3. Router R3:
▪ Receives packets with Label 66.
▪ Changes the label to 22 and forwards to Router R4.
4. Router R4:
▪ Receives packets with Label 22.
▪ Changes the label to 77 and forwards to Destination B.
5. Destination B receives the packets with Label 77 (which it recognizes from
setup).
3. Teardown Phase
• Header:
o 20 to 60 bytes in length.
o Contains crucial fields to ensure the proper routing and handling of the packet.
o Shown in 4-byte (32-bit) sections for easy reference.
• Payload:
o Contains the data from the upper-layer protocols, such as TCP, UDP, or other
transport or network protocols.
1. Version (4 bits):
o Specifies the IP version. For IPv4, the value is always 4.
2. Header Length (HLEN) (4 bits):
o Indicates the length of the header in 4-byte words.
o Helps identify where the header ends and the data (payload) begins.
3. Service Type (8 bits):
o Originally called Type of Service (TOS), now redefined as Differentiated
Services (DiffServ).
o Used for prioritizing different types of network traffic (e.g., voice over IP).
4. Total Length (16 bits):
o Specifies the total length of the datagram, including both header and data, in
bytes.
o Helps receivers distinguish between actual data and any padding that might be
added (e.g., in Ethernet frames).
5. Identification, Flags, and Fragmentation Offset:
o Used for fragmenting datagrams that exceeds the maximum transmission unit
(MTU) of the network.
o Allows reassembly of fragmented packets at the destination.
6. Time-to-Live (TTL) (8 bits):
o Limits the number of hops a datagram can take.
o Each router decrements this value, and if it reaches zero, the datagram is
discarded.
o Prevents datagrams from endlessly circulating due to routing errors.
7. Protocol (8 bits):
o Identifies the protocol of the encapsulated payload (e.g., TCP = 6, UDP = 17).
o Ensures the correct upper-layer protocol receives the data at the destination
(demultiplexing).
8. Header Checksum (16 bits):
o Used to verify the integrity of the header (not the payload).
o Each router recalculates the checksum since fields like TTL change with every
hop.
9. Source and Destination IP Addresses (32 bits each):
o Source IP Address: The IP address of the sender.
o Destination IP Address: The IP address of the receiver.
o These fields remain unchanged as the datagram travels across the network.
10. Options (0–40 bytes):
o Optional field used for network testing, debugging, or special features.
o Adds flexibility, but may require routers to recalculate the checksum if options
are altered.
3. Payload (Data)
• The payload is the data encapsulated in the datagram, which comes from upper-layer
protocols (e.g., TCP, UDP).
• The payload is the primary reason for sending the datagram, with the header providing
the necessary instructions for delivery.
4. Important Concepts
• The address space is the total number of addresses available for use in the IPv4 protocol.
• IPv4 uses 32 bits, so the address space is 2³² (or 4,294,967,296 addresses).
• In theory, this would allow more than 4 billion devices to connect to the Internet, but
practical limitations such as network design reduce the usable address space.
• Classful Addressing divides the IPv4 address space into five classes (A, B, C, D, E),
designed to accommodate different network sizes.
1. Class A:
o Prefix length: 8 bits (first bit is always 0, so only 7 bits are available for network
identification).
o Supports up to 128 networks.
o Example range: 1.0.0.0 to 126.0.0.0.
2. Class B:
o Prefix length: 16 bits (first two bits are 10, so 14 bits for network identification).
o Supports up to 16,384 networks.
o Example range: 128.0.0.0 to 191.255.0.0.
3. Class C:
o Prefix length: 24 bits (first three bits are 110, so 21 bits for network
identification).
o Supports up to 2,097,152 networks.
o Example range: 192.0.0.0 to 223.255.255.0.
4. Class D (Multicast):
o First four bits are 1110.
o Reserved for multicast addresses (group communication).
o Range: 224.0.0.0 to 239.255.255.255.
5. Class E (Experimental):
o First four bits are 1111.
o Reserved for experimental purposes.
o Range: 240.0.0.0 to 255.255.255.255.
Address Depletion
Problem: Classful addressing led to rapid depletion of IPv4 addresses due to inefficient
distribution.
• Class A:
o Designed for very large organizations.
o Only 128 networks available, each with 16,777,216 addresses.
o Most organizations didn't need so many addresses, leading to significant waste.
• Class B:
o Designed for midsize organizations.
o Despite more networks available, many addresses remained unused.
• Class C:
o Intended for smaller networks.
o Each network had only 256 addresses, which was often too few for organizations.
• Class E: Reserved and almost never used, leading to wastage of the entire class.
• Subnetting:
o Concept: Divides a large class A or class B network into smaller subnets.
o Method: Increases the prefix length, creating multiple smaller networks from a
single large network.
o Issue: Not widely adopted because large organizations were reluctant to share
unused addresses with smaller ones.
• Supernetting:
o Concept: Combines several smaller class C networks into a larger block.
o Purpose: Designed to create larger address blocks for organizations needing
more than 256 addresses.
o Issue: Made packet routing more complex, limiting its effectiveness.
• Simplicity: The class of an address is easily identifiable from the address itself.
• Fixed Prefix Length:
o Each address class (A, B, C) has a predefined prefix length.
o No additional information is required to determine the prefix and suffix, making
it easier to understand and manage
• Classless addressing was introduced to solve the IPv4 address depletion problem.
• It eliminates the rigid class structure (A, B, C) of classful addressing and allows
variable-length blocks of IP addresses.
• Provides more efficient and flexible distribution of IP addresses to organizations and
ISPs.
• Classful addressing wasted many IP addresses due to fixed-size blocks; classless
addressing resolves this by allowing different block sizes.
3. Variable-Length Blocks:
• In classless addressing, IP addresses are grouped into blocks of varying sizes, which
can be 2, 4, 8, 16, 32, 64 addresses, and so on.
• The block sizes must be a power of 2, such as 21, 22, 23 and so on.
• The length of the network portion of the IP address is indicated by the prefix length.
• Slash Notation or CIDR (Classless Interdomain Routing) is used to specify the
prefix length, written as /n, where n is the number of bits used for the network part.
o Example: 192.168.1.0/24 means the first 24 bits are for the network and the
remaining 8 bits are for hosts.
• Larger prefix length = smaller network (fewer hosts).
5. Block of Addresses:
• A block of addresses is determined by the prefix (network part) and the suffix (host
part).
• The size of the block is based on the prefix length.
• The number of addresses in a block is calculated using the formula: N=232-n where n is
the prefix length.
Example : A classless address is given as 167.199.170.82/27. We can find the above three
pieces of information as follows. The number of addresses in the network is 232 − n = 25 = 32
addresses.
Example 18.3
In classless addressing, an address cannot per se define the block the address belongs to. For
example, the address 230.8.24.56 can belong to many blocks. Some of them are shown below
with the value of the prefix associated with that block.
Network Address
The above examples show that, given any address, we can find all information about the block.
The first address, the network address, is particularly important because it is used in routing a
packet to its destination network.
• Efficient use of IP addresses: Avoids the waste of addresses that occurs with classful
addressing.
• Scalability: Allows for more precise address allocation based on actual need, which is
crucial as the number of devices connected to the Internet grows.
• Better management by ISPs: ISPs can assign blocks of different sizes to customers,
ensuring everyone gets only the number of addresses they need.
Classless addressing (CIDR) was a crucial development in managing the limited IPv4 address
space. By allowing variable-length prefixes and more flexible block sizes, it ensures a more
efficient and scalable distribution of IP addresses across the Internet.
• Global Authority (ICANN): The Internet Corporation for Assigned Names and
Numbers (ICANN) is responsible for assigning IP address blocks.
o ICANN does not assign addresses to individual users but allocates large blocks to
ISPs or large organizations.
• Responsibilities of ISPs: ISPs receive large blocks of addresses from ICANN, which
they further subdivide and assign to customers.
1. Overview of Subnetting:
2. Designing Subnets:
Example:
After designing the subnetworks, key information about each subnet (such as the first address
and last address) can be calculated using the same method applied to larger networks. The
process is as follows:
1. First Address:
o The first address of the subnet is found by setting the host bits (the last 32−n sub
bits) to 0.
2. Last Address:
o The last address is found by setting the host bits to 1.
• If a subnet has a prefix length of /24, the first address will have the last 8 bits set to 0,
and the last address will have the last 8 bits set to 1.
This approach ensures optimal usage of IP addresses, simplifies routing, and improves the
scalability of network infrastructure.
Address Aggregation
One of the advantages of the CIDR strategy is address aggregation (sometimes called address
summarization or route summarization). When blocks of addresses are combined to create a
larger block, routing can be done based on the prefix of the larger block. ICANN assigns a large
block of addresses to an ISP. Each ISP in turn divides its assigned block into smaller sub blocks
and grants the sub locks to its customers.
Example: An organization has been granted a block of 256 addresses, starting at 14.24.74.0/24.
The organization needs to divide this block into three subnets with the following requirements:
The solution involves allocating a number of addresses that are powers of 2, which are larger
than or equal to the required number. The subnets are designed by starting with the largest
requirement and working down to the smallest.
1. Total Addresses:
o The block 14.24.74.0/24 has a total of: 232−24=256 addresses
o First address: 14.24.74.0
o Last address: 14.24.74.255
Remaining Addresses:
• After assigning the three subnets, the total number of allocated addresses is:
128+64+16=208 addresses
• This leaves 48 addresses unused.
• First address of unused range: 14.24.74.208
• Last address of unused range: 14.24.74.255
• Prefix length: To be determined, but the range can be used for future subnets or other
purposes.
Summary of Subblocks:
• Subnet A:
o 120 required, 128 allocated
o First address: 14.24.74.0/25
o Last address: 14.24.74.127/25
• Subnet B:
o 60 required, 64 allocated
o First address: 14.24.74.128/26
o Last address: 14.24.74.191/26
• Subnet C:
o 10 required, 16 allocated
o First address: 14.24.74.192/28
o Last address: 14.24.74.207/28
• Unused Block:
o First address: 14.24.74.208
o Last address: 14.24.74.255
o 48 addresses left for future use.
This method ensures efficient utilization of IP addresses while allowing for potential future
expansions.
IPv4 includes several special-purpose addresses used for specific functions in networking. Here
are five important types:
• Address: 0.0.0.0/32
• Purpose: Used when a host doesn't know its own IP address and needs to communicate.
• Use Case: A host might use this address as a source address before it knows its IP (e.g.,
during DHCP requests).
• Address: 255.255.255.255/32
• Purpose: Sends a datagram to all devices on the local network.
• Restrictions: Routers block these packets from being forwarded to other networks (they
stay within the local network).
• Use Case: A host can broadcast to all devices within the same local network segment.
Dept. of CSE-DS, RNSIT Dr. Mahantesh K 21
Computer Networks (BCS502)
4. Private Addresses
• Blocks:
o 10.0.0.0/8
o 172.16.0.0/12
o 192.168.0.0/16
o 169.254.0.0/16 (link-local addresses)
• Purpose: Used for internal/private networks. These addresses are not routable on the
public Internet.
• Use Case: Networks within homes, businesses, or organizations. They require Network
Address Translation (NAT) for accessing the Internet.
These addresses serve distinct roles in networking, ensuring proper communication, testing, and
private address use within internal networks.
1. What is DHCP?
o Definition: DHCP (Dynamic Host Configuration Protocol) automates the process
of assigning IP addresses and other essential network configurations to devices
within a network.
o Purpose: Reduces the need for manual IP address setup by network
administrators.
2. IP Address Allocation Sources
o Large Organizations and ISPs: Receive IP address blocks directly from
ICANN (Internet Corporation for Assigned Names and Numbers).
o Small Organizations: Obtain IP address blocks from their ISP.
3. Manual vs. Automatic Assignment
o Manual Assignment: Admins manually assign each device an IP address, which
can be time-consuming.
o Automatic Assignment with DHCP: DHCP automatically assigns IPs,
improving efficiency and reducing errors.
4. How DHCP Works
o Layer and Model: Operates at the application layer and follows a client-server
model.
o Process: Devices (clients) request IP configuration from a DHCP server, which
assigns an IP and other necessary details.
5. Plug-and-Play Protocol
o DHCP is often called "plug-and-play" because it allows devices to connect to the
network and obtain configuration settings automatically, without user
intervention.
6. Permanent vs. Temporary IP Addressing
o Permanent IP Assignment: For devices like servers and routers needing a stable
IP.
o Temporary IP Assignment: For devices requiring short-term connectivity (e.g.,
laptops in hotels).
o Example of Efficiency: ISPs with limited IPs can use DHCP to support more
devices by reallocating addresses dynamically, such as serving 4,000 households
with 1,000 IPs if only 25% are online simultaneously.
7. Essential Information Provided by DHCP
o IP Address: Unique identifier for the device.
DHCP is crucial for modern networks, making IP management simple and efficient. It provides
both permanent and temporary IP assignments along with other essential network information,
ensuring that devices can connect to the network with minimal setup.
The 64-byte option field has a dual purpose. It can carry either additional information or some
specific vendor information.
The server uses a number, called a magic cookie, in the format of an IP address with the
value of 99.130.83.99. When the client finishes reading the message, it looks for this magic
cookie. If present, the next 60 bytes are options. An option is composed of three fields: a 1-byte
tag field, a 1-byte length field, and a variable-length value field. There are several tag fields that
are mostly used by vendors. If the tag field is 53, the value field defines one of the 8 message
types shown in Figure 18.26. We show how these message types are used by DHCP.
1. DHCPDISCOVER:
o The new host (client) sends a DHCPDISCOVER message to locate a DHCP
server. This message includes only a transaction ID, a unique random identifier
to track the session, as the host has no IP address or server information.
o The message is encapsulated in a UDP datagram with source port 68 and
destination port 67 (well-known DHCP ports).
o The IP layer uses source IP address 0.0.0.0 (since the host has no IP address)
and destination IP address 255.255.255.255 (broadcast address) to ensure it
reaches any DHCP server on the network.
2. DHCPOFFER:
o One or more DHCP servers respond with a DHCPOFFER message. This
message includes:
▪ Your IP Address: the offered IP address for the client.
▪ Server IP Address: identifies the server making the offer.
▪ Lease Time: duration for which the IP address is valid.
o The DHCPOFFER message is encapsulated in a UDP datagram with source port
67 and destination port 68 (reverse of the DISCOVER message).
o The IP layer sets the server’s IP address as the source and broadcasts the
destination address so other DHCP servers can see the offer and, if necessary,
make better offers.
3. DHCPREQUEST:
o The client selects the best offer and responds with a DHCPREQUEST message
to the chosen server.
o This message includes the chosen IP address and other relevant details and is sent
with source port 68 and destination port 67.
o The IP source address is the client’s new IP address, while the destination
remains the broadcast address, informing other servers that their offers were not
accepted.
4. DHCPACK or DHCPNACK:
The DHCP protocol relies on two well-known ports (68 and 67) and includes features for file
retrieval, error control, and address allocation management. Here's a breakdown of these aspects:
Figure 18.28 shows the transition diagram with the main states.
The DHCP client progresses through several states as it acquires and manages its IP address
lease. Key stages and timers include:
oIn this state, the client attempts to renew its lease directly with the server.
o If the server renews the lease, the client moves back to the BOUND state.
6. REBINDING State:
o If the lease isn’t renewed and 75% of the lease time expires, the rebinding timer
triggers, moving the client to the REBINDING state.
o The client tries to renew the lease by broadcasting a request to any available
DHCP server.
o If successful, the client moves back to the BOUND state.
7. INIT State (Again):
o If the lease expires (without renewal) or no server responds, the client’s
expiration timer (set to 100% of the lease time) triggers, returning it to the INIT
state to request a new IP address.
DHCP Timers
o When a device on the local network requests internet access, the NAT router
translates the private IP address into the router’s public IP address, creating a
mapping table to keep track of active connections.
o Translation Table: NAT maintains a table mapping each internal device’s
private IP and port to an external IP and port, allowing multiple internal devices
to share the same public IP address while still keeping connections unique.
4. Virtual Private Network (VPN) Compatibility:
o NAT supports VPNs by allowing secure and private communication within the
local network, even when some devices communicate with the global internet.
5. Types of NAT:
o Static NAT: Maps a single private IP to a single public IP.
o Dynamic NAT: Maps a private IP to any available public IP from a pool.
o Port Address Translation (PAT): Also known as "overloading," it allows
multiple devices to share one public IP by assigning different port numbers to
each connection.
6. Advantages of NAT:
o Conserves IP Addresses: NAT reduces the number of public IP addresses
needed, which is useful with the limited IPv4 address pool.
o Security: NAT hides internal IP addresses from external networks, adding a layer
of security.
• Functionality of NAT:
o NAT (Network Address Translation) is a method used to modify IP address
information in packet headers while in transit across a routing device.
o It primarily allows multiple devices on a local network to share a single public IP
address for Internet communication.
Outgoing Packets
• Process:
o When a device within a private network sends a packet to the Internet, the packet
is routed through the NAT router.
o The NAT router modifies the packet:
▪ It replaces the source address (the private IP address of the sending
device) with its own global NAT address (the public IP address assigned
by the ISP).
o This allows the packet to be routed properly through the Internet.
Incoming Packets
• Process:
o Incoming packets from the Internet are also processed by the NAT router.
o The NAT router changes the packet:
▪ It replaces the destination address (the NAT router's global address) with
the appropriate private IP address of the intended recipient within the local
network.
Translation Table
• Purpose:
o The translation table is essential for keeping track of the mappings between
private and public addresses.
o It solves the challenge of identifying which internal device should receive packets
that are addressed to the public IP.
• Structure:
o In its simplest form, the translation table contains two columns:
▪ Private Address: The internal IP address of a device in the local network.
▪ External Address: The corresponding public IP address that the device
used when communicating with the Internet.
• Operation:
o When a packet is sent out:
▪ The NAT router records the destination address of the outgoing packet
in the translation table along with the modified source address.
o When a response packet arrives:
▪ The NAT router checks the source address of the incoming packet (the
public address).
▪ It looks up this address in the translation table to find the corresponding
private address.
▪ The router then modifies the packet's destination address to route it to the
correct internal device.
• Functionality:
o To overcome the limitation of a single global address, a NAT router can utilize a
pool of global addresses.
o For example, instead of just one address (e.g., 200.24.5.8), a NAT router can
manage multiple addresses (e.g., 200.24.5.8, 200.24.5.9, 200.24.5.10, and
200.24.5.11).
• Benefits:
o With a pool of global addresses, multiple private-network hosts can communicate
with the same external host simultaneously.
o Each private address can pair with a unique global address, effectively allowing
up to four private hosts to connect to the same external server at the same time.
• Connection Restrictions:
o Even with a pool of addresses, the NAT router imposes some limitations:
▪ No more than the number of global addresses in the pool can be used to
connect to the same destination simultaneously (in this case, a maximum
of four connections).
▪ A private-network host cannot access multiple external server programs
(e.g., HTTP and TELNET) simultaneously due to the shared global
address.
▪ Two private-network hosts cannot access the same external server
program (e.g., both trying to access an HTTP server) at the same time if
they require the same global address.
• Many-to-Many Relationships:
o To facilitate a many-to-many relationship between private-network hosts and
external server programs, more detailed information must be included in the NAT
translation table.
o The translation table can expand from two columns to five, incorporating:
▪ Private Address: The internal IP address of the private-network host.
▪ Global Address: The external IP address assigned by the NAT router.
▪ Source Port: The port number used by the private-network host for the
outgoing connection.
▪ Destination Port: The port number used by the external server for the
service being accessed.
▪ Transport Layer Protocol: Identifies the protocol used (e.g., TCP, UDP)
for the connection.
• Example Scenario:
o If two hosts (172.18.3.1 and 172.18.3.2) need to access the same HTTP server
(25.8.3.2):
▪ The translation table can differentiate the two requests based on their
source ports.
▪ This eliminates ambiguity and allows both hosts to maintain separate
connections to the external server without conflict.
Transitioning from IPv4 to IPv6 involves changing the packet format to accommodate a larger
address space. The designers aimed to address IPv4's limitations while implementing new
features.
o
Special Handling: These new fields enable the source to request prioritized
handling for certain types of traffic, which is crucial for real-time applications
like audio and video streaming.
5. Enhanced Security
o Encryption & Authentication: Built-in options for encryption and
authentication improve the confidentiality and integrity of data packets.
o Secure Communications: These security features provide a more robust
framework for safe data transmission.
Packet Format
The IPv6 packet is shown in Figure 22.6. Each packet is composed of a base header followed
by the payload. The base header occupies 40 bytes, whereas payload can be up to 65,535
bytes of information. The description of fields follows.
1. Version
• Definition: A 4-bit field that specifies the version number of the IP protocol.
• Value for IPv6: The version is set to 6.
2. Traffic Class
3. Flow Label
4. Payload Length
5. Next Header
6. Hop Limit
• Source Address: A 16-byte (128-bit) address identifying the original source of the
datagram.
• Destination Address: A 16-byte (128-bit) address identifying the intended recipient of
the datagram.
8. Payload
• Comparison to IPv4: The payload field in IPv6 has a different format and meaning
compared to IPv4, accommodating new types of data and extension headers.
Payload Structure
• Definition: In IPv6, the payload consists of zero or more extension headers followed by
the data from higher-layer protocols (e.g., UDP, TCP).
• Extension Headers: Unlike IPv4, where options are part of the main header, IPv6
treats options as separate extension headers.
Extension Headers
• Flexibility: The payload can contain multiple extension headers, allowing for
customization based on specific requirements.
• Mandatory Fields:
1. Next Header: Indicates the type of the next header (which can be another
extension header or the data payload).
2. Length: Specifies the length of the extension header in bytes.
• Field Values: Each next header field value (code) defines the type of the next header:
o Types: This includes options like hop-by-hop options, source routing options, etc.
o Final Header: The last next header field in the chain specifies the protocol type
of the payload data (e.g., UDP, TCP).
The Internet Protocol (IP) was originally designed as a connectionless protocol, meaning each
packet operates independently, with no connection between sender and receiver. Over time, there
has been a trend toward using IP as a connection-oriented protocol to improve efficiency and
guarantee certain types of service. In IPv4, the MPLS (Multiprotocol Label Switching)
technology is used to simulate connection-oriented behavior by encapsulating packets with
labels. However, IPv6 integrates a flow label directly into its datagram format, allowing IPv6 to
achieve a similar effect natively.
In IPv6, the flow label is a unique identifier for a sequence of packets, known as a flow, that
share common characteristics. For example, packets within the same flow typically travel the
same path, use the same resources, and may have similar security or processing requirements.
The flow label allows routers to efficiently manage packets with different requirements. Routers
that handle flow labels have a flow label table where each active flow label has a corresponding
entry.
In IPv6, fragmentation and reassembly processes are handled differently than in IPv4, with a few
key distinctions aimed at optimizing network performance.
1. Source-Only Fragmentation:
o IPv6 fragmentation is handled solely by the source, not by intermediate
routers. This change reduces the processing load on routers, enhancing their
efficiency and speed.
o When a source needs to send a large packet, it is responsible for determining
whether fragmentation is necessary. If the packet exceeds the Maximum
Transmission Unit (MTU) of the path, the source fragments it before sending.
2. Router Processing:
o Routers do not fragment packets in IPv6. Fragmenting packets at a router
requires considerable processing, such as recalculating the values of
fragmentation-related fields. By removing this requirement, IPv6 reduces router
processing demands and allows packets to be processed more swiftly.
Extension Header
An IPv6 packet is made of a base header and some extension headers. The length of the
base header is fixed at 40 bytes. To give more functionality to the IP datagram, the base header
can be followed by up to six extension headers.
Many of these headers are options in IPv4. Six types of extension headers have been
defined. These are hop-by-hop option, source routing, fragmentation, authentication, encrypted
security payload, and destination option (see Figure 22.8).
Hop-by-Hop Option
The hop-by-hop option is designed for scenarios where information needs to be processed by
every router along the datagram’s path. This is typically used for control functions, debugging,
and packet management. Some defined hop-by-hop options include:
• Pad1: A 1-byte option added for alignment purposes to ensure certain options start at
specific bits within a 32-bit word.
• PadN: Similar to Pad1 but used when more than 1 byte of padding is needed for
alignment.
• Jumbo Payload: Extends payload capacity beyond the typical IPv6 limit of 65,535 bytes,
enabling larger datagrams if necessary.
Dept. of CSE-DS, RNSIT Dr. Mahantesh K 38
Computer Networks (BCS502)
Destination Option
The destination option is used when information should be read only by the destination node.
Routers along the way do not access this information, keeping it private for the destination. This
option has the same format as the hop-by-hop option and currently includes:
• Pad1 and PadN: Similar to the hop-by-hop options, these padding bytes are used for
alignment in the destination option header.
Source Routing
The source routing extension header allows the sender to specify specific intermediate nodes
or addresses that the packet must visit before reaching its destination. This combines the
functionalities of IPv4's strict and loose source routing options, enabling flexible routing paths
for specific applications.
Fragmentation
IPv6 fragmentation functions similarly to IPv4 but with key differences in where fragmentation
occurs:
• Only the original source is allowed to fragment IPv6 packets, which reduces the load on
routers.
• The source uses Path MTU Discovery to determine the smallest MTU on the packet’s
path and fragments the packet accordingly.
• If Path MTU Discovery is not available or used, the source fragments the packet to a size
of 1280 bytes or smaller, as this is the minimum MTU for networks connected to the
Internet.
Authentication
The authentication extension header ensures that a packet originates from a genuine sender
and maintains data integrity. This prevents impersonation and verifies that data has not been
altered en route, securing the communication between sender and receiver.
The ESP extension header provides confidentiality for data in transit by encrypting the payload,
protecting it from eavesdropping. This extension helps ensure secure transmission over
potentially untrusted networks. Each of these headers allows IPv6 to be flexible, secure, and
suitable for a wide variety of applications while keeping the base header lightweight.
IPv6 introduces a new approach to handling packet options by using extension headers instead
of embedding options within the main header as in IPv4. Here’s a comparison of specific options
between IPv4 and IPv6:
1. Padding Options:
o IPv4: Utilizes no-operation and end-of-option fields for alignment.
o IPv6: Replaces these with Pad1 (1 byte) and PadN (for 2+ bytes) to manage
alignment within extension headers.
2. Record Route Option:
o IPv4: Includes a record route option, but it was seldom used.
o IPv6: This option is removed due to limited use.
3. Timestamp Option:
o IPv4: Includes a timestamp option for tracking packet times along the route, but
it was also rarely used.
o IPv6: This option is not implemented.
4. Source Route Option:
o IPv4: Has a source route option, allowing the sender to specify the route.
o IPv6: Implements this as the source route extension header, allowing more
flexible source-routing control.
5. Fragmentation:
o IPv4: Handles fragmentation within the base header, allowing both the source
and routers to fragment packets.
o IPv6: Moves fragmentation control to the fragmentation extension header,
where only the original source handles fragmentation.
6. Authentication:
o IPv4: Lacks built-in support for authentication.
o IPv6: Adds a new authentication extension header to validate the sender’s
identity and ensure data integrity.
7. Encrypted Security Payload (ESP):
o IPv4: Has no built-in option for encryption.
o IPv6: Introduces the ESP extension header for encrypting data, enhancing
confidentiality and protecting against eavesdropping.
IPv6's extension headers streamline packet processing, enhance security, and add flexibility,
while removing outdated or rarely-used options from IPv4. This modular approach makes IPv6
better suited to handle diverse network demands.
1. Introduction:
• Unicast routing in the Internet, with a large number of routers and a huge number of
hosts, can be done only by using hierarchical routing: routing in several steps using
different routing algorithms.
• The source host needs no forwarding table because it delivers its packet to the default
router in its local network. The destination host needs no forwarding table either because
it receives the packet from its default router in its local network.
• Routers that glue together the networks in the internet need forwarding tables.
• There are several routes that a packet can travel from the source to the destination; what
must be determined is which route the packet should take.
1.1 An Internet as a Graph:
• An internet can be modeled as a graph. A graph in computer science is a set of nodes and
edges (lines) that connect the nodes.
• Each router as a node and each network between a pair of routers as an edge.
• Internet is, modeled as a weighted graph, in which each edge is associated with a cost.
1.2 Least-Cost Routing
Internet is modelled as a weighted graph; the source router chooses a route to the destination
router in such a way that the total cost for the route is the least cost among all possible routes.
Least-Cost Trees
• If there are N routers in an internet, there are (N − 1) least-cost paths from each router to
• any other router. This means we need N × (N − 1) least-cost paths for the whole internet.
• A least-cost tree is a tree with the source router as the root that spans the whole graph
(visits all other nodes) and in which the path between the root and any other node is the
shortest.
• One shortest-path tree for each node; we have N least-cost trees for the whole internet.
2. Routing Algorithms
Depending on way they interpret the least cost and the way they create the least-cost tree:
• Distance-Vector Routing
• Link-State Routing
• Path-Vector Routing
2.1Distance-Vector Routing
• Each node creates is its own least-cost tree with the rudimentary information it has about
its immediate neighbours.
• The incomplete trees are exchanged between immediate neighbors to make the trees more
and more complete and to represent the whole internet.
• Use Bellman-Ford Equation.
Bellman-Ford Equation.
This equation is used to find the least cost (shortest distance) between a source node, x, and
a destination node, y, through some intermediary nodes (a, b, c, . . .) when the costs between
the source and the intermediary nodes and the least costs between the intermediary nodes
and the destination are given.
• The general case in which Dij is the shortest distance and cij is the cost between nodes i
and j.
• In distance-vector routing, normally we want to update an existing least cost with a least
cost through an intermediary node, such as z.
The Bellman-Ford equation enables us to build a new least-cost path from previously established
least-cost paths.
Distance Vectors
• A least-cost tree is a combination of least-cost paths from the root of the tree to all
destinations.
• These paths are graphically glued together to form the tree.
• Distance-vector routing unglues these paths and creates a distance vector, a one-
dimensional array to represent the tree.
Step 1:
• Each node in an internet, when it is booted, creates a very rudimentary distance vector
with the minimum information the node can obtain from its neighborhood.
• Discovers the identity of the immediate neighbors and the distance between itself and
each neighbor.
• A simple distance vector is created by inserting the discovered distances in the
corresponding cells and leaves the value of other cells as infinity.
• These rudimentary vectors cannot help the internet to effectively forward a packet. For
example, node A thinks that it is not connected to node G because the corresponding cell
shows the least cost of infinity.
• After each node has created its vector, it sends a copy of the vector to all its immediate
neighbors. After a node receives a distance vector from a neighbor, it updates its distance
vector using the Bellman-Ford equation.
In the first event, node A has sent its vector to node B. Node B updates its vector using the cost
cBA = 2. In the second event, node E has sent its vector to node B. Node B updates its vector
using the cost cEA = 4.
After the first event, node B has one improvement in its vector: its least cost to node D has
changed from infinity to 5 (via node A). After the second event, node B has one more
improvement in its vector; its least cost to node F has changed from infinity to 6 (via node E).
Count to infinity:
If a link is broken (cost becomes infinity), every other router should be aware of it immediately,
but in distance-vector routing, this takes some time. The problem is referred to as count to
infinity.
Two-Node Loop;
• At the beginning, both nodes A and B know how to reach node X. But suddenly, the link
between A and X fails. Node A changes its table. If A can send its table to B immediately,
everything is fine.
• However, the system becomes unstable if B sends its forwarding table to A before
receiving A’s forwarding table.
• Node A receives the update and, assuming that B has found a way to reach X,
immediately updates its forwarding table. Now A sends its new update to B. Now B
thinks that something has been changed around A and updates its forwarding table. The
cost of reaching X increases gradually until it reaches infinity.
• Packets bounce between A and B, creating a two-node loop problem.
Split Horizon:
Instead of flooding the table through each interface, each node sends only part of its table through
each interface.
Flooding: The process of creating LSDB that contains information of whole internet. Each node
can send some greeting messages to all its immediate neighbors (those nodes to which it is
connected directly) to collect two pieces of information for each neighboring node: the identity
of the node and the cost of the link.
The combination of these two pieces of information is called the Link State - LS packet (LSP);
the LSP is sent out of each interface, as shown in Figure:
Example:
Watch: https://www.youtube.com/watch?v=XB4MIexjvY0
2.3Path-Vector Routing
Both link-state and distance-vector routing are based on the least-cost goal, does not allow a
sender to apply specific policies to the route a packet may take.
Path-vector routing: Route is determined by the source using the policy it imposes on the route.
In other words, the source can control the path. Although path-vector routing is not actually used
in an internet, and is mostly designed to route a packet between ISPs
Spanning Trees:
• The path from a source to all destinations is also determined by the best spanning tree.
The best spanning tree, however, is not the least-cost tree.
• The tree determined by the source when it imposes its own policy. If there is more than
one route to a destination, the source can choose the route that meets its policy best.
• A source may apply several policies at the same time. One of the common policies uses
the minimum number of nodes to be visited (something similar to least-cost). Another
common policy is to avoid some nodes as the middle node in a route.
From the above example figure, the policy imposed by all sources is to use the minimum number
of nodes to reach a destination. The spanning tree selected by A and E is such that the
communication does not pass through D as a middle node.
Creation of Spanning Trees:
The spanning trees are made, gradually and asynchronously, by each node. When a node is
booted, it creates a path vector based on the information it can obtain about its immediate
neighbor. A node sends greeting messages to its immediate neighbors to collect these pieces of
information.
Each node, after the creation of the initial path vector, sends it to all its immediate neighbours.
Each node, when it receives a path vector from a neighbour, updates its path vector using an
equation similar to the Bellman-Ford, but applying its own policy instead of looking for the
least cost. We can define this equation as:
Path(x, y) = best {Path(x, y), [(x + Path(v, y)]} for all v’s in the internet.
The policy is defined by selecting the best of multiple paths. Path-vector routing also imposes
one more condition on this equation: If Path (v, y) includes x, that path is discarded to avoid a
loop in the path.
In the first event, node C receives a copy of B’s vector, which improves its vector: now it knows how to
reach node A.
In the second event, node C receives a copy of D’s vector, which does not change its vector. As a matter
of fact the vector for node C after the first event is stabilized and serves as its forwarding table.
• The Internet has changed from a tree-like structure, with a single backbone, to a multi-backbone
structure run by different private corporations today.
• There are several backbones run by private communication companies that provide global
connectivity. These backbones are connected by some peering points that allow connectivity
between backbones.
• At a lower level, there are some provider networks that use the backbones for global connectivity
but provide services to Internet customers.
• Finally, there are some customer networks that use the services provided by the provider
networks.
Hierarchical Routing:
Hierarchical routing means considering each ISP as an autonomous system (AS). Each AS can run
a routing protocol that meets its needs, but the global Internet runs a global protocol to glue all ASs
together.
• The routing protocol run in each AS is referred to as intra-AS routing protocol, intradomain
routing protocol, or interior gateway protocol (IGP);
• The global routing protocol is referred to as inter-AS routing protocol, interdomain routing
protocol, or exterior gateway protocol (EGP).
Presently,
• The two common intradomain routing protocols are RIP and OSPF;
• The only interdomain routing protocol is BGP.
Autonomous Systems:
As we said before, each ISP is an autonomous system when it comes to managing networks and
routers under its control. Although we may have small, medium-size, and large ASs, each AS is given
an autonomous number (ASN) by the ICANN.
Stub AS: A stub AS has only one connection to another AS. The data traffic can be either initiated or
terminated in a stub AS; the data cannot pass through it. A good example of a stub AS is the customer
network, which is either the source or the sink of data.
Multihomed AS. A multihomed AS can have more than one connection to other ASs, but it does not
allow data traffic to pass through it. A good example of such an AS is some of the customer ASs that may
use the services of more than one provider network, but their policy does not allow data to be passed
through them.
Transient AS. A transient AS is connected to more than one other AS and also allows the traffic to pass
through. The provider networks and the backbone are good examples of transient ASs.
Figure shows the concept of hop count advertised by three routers from a source host to a
destination host.
Forwarding Tables
A forwarding table in RIP is a three-column table in which the first column is the address of the
destination network, the second column is the address of the next router to which the packet
should be forwarded, and the third column is the cost (the number of hops) to reach the
destination network.
RIP Implementation
• Instead of sending only distance vectors, a router needs to send the whole contents of its
forwarding table in a response message.
• The receiver adds one hop to each cost and changes the next router field to the address
of the sending router. We call each route in the modified forwarding table the received
route and each route in the old forwarding table the old route. The received router selects
the old routes as the new ones except in the following three cases:
1. If the received route does not exist in the old forwarding table, it should be added to the
route.
2. If the cost of the received route is lower than the cost of the old one, the received route
should be selected as the new one.
3. If the cost of the received route is higher than the cost of the old one, but the value of the
next router is the same in both routes, the received route should be selected as the new
one.
Each OSPF router can create a forwarding table after finding the shortest-path tree between itself
and the destination using Dijkstra’s algorithm.
Areas:
• Compared with RIP, which is normally used in small ASs, OSPF was designed to be able
to handle routing in a small or large autonomous system.
• The formation of shortest-path trees in OSPF requires that all routers flood the whole AS
with their LSPs to create the global LSDB leads to a huge volume of traffic in a large AS.
• The AS needs to be divided into small sections called areas. Each area acts as a small
independent domain for flooding LSPs.
• However, each router in an area needs to know the information about the link states not
only in its area but also in other areas. For this reason, one of the areas in the AS is
designated as the backbone area, responsible for gluing the areas together.
Link-State Advertisement:
OSPF is based on the link-state routing algorithm, which requires that a router advertise the
state of each link to all neighbors for the formation of the LSDB.
5 types of l ink-state advertisements: router link, network link, summary link to network,
summary link to AS border router, and external link.
Router link. A router link advertises the existence of a router as a node. In addition to giving
the address of the announcing router, this type of advertisement can define one or more types
of links that connect the advertising router to other entities.
Network link. A network link advertises the network as a node. However, since a network
cannot do announcements itself (it is a passive entity), one of the routers is assigned as the
designated router and does the advertising.
Summary link to network. This is done by an area border router; it advertises the summary
of links collected by the backbone to an area or the summary of links collected by the area to
the backbone.
Summary link to AS. This is done by an AS router that advertises the summary links from
other ASs to the backbone area of the current AS, information which later can be
disseminated to the areas so that they will know about the networks in other ASs.
External link. This is also done by an AS router to announce the existence of a single network
outside the AS to the backbone area to be disseminated into the areas.
OSPF Implementation:
OSPF is implemented as a program in the network layer, using the service of the IP for
propagation. An IP datagram that carries a message from OSPF sets the value of the protocol
field to 89. This means that, although OSPF is a routing protocol to help IP to route its
datagrams inside an AS, the OSPF messages are encapsulated inside datagrams.
Performance:
• Use Areas: Divide large networks into multiple OSPF areas to reduce the size of LSDB
and SPF calculations.
• Tune Timers: Adjust Hello and Dead intervals to improve convergence time, but balance
with CPU/memory usage.
• Summarize Routes: Implement route summarization at ABRs and ASBRs to limit the
number of routes and LSAs exchanged.
• Reduce LSA Flooding: Use LSA throttling and limit the scope of LSAs to reduce
network overhead.
• Enhance Router Resources: Ensure routers have sufficient CPU and memory to handle
SPF calculations and large LSDBs.
• Implement OSPF Authentication: Secure the OSPF network by using authentication,
reducing the risk of rogue LSAs.
• An internet with four autonomous systems. AS2, AS3, and AS4 are stub autonomous
systems; AS1 is a transient one. In our example, data exchange between AS2, AS3,
and AS4 should pass through AS1.
• Each autonomous system in this figure uses one of the two common intradomain
protocols, RIP or OSPF.
• To enable each router to route a packet to any network in the internet, we first install
a variation of BGP4, called external BGP (eBGP), on each border router (the one at
the edge of each AS which is connected to a router at another AS).
• We then install the second variation of BGP, called internal BGP (iBGP), on all
routers.
• This means that the border routers will be running three routing protocols
(intradomain, eBGP, and iBGP), but other routers are running two protocols
(intradomain and iBGP).
4. Multicasting Routing-MOSPF
• Multicast Open Shortest Path First (MOSPF) is the extension of the Open Shortest Path
First (OSPF) protocol.
• It also uses the source-based tree approach to multicasting.
• MOSPF routers maintains current image of network topology through OSPF.
• Routers are required to implement a local group database which maintain a list of directly
attached group.
A router goes through the following steps to forward a multicast packet received from source
S and to be sent to destination G (a group of recipients):
1. The router uses the Dijkstra algorithm to create a shortest-path tree with S as the root
and all destinations in the internet as the leaves. Each source we need to create a
different tree.
2. The router finds itself in the shortest-path tree created in the first step. In other words,
the router creates a shortest-path subtree with itself as the root of the subtree.
3. The shortest-path subtree is actually a broadcast subtree with the router as the root
and all networks as the leaves. The IGMP protocol is used to find the information at
the leaf level. MOSPF has added a new type of link state update packet that floods
the membership to all routers.
4. The router can now forward the received packet out of only those interfaces that
correspond to the branches of the multicast tree.