CN Unit III
CN Unit III
CN Unit III
NETWORK LAYER
Switching : Packet Switching - Internet protocol - IPV4 – IP Addressing – Subnetting - IPV6,
ARP, RARP, ICMP, DHCP
NETWORK LAYER
The network layer in the TCP/IP protocol suite is responsible for the host-
to-host delivery of datagrams.
It provides services to the transport layer and receives services from the data-
link layer.
The network layer translates the logical addresses into physical addresses
It determines the route from the source to the destination and also manages the
traffic problems such as switching, routing and controls the congestion of
datapackets.
The main role of the network layer is to move the packets from sending
host tothe receiving host.
SWITCHING
o The technique of transferring the information from one computer network to
another network is known as switching.
o Switching in a computer network is achieved by using switches.
o A switch is a small hardware device which is used to join multiple computers
together with one local area network (LAN).
o Switches are devices capable of creating temporary connections between two or more
devices linked to the switch.
o Switches are used to forward the packets based on MAC addresses.
o A Switch is used to transfer the data only to the device that has been addressed. It
verifies the destination address to route the packet appropriately.
o It is operated in full duplex mode.
o It does not broadcast the message as it works with limited bandwidth.
Advantages of Switching:
o Switch increases the bandwidth of the network.
o It reduces the workload on individual PCs as it sends the information to only that
device which has been addressed.
o It increases the overall performance of the network by reducing the traffic on the
network.
o There will be less frame collision as switch creates the collision domain for each
connection.
Disadvantages of Switching:
o A Switch is more expensive than network bridges.
o A Switch cannot determine the network connectivity issues easily.
o Proper designing and configuration of the switch are required to handle multicast
packets.
2. Data transfer - Once the circuit has been established, data and voice are
transferred from the source to the destination. The dedicated connection remains as long
as the end parties communicate.
Disadvantages
Circuit switching establishes a dedicated connection between the end parties. This
dedicated connection cannot be used for transmitting any other data, even if the data
load is very low.
Bandwidth requirement is high even in cases of low data volume.
There is underutilization of system resources. Once resources are allocated to a
particular connection, they cannot be used for other connections.
Time required to establish connection may be high.
It is more expensive than other switching techniques as a dedicated path is
required for each connection.
PACKET SWITCHING
o The packet switching is a switching technique in which the message is sent in one go, but
it is divided into smaller pieces, and they are sent individually.
o The message splits into smaller pieces known as packets and packets are given a unique
number to identify their order at the receiving end.
o Every packet contains some information in its headers such as source address,
destination address and sequence number.
o Packets will travel across the network, taking the shortest path as possible.
o All the packets are reassembled at the receiving end in correct order.
o If any packet is missing or corrupted, then the message will be sent to resend the
message.
o If the correct order of the packets is reached, then the acknowledgment message will be
sent.
Advantages of Packet Switching:
o Cost-effective: In packet switching technique, switching devices do not require
massive secondary storage to store the packets, so cost is minimized to some extent.
Therefore, we can say that the packet switching technique is a cost- effective
technique.
o Reliable: If any node is busy, then the packets can be rerouted. This ensures that the
Packet Switching technique provides reliable communication.
o Efficient: Packet Switching is an efficient technique. It does not require any
established path prior to the transmission, and many users can use the same
communication channel simultaneously, hence makes use of available bandwidth very
efficiently.
Routing Table
In this type of network, each switch (or packet switch) has a routing table which is based on the
destination address. The routing tables are dynamic and are updated periodically. The
destination addresses and the corresponding forwarding output ports are recorded in the tables.
Example :
Source A sends a frame to Source B through Switch 1, Switch 2 and Switch 3.
Types of Virtual Circuits
There are two broad classes of Virtual Circuits.
They are
1. PVC – Permanent Virtual Circuit
Network Administrator will configure the state
The virtual circuit is permanent (PVC)
PACKET SWITCHING
CIRCUIT
SWITCHING
Virtual Circuit Switching Datagram Switching
A dedicated path exists A dedicated path exists for No dedicated path exists for
for data transfer data transfer data transfer
All the packets take the All the packets take the All the packets may not take
same path same path the same path
MESSAGE SWITCHING
IP - INTERNET PROTOCOL
The Internet Protocol is the key tool used today to build scalable,
heterogeneous internetworks.
IP runs on all the nodes (both hosts and routers) in a collection of networks
IP defines the infrastructure that allows these nodes and networks to function as a
single logical internetwork.
IP SERVICE MODEL
Service Model defines the host-to-host services that we want to provide
The main concern in defining a service model for an internetwork is that we can
provide a host-to-host service only if this service can somehow be provided over each
of the underlying physical networks.
The Internet Protocol is the key tool used today to build scalable, heterogeneous
internetworks.
The IP service model can be thought of as having two parts:
A GLOBAL ADDRESSING SCHEME - which provides a way to
identify all hosts in the internetwork
A DATAGRAM DELIVERY MODEL – A connectionless model of data
delivery.
FIELD DESCRIPTION
Version Specifies the version of IP. Two versions exists – IPv4 and IPv6.
HLen Specifies the length of the header
TOS An indication of the parameters of the quality of service
(Type of Service) desired such as Precedence, Delay, Throughput and Reliability.
Length Length of the entire datagram, including the header. The maximum
size of an IP datagram is 65,535(210 )bytes
Ident Uniquely identifies the packet sequence number.
(Identification) Used for fragmentation and re-assembly.
Example:
The original packet starts at the client; the fragments are reassembled at the
server.
The value of the identification field is the same in all fragments, as is the value of the
flags field with the more bit set for all fragments except the last.
Also, the value of the offset field for each fragment is shown.
Although the fragments arrived out of order at the destination, they can be
correctly reassembled.
The value of the offset field is always relative to the original datagram.
Even if each fragment follows a different path and arrives out of order, the final
destination host can reassemble the original datagram from the
fragments received (if none of them is lost) using the following strategy:
1) The first fragment has an offset field value of zero.
2) Divide the length of the first fragment by 8. The second fragment has an offset
value equal to that result.
3) Divide the total length of the first and second fragment by 8. The third
fragment has an offset value equal to that result.
4) Continue the process. The last fragment has its M bit set to 0.
5) Continue the process. The last fragment has a more bit value of 0.
Reassembly:
Reassembly is done at the receiving host and not at each router.
To enable these fragments to be reassembled at the receiving host, they all carry
the same identifier in the Ident field.
This identifier is chosen by the sending host and is intended to be unique
among all the datagrams that might arrive at the destination from this source over
some reasonable time period.
Since all fragments of the original datagram contain this identifier, the
reassembling host will be able to recognize those fragments that go together.
For example, if a single fragment is lost, the receiver will still attempt to
reassemble the datagram, and it will eventually give up and have to garbage- collect
the resources that were used to perform the failed reassembly.
Hosts are now strongly encouraged to perform “path MTU discovery,” a process by
which fragmentation is avoided by sending packets that are small
enough to traverse the link with the smallest MTU in the path from sender to
receiver.
IPV4 ADDRESSES
The identifier used in the IP layer of the TCP/IP protocol suite to identify the
connection of each device to the Internet is called the Internet address or IP
address.
Internet Protocol version 4 (IPv4) is the fourth version in the development of the
Internet Protocol (IP) and the first version of the protocol to be widely
deployed.
IPv4 is described in IETF publication in September 1981.
The IP address is the address of the connection, not the host or the router. An IPv4
address is a 32-bit address that uniquely and universally defines the connection .
If the device is moved to another network, the IP address may be changed.
IPv4 addresses are unique in the sense that each address defines one, and only one,
connection to the Internet.
If a device has two connections to the Internet, via two networks, it has two
IPv4 addresses.
Pv4 addresses are universal in the sense that the addressing system must be
accepted by any host that wants to be connected to the Internet.
In binary notation, an IPv4 address is displayed as 32 bits. To make the address more
readable, one or more spaces are usually inserted between bytes (8 bits).
CLASSFUL ADDRESSING
An IPv4 address is 32-bit long(4 bytes).
An IPv4 address is divided into sub-classes:
Classful Network Architecture
Class A
In Class A, an IP address is assigned to those networks that contain a large
number of hosts.
The network ID is 8 bits long.
The host ID is 24 bits long.
In Class A, the first bit in higher order bits of the first octet is always set to 0 and
the remaining 7 bits determine the network ID.
The 24 bits determine the host ID in any network.
The total number of networks in Class A = 2 7 = 128 network address
The total number of hosts in Class A = 2 24 - 2 = 16,777,214 host address
Class B
In Class B, an IP address is assigned to those networks that range from small-
sized to large-sized networks.
The Network ID is 16 bits long.
The Host ID is 16 bits long.
In Class B, the higher order bits of the first octet is always set to 10, and the
remaining14 bits determine the network ID.
The other 16 bits determine the Host ID.
The total number of networks in Class B = 2 14 = 16384 network address
The total number of hosts in Class B = 2 16 - 2 = 65534 host address
Class C
In Class C, an IP address is assigned to only small-sized networks.
The Network ID is 24 bits long.
The host ID is 8 bits long.
In Class C, the higher order bits of the first octet is always set to 110, and the
remaining 21 bits determine the network ID.
The 8 bits of the host ID determine the host in a network.
The total number of networks = 2 21 = 2097152 network address
The total number of hosts = 2 8 - 2 = 254 host address
Class D
In Class D, an IP address is reserved for multicast addresses.
It does not possess subnetting.
The higher order bits of the first octet is always set to 1110, and the remaining bits
determines the host ID in any network.
Class E
In Class E, an IP address is used for the future use or for the research and
development purposes.
It does not possess any subnetting.
The higher order bits of the first octet is always set to 1111, and the remaining bits
determines the host ID in any network.
Address Depletion in Classful Addressing
The reason that classful addressing has become obsolete is address depletion.
Since the addresses were not distributed properly, the Internet was faced with the
problem of the addresses being rapidly used up.
This results in no more addresses available for organizations and individuals that
needed to be connected to the Internet.
To understand the problem, let us think about class A.
This class can be assigned to only 128 organizations in the world, but each
organization needs to have a single network with 16,777,216 nodes .
Since there may be only a few organizations that are this large, most of the
addresses in this class were wasted (unused).
Class B addresses were designed for midsize organizations, but many of the
addresses in this class also remained unused.
Class C addresses have a completely different flaw in design. The number of
addresses that can be used in each network (256) was so small that most
companies were not comfortable using a block in this address class.
Class E addresses were almost never used, wasting the whole class.
Subnetting
In subnetting, a class A or class B block is divided into several subnets.
Each subnet has a larger prefix length than the original network.
For example, if a network in class A is divided into four subnets, each subnet has a
prefix of nsub = 10.
At the same time, if all of the addresses in a network are not used, subnetting allows
the addresses to be divided among several organizations.
CLASSLESS ADDRESSING
In 1996, the Internet authorities announced a new architecture called classless
addressing.
In classless addressing, variable-length blocks are used that belong to no
classes.
We can have a block of 1 address, 2 addresses, 4 addresses, 128 addresses, and so on.
In classless addressing, the whole address space is divided into variable length
blocks.
The prefix in an address defines the block (network); the suffix defines the node
(device).
Theoretically, we can have a block of 2 0, 21, 22, 232 addresses.
The number of addresses in a block needs to be a power of 2. An organization can be
granted one block of addresses.
Address Aggregation
One of the advantages of the CIDR strategy is address aggregation
(sometimes called address summarization or route summarization).
When blocks of addresses are combined to create a larger block, routing can be
done based on the prefix of the larger block.
ICANN assigns a large block of addresses to an ISP.
Each ISP in turn divides its assigned block into smaller subblocks and grants the
subblocks to its customers.
Limited-broadcast Address
The only address in the block 255.255.255.255/32 is called the limited-
broadcast address.
It is used whenever a router or a host needs to send a datagram to all devices in a
network.
The routers in the network, however, block the packet having this address as the
destination;the packet cannot travel outside the network.
Loopback Address
The block 127.0.0.0/8 is called the loopback address.
A packet with one of the addresses in this block as the destination address never
leaves the host; it will remain in the host.
Private Addresses
Four blocks are assigned as private addresses: 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16, and 169.254.0.0/16.
Multicast Addresses
The block 224.0.0.0/4 is reserved for multicast addresses.
SUBNETTING:
When a bigger network is divided into smaller networks, to maintain security, then that
is known as Subnetting. So, maintenance is easier for smaller networks. For example, if we consider a class
A address, the possible number of hosts is 224 for each network, it is obvious that it is difficult to maintain
such a huge number of hosts, but it would be quite easier to maintain if we divide the network into small
parts.
Uses of Subnetting
Subnetting helps in organizing the network in an efficient way which helps in
expanding the technology for large firms and companies.
Subnetting is used for specific staffing structures to reduce traffic and maintain order and
efficiency.
Subnetting divides domains of the broadcast so that traffic is routed efficiently, which helps
in improving network performance.
Subnetting is used in increasing network security.
A Subnet is created from the bits taken from the Host ID.
To understand about this concept let take an example of a network this belongs to class C.
Our goal is to create to build a network. The capacity of each network must be Thirty (30) Devices.
We have three networks of type Class C Network based on IPv4 Addressing.
Each Class C Network can provide Two Hundred and Fifty Four (254) Internet Protocol Addresses. The
Capacity of each device which we require is very less than the Capacity which we require.
So, now we divide the four networks based on the requirement. Let us see how this division
happens.
We have four Class C Networks of imaginary Internet Protocol (IP) Addresses like:
Network 1 : 255.147.1.0
Network 2 : 255.147.2.0
Network 3 : 255.147.3.0
Network 4 : 255.147.4.0
We know that each network can produce 254 IP Addresses alone. This means four networks can produce
254 * 4 = 1016 (Thousand and Sixteen ) Internet Protocol Addresses can be formed. But
what we require is only thirty Internet Protocol Addresses from each Network. This means we only
need hundred and Twenty (120) IP Addresses only. This
Eight Hundred and Ninety-Six Addresses created are wasted. So, we need to use the Host ID bits wisely.
So, by some calculation we will get to know that if we take 5 bits from each network we will be able to get 30
IP Addresses from each Network.
The total number of IP Addresses creatable = 2 The total number of Host ID Bits - 2.
So, by considering we can create 30 Usable IP Addresses from each Class C Network.
So, now we have 3 more Host ID Bits left over unused. We also have different ways in using these
remaining bits.
Example:
Working of Subnets
Subnetting, as we all know, separates the network into small subnets. While each subnet permits
communication between the devices connected to it, subnets are connected together by routers. The network
technology being utilized and the connectivity requirements define the size of a subnet.
Each organization is responsible for selecting the number and size of the subnets it produces, within
the constraints of the address space available for its use.
For the construction of the subnets, we usually check the MSB (Most Significant Bit) bits of the
host ID and if found wrong we make it right. In order to create two network
subnets, we fix one of the host's MSB (Most Significant Bit) bits in the table below. We are
unable to alter network bits since doing so would alter the entire network.
We need a subnet mask to identify a subnet, which is created by substituting the number "1" for each
Network ID bit and the amount of bits we reserve for Host ID to create the subnet. A data packet
from the internet is intended to be forwarded to the specified subnet network using the subnet
mask.
A part of an address should be used as the Subnet ID is also specified by the subnet mask. In order to
apply the subnet mask to the whole network address, a binary AND operation is utilized. When
performing an AND operation, it is assumed that the result will be "true" if both inputs are. If not,
"false" is presented. This is only possible when both bits are 1.
The Subnet ID results from this. The Subnet ID is used by routers to choose the best route among the
sub - networks.
The two components that make up an IP address are the Network Prefix (sometimes called the
Network ID) and the Host ID. Depending on whether the address is Class A, B, or C, either the
Network Prefix or the Host ID must be separated. A Class B IPv4 address,
172.16.37.5, is seen in the image below. The Network Prefix is 172.16.0.0, and the Host
ID is 37.5.
We use permutations to the amount of bits set aside to form subnets if we wish to produce subnets
of varied length. Variable Length Subnet Masking is the name of this subnetting (VLSM).
After setting aside some bits to indicate the subnet, the broadcast address of a subnet is
computed by setting all the remaining bits of the host id to 1.The message is sent to all
network hosts using the broadcast address.
Example 2: An organization has a class C network address of 201.32.64.0. It uses a subnet mask of
255.255.255.248. Which of the following is NOT a valid broadcast address for any subnetworks?
1. 201.32.64.135
2. 201.32.64.240
3. 201.32.64.207
Solution:
4. 201.32.64.231
Converting the last octet of the netmask into the binary form: 255.255.255.11111000
Converting the last octet of option 1 into the binary form: 201.32.64. 10000111
Converting the last octet of option 2 into the binary form: 201.32.64. 11110000
Converting the last octet of option 3 into the binary form: 201.32.64. 11001111
Converting the last octet of option 4 into the binary form: 201.32.64. 11100111
From the above, we can see that in OPTION 1, 3, and 4, all the host bits are 1 and give the valid
broadcast address of subnetworks.
and OPTION 2, the last three bits of the Host address are not 1 therefore it’s not a valid
broadcast address.
Advantages of Subnetting
The advantages of Subnetting are mentioned below:
It provides security to one network from another network. eg) In an Organisation, the code of the
Developer department must not be accessed by another department.
It may be possible that a particular subnet might need higher network priority than others.
For example, a Sales department needs to host webcasts or video conferences.
In the case of Small networks, maintenance is easy.
Disadvantages of Subnetting
The disadvantages of Subnetting are mentioned below:
In the case of a single network, only three steps are required to reach a Process i.e Source Host to
Destination Network, Destination Network to Destination Host, and then Destination Host to
Process.
In the case of a Single Network only two IP addresses are wasted to represent Network Id and
Broadcast address but in the case of Subnetting two IP address es are wasted for each Subnet.
The cost of the overall Network also increases. Subnetting requires internal routers,
Switches, Hubs, Bridges, etc. which are very costly.
FEATURES OF IPV6
1. Better header format - IPv6 uses a new header format in which options are
separated from the base header and inserted, when needed, between the base header
and the data. This simplifies and speeds up the routing process because most of the
options do not need to be checked by routers.
2. New options - IPv6 has new options to allow for additional functionalities.
3.Allowance for extension - IPv6 is designed to allow the extension of the
protocol if required by new technologies or applications.
4. Support for resource allocation - In IPv6, the type-of-service field has been
removed, but two new fields, traffic class and flow label, have been added to enable
the source to request special handling of the packet. This mechanism can be used to
support traffic such as real-time audio and video.
Additional Features :
1. Need to accommodate scalable routing and addressing
2. Support for real-time services
3. Security support
4.Autoconfiguration -
The ability of hosts to automatically configure themselves with such
information as their own IP address and domain name.
5. Enhanced routing functionality, including support for mobile hosts
6. Transition from ipv4 to ipv6
Representation
A computer normally stores the address in binary, but it is clear that 128 bits cannot easily be handled
by humans. Several notations have been proposed to represent IPv6 addresses when they are handled
by humans. The following shows two of these notations: binary and colon hexadecimal.
Address Space
The address space of IPv6 contains 2128 addresses. This address space is 296 times the IPv4
address—definitely no address depletion—as shown, the size of the space is
GLOBAL UNICAST
Large chunks (87%) of address space are left unassigned for future use.
IPv6 defines two types of local addresses for private networks.
oLink local - enables a host to construct an address that need not be
globally unique.
oSite local - allows valid local address for use in a isolated site with
several subnets.
Reserved addresses start with prefix of eight 0's.
oUnspecified address is used when a host does not know its address
oLoopback address is used for testing purposes before connecting
oCompatible address is used when IPv6 hosts uses IPv4 network
o Mapped address is used when a IPv6 host communicates with a IPv4 host
IPv6 defines anycast address, assigned to a set of interfaces.
Packet with anycast address is delivered to only one of the nearest interface.
IPv4 address is mapped to IPv6 address by prefixing the 32-bit IPv4 address with 2
bytes of 1s and then zero-extending the result to 128 bits.
For example,
128. 96.33.81 → : : FFFF : 128.96.33.81
This notation is called as CIDR notation or slash notation.
Extension Headers
Extension header provides greater functionality to IPv6.
Base header may be followed by six extension headers.
Each extension header contains a NextHeader field to identify the header
following it.
Hop-by-Hop — source host passes information to all routers visited by the packet
Destination — source host information is passed to the destination only.
Source Routing — routing information provided by the source host.
Fragmentation — In IPv6, only the source host can fragment. Source uses a path MTU
discovery technique to find smallest MTU on the path.
Authentication — used to validate the sender and ensures data integrity.
ESP (Encrypted Security Payload) — provides confidentiality against
eavesdropping.
ADVANCED CAPABILITIES OF IPV6
Auto Configuration — Auto or stateless configuration of IP address to hosts
without the need for a DHCP server, i.e., plug and play.
Advanced Routing — Enhanced routing support for mobile hosts is provided.
Additional Functions ― Enhanced routing functionality with support formobile hosts.
Security ― Encryption and authentication options provide confidentiality and
integrity.
Resource allocation ― Flow label enables the source to request specialhandling of
real-time audio and video packets
ADVANTAGES OF IPV6
Address space ― IPv6 uses 128-bit address whereas IPv4 uses 32-bit address.
Hence IPv6 has huge address space whereas IPv4 faces address shortage
problem.
Header format ― Unlike IPv4, optional headers are separated from base header
in IPv6. Each router thus need not process unwanted addition
information.
Extensible ― Unassigned IPv6 addresses can accommodate needs of future
technologies.
Dual Stack
Tunneling strategy
Header translation
Ping
The ping program is used to find if a host is alive and responding.
The source host sends ICMP echo-request messages; the destination, if alive,
responds with ICMP echo-reply messages.
The ping program sets the identifier field in the echo-request and echo-reply message
and starts the sequence number from 0; this number is incremented by
1 each time a new message is sent.
The ping program can calculate the round-trip time.
It inserts the sending time in the data section of the message.
When the packet arrives, it subtracts the arrival time from the departure time to get the
round-trip time (RTT).
$ ping google.com
Traceroute or Tracert
The traceroute program in UNIX or tracert in Windows can be used to trace
the path of a packet from a source to the destination.
It can find the IP addresses of all the routers that are visited along the path.
The program is usually set to check for the maximum of 30 hops (routers) to be
visited.
The number of hops in the Internet is normally less than this.
$ traceroute google.com
A DHCP packet is actually sent using a protocol called the User Datagram
Protocol (UDP).