Understanding the Network Layer Functions
Understanding the Network Layer Functions
B.TECH CSE
3rd Year – 1st Sem
UNIT – III
Network Layer
DEPARTMENT OF CSE
VIGNAN INSTITUTE OF TECHNOLOGY & SCIENCE
DESHMUKHI
Network Layer
The network layer is a crucial component of the OSI (Open Systems Interconnection) model
and the TCP/IP (Transmission Control Protocol/Internet Protocol) protocol suite. It operates
at Layer 3 of the OSI model and is responsible for routing packets of data between devices
across different networks.
The network layer is responsible for the source-to-destination delivery of a packet, possibly
across multiple networks (links). Whereas the data link layer oversees the delivery of the
packet between two systems on the same network (links), the network layer ensures that each
packet gets from its point of origin to its final destination. Communication at the network layer
is host-to-host (computer-to-computer); a computer somewhere in the world needs to
communicate with another computer somewhere else in the world.
The packet transmitted by the sending computer may pass through several LANs or WANs
before reaching the destination computer. The term IP address to mean a logical address in the
network layer of the TCP/IP protocol suite. The Internet addresses are 32 bits in length; this
gives us a maximum of 232 addresses.
These addresses are referred to as IPv4 (IP version 4) addresses or simply IP addresses if there
is no confusion.
As:- IPAddress: 117.149.29.2
Network layer: Handles the routing and sending of data between different networks.
✓ The most important protocols at this layer are IP and ICMP.
Network Protocol: A protocol is an agreed-upon way of formatting data so that two or
more devices are able to communicate with and understand each other.
A number of different protocols make connections, testing, routing, and encryption
possible at the network layer, including IP, IPsec, ICMP, IGMP, GRE, OSPF, RIP, NAT,
VRRP.
Error Handling: While the network layer does not perform error detection
and correction like the data link layer, it may detect errors and initiate actions
to handle them, such as requesting packet retransmission.
1. Packet Reception: The network device (e.g., router) receives a data packet on an
incoming link.
2. Storage: The entire packet is buffered in memory, waiting for complete reception.
3. Error Checking: The packet's integrity is verified using error detection codes (e.g.,
CRC).
4. Routing: Based on the destination address, the next path or hop is determined.
5. Forwarding: If error-free, the packet is transmitted to the next device on the chosen
path.
6. Buffer Management: Buffers are monitored and packets may be discarded if storage
space becomes unavailable.
Core Services:
Logical Addressing: Assigns unique logical addresses (e.g., IP addresses) to devices
on the network, enabling identification and communication.
Routing: Determines the best path for packets to take from source to destination,
using protocols like IP routing and BGP.
Packet Forwarding: Receives packets from the data link layer, analyzes routing
information, and sends them towards the next hop on the chosen path.
Error Handling: Detects and handles errors that might occur during transmission,
potentially using mechanisms like ICMP messages.
Congestion Control: Implements mechanisms to prevent network congestion,
ensuring smooth data flow.
Internetworking: Enables communication between different networks with varying
technologies and protocols.
Routing algorithms
A routing algorithm is a procedure that lays down the route or path to transfer data packets
from source to the destination. hey help in directing Internet traffic efficiently. After a data
packet leaves its source, it can choose among the many different paths to reach its destination.
Routing algorithm mathematically computes the best path, i.e. “least – cost path” that the
packet can be routed through. The main function of the network layer is routing packets from
the source machine to the destination machine.
In most networks, packets will require multiple hops to make the journey.
The Routing protocol is a routing algorithm that provides the best path from the source
to the destination. The best path is the path that has the "least-cost path" from source to
the destination.
Routing is the routing algorithm determines the process of forwarding the packets from
source to the destination but the best route to send the packets.
The routing algorithm is that part of the network layer software responsible for deciding
which output line an incoming packet should be transmitted on.
In this process, a routing table is created which contains information regarding routes
that data packets follow.
Various routing algorithms are used for the purpose of deciding which route an incoming
data packet needs to be transmitted on to reach the destination efficiently.
The algorithms that change their routing decisions whenever network topology or traffic load
changes. These make use of dynamic information such as current topology, load, delay, etc. to
select routes. A router may select a new route for each packet (even packets belonging to the
same transmission) in response to changes in the condition and topology of the networks.
Optimization parameters are distance, number of hops, and estimated transit time.
Graphs
Graph is non-linear data structures representing the "connections" between the vertices
through edges.
Vertices: Vertices are the basic units of the graph used to represent real-life, objects,
persons, or entities. Sometimes, vertices are also known as Nodes.
Edges: Edges are drawn or used to connect two vertices of the graph. Sometimes, edges
are also known as Arcs.
Example : Shortest path routing
Example
Step 1: Start from Node 0 and mark Node 0 as visited and check adjacent nodes
Step 2: Check for adjacent Nodes, (Either choose Node1 with distance 2 or either choose
Node 2 with distance 6 ) and choose Node with minimum distance.
Distance: Node 0 -> Node 1 = 2
Step 3: Then Move Forward and check for adjacent Node which is Node 3, so marked it as
visited and add up the distance, Now the distance will be: Distance: Node 0 -> Node 1 ->
Node 3 = 2 + 5 = 7
Step 4: Again two choices for adjacent Nodes (Either choose Node 4 with distance 10 or either
choose Node 5 with distance 15) so choose Node with minimum distance.
Node 4 is Minimum distance adjacent Node, so marked it as visited and add up the distance.
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 = 2 + 5 + 10 = 17
Step 5: Again, Move Forward and check for adjacent Node which is Node 6, so marked it as
visited and add up the distance, Now the distance will be:
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 -> Node 6 = 2 + 5 + 10 + 2 = 19
So, the Shortest Distance from the Source Vertex is 19 which is optimal one
Flooding
Flooding is a technique of routing in computer networking, in which a sender node transmits
packets via all the outgoing links. Flooding is similar to broadcasting in that it happens when
sender packets are transferred without routing data to each network node attached.
Hierarchical routing
Hierarchical routing algorithm is one of the adaptive algorithms used to reduce the size of
routing table. Drawback of this algorithm is that the reduced table size comes at the expense
of increased path length. Hierarchical routing is the procedure of arranging routers in a
hierarchical manner. As networks grow in size, the router routing tables grow proportionally.
Broadcast Routing
Broadcast routing is a networking concept that facilitates the transmission of data, messages or
signals, from a source to destinations within a network. Unlike routing (one to one) or multicast
routing (one to many) broadcast routing ensures that information reaches all devices or nodes
in the network. Broadcast routing sends a single message to every device on a network segment,
like a group chat message. It uses a special address and routers forward it to all connected
devices.
• Broadcast routing ensures that packets reaches all devices or nodes within the
network.
An improvement is multidestination routing, in which each packet contains either a list of
destinations or a bit map indicating the desired destinations. When a packet arrives at a router,
the router checks all the destinations to determine the set of output lines that will be needed.
A spanning tree is a subset of the network that includes all the routers but
contains no loops. Sink trees are spanning trees.
Reverse path forwarding: a broadcast packet arrives at a router, the router checks to see if
the packet arrived on the link that is normally used for sending packets toward the source of
the broadcast.
Reverse path forwarding: a broadcast packet arrives at a router, the router checks to see if the
packet arrived on the link that is normally used for sending packets toward the source of the
broadcast.
Multicast routing
Multicast routing is a networking method for efficient distribution of one-to-many traffic.
A multicast source, such as a live video conference, sends traffic in one stream to a multicast
group. The multicast group contains receivers such as computers, devices, and IP phones.
Multicast routing is a networking method for efficient distribution of one-to-many
traffic.
Multicast routing begins by sending a select group of receivers the data, which they
filter out to other necessary receivers.
Sending a message to such a group is called multicasting, and the routing algorithm
used is called multicast routing.
Multicast routing schemes build on the broadcast routing schemes we have already studied,
sending packets along spanning trees to deliver the packets to the members of the group while
making efficient use of bandwidth.
Difference between Broadcast and Multicast Routing
Distance vector routing
The distance vector routing algorithm is one of the most commonly used routing algorithms.
It is a distributed algorithm, meaning that it is run on each router in the network. The algorithm
works by each router sending updates to its neighbours about the best path to each destination.
A distance-vector protocol calculates the distance and direction of the vector of the next hop
from the information obtained by the neighboring router. Distant vector routing protocol also
called as Bellman-Ford algorithm or Ford Fulkerson algorithm used to calculate a path.
Historically known as the old ARPANET routing algorithm {or known as Bellman Ford
(BF) algorithm}.
Bellman-Ford algorithm
The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single
source vertex to all of the other vertices in a weighted digraph.
Step to calculates shortest distances used (V - 1) times/Iteration, where V is the number of nodes
in given network.
To calculate the distance between X and Y node using bellmen- ford equation.
where, dx(y) = The least distance from x to y
c(x,v) = Node x's cost from each of its neighbor
vdv(y) = Distance to each node from initial node
minv = Selecting shortest distance
Congestion Control Algorithms,
Congestion:
A state occurring in network layer when the message traffic is so heavy that it slows down
network response time. When too many packets are present in the network it causes packet
delay and loss of packet which degrades the performance of the system. This situation is called
congestion.
The network layer and transport layer share the responsibility for handling congestions. One
of the most effective ways to control congestion is trying to reduce the load that transport layer
is placing on the network.
Effects of Congestion
✓As delay increases, performance decreases.
✓If delay increases, retransmission occurs, making situation worse.
Congestion collapse
When the number of packets hosts send into the network is well within its carrying capacity,
the number delivered is proportional to the number sent. If twice as many are sent, twice as
many are delivered.
Causes of Congestion
If all of a sudden, streams of packets begin arriving on three or four input lines and all need
the same output line, a queue will build up.
✓ If there is insufficient memory to hold all of them, packets will be lost.
i Slow processors can also cause congestion.
i. If the routers’ CPUs are slow at performing the bookkeeping tasks
required of them (queueing buffers, updating tables, etc.) queues can
build up even though there is excess line capacity.
ii. Low-bandwidth lines can also cause congestion.
ii Low-bandwidth links or routers that process packets more slowly than the line rate can
also become congested.
Example:
Case 1: consider a network made up of 100-Gbps fiber optic links on which a supercomputer
is trying to force feed a large file to a personal computer that is capable of handling only 1
Gbps. Although there is no congestion (the network itself is not in trouble), flow control is
needed to force the supercomputer to stop frequently to give the personal computer a chance
to breathe.
Case 2: consider a network with 1-Mbps lines and 1000 large computers, half of which are
trying to transfer files at 100 kbps to the other half. Here, the problem is not that of fast senders
overpowering slow receivers, but that the total offered traffic exceeds what the network can
handle.
Network provisioning
Network provisioning is the process of setting up a network so that authorized users,
devices, and servers can access it. In practice, network provisioning primarily concerns
connectivity and security, which means a heavy focus on device and identity management.
Sometimes resources can be added dynamically when there is serious congestion.
More often, links and routers that are regularly heavily utilized are upgraded at the
earliest opportunity happens on a time scale of months, driven by long-term traffic
trends. Traffic-aware routing
To make the most of the existing network capacity, routes can be tailored to traffic patterns
that change during the day as network users wake and sleep in different time zones.
Splitting traffic across multiple paths is also helpful
Admission control
Admission control (AC) is a mechanism used in computer networks and telecommunications
to ensure that new connections or traffic do not exceed the network's capacity or cause a
degradation in the quality of service (QoS) provided to existing connections. Admission control
can be performed at different levels of the network, such as at the application, transport,
network, or link layer. In this article, we will focus on admission control at the network layer,
which is also known as network admission control (NAC).
Sometimes it is not possible to increase capacity.
New connections can be refused if they would cause the network to become congested.
Traffic throttling
Traffic Throttling is an approach used to avoid congestion. In networks and the internet, the
senders try to send as much traffic as possible as the network can readily deliver. In a network
when congestion is approaching it should tell the senders of packets to slow down them.
Routers can monitor the average load, queueing delay, or packet loss. In all cases,
rising numbers indicate growing congestion.
Load shedding
Load shedding is one of the techniques used for congestion control. A network router consists
of a buffer. This buffer is used to store the packets and then route them to their destination.
Load shedding is defined as an approach of discarding the packets when the buffer is full
according to the strategy implemented in the data link layer. The selection of packets to discard
is an important task. Many times packets with less importance and old packets are discarded.
When all else fails, the network is forced to discard packets that it cannot deliver.
A good policy for choosing which packets to discard can help to prevent congestion
collapse
There are two congestion control algorithm which are under admission control approach
as follows:
i. Leaky Bucket Algorithm
ii. Token Bucket algorithm
Congestion control algorithm under
Admission control
Bursty traffic is sudden, unexpected network volume traffic, peak and depression in a network
Suppose data enters the network from various sources at different speed.
Consider one bursty source that
Sends data at 20 Mbps for 2 seconds for total of 40 Mb.
Then it silent, sending no data for 5 seconds.
Then it again transmits data at a rate of 10 Mbps for 3 seconds, thus sending a total
of 30 Mbps.
So, in a time span of 10 seconds the source sends 70 Mb data.
The network has only committed a bandwidth of 5 Mbps for this source.
It uses the leaky bucket algorithm to output traffic at the rate of 5 Mbps during the
same time period of 10 Seconds, which smooths out the network traffic.
Token Bucket Algorithm
Token bucket algorithm is one of the techniques for congestion control algorithms. When too
many packets are present in the network it causes packet delay and loss of packet which
degrades the performance of the system. This situation is called congestion. Token bucket
algorithm is based on analogy of a fixed capacity bucket into which tokens, normally
representing a unit of bytes or a single packet of predetermined size, are added a fixed rate.
Quality of Service (QoS) is an internetworking issue that has been discussed more than
defined.
Four issues must be addressed to ensure quality of service:
i. What applications need from the network
ii. How to regulate the traffic that enters the network. iii. How to reserve
resources at routers to guarantee performance.
iii. Whether the network can safely accept more traffic
Application
Requirements
Leaky Buckets
Traffic Shaping
Token Buckets
Packet Scheduling
QUALITY OF
SERVICE Admission Control
RSVP—The
Integrated Resource
Services reSerVation
Protocol
Expedited
Forwarding
Differentiated
Services
Assured
Forwarding
INTERNETWORKING
Internetworking is the practice of interconnecting multiple computer networks, such that
any pair of hosts in the connected networks can exchange messages irrespective of their
hardware-level networking technology. Connecting computer networks to additional
networks using gateways and routers is commonly known as internetworking. These
interconnected networks are called internetworks. It would be much simpler to join
networks together if everyone used a single networking technology, and it is often the case that
there is a dominant kind of network, such as Ethernet. A router that can handle multiple
network protocols is called a multiprotocol router.
Since networks often differ in important ways, getting packets from one network to another
is not always so easy. The problems of heterogeneity, and also problems of scale as the
resulting internet grows very large.
INTERNETWORKING
Deployment of a network protocol with a new feature is a common reason, as our ‘‘IPv6 over
IPv4’’ example shows.
The limitation of tunnels is turned into an advantage with VPNs (Virtual Private Networks).
A VPN is simply an overlay that is used to provide a measure of security. Tunneling is widely
used to connect isolated hosts and networks using other networks. The network that results
is called an overlay since it has effectively been overlaid on the base network.
Tunneling is a mechanism by which two or more same networks communicate with each
other, by passing intermediate networking complexities.
Tunneling is configured at both ends.
Internetwork Routing
Routing between two networks is called internetworking. Networks can be considered
different based on various parameters such as, Protocol, topology, Layer-2 network and
addressing scheme. In internetworking, routers have knowledge of each other's address and
addresses beyond them. Routing through an internetwork is similar to routing within a single
subnet, but with some added complications.
In internetworking, routers have knowledge of each other’s address and addresses beyond
them. They can be statically configured go on different network or they can learn by using
internetworking routing protocol.
Routing protocols
A routing protocol specifies how routers exchange routing information with each other,
enabling them to determine routes between any two nodes on a computer network.
Within each network, an intradomain or interior gateway protocol is used for routing.
(‘‘Gateway’’ is an older term for ‘‘router’’). Across the networks that make up the internet, an
interdomain or exterior gateway protocol is used. The networks may all use different
intradomain protocols, but they must use the same interdomain protocol.
Routing protocols which are used within an organization or administration are called
Interior Gateway Protocols (IGP).
RIP, OSPF are examples of IGP.
Routing between different organizations or administrations may have Exterior Gateway
Protocol and there is only one EGP i.e. Border Gateway Protocol.
In the Internet, the interdomain routing protocol is called BGP (Border Gateway
Protocol).
Packet Fragmentation
Fragmentation dissects the packets into smaller pieces so that they can fit the smaller links
as they travel the network. Every packet based network has an MTU (Maximum
Transmission Unit) size. The MTU is the size of the largest packet that network can
transmit. Fragmentation: when the maximum size of datagram is greater than maximum
size of data that can be held in a frame i.e., its Maximum Transmission Unit, The network
layer divides the datagram received from the transport layer into fragments so that data flow
is not disrupted. Packets larger than the allowable MTU must be divided into smaller
packets or fragments to enable them to traverse the network.
IP fragmentation is an Internet Protocol (IP) process that breaks packets into smaller pieces
(fragments), so that the resulting pieces can pass through a link with a smaller maximum
transmission unit (MTU) than the original packet size. The fragments are reassembled by the
receiving host.
Packet Fragmentation
Transparent fragmentation is straightforward but has some problems.
Nontransparent fragmentation strategy is to refrain from recombining fragments
at any intermediate routers.
The main advantage of nontransparent fragmentation is that it requires routers to do less work.
Public IP Address
A public IP address, or external-facing IP address, applies to the main device people use to
connect their business or home internet network to their internet service provider (ISP). In most
cases, this will be the router. All devices that connect to a router communicate with other IP
addresses using the router’s IP address.
Knowing an external-facing IP address is crucial for people to open ports used for online
gaming, email and web servers, media streaming, and creating remote connections.
Private IP Address
A private IP address, or internal-facing IP address, is assigned by an office or home intranet
(or local area network) to devices, or by the internet service provider (ISP). The home/office
router manages the private IP addresses to the devices that connect to it from within that local
network. Network devices are thus mapped from their private IP addresses to public IP
addresses by the router.
Private IP addresses are reused across multiple networks, thus preserving valuable IPv4 address
space and extending addressability beyond the simple limit of IPv4 addressing (4,294,967,296
or 2^32).
An Internet Protocol (IP) address is a unique numerical identifier for every device or
network that connects to the internet.
There are two versions of IP addresses that are commonly used on the internet:• IPv4
and IPv6.
An IPv4 address is expressed as a set of four dotted decimal numbers, where each octet
is separated by a period, such as 192.168.35.4
A full IP address ranges from 0.0.0.0 to 255.255.255.255.
An IPv6 address represents eight groups of four hexadecimal digits separated by colons,
such as 2620:cc:8000:1c82:544c:cc2e:f2fa:5a9b.
IPv4 Addresses
The IPv4 address consists of a network address and a host address. Within the Internet, a central
authority, the Network Information Center (NIC), assigns the network addresses. The class of
address determines the portion of the IPv4 address that is used for each of these addresses.
A defining feature of IPv4 is its 32-bit addresses. Every host and router on the Internet has an
IP address that can be used in the Source address and Destination address fields of IP packets.
An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a
device to the Internet.
In IPv4, a unique sequence of bits is assigned to a computer, a total of (2^32) devices
approximately = 4,294,967,296 can be assigned with IPv4.
An IP address is an online device address used for communicating across the internet. It really
refers to a network interface, so if a host is on two networks, it must have two IP addresses.
However, in practice, most hosts are on one network and thus have one IP address.
In contrast, routers have multiple interfaces and thus multiple IP addresses
The 0.0.0.0 is a Non-routable address is that indicates an invalid, or inapplicable end-
user address.
A loopback address is a distinct reserved IP address range that starts from 127.0.0.0
ends at 127.255.255.255.
127.255.255.255 is the broadcast address for 127.0.0.0/8.
The loopback addresses are built into the IP domain system, enabling devices to
transmit and receive the data packets.
The loopback address 127.0.0.1 is generally known as localhost.
IP addresses are assigned and managed by a nonprofit corporation called ICANN (Internet
Corporation for Assigned Names and Numbers), to avoid conflicts. ICANN has delegated
parts of the address space to various regional authorities, which dole out IP addresses to ISPs
and other companies. This is the process by which a company is allocated a block of IP
addresses.
Maximum number of
IP Class Address Range
networks
IP Version 6
IPv6 or Internet Protocol Version 6 is a network layer protocol that allows communication to
take place over the network. Internet Engineering Task Force (IETF) designed IPv6 in
December 1998 with the purpose of superseding the IPv4 due to the global exponentially
growing internet users.
Internet Protocol (IP) version 6 (IPv6 or IPng) is the next generation of IP and has been
designed to be an evolutionary step from IP version 4 (IPv4). An IPv6 address is a 128-bit
alphanumeric value that identifies an endpoint device in an Internet Protocol Version 6 (IPv6)
network. IPv6 was developed by Internet Engineering Task Force (IETF) to deal with the
problem of IPv4 exhaustion. IPv6 is a 128-bits address having an address space of 2128, which
is way bigger than IPv4. An IPv6 address is 128 bits long and is arranged in eight groups, each
of which is 16 bits. Each group is expressed as four hexadecimal digits and the groups are
separated by colons (:).
An IPv6 address is split into two parts: a network and a node component.
The network component is the first 64 bits of the address and is used for routing.
The node component is the later 64 bits and is used to identify the address of the
interface.
It is derived from the physical, or MAC address, using the 64-bit extended unique identifier
(EUI-64) format defined by the Institute of Electrical and Electronics Engineers (IEEE).
Type: It is an 8-bit field. It defines the ICMP message type. The values range from
0 to 127 are defined for ICMPv6, and the values from 128 to 255 are the
informational messages.
Code: It is an 8-bit field that defines the subtype of the ICMP message.
Checksum: It is a 16-bit field to detect whether the error exists in the message or
not.
On a router-to-router line using PPP as the framing protocol, the frame format,
including the PPP, MPLS, IP, and TCP headers, is as shown in Fig. 5-62.
The protocol which aims at moving the packet within a large autonomous system or routing
domain. It is an intradomain protocol, which means that it is used within an area or a network.
It is based on a link-state routing algorithm in which each router contains the information of
every domain, and based on this information, it determines the shortest path. The goal of
routing is to learn routes.
The OSPF achieves by learning about every router and subnet within the entire network. OSPF
uses a link-state routing algorithm. Each router has information about every link and router in
the network. It finds the shortest path to each destination. OSPF learns about all routers and
subnets in the network to build a link-state database (LSDB). Routers exchange link-state
advertisements (LSAs) to share information about routers, subnets, and more.