CN Unit 3 CN Unit 3
CN Unit 3 CN Unit 3
CN UNIT-3 - CN UNIT 3
                         Computer Networks(CN)
                                           Unit – 3
                                        Network Layer
Authentication Protocols (AP) − These protocols authenticate endpoints for use of services.
The two authentication protocols of PPP are
Network Control Protocols (NCPs) − These protocols are used for negotiating the parameters
and facilities for the network layer. For every higher-layer protocol supported by PPP, one NCP
is there.
Key takeaway:
A private data links securely linking two or more locations for private data services is known as a
point-to-point connection.
Point - to - Point Protocol is a communication protocol of the data link layer that is used to
transmit multiprotocol data between two directly connected computers.
What is IP?
An IP stands for internet protocol. An IP address is assigned to each device connected to a
network. Each device uses an IP address for communication. It also behaves as an identifier as
this address is used to identify the device on a network. It defines the technical format of the
packets. Mainly, both the networks, i.e., IP and TCP, are combined together, so together, they
are referred to as TCP/IP. It creates a virtual connection between the source and the
destination.
We can also define an IP address as a numeric address assigned to each device on a network.
An IP address is assigned to each device so that the device on a network can be identified
uniquely. To facilitate the routing of packets, TCP/IP protocol uses a 32-bit logical address
known as IPv4(Internet Protocol version 4).
IPv4 on its own does not provide any security feature which is vulnerable as data on the
Internet, which is a public domain, is never safe. Data has to be encrypted with some other
security application before being sent on the Internet. Data prioritization in IPv4 is not up to
date. Though IPv4 has few bits reserved for Type of Service or Quality of Service, they do not
provide much functionality.
IPv4 enabled clients can be configured manually or they need some address configuration
mechanism. There exists no technique which can configure a device to have globally unique IP
addresses.
An IP address consists of two parts, i.e., the first one is a network address, and the other one is
a host address.
What is IPv4?
IPv4 is a version 4 of IP. It is a current version and the most commonly used IP address. It is a
32-bit address written in four numbers separated by 'dot', i.e., periods. This address is unique
for each device.
The above example represents the IP address in which each group of numbers separated by
periods is called an Octet. Each number in an octet is in the range from 0-255. This address can
produce 4,294,967,296 possible unique addresses.
In today's computer network world, computers do not understand the IP addresses in the
standard numeric format as the computers understand the numbers in binary form only. The
binary number can be either 1 or 0. The IPv4 consists of four sets, and these sets represent the
octet. The bits in each octet represent a number.
Each bit in an octet can be either 1 or 0. If the bit is 1, then the number it represents will count,
and if the bit is 0, then the number it represents does not count.
To obtain 66, we put 1 under 64 and 2 as the sum of 64 and 2 is equal to 66 (64+2=66), and the
remaining bits will be zero, as shown above. Therefore, the binary bit version of 66 is 01000010.
Drawback of IPv4
Currently, the population of the world is 7.6 billion. Every user is having more than one device
connected with the internet, and private companies also rely on the internet. As we know that
IPv4 produces 4 billion addresses, which is not enough for each device connected to the
internet on a planet.
Although various techniques were invented, such as variable- length mask, network address
translation, port address translation, classes, inter-domain translation, to conserve the
bandwidth of IP address and slow down the depletion of an IP address. In these techniques,
public IP is converted into a private IP due to which the user having public IP can also use the
internet. But still, this was not so efficient, so it gave rise to the development of the next
generation of IP addresses, i.e., IPv6.
Key takeaways:
   ● An IP stands for internet protocol. An IP address is assigned to each device connected
      to a network.
   ● Each device uses an IP address for communication.
   ● It also behaves as an identifier as this address is used to identify the device on a
      network.
   ● It creates a virtual connection between the source and the destination.
   ● We can also define an IP address as a numeric address assigned to each device on a
      network.
IP
An IP stands for internet protocol. An IP address is assigned to each device connected to a
network. Each device uses an IP address for communication. It also behaves as an identifier as
this address is used to identify the device on a network. It defines the technical format of the
packets. Mainly, both the networks, i.e., IP and TCP, are combined together, so together, they
are referred to as TCP/IP. It creates a virtual connection between the source and the
destination.
We can also define an IP address as a numeric address assigned to each device on a network.
An IP address is assigned to each device so that the device on a network can be identified
uniquely. To facilitate the routing of packets, TCP/IP protocol uses a 32-bit logical address
known as IPv4(Internet Protocol version 4).
Function:
The internet protocol's main purpose is to provide hosts with addresses, encapsulate data into
packet structures, and route data from source to destination through one or more IP networks.
The internet protocol provides two main items in order to achieve these functionalities, which
are mentioned below.
    ● Format of IP packet
    ● IP Addressing system
IP packet
Until an IP packet is sent over the network, it contains two main components: a header and a
payload.
Fig 3: IP packet
   ●   The source IP address is that of the person who is sending the data.
   ●   IP address of the destination: The destination is a host that collects data from the
       sender.
   ●   Header length
   ●   Packet length
   ●   TTL (Time to Live) of a packet is the amount of hops that must occur before the packet is
       discarded.
   ●   The internet protocol's transport protocol, which can be TCP or UDP, is known as the
       transport protocol.
CIDR
CIDR stands for Classless Inter-Domain Routing, and it is an IP addressing scheme that
enhances IP address allocation. It replaces the old scheme of A, B, and C classes. This scheme
also aided in extending the life of IPv4 and reducing the size of routing tables.
CIDR IP addresses are made up of two groups of numbers, also known as groups of bits. The
network address is the most significant of these types, since it is used to define a network or a
sub-network (subnet). The host identifier is the smallest of the bit classes. The host identifier is
used to identify which network host or computer should accept incoming data packets.
Representation: It's also a 32-bit address with a special number indicating the number of bits in
the Block Id.
a. b. c. d / n
Example:
If you need to quickly figure out what IP range a given CIDR address corresponds to, the CIDR
Calculation tool comes in handy. Simply type in the CIDR address and hit the Calculate button.
The first IP, last IP, number of hosts, and other details will be returned.
Fig 4: example
Types of ARP
There are four types of Address Resolution Protocol, which is given below:
●   Proxy ARP
●   Gratuitous ARP
●   Reverse ARP (RARP)
●   Inverse ARP
Fig 5: ARP
Proxy ARP - Proxy ARP is a method through which a Layer 3 device may respond to ARP
requests for a target that is in a different network from the sender. The Proxy ARP configured
router responds to the ARP and maps the MAC address of the router with the target IP address
and fools the sender that it has reached its destination.
At the backend, the proxy router sends its packets to the appropriate destination because the
packets contain the necessary information.
Example - If Host A wants to transmit data to Host B, which is on the different network, then
Host A sends an ARP request message to receive a MAC address for Host B. The router
responds to Host A with its own MAC address pretending itself as a destination. When the data
is transmitted to the destination by Host A, it will send to the gateway so that it sends to Host B.
This is known as proxy ARP.
Gratuitous ARP - Gratuitous ARP is an ARP request of the host that helps to identify the
duplicate IP address. It is a broadcast request for the IP address of the router. If an ARP request
is sent by a switch or router to get its IP address and no ARP responses are received, so all
other nodes cannot use the IP address allocated to that switch or router. Yet if a router or switch
sends an ARP request for its IP address and receives an ARP response, another node uses the
IP address allocated to the switch or router.
There are some primary use cases of gratuitous ARP that are given below:
   ● The gratuitous ARP is used to update the ARP table of other devices.
   ● It also checks whether the host is using the original IP address or a duplicate one.
When a new system is set up or any machine that has no memory to store the IP address, then
the user has to find the IP address of the device. The device sends a RARP broadcast packet,
including its own MAC address in the address field of both the sender and the receiver
hardware. A host installed inside of the local network called the RARP-server is prepared to
respond to such a type of broadcast packet. The RARP server is then trying to locate a mapping
table entry in the IP to MAC address. If any entry matches the item in the table, then the RARP
server sends the response packet along with the IP address to the requesting computer.
Fig 6: RARP
Inverse ARP (In ARP) - Inverse ARP is inverse of the ARP, and it is used to find the IP
addresses of the nodes from the data link layer addresses. These are mainly used for the frame
relays, and ATM networks, where Layer 2 virtual circuit addressing are often acquired from
Layer 2 signaling. When using these virtual circuits, the relevant Layer 3 addresses are
available.
ARP conversions Layer 3 addresses to Layer 2 addresses. However, its opposite address can
be defined by In ARP. The In ARP has a similar packet format as ARP, but operational codes
are different.
DHCP can be implemented on local networks as well as large enterprise networks. DHCP is the
default protocol used by most routers and networking equipment. DHCP is also called RFC
(Request for comments) 2131.
DHCP is also used to configure the proper subnet mask, default gateway and DNS server
information on the node or device.
There are many versions of DHCP available for use in IPV4 (Internet Protocol Version 4) and
IPV6 (Internet Protocol Version 6).
Components of DHCP
When working with DHCP, it is important to understand all of the components. Following is the
list of components:
   ●   DHCP Server: DHCP server is a networked device running the DCHP service that holds
       IP addresses and related configuration information. This is typically a server or a router
       but could be anything that acts as a host, such as an SD-WAN appliance.
   ●   DHCP client: DHCP client is the endpoint that receives configuration information from a
       DHCP server. This can be any device like computer, laptop, IoT endpoint or anything
       else that requires connectivity to the network. Most of the devices are configured to
       receive DHCP information by default.
   ●   IP address pool: IP address pool is the range of addresses that are available to DHCP
       clients. IP addresses are typically handed out sequentially from lowest to the highest.
   ●   Subnet: Subnet is the partitioned segment of the IP networks. Subnet is used to keep
       networks manageable.
   ●   Lease: Lease is the length of time for which a DHCP client holds the IP address
       information. When a lease expires, the client has to renew it.
   ●   DHCP relay: A host or router that listens for client messages being broadcast on that
       network and then forwards them to a configured server. The server then sends
       responses back to the relay agent that passes them along to the client. DHCP relay can
       be used to centralize DHCP servers instead of having a server on each subnet.
Benefits of DHCP
There are following benefits of DHCP:
   ●   Seamless IP host configuration: The use of DHCP ensures that DHCP clients get
       accurate and timely IP configuration IP configuration parameters such as IP address,
       subnet mask, default gateway, IP address of DND server and so on without user
       intervention.
   ●   Flexibility and scalability: Using DHCP gives the administrator increased flexibility,
       allowing the administrator to easily change IP configuration when the infrastructure
       changes.
ICMP
The ICMP stands for Internet Control Message Protocol. The ICMP protocol is a network layer
protocol that hosts and routers use to notify the sender of IP datagram problems. The echo
test/reply method is used by ICMP to determine if the destination is reachable and responding.
ICMP can handle both control and error messages, but its primary purpose is to record errors
rather than to fix them. An IP datagram includes the source and destination addresses, but it
does not know the address of the previous router it passed through.
As a result, ICMP can only send messages to the source, not to the routers in the immediate
vicinity. The sender receives error messages via the ICMP protocol. The errors are returned to
the user processes via ICMP messages.
ICMP messages are sent as part of an IP datagram.
Fig 7: ICMP
Format of ICMP
Key takeaways:
   ● Address Resolution Protocol (ARP) is a communication protocol used to find the MAC
      (Media Access Control) address of a device from its IP address.
   ● This protocol is used when a device wants to communicate with another device on a
      Local Area Network or Ethernet.
   ● An IP address is assigned to each device connected to a network.
   ● CIDR IP addresses are made up of two groups of numbers, also known as groups of
      bits.
   ● It is a networking protocol used by the client system in a local area network (LAN) to
      request its IPv4 address from the ARP gateway router table.
   ● DHCP automates and centrally manages these configurations.
3.4 Routing
A Router is a process of selecting a path along which the data can be transferred from source to
the destination. Routing is performed by a special device known as a router. A Router works at
the network layer in the OSI model and internet layer in TCP/IP model A router is a networking
device that forwards the packet based on the information available in the packet header and
forwarding table.
The routing algorithms are used for routing the packets. The routing algorithm is nothing but a
software responsible for deciding the optimal path through which packets can be transmitted.
The routing protocols use the metric to determine the best path for the packet delivery. The
metric is the standard of measurement such as hop count, bandwidth, delay, current load on the
path, etc. used by the routing algorithm to determine the optimal path to the destination. The
routing algorithm initializes and maintains the routing table for the process of path
determination.
Hop count: Hop count is defined as a metric that specifies the number of passes through
internetworking devices such as a router, a packet must travel in a route to move from source to
the destination. If the routing protocol considers the hop as a primary metric value, then the path
with the least hop count will be considered as the best path to move from source to the
destination.
Delay: It is a time taken by the router to process, queue and transmit a datagram to an
interface. The protocols use this metric to determine the delay values for all the links along the
path end-to-end. The path having the lowest delay value will be considered as the best path.
Bandwidth: The capacity of the link is known as the bandwidth of the link. The bandwidth is
measured in terms of bits per second. The link that has a higher transfer rate like gigabit is
preferred over the link that has the lower capacity like 56 kb. The protocol will determine the
bandwidth capacity for all the links along the path, and the overall higher bandwidth will be
considered as the best route.
Load: Load refers to the degree to which the network resource such as a router or network link
is busy. A Load can be calculated in a variety of ways such as CPU utilization, packets
processed per second. If the traffic increases, then the load value will also be increased. The
load value changes with respect to the change in the traffic.
Reliability: Reliability is a metric factor that may be composed of a fixed value. It depends on
the network links, and its value is measured dynamically. Some networks go down more often
than others. After network failure, some network links are repaired more easily than other
network links. Any reliability factor can be considered for the assignment of reliability ratings,
which are generally numeric values assigned by the system administrator.
Types of Routing
Routing can be classified into three categories:
   ● Static Routing
   ● Default Routing
   ● Dynamic Routing
Default Routing
Default Routing is a technique in which a router is configured to send all the packets to the
same hop device, and it doesn't matter whether it belongs to a particular network or not. A
Packet is transmitted to the device for which it is configured in default routing. Default Routing is
used when networks deal with the single exit point. It is also useful when the bulk of
transmission networks have to transmit the data to the same hp device. When a specific route is
mentioned in the routing table, the router will choose the specific route rather than the default
route. The default route is chosen only when a specific route is not mentioned in the routing
table.
Key takeaway:
   ● A Router is a process of selecting a path along which the data can be transferred from
      source to the destination.
   ● Routing is performed by a special device known as a router.
   ● Default Routing is a technique in which a router is configured to send all the packets to
      the same hop device, and it doesn't matter whether it belongs to a particular network or
      not.
   ●   The term "forwarding" refers to the process of placing a packet on its way to its intended
       destination.
          1. Since the Internet today is made up of a series of connections, forwarding refers
              to the process of delivering a packet to the next hop.
   ●   Despite the fact that the IP protocol was built to be a connectionless protocol, the trend
       today is to use IP as a connection-oriented protocol based on the label attached to an IP
       datagram.
   ●   Based on the destination address, forwarding is performed.
          1. Next-hop
          2. Network- Specific Method
          3. Host-Specific Method
          4. Default Method
   ●   Label-based forwarding.
Delivery
The network layer is in charge of overseeing how packets are handled by the physical networks
under it. This is referred to as "packet distribution."
A packet may be sent to its final destination in one of two ways: direct or indirect.
Direct Delivery
   ● The packet's final destination is a host on the same physical network as the deliverer.
   ● The packet's source and destination are on the same physical network, and the packet is
       sent between the last router and the destination host.
   ● Extract the destination's network address and link it to the addresses of the networks to
       which it is connected.
           ○ If a match is found, the message is sent directly.
   ● The sender looks up the destination physical address using the destination IP address
Indirect Delivery
   ● The distribution is not on the same network as the destination host.
   ● The packet is passed from one router to the next before it enters a router that is
       connected to the same physical network.
   ● To find the IP address of the next router, the sender uses the destination IP address and
       a routing table.
Key takeaway:
   ● The term "forwarding" refers to the process of placing a packet on its way to its intended
      destination.
   ● The network layer is in charge of overseeing how packets are handled by the physical
      networks under it.
● A packet may be sent to its final destination in one of two ways: direct or indirect.
Static Routing
Static Routing is also known as Non-Adaptive Routing. It is a technique in which the
administrator manually adds the routes in a routing table. A Router can send the packets for the
destination along the route defined by the administrator. In this technique, routing decisions are
not made based on the condition or topology of the network.
Dynamic Routing
It is also known as Adaptive Routing. It is a technique in which a router adds a new route in the
routing table for each packet in response to the changes in the condition or topology of the
network. Dynamic protocols are used to discover the new routes to reach the destination. In
Dynamic Routing, RIP and OSPF are the protocols used to discover the new routes. If any route
goes down, then the automatic adjustment will be made to reach the destination. The Dynamic
protocol should have the following features: All the routers must have the same dynamic routing
protocol in order to exchange the routes. If the router discovers any change in the condition or
topology, then the router broadcasts this information to all other routers.
Key takeaway:
   ● Static Routing is also known as Non-Adaptive Routing.
   ● In Dynamic Routing, RIP and OSPF are the protocols used to discover the new routes.
A routing algorithm is a process that establishes the route or path for data packets to be
transferred from source to destination. They aid in the efficient routing of Internet traffic. After
leaving its source, a data packet can choose from a variety of paths to reach its destination. The
best path, i.e,. the “least – cost path,” that the packet can be routed through is calculated
mathematically by the routing algorithm.
   ●   Centralized algorithm - It uses global network awareness to find the cheapest route
       between source and destination nodes. As a result, it's often referred to as the global
       routing algorithm.
   ●   Isolated algorithm - Instead of collecting information from other nodes, this algorithm
       obtains routing information by using local information.
   ●   Distributed algorithm - This is a distributed, iteratively computed decentralized
       algorithm that finds the cheapest path between source and destination.
   ●   Flooding - When a data packet arrives at a router in flooding mode, it is sent to all
       outgoing links except the one on which it arrived. Uncontrolled, regulated, or selective
       flooding are all possibilities.
   ●   Random walks - This is a probabilistic algorithm in which the router sends a data packet
       to all of its neighbors at random.
Key takeaway:
   ● A routing algorithm is a process that establishes the route or path for data packets to be
      transferred from source to destination.
   ● Adaptive routing algorithms, also known as dynamic routing algorithms, make routing
      decisions based on network conditions in real time.
Congestion
When message traffic is so high that network response time is slowed, a state occurs in the
network layer.
Congestion's Effects
   ● Output suffers as the delay lengthens.
   ● Retransmission happens as the delay increases, worsening the situation.
       Imagine a bucket with a small hole in the bottom. No matter at what rate water enters the
       bucket, the outflow is at a constant rate. When the bucket is full with water additional
       water entering spills over the sides and is lost.
Similarly, each network interface contains a leaky bucket and the following steps are involved in
leaky bucket algorithm:
    ● When the host wants to send a packet, the packet is thrown into the bucket.
    ● The bucket leaks at a constant rate, meaning the network interface transmits packets at
        a constant rate.
    ● Bursty traffic is converted to uniform traffic by the leaky bucket.
    ● In practice the bucket is a finite queue that outputs at a finite rate.
The leaky bucket algorithm enforces output patterns at the average rate, no matter how bursty
the traffic is. So, in order to deal with the bursty traffic we need a flexible algorithm so that the
data is not lost. One such algorithm is the token bucket algorithm.
In the figure we see a bucket holding three tokens, with five packets waiting to be transmitted.
For a packet to be transmitted, it must capture and destroy one token. In figure (B) We see that
three of the five packets have gotten through, but the other two are stuck waiting for more
tokens to be generated.
The leaky bucket algorithm controls the rate at which the packets are introduced in the network,
but it is very conservative in nature. Some flexibility is introduced in the token bucket algorithm.
In the token bucket, algorithm tokens are generated at each tick (up to a certain limit). For an
incoming packet to be transmitted, it must capture a token and the transmission takes place at
the same rate. Hence some of the busty packets are transmitted at the same rate if tokens are
available and thus introduces some amount of flexibility in the system.
Formula: M * s = C + ρ * s
Key takeaway:
   ● When message traffic is so high that network response time is slowed, a state occurs in
      the network layer.
   ● The leaky bucket algorithm enforces output patterns at the average rate, no matter how
      bursty the traffic is. So, in order to deal with the bursty traffic we need a flexible algorithm
      so that the data is not lost.
3.9 IPv6
Internet Protocol version 6 (IPv6) is the latest revision of the Internet Protocol (IP) and the first
version of the protocol to be widely deployed. IPv6 was developed by the Internet Engineering
Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion. The
Internet has grown exponentially and the address space allowed by IPv4 is saturating.
There is a requirement of protocol which can satisfy the need of future Internet addresses which
are expected to grow in an unexpected manner. Using features such as NAT, has made the
Internet discontinuous i.e. one part which belongs to intranet, primarily uses private IP
addresses; which has to go through a number of mechanisms to reach the other part, the
Internet, which is on public IP addresses.
What is IPv6?
IPv4 produces 4 billion addresses, and the developers think that these addresses are enough,
but they were wrong. IPv6 is the next generation of IP addresses. The main difference between
IPv4 and IPv6 is the address size of IP addresses. The IPv4 is a 32-bit address, whereas IPv6
is a 128-bit hexadecimal address. IPv6 provides a large address space, and it contains a simple
header as compared to IPv4.
It provides transition strategies that convert IPv4 into IPv6, and these strategies are as follows:
   ●   Dual stacking: It allows us to have both the versions, i.e., IPv4 and IPv6, on the same
       device.
   ●   Tunneling: In this approach, all the users have IPv6 and communicate with an IPv4
       network to reach IPv6.
   ●   Network Address Translation: The translation allows the communication between the
       hosts having a different version of IP.
This hexadecimal address contains both numbers and alphabets. Due to the usage of both the
numbers and alphabets, IPv6 is capable of producing over 340 undecillion (3.4*1038) addresses.
IPv6 is a 128-bit hexadecimal address made up of 8 sets of 16 bits each, and these 8 sets are
separated by a colon. In IPv6, each hexadecimal character represents 4 bits. So, we need to
convert 4 bits to a hexadecimal number at a time
The above diagram shows the address format of IPv4 and IPv6. An IPv4 is a 32-bit decimal
address. It contains 4 octets or fields separated by 'dot', and each field is 8-bit in size. The
number that each field contains should be in the range of 0-255. Whereas an IPv6 is a 128-bit
hexadecimal address. It contains 8 fields separated by a colon, and each field is 16-bit in size.
Classes             IPv4 has 5 different classes of IP IPv6 does not contain classes of
                    address that includes Class A, IP addresses.
                    Class B, Class C, Class D, and
                    Class E.
Encryption     and It does not provide encryption and It  provides    encryption                          and
Authentication     authentication.                    authentication.
Packet         flow It does not provide any mechanism                      It uses a flow label field in the
identification      for packet flow identification.                        header for the packet flow
                                                                           identification.
Key takeaway:
   ● Network layer manages options pertaining to host and network addressing, managing
      sub-networks, and internet working.