Network Layer

Network Layer

Network Layer, Routing Algorithms, IP Addresses

Network Layer

The network layer is the third layer in the OSI (Open Systems Interconnection) model. It is responsible for providing end-to-end logical addressing, routing, and forwarding of data packets across different networks. The primary function of the network layer is to enable communication between devices on different networks by forwarding data packets from a source device to a destination device.

The network layer is responsible for addressing and routing packets, ensuring that they are delivered to the correct destination device. This is achieved through the use of logical addresses, such as IP (Internet Protocol) addresses. The network layer adds this logical address to the data packet's header, which is then used by routers to determine the best path for the packet to take through the network.

Additionally, the network layer is responsible for the fragmentation and reassembly of packets, which is necessary when data packets are too large to be transmitted over a network in a single transmission. The network layer breaks up the packets into smaller, more manageable units, which can then be reassembled at the destination device.

Network Layer in Computer Networks - Studytonight

Services Provided

  1. Logical Addressing: One of the primary services provided by the Network Layer is logical addressing. This involves assigning a unique IP address to each device on the network. The IP address is used to identify the source and destination of data packets.

  2. Routing: The Network Layer provides routing services that allow packets to be transferred between different networks. The routing function involves selecting the best path for a packet to reach its destination based on the IP address and network topology.

  3. Packet Fragmentation: The Network Layer can fragment large packets into smaller ones for transmission over the network. This is important because different networks may have different maximum packet sizes. The fragmentation process ensures that packets can be sent and received without loss or delay.

  4. Error Detection and Correction: The Network Layer provides error detection and correction services that ensure the integrity of data packets. This is accomplished through the use of error detection codes and other techniques that identify and correct errors in packets.

  5. Congestion Control: The Network Layer provides congestion control services that help to prevent network congestion. This involves managing the flow of packets on the network to ensure that it does not become overloaded.

  6. Quality of Service (QoS): The Network Layer provides QoS services that prioritize certain types of traffic over others. This is important to ensure that time-sensitive traffic, such as voice and video, is delivered in a timely manner.

  7. Security: The Network Layer provides security services that protect against unauthorized access and data theft. This includes features such as encryption, authentication, and access control.

Design issues

Several design issues need to be considered when designing a network layer. These include:

  • Store-and-forward packet switching: Store-and-forward packet switching is a method of routing packets in which each packet is stored at a router before it is forwarded to the next router. This method is used to ensure that packets are not lost in the event of a network failure.

    When a packet arrives at a router, the router first checks the destination address of the packet. If the destination address is within the router's own network, the router will forward the packet directly to the destination. If the destination address is not within the router's own network, the router will store the packet in its buffer until a link to the destination network becomes available. Once a link to the destination network becomes available, the router will forward the packet to the next router on the path to the destination.

    Store-and-forward packet switching is a reliable method of routing packets, but it can add latency to the network. This is because the router must store each packet in its buffer before forwarding it to the next router. The amount of latency added by store-and-forward packet switching depends on the size of the packets and the speed of the routers.

    Store-and-forward packet switching is the most common method of routing packets in the Internet. It is also used in many other networks, such as corporate networks and local area networks (LANs).

    Here are some of the advantages of store-and-forward packet switching:

    • It is a reliable method of routing packets.

    • It can be used to route packets over a variety of networks, including the Internet.

    • It is a relatively simple method of routing packets.

Here are some of the disadvantages of store-and-forward packet switching:

  • It can add latency to the network.

  • It can require more resources than other methods of routing packets.

  • It can be more difficult to troubleshoot than other methods of routing packets.

A3 H5 The Network Layer

  • Services provided to the transport layer: The network layer provides several services to the transport layer, including:

    • Routing: The network layer is responsible for routing packets from the source to the destination. This includes finding the best path for each packet to take to its destination.

    • Error handling: The network layer needs to be able to handle errors that occur in the network. This may include errors in the data itself, as well as errors in the routing information.

    • Congestion control: The network layer needs to be able to handle congestion on the network. This may include dropping packets, reordering packets, or delaying packets.

  • Implementation of connectionless service: A connectionless service is a service in which each packet is sent independently of the other packets. This type of service is typically used for applications that do not require guaranteed delivery, such as email and web browsing.

    The network layer implements a connectionless service by simply forwarding each packet to the next hop on its way to the destination. The network layer does not keep track of the packets or ensure that they are delivered in the correct order.

    The following are some of the advantages of a connectionless service:

    • It is a simple and efficient way to send data.

    • It is less overhead than a connection-oriented service.

    • It is more scalable than a connection-oriented service.

The following are some of the disadvantages of a connectionless service:

  • It is not guaranteed that all packets will be delivered.

  • The packets may not be delivered in the correct order.

  • It is not suitable for applications that require guaranteed delivery, such as voice and video conferencing.

Difference between Connection-oriented and Connection-less Services -  GeeksforGeeks

  • Implementation of connection-oriented service: A connection-oriented service is a service in which a connection is established between the source and destination before any data is sent. This type of service is typically used for applications that require guaranteed delivery, such as voice and video conferencing.

    The network layer implements a connection-oriented service by first establishing a connection between the source and destination. This involves exchanging control information, such as the source and destination addresses, the type of service, and the maximum amount of data that can be sent in each packet. Once the connection is established, data can be sent between the source and destination. The network layer keeps track of the packets and ensures that they are delivered in the correct order.

    The following are some of the advantages of a connection-oriented service:

    • It is guaranteed that all packets will be delivered.

    • The packets will be delivered in the correct order.

    • It is suitable for applications that require guaranteed delivery, such as voice and video conferencing.

The following are some of the disadvantages of a connection-oriented service:

  • It is more complex and less efficient than a connectionless service.

  • It requires more overhead than a connectionless service.

  • It is not as scalable as a connectionless service.

Difference between Connection-oriented and Connection-less Services -  GeeksforGeeks

Routing algorithms

Routing algorithms are used by routers to determine the best path for packets to take to their destination. There are many different routing algorithms, each with its own advantages and disadvantages.

Here are some of the factors that need to be considered when choosing a routing algorithm:

  • The size of the network: Distance-vector routing algorithms are typically used in small networks, while link-state routing algorithms are typically used in large networks.

  • The topology of the network: The topology of the network refers to the way that the routers are connected. Some routing algorithms are better suited for certain topologies than others.

  • The cost of the links: The cost of a link is the amount of money that it costs to send a packet over the link. Some routing algorithms take the cost of the links into account when determining the best path.

  • The capacity of the links: The capacity of a link is the maximum amount of data that can be sent over the link in a given amount of time. Some routing algorithms take the capacity of the links into account when determining the best path.

Least Cost Routing algorithm

The least-cost routing algorithm is a routing algorithm that chooses the path with the lowest cost to the destination. The cost of a path can be determined by several factors, such as the number of hops, the link speed, or the link cost.

The least-cost routing algorithm works by maintaining a routing table for each router in the network. The routing table contains the destination, the next hop, and the cost of the path to the destination. When a router receives a packet, it looks up the destination in its routing table and forwards the packet to the next hop.

The least-cost routing algorithm is a simple and efficient routing algorithm. It is easy to implement and it can be used in a variety of networks. However, the least-cost routing algorithm is not always the best routing algorithm. For example, the least-cost routing algorithm may not be the best choice for networks with a lot of traffic. In these networks, a routing algorithm that takes into account the congestion of the links may be a better choice.

Here are some of the advantages of the least-cost routing algorithm:

  • It is simple and easy to implement.

  • It can be used in a variety of networks.

  • It is efficient in terms of the number of routing table updates that are required.

Here are some of the disadvantages of the least-cost routing algorithm:

  • It may not be the best choice for networks with a lot of traffic.

  • It may not be the best choice for networks with dynamic topologies.

  • It may not be the best choice for networks with security requirements.

Dijkstra's algorithm

Dijkstra's algorithm is an algorithm for finding the shortest path between two nodes in a graph. The algorithm works by repeatedly adding the node with the lowest distance to the shortest path.

The algorithm works as follows:

  1. Initialize a set S to contain the source node.

  2. Initialize a set U to contain all of the other nodes in the graph.

  3. Initialize the distance from the source node to all other nodes to infinity.

  4. Set the distance from the source node to itself to 0.

  5. While U is not empty:

    • Select the node v in U with the lowest distance.

    • Add v to S.

    • For each neighbour w of v:

      • If the distance from v to w is greater than the distance from the source node to v plus the cost of the edge (v, w):

        • Update the distance from the source node to w to the distance from the source node to v plus the cost of the edge (v, w).
  6. The shortest path from the source node to any node in S is the sequence of nodes in S from the source node to that node.

Dijkstra's algorithm is a greedy algorithm. This means that it always chooses the best option that it knows about at the time. This makes it a very efficient algorithm, but it can also lead to suboptimal solutions if the graph is not fully connected.

Example: https://www.javatpoint.com/dijkstras-algorithm

Bellman-ford algorithm

The Bellman-Ford algorithm is an algorithm for finding the shortest paths from a single source vertex to all other vertices in a weighted graph. It works by repeatedly relaxing the edges of the graph, which means updating the distance from the source vertex to each vertex. The algorithm continues to relax edges until no more updates can be made.

The algorithm works as follows:

  1. Initialize the distance from the source vertex to all other vertices to infinity.

  2. Set the distance from the source vertex to itself to 0.

  3. For each edge (u, v) in the graph:

    • If the distance from the source vertex to u is finite and the distance from u to v is less than the distance from the source vertex to v plus the weight of the edge (u, v):

      • Update the distance from the source vertex to v to the distance from the source vertex to u plus the weight of the edge (u, v).
  4. If no updates were made in the previous step, then the algorithm has terminated and the distances from the source vertex to all other vertices are correct. Otherwise, the algorithm must be repeated from step 3.

Example: https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/

Hierarchical Routing

Hierarchical routing is a routing protocol that divides a network into smaller regions, called areas, and each area is assigned a unique identifier. Routers within an area only need to know about the topology of that area, and routers between areas only need to know about the topology of their own area and the areas that are directly connected to it. This reduces the amount of routing information that needs to be stored and exchanged, which makes the routing protocol more efficient.

Hierarchical routing is used in many large-scale networks, such as the Internet. It is also used in some smaller networks, such as corporate networks.

There are two main types of hierarchical routing:

  • Area-based routing is a type of hierarchical routing in which the network is divided into areas, and each area is assigned a unique identifier. Routers within an area only need to know about the topology of that area.

  • Core-based routing is a type of hierarchical routing in which the network is divided into a core and an edge. The core is the central part of the network, and it is responsible for carrying traffic between different areas. The edge is the periphery of the network, and it is responsible for carrying traffic between hosts and the core.

Hierarchical routing has several advantages over flat routing, including:

  • Reduced routing table size: Hierarchical routing reduces the amount of routing information that needs to be stored and exchanged, which makes the routing protocol more efficient.

  • Improved scalability: Hierarchical routing makes it possible to scale networks to a larger size without sacrificing performance.

  • Improved fault tolerance: Hierarchical routing makes it possible to isolate faults to a smaller area of the network, which can improve the overall availability of the network.

Hierarchical routing – Multimedia Communications Group

Broadcast Routing

Broadcast routing is a routing protocol that is used to deliver broadcast messages to all hosts in a network. Broadcast messages are messages that are sent to all hosts in a network, regardless of their destination. Broadcast messages are used for a variety of purposes, such as network discovery, IP address allocation, and multicasting.

Broadcast routing is a simple and efficient way to deliver broadcast messages to all hosts in a network. However, broadcast routing can also be a source of congestion and security problems. To mitigate these problems, broadcast routing is often used in conjunction with other routing protocols, such as spanning tree protocol and multicast routing.

Here are some of the key features of broadcast routing:

  • Broadcast messages are sent to all hosts in a network, regardless of their destination.

  • Broadcast routing is a simple and efficient way to deliver broadcast messages to all hosts in a network.

  • Broadcast routing can be a source of congestion and security problems.

  • Broadcast routing is often used in conjunction with other routing protocols to mitigate these problems.

Network Layer Routing

There are two main types of broadcast routing:

  • Limited Broadcast: Limited broadcast is a type of broadcast routing in which broadcast messages are only delivered to hosts in the same broadcast domain. A broadcast domain is a group of hosts that are connected to each other by a single router.

  • Unlimited Broadcast: Unlimited broadcast is a type of broadcast routing in which broadcast messages are delivered to all hosts in the network, regardless of their broadcast domain. Unlimited broadcast is not recommended for use in large networks, as it can consume a lot of bandwidth.

Multicast Routing

Multicast routing is a routing protocol that is used to deliver multicast messages to a group of hosts. Multicast messages are messages that are sent to a specific group of hosts, rather than to all hosts in a network. Multicast routing is often used for applications such as video conferencing and live streaming.

There are two main types of multicast routing protocols:

  • Dense mode multicast routing (DMR) is a type of multicast routing protocol in which multicast messages are flooded throughout the network until they reach their destination. DMR is simple to configure and manage, but it can consume a lot of bandwidth, especially in large networks.

  • Sparse mode multicast routing (SMM) is a type of multicast routing protocol in which multicast messages are only forwarded to the routers that are connected to hosts that are interested in receiving the message. SMM is more efficient than DMR, but it is more complex to configure and manage.

Multicast routing is a complex topic, but it is an important part of any network that needs to deliver multicast messages. If you are planning to use multicast routing in your network, it is important to carefully consider the type of multicast routing protocol that you will use and to configure your network accordingly.

Here are some of the key features of multicast routing:

  • Multicast messages are sent to a specific group of hosts, rather than to all hosts in a network.

  • Multicast routing is often used for applications such as video conferencing and live streaming.

  • There are two main types of multicast routing protocols: dense mode multicast routing (DMR) and sparse mode multicast routing (SMM).

  • Multicast routing is a complex topic, but it is an important part of any network that needs to deliver multicast messages.

Network Layer Routing

IP Addresses

An IP address (Internet Protocol address) is a unique identifier for every device or network that connects to the Internet. Typically assigned by an internet service provider (ISP), an IP address is an online device address used for communicating across the internet. Two versions of IP addresses are commonly used on the internet: IPv4 and IPv6.

  • IPv4 is the older version of IP addressing and uses 32-bit addresses. IPv4 addresses are written as four sets of numbers separated by periods, such as 192.168.1.1.

  • IPv6 is the newer version of IP addressing and uses 128-bit addresses. IPv6 addresses are written as eight sets of hexadecimal numbers separated by colons, such as 2001:0db8:0000:0000:0000:ff00:0042:8329.

IP addresses are used to route data packets across the internet. When you send a message to someone on the internet, your computer first needs to find the IP address of the recipient's computer. Once your computer has the recipient's IP address, it can then send the message to that address.

IP addresses are an essential part of the internet. Without IP addresses, it would be impossible to send messages or access websites.

Here are some of the key features of IP addresses:

  • IP addresses are unique identifiers for every device or network that connects to the internet.

  • IP addresses are used to route data packets across the internet.

  • There are two versions of IP addresses: IPv4 and IPv6.

  • IPv4 is the older version of IP addressing and uses 32-bit addresses.

  • IPv6 is the newer version of IP addressing and uses 128-bit addresses.

  • IP addresses are an essential part of the internet.

Header format

The IP header format is a standard way of organizing the information in an IP packet. The IP header contains information about the source and destination IP addresses, the protocol that is being used, and the length of the packet.

The IP header format is as follows:

  • Version: This field is 4 bits long and indicates the version of the IP protocol that is being used. For IPv4, the version number is 4.

  • Header Length: This field is 4 bits long and indicates the length of the IP header in 32-bit words. The minimum value is 5, which indicates a length of 20 bytes, and the maximum value is 15, which indicates a length of 60 bytes.

  • Type of Service: This field is 8 bits long and specifies how the datagram should be handled. The first 3 bits are the priority bits.

  • Total Length: This field is 16 bits long and indicates the length of the entire packet (header + data).

  • Identification: This field is 16 bits long and is used to identify fragmented packets.

  • Flags: This field is 3 bits long and is used to control or identify fragments.

  • Fragment Offset: This field is 13 bits long and is used to indicate the offset of the current fragment within the original datagram.

  • Time to Live: This field is 8 bits long and specifies the maximum number of hops that the datagram can traverse before it is discarded.

  • Protocol: This field is 8 bits long and indicates the protocol that is being used in the datagram.

  • Header Checksum: This field is 16 bits long and is used to verify the integrity of the IP header.

  • Source IP Address: This field is 32 bits long and specifies the IP address of the sender.

  • Destination IP Address: This field is 32 bits long and specifies the IP address of the recipient.

  • Options: This field is variable in length and can be used to carry additional information.

The IP header format is a critical part of the IP protocol. It is used to route data packets across the internet and to ensure the integrity of the data.

Internet Protocol version 4 - Wikipedia

Packet forwarding

Packet forwarding is the process of moving data packets from one network to another. It is a critical part of the internet, as it allows data to be routed from one computer to another, even if they are not on the same network.

Packet forwarding is performed by routers. Routers are devices that connect two or more networks. When a router receives a data packet, it looks at the destination IP address in the packet header. The router then uses a routing table to determine the next hop towards the destination. The router then forwards the packet to the next hop.

The routing table is a database that contains information about the networks that are connected to the router. The routing table contains the IP address of each network, as well as the next hop towards that network. The routing table is updated periodically, as networks are added or removed.

Packet forwarding is a complex process, but it is essential for the Internet to function. Without packet forwarding, it would be impossible to send data from one computer to another.

Fragmentation and reassembly

IP fragmentation is the process of dividing an IP datagram into smaller pieces, called fragments so that it can be transmitted over a network link with a smaller maximum transmission unit (MTU) than the original datagram.

IP fragmentation - Wikipedia

IP reassembly is the process of putting the fragments back together into the original datagram at the destination.

Fragmentation and reassembly are performed by the IP layer. The IP layer is responsible for routing IP datagrams across the internet.

When an IP datagram is too large to be transmitted over a network link, the IP layer will fragment the datagram into smaller pieces. The IP layer will add a fragmentation header to each fragment. The fragmentation header contains information about the original datagram, such as the sequence number of the fragment and the total number of fragments in the datagram.

The fragments are then transmitted over the network link. When the fragments arrive at the destination, the IP layer will reassemble the fragments into the original datagram. The IP layer will then pass the original datagram to the next layer up in the protocol stack.

Fragmentation and reassembly are essential for the reliable delivery of IP datagrams over the internet. Without fragmentation, datagrams that are too large to be transmitted over a network link would be discarded. Without reassembly, datagrams that have been fragmented would not be able to be reassembled at the destination.

Here are some of the key features of IP fragmentation and reassembly:

  • Fragmentation is performed by the IP layer.

  • Reassembly is performed by the IP layer.

  • Fragmentation is used when a datagram is too large to be transmitted over a network link with a smaller MTU.

  • Reassembly is used to put the fragments back together into the original datagram at the destination.

  • Fragmentation and reassembly are essential for the reliable delivery of IP datagrams over the internet.

ICMP

ICMP is a network protocol that is used for error reporting and network testing. It is part of the Internet Protocol Suite (TCP/IP).

ICMP messages are used to report errors in IP datagrams, such as when a datagram is lost or corrupted. ICMP messages are also used to test the reachability of hosts and networks.

There are many different types of ICMP messages, including:

  • Echo Request: This message is used to test the reachability of a host.

  • Echo Reply: This message is sent in response to an Echo Request message.

  • Destination Unreachable: This message is sent when a datagram cannot be delivered to its destination.

  • Time Exceeded: This message is sent when a datagram takes too long to reach its destination.

  • Parameter Problem: This message is sent when an IP datagram is malformed.

ICMP Protocol (Internet Control Message Protocol): A Guide - Okta SG

ICMP is a valuable tool for network administrators. It can be used to troubleshoot network problems and to test the reachability of hosts and networks.

Here are some of the key features of ICMP:

  • ICMP is a network protocol that is used for error reporting and network testing.

  • ICMP is part of the Internet Protocol Suite (TCP/IP).

  • There are many different types of ICMP messages, each with a specific purpose.

  • ICMP is a valuable tool for network administrators.

Comparative study of IPv4 & IPv6

FeatureIPv4IPv6
Address size32 bits128 bits
Address space4.3 billion addresses340 undecillion addresses
Addressing schemeClassfulClassless
Network address translation (NAT)RequiredNot required
FragmentationRequiredNot required
SecurityLess secureMore secure
DeploymentWidely deployedStill in the early stages of deployment
CostLowHigh
ComplexityLess complexMore complex

Did you find this article valuable?

Support Vishesh Raghuvanshi by becoming a sponsor. Any amount is appreciated!