UNIT - III Network Layer
UNIT - III Network Layer
Network Layer
• 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.
• Guaranteed delivery with bounded delay: The packet will be delivered within a specified host-to-host
delay bound.
• In-Order packets: The packet arrives at the destination in the order in which they are sent.
• Guaranteed max jitter: The amount of time taken between two successive transmissions at the sender is
equal to the time between their receipt at the destination.
• Security services: The network layer provides security by using a session key between the source and
destination host.
✔ The source host encrypts the payloads of datagrams being sent to the destination host.
✔ The destination host would then decrypt the payload. In such a way, the network layer
maintains the data integrity and source authentication services.
Implementation of Connectionless Service
• Packet are termed as “datagrams” and corresponding subnet as “datagram subnets”.
✔ When the message size that has to be transmitted is 4 times the size of the packet, then the network layer
divides into 4 packets and transmits each packet to router via. a few protocol.
✔ Each data packet has destination address and is routed independently irrespective of the packets.
Implementation of Connectionless Service
Implementation of Connection-Oriented
Service
• A connection-oriented service, first establishes a connection, use it and then release it.
• The data packets are delivered to the receiver in the same order in which they have been sent by the
sender.
• 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 process of forwarding the packets from source to the destination but the best route to
send the packets is determined by the routing algorithm.
• 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.
Classification of Routing Algorithms
The routing algorithms can be classified as follows:
Adaptive Algorithms/ dynamic routing
✔ 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.
Non-Adaptive Algorithms/ static routing
✔ The algorithms that do not change their routing decisions once they have been selected, as a
route to be taken is computed in advance and downloaded to routers when a router is booted.
✔ Once the pathway to the destination has been selected, the router sends all packets for that
destination along that one route.
✔ Nonadaptive algorithms do not base their routing decisions on any measurements or estimates of the
current topology and traffic.
Types of Routing Algorithms
Shortest path
1. Shortest path routing routing
Distanc
2. Flooding e
Types Flooding
vector
3. Hierarchical routing, of
routing
4. Broadcast, Routing
Algorit
5. Multicast, Broadc
hms Hierarchical
routing
ast
6. Distance vector routing
Multic
ast
Shortest path routing
• Dijkstra’s Shortest Path Algorithm which was developed by Dutch computer scientist
Edsger W. Dijkstra in 1956.
• Dijkstra’s algorithm is a popular algorithms for solving many single-source shortest path
problems having non-negative edge weight in the graphs i.e., it is to find the shortest
distance between two vertices on a graph.
• Finds shortest paths from given source nodes to all other nodes.
• The aim is to find the optimal paths between the network nodes so that routing cost is
minimized.
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
In a computer network, flooding occurs when a router uses a non-adaptive routing algorithm
to send an incoming packet to every outgoing link except the node on which the packet
arrived.
Flooding is a way to distribute routing protocols updates quickly to every node in a large
network.
✔ Each router has complete details about how to route packets to destinations within its
own region, but has no information about routers in other regions.
✔ When different networks are interconnected, it is natural to regard each one as a separate region
to free the routers in one network from having to know the topological structure of the other ones.
Figure 5-14 gives a quantitative example of routing in a two-level hierarchy with five regions. The full routing table for router 1A has 17
entries, as shown in Fig. 5-14(b). When routing is done hierarchically, as in Fig. 5-14(c), there are entries for all the local routers, as before,
but all other regions are condensed into a single router, so all traffic for region 2 goes via the 1B-2A line, but the rest of the remote traffic
goes via the 1C-3B line. Hierarchical routing has reduced the table from 17 to 7 entries.
Broadcast Routing
Hosts need to send messages to many or all other
hosts.
• Sending a packet to all destinations simultaneously is
called broadcasting.
• Broadcast routing ensures that packets reaches all
devices or nodes within the network.
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 v
dv(y) = Distance to each node from initial node
minv = Selecting shortest distance
Step - 1
Example As we can see in the above diagram of the DVR network, the routers in the network start sharing
their information with the neighboring routers in the network.
For Router A:
The router A has a direct connection to neighboring routers B and D.
For router A:
Destination Vector B Vector D
A 8 5
B 0 5
C 2 3
Consequently, A's new routing table is:
D 5 0
Destination distance Hop
A 0 A
B 8 B
C 8 D
D 5 D
For router B:
The router B receives information from A and C.
• 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.
• Slow processors can also cause congestion.
✔ 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.
✔ Low-bandwidth lines can also cause congestion.
• 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.
Congestion control algorithms
• Congestion Control is a mechanism that controls the entry of data packets into the network,
enabling a better use of a shared network infrastructure and avoiding congestive collapse.
• Congestive-Avoidance Algorithms (CAA) are implemented at the TCP layer as the
mechanism to avoid congestive collapse in a network.
✔ By detecting congestion and adjusting the data transmission rate to avoid it.
• 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 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.
• Reliability
✔ Reliability is a characteristic that a flow needs.
• Delay
✔ Source-to-destination delay is another flow characteristic.
• Jitter
✔ Jitter is the variation in delay for packets belonging to the same flow.
• Bandwidth
✔ Different applications need different bandwidths.
Quality of Service
• Quality of Service (QoS) is an internetworking issue that has been discussed
more than defined.
QUALITY OF SERVICE
Admission Control
RSVP—The Resource
Integrated Services
reSerVation Protocol
Expedited
Forwarding
Differentiated
Services
Assured Forwarding
INTERNETWORKING
• 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.
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
✔ 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
✔ 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
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
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.
✔ These limits have various causes, among them :
i. Hardware (e.g., the size of an Ethernet frame).
ii. Operating system (e.g., all buffers are 512 bytes).
iii. Protocols (e.g., the number of bits in the packet length field).
iv. Compliance with some (inter)national standard.
v. Desire to reduce error-induced retransmissions to some level.
vi. Desire to prevent one packet from occupying the channel too long.
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.
THE NETWORK LAYER IN THE INTERNET
In the network layer, the Internet can be viewed as a collection of networks or ASes (Autonomous
Systems) that are interconnected.
✔ ISPs (Internet Service Providers) that provide Internet access to homes and businesses, data centers and colocation
facilities full of server machines, and regional (mid-level) networks.
✔ The data centers serve much of the content that is sent over the Internet.
✔ Attached to the regional networks are more ISPs, LANs at many universities and companies, and
other edge networks.
The glue that holds the whole Internet together is the network layer protocol, IP (Internet Protocol).
The Network layer protocols, IP was designed from the beginning with internetworking in mind.
✔ To provide a best-effort (i.e., not guaranteed) way to transport packets from source to destination,
without regard to whether these machines are on the same network or whether there are other
networks in between them.
THE NETWORK LAYER IN THE INTERNET
THE NETWORK LAYER IN THE INTERNET
✔ The IP Version 4 Protocol,
✔ IP Addresses,
✔ IP Version 6,
✔ Internet Control Protocols,
✔ Label Switching and MPLS,
✔ OSPF—An Interior Gateway Routing Protocol,
✔ BGP—The Exterior Gateway Routing Protocol,
✔ Internet Multicasting,
✔ Mobile IP,
The IP Version 4 Protocol
• The network layer in the Internet is with the format of the IP datagrams themselves.
• An IPv4 datagram consists of a header part and a body or payload part.
• The header has a 20-byte fixed part and a variable-length optional part.
• The bits are transmitted from left to right and top to bottom, with the high-order bit of the Version field
going first.
The IPv4 (Internet Protocol) header
• An IPv6 address represents eight groups of four hexadecimal digits separated by colons, such as
2620:cc:8000:1c82:544c:cc2e:f2fa:5a9b.
IP 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.
✔ The 0.0.0.0 is a Non-routable address is that indicates
IP Addresses an invalid, or inapplicable end-user address.
• An IP address is an online device address used ✔ A loopback address is a distinct reserved IP address
for communicating across the internet. range that starts from 127.0.0.0 ends at 127.255.255.255.
• It really refers to a network interface, so if a host ✔ 127.255.255.255 is the broadcast address for
is on two networks, it must have two IP addresses. 127.0.0.0/8.
✔ However, in practice, most hosts are on one ✔ The loopback addresses are built into the IP domain
network and thus have one IP address. system, enabling devices to transmit and receive the data
✔ In contrast, routers have multiple interfaces packets.
and thus multiple IP addresses.
✔ The loopback address 127.0.0.1 is generally known as
localhost.
IP Addresses
✔ 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
Address
IP Class number of
Range
networks
Reserved for
Class E 240-254 Research and
development
Subnetting is the process of creating a subnetwork
Subnetting (also known as a subnet) within a network. Network
interfaces and devices within a subnet can communicate
with each other directly. Routers facilitate communication
between different subnets.
IP Version 6
• 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.
i. The network component is the first 64 bits of the address and is used for routing.
ii. 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).
The Main IPv6
Header The IPv6 header is more streamlined: it contains 8 fields,
✔ Flow label field provides a way for a source and destination to mark groups of packets that forming a pseudo connection.
✔ Payload length field tells how many bytes follow the 40-byte header.
✔ Next header field lets the cat out of the bag.
✔ Hop limit field is used to keep packets from living forever.
✔ Source address and Destination address fields.
Internet Control Protocols
• The Internet has several companion control protocols that are used in the network layer.
IMCP—The Internet
Control Message Protocol
ARP—The Address
Internet Control Protocols
Resolution Protocol
✔ DHCP server: This is the central device that holds, assigns, and manages IP addresses.
✔ It can be a server, router, or SD-WAN appliance.
✔ DHCP client: This is the endpoint that requests for IP addresses and can be installed on any
type of peripheral device, although most are part of the default settings.
✔ DHCP relay: This refers to devices like routers that acts as a middleman between clients and
server, amplifying the messages to reach their destination goal.
Label Switching and MPLS
• Multi Protocol Label Switching (MPLS) is an IP packet routing technique that routes IP packet through
paths via labels instead of looking at complex routing tables of routers.
✔ This feature helps in increasing the delivery rate of IP packets.
• MPLS is a networking technology that routes traffic using the shortest path based on “labels,” rather than
network addresses, to handle forwarding over private wide area networks.
• MPLS is multiprotocol, which means it can handle multiple network protocols.
✔ MPLS is highly versatile and unifying, as it provides mechanisms to carry a multitude of traffic, including Ethernet traffic.
✔ One of the key differentiators between MPLS and traditional routers is it doesn't need specialized or additional hardware.
• 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.
OSPF—An Interior Gateway Routing Protocol
BGP—The Exterior Gateway Routing
Protocol
✔ Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing
and reachability information among autonomous systems (AS) on the Internet.
✔ BGP is one of a family of IP Routing protocols, and is an Exterior Gateway Protocol (EGP) designed to
distribute routing information between ASs.