Tribhuvan University
Faculty of Humanities and Social Sciences
Bachelor in Computer Application (BCA)
5Th Semester
Computer Networking (CACS-303 )
Unit-4: Network Layer 8hrs
Part I
Instructor
Tekendra Nath Yogi
Tekendranath@[Link]
8/17/2024 By: Tekendra Nath Yogi 1
Contents
• 4.1. Functions of Network Layer
• 4.2. Virtual circuits and Datagram Subnets.
• 4.3. IPv4 Addresses: Address Space, Notations, Class-full addressing and
Classless Addressing, Subnetting and Network Address Translation (NAT).
• 4.4. IPv4 Datagram Formats and fragmentation.
• 4.5. IPv6 Address structure and advantages over IPV4
• 4.6. Routing Algorithms: Distance Vector Routing, Link Stage Routing.
• 4.7. Internet Control Protocol: ARP, RARP, ICMP.
• 4.8. Routing Protocols: OSPF, BGP, Unicast, Multicast and Broadcast.
8/17/2024 By: Tekendra Nath Yogi 2
4.1. Network Layer
• Network Layer is third layer of the OSI model as shown in figure below.
• This layer is responsible for the delivery of individual packets from the
source host to the destination host possibly across the multiple network.
8/17/2024 By: Tekendra Nath Yogi 3
4.1. Network Layer Functions
• Other responsibilities of the network layer include the following:
– Packetizing: Receives the data segments from the transport layer and
converts them into packets by adding header information.
– Internetworking: provides the logical connection between different
types of networks.
– Logical Addressing: Assign a logical address to each device in a
network.
– Routing: Determines the best optimal path out of the multiple paths
from source to the destination. For this purpose routing algorithms are
used.
– Forwarding: move packets from router’s input to appropriate router
output
8/17/2024 By: Tekendra Nath Yogi 4
4.2. Virtual circuits and Datagram Subnets
• Virtual Circuit Network:
– Call setup, maintain teardown for each call before data can flow (connection
oriented service).
– Each packet carries VC identifier (not destination host address). Every router
on source-destination path maintains “state” for each passing connection
– link, router resources (bandwidth, buffers) may be allocated to VC (dedicated
resources = predictable service)
8/17/2024 By: Tekendra Nath Yogi 5
4.2. Virtual circuits and Datagram Subnets
• Datagram Network:
– No call setup at network layer (connectionless service).
– Routers: no state about end-to-end connections
• no network-level concept of “connection”
– Packets forwarded using destination host address
• packets between same source-destination pair may take different paths
8/17/2024 By: Tekendra Nath Yogi 6
4.3.1. IPv4 Addresses: Address Space and Notations
• An Internet Protocol (IP) address is a numerical label (such as
[Link]) of a device connected to a network that uses the Internet
Protocol.
• It serves two main functions: network interface identification and
location addressing.
• Allocated by the Internet Assigned Numbers Authority (IANA), a
division of the Internet Corporation for Assigned Names and
Numbers (ICANN).
• Two versions of IP address is available:
– IPV4 and
– IPV6
8/17/2024 By: Tekendra Nath Yogi 7
4.3.1. IPv4 Addresses: Address Space and Notations
• An IPv4 address is a 32-bit address that uniquely and universally
defines the connection of a device to the Internet.
• The address space of IPv4 is 232 or 4,294,967,296.
• There are two prevalent notations for IPv4 address:
– Binary Notation: 01110101 10010101 00011101 00000010
– Dotted-Decimal Notation: [Link]
• Each byte is 8 bits, therefore, each number in dotted-decimal
notation is a value ranging from 0 to 255.
• Therefore, Address space Range is:
– [Link] to [Link] or
– 00000000 00000000 00000000 00000000 to 11111111 11111111 11111111.
11111111
8/17/2024 By: Tekendra Nath Yogi 8
4.3.1. IPv4 Addresses: Address Space and Notations
• The IP address is divided into 2 components- Net ID and Host ID.
• Network ID:
– Represents the IP Address of the network and is used to identify the network.
– Note: The bits within the network portion of the address must be identical for all devices
that reside in the same network.
• Host ID:
– Represents the IP Address of the host and is used to identify the host within the network.
– The bits within the host portion of the address must be unique to identify a specific host
within a network.
• Boundary can be anywhere.
8/17/2024 By: Tekendra Nath Yogi 9
4.3.1. IPv4 Addresses: Address Space and Notations --
Network Masks
• Network Mask also known as subnet mask defines which bits are used to
describe the Network Part and which for hosts.
– IP address: [Link]
– Subnet Mask:[Link]
• Network mask also has two Representations:
– Dotted-Decimal notation: [Link]
– Binary notation: 11111111 11111111 11100000 00000000 or /19
8/17/2024 By: Tekendra Nath Yogi 10
4.3.1. IPv4 Addresses: Address Space and Notations, --
Address types
• Within each network, there are three types of IP addresses:
– Network address
– Host address
– Broadcast address
8/17/2024 By: Tekendra Nath Yogi 11
4.3.1. IPv4 Addresses: Address Space and Notations, --
Address types
• Network address:
– A network address is an address that represents a specific network.
– It has all 0 bits in the host portion.
– E. g., IP [Link] with subnet Mask [Link]
– A network address cannot be assigned to a device.
– A device belongs to a network if it has the same subnet mask as the
network address.
8/17/2024 By: Tekendra Nath Yogi 12
4.3.1. IPv4 Addresses: Address Space and Notations, --
Address types
• Host address:
– The host portion of the address is the bits indicated by 0 bits in the subnet
mask.
– Host addresses can have any combination of bits in the host portion except for
all 0 bits (this would be a network address) or all 1 bits (this would be a
broadcast address).
– All devices within the same network, must have the same subnet mask and the
same network bits. Only the host bits will differ and must be unique.
– can be assigned to a device such as a host computer, laptop, smart phone, web
camera, printer, router, etc.
– E.g., [Link] through [Link]
8/17/2024 By: Tekendra Nath Yogi 13
4.3.1. IPv4 Addresses: Address Space and Notations, --
Address types
• Broadcast address:
– The network broadcast address has all 1 bits in the host portion
• E.g., IP [Link] with subnet mask [Link]
– Used when it is required to reach all devices on the IPv4 network.
– A broadcast address cannot be assigned to a device.
8/17/2024 By: Tekendra Nath Yogi 14
4.3.2. IPv4 Addresses: Class-full Addressing
• There are two systems in which IP Addresses are classified
– Classful Addressing System
– Classless Addressing System
• In classful addressing, the address space is divided into five classes as
shown below:
IP Address
Classes
Class A Class B Class C Class D Class E.
8/17/2024 By: Tekendra Nath Yogi 15
4.3.2. IPv4 Addresses: Class-full Addressing -- Class A
• In class A IP Address, the first 8 bits are used for the Network ID and the
remaining 24 bits are used for the Host ID as shown in figure below.
• Class A address starts with a bit 0.
• Its Range: [Link] to [Link]
• Default mask: [Link] (i.e., always 1 for Network bit and 0 for Host bit).
8/17/2024 By: Tekendra Nath Yogi 16
4.3.2. IPv4 Addresses: Class-full Addressing -- Class A
• Total number of IP Addresses available in class A = 232-1 =2147483648.
• Total Number Of Networks: 2n-1 – 2 = 28-1 – 2 = 27 – 2 =128-2 =126.
– n-1 because among n bits 1 bit for network class identification.
– 2 is subtracted because two addresses are reserved for special purpose.
– [Link] - used to designate an invalid, unknown or non-applicable target.
– [Link] - used by a host to direct traffic to itself (loop back)
• Total Number of Hosts Per Network: 2n – 2 = 224 – 2 = 16777216 – 2 =
16777214.
– 2 is subtracted because two addresses are reserved for special purpose e.g. 1st address is
used as network address and last address used as broadcast address.
• Class A is used by organizations requiring very large size networks like
NASA, Pentagon etc.
8/17/2024 By: Tekendra Nath Yogi 17
4.3.2. IPv4 Addresses: Class-full Addressing -- Class B
• In class B IP Address, the first 16 bits are used for the Network ID and the
remaining 16 bits are used for the Host ID as shown in figure below.
• Class B address starts with a bits 10.
• Its Range: [Link] to [Link]
• Default mask: [Link].
8/17/2024 By: Tekendra Nath Yogi 18
4.3.2. IPv4 Addresses: Class-full Addressing -- Class B
• Total number of IP Addresses available in class B = 232-2=1073741824.
• Total Number Of Networks: 2n-2 = 216-2 = 214 =16384.
– n-2 because among n bits 2 bit for network class identification.
• Total Number Of Hosts Per Network: 2n – 2 = 216 – 2 = 65536 – 2 =
65534.
– 2 is subtracted because two addresses are reserved for special purpose e.g. 1st address is
used as network address and last address used as broadcast address.
• Class B is used by organizations requiring medium size networks banks.
8/17/2024 By: Tekendra Nath Yogi 19
4.3.2. IPv4 Addresses: Class-full Addressing -- Class C
• In class C IP Address, the first 24 bits are used for the Network ID and the
remaining 8 bits are used for the Host ID as shown in figure below.
• Class C address starts with a bits 110.
• Its Range: [Link] to [Link]
• Default mask: [Link].
8/17/2024 By: Tekendra Nath Yogi 20
4.3.2. IPv4 Addresses: Class-full Addressing -- Class C
• Total number of IP Addresses available in class B = 232-3 =536870912.
• Total Number Of Networks: 2n-3 = 224-3 = 221 =2097152.
– n-3 because among n for network bits 3 bit for network class identification.
• Total Number Of Hosts Per Network: 2n – 2 = 28 – 2 = 256 – 2 = 254.
– 2 is subtracted because two addresses are reserved for special purpose e.g. 1st address is
used as network address and last address used as broadcast address.
• Class C is used by organizations requiring small to medium size networks.
For example- colleges, small universities, small offices etc.
8/17/2024 By: Tekendra Nath Yogi 21
4.3.2. IPv4 Addresses: Class-full Addressing– Class D
• Class D is not divided into Network ID and Host ID as shown in figure
below.
• Class D address starts with bits 1110
• Its Range: [Link] to [Link]
• Total number of IP Addresses available in class D = 232-4 = 268435456
• Class D is reserved for multicasting. In multicasting, there is no need to
extract host address from the IP Address. This is because data is not
destined for a particular host.
8/17/2024 By: Tekendra Nath Yogi 22
4.3.2. IPv4 Addresses: Class-full Addressing – Class E
• Class E is not divided into Network ID and Host ID as shown in figure
below.
• Class E address starts with bits 1111
• Its Range: [Link] to [Link]
• Total number of IP Addresses available in class E = 232-4 = 268435456
• Class E is reserved for future or experimental purposes (Only for IANA
use).
8/17/2024 By: Tekendra Nath Yogi 23
4.3.2. IPv4 Addresses: Class-full Addressing
• All the classes of IP Address are summarized in the following table-
Total Number 1st Octet Number of
Class of IP Hosts per Default Subnet
of IP Decimal Networks
Address network Mask
Addresses Range available
Class A 231 1 – 127 27 – 2 224 – 2 [Link]
Class B 230 128 – 191 214 216 – 2 [Link]
Class C 229 192 – 223 221 28 – 2 [Link]
Not
Class D 228 224 – 239 Not defined Not defined
defined
Not
Class E 228 240 – 254 Not defined Not defined
defined
8/17/2024 By: Tekendra Nath Yogi 24
4.3.2. IPv4 Addresses: Class-full Addressing --Public and
Private Addresses
• Private IP:
– For Class A: [Link]. to [Link]
– For Class B: [Link]. to [Link]
– For Class C: [Link]. to [Link]
– Automatic Private IP Address (APIPA) :[Link] to [Link]
• All remaining IP addresses are Public IP addresses.
• Private IP is used for internal purpose of organization.
• Private IP is not accessible from outside the organization where as public IP
is accessible from any where.
8/17/2024 By: Tekendra Nath Yogi 25
4.3.2. IPv4 Addresses: Class-full Addressing --Public and
Private Addresses
• Private IP are free where as public IP are not free.
• Private IP is routable ( private to private):
– Network to Network
– Subnet to subnet
• Public IP is routable (public to public):
– Network to Network
– Subnet to subnet
• Routing is not possible directly from public to private and vice versa ( For
this purpose NATing is required).
• APIPA is not routable.
8/17/2024 By: Tekendra Nath Yogi 26
4.3.3. IPv4 Addresses: IPv4 Sub-netting
A problem with a large broadcast domain is that hosts within network can generate
excessive broadcasts and negatively affect the network.
Figure: A Large Broadcast domain
8/17/2024 By: Tekendra Nath Yogi 27
4.3.3. IPv4 Addresses: IPv4 Sub-netting
The solution is to reduce the size of the network to create smaller broadcast domains in
a process called subnetting. These smaller network spaces are called subnets.
8/17/2024 By: Tekendra Nath Yogi 28
4.3.3. IPv4 Addresses: IPv4 Sub-netting
• Reasons for Segmenting Networks:
– Subnetting reduces overall network traffic and improves network
performance.
– It also enables an administrator to implement security policies such as
which subnets are allowed or not allowed to communicate together.
– It reduces the number of devices affected by abnormal broadcast traffic
due to misconfigurations, hardware/software problems, or malicious
intent.
8/17/2024 By: Tekendra Nath Yogi 29
4.3.3. IPv4 Addresses: IPv4 Sub-netting
• There are various ways of using subnets to help manage network devices.
8/17/2024 By: Tekendra Nath Yogi 30
4.3.3. IPv4 Addresses: IPv4 Sub-netting
8/17/2024 By: Tekendra Nath Yogi 31
4.3.3. IPv4 Addresses: IPv4 Sub-netting
Network administrators can create subnets using any other division that makes sense
for the network.
8/17/2024 By: Tekendra Nath Yogi 32
4.3.3. IPv4 Addresses: IPv4 Sub-netting
• IPv4 subnets are created by using one or more of the host bits as network
bits.
• The more host bits that are borrowed, the more subnets that can be defined.
• The more bits that are borrowed to increase the number of subnets reduces
the number of hosts per subnet.
8/17/2024 By: Tekendra Nath Yogi 33
4.3.3. IPv4 Addresses: IPv4 Sub-netting– Class C
• Consider a company has five departments and each department has 30
employee. Create subnets for each department.
• Solution: Here, total required number of subnets =5 and required number
of host per subnet =30
• Let us take any network in a class C:
• IP : [Link] ( 11000000.10101000.00001010.00000000)
• Mask:[Link] ≡ 11111111.11111111.11111111.00000000
• Take sufficient number of host bit to make 5 subnets
– Three bits will be sufficient to make 5 subnets, . i.e., 23=8 >5.
• Now, mask becomes: 11111111.11111111.11111111.11100000 =
[Link]
8/17/2024 By: Tekendra Nath Yogi 34
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class C
• Here, total subnets created = 8
• Total addresses needed in each subnet = 1 network + 30 host + 1
broadcast.
• Subnet 1: [Link] to 31
– Network address : [Link]
– Valid host addresses: [Link] to 30
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 2: [Link] to 63
– Network address : [Link]
– Valid host addresses: [Link] to 62
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 35
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class C
• Subnet 3: [Link] to 95
– Network address : [Link]
– Valid host addresses: [Link] to 94
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 4: [Link] to 127
– Network address : [Link]
– Valid host addresses: [Link] to 126
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 36
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class C
• Subnet 5: [Link] to 159
– Network address : [Link]
– Valid host addresses: [Link] to 158
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 6: [Link] to 191
– Network address : [Link]
– Valid host addresses: [Link] to 190
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 37
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class C
• Subnet 7: [Link] to 223
– Network address : [Link]
– Valid host addresses: [Link] to 222
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 8: [Link] to 255
– Network address : [Link]
– Valid host addresses: [Link] to 254
– Broadcast address: [Link]
– Subnet mask: [Link]
• Any five can be used other three can be keep or sell.
8/17/2024 By: Tekendra Nath Yogi 38
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class B
• Example: Consider a company has two departments and each department
has 18000 employee. Create subnets for each department.
• Solution: Here, total required no. of subnets =2 and required number of
host per subnet = 18000
• Let us take any network in a class B:
• IP : [Link]
• Mask:255.255. 0.0 ≡ 11111111.11111111. 00000000.00000000
• Take sufficient number of host bit to make 2 subnets
– One bits will be sufficient to make 2 subnets, . i.e., 21=2 >=2.
• Now, mask becomes: 11111111.11111111. 10000000.00000000
255.255. 128.0
8/17/2024 By: Tekendra Nath Yogi 39
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class B
• Here, total subnets created = 2
• Host per subnet = 65536/2 =32768 which is sufficient for 18002 required
addresses per subnet.
– Total addresses needed in each subnet = 1 network + 18000 host + 1 broadcast.
• Subnet 1: [Link] to [Link] because there could be only 215 hosts
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 2: [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 40
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class A
• Example : Consider a company has two departments and each department
has 4004304 employee. Create subnets for each department.
• Solution: Here, total required no. of subnets =2 and required number of
host per subnet = 4004304
• Let us take any network in a class A:
• IP : [Link]
• Mask:255. 0. 0.0 ≡ 11111111. 00000000. 00000000.00000000
• Take sufficient number of host bit to make 2 subnets
– One bits will be sufficient to make 2 subnets, . i.e., 21=2 >=2.
• Now, mask becomes: 11111111. 10000000. 00000000.00000000
255.128. 0.0
8/17/2024 By: Tekendra Nath Yogi 41
4.3.3. IPv4 Addresses: IPv4 Sub-netting – Class A
• Here, total subnets created = 2
• Host per subnet = 8388608/2 =4194304 which is sufficient for 4004306
required addresses per subnet.
– Total addresses needed in each subnet = 1 network + 4004304 host + 1 broadcast.
• Subnet 1: [Link] to [Link] because there could be only 223 hosts
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
• Subnet 1: [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 42
4.3.4. IPv4 Addresses: Classless Addressing
• In classful addressing, a large part of the available addresses were wasted.
• Classful addressing is replaced with classless addressing.
• Also known as Classless Inter Domain Routing (CIDR).
• In CIDR, a block of addresses can be defined as: x.y.z.t /n
– x.y.z.t defines one of the addresses and
– The /n defines the mask (network prefix).
– IP network prefix tells the number of bits used for the identification of network.
– Remaining bits are used for the identification of hosts in the network.
• E.g., [Link]/28
– IP: 11001101 00010000 00100101 00100111
– Mask: 11111111 11111111 11111111 11110000.
8/17/2024 By: Tekendra Nath Yogi 43
4.3.4. IPv4 Addresses: Classless Addressing
• Features of IP addresses in CIDR:
– The first address in the block can be found by setting the rightmost 32
− n bits to 0s. Here, n represents number of network bits or prefix.
– The last address in the block can be found by setting the rightmost 32
− n bits to 1s.
– The number of addresses in the block can be found by using the
formula 232−n.
• The number of addresses is a power of 2. e.g., 2, 4, 8, 16,….
– All the IP Addresses in the CIDR block must be contiguous.
8/17/2024 By: Tekendra Nath Yogi 44
4.3.4. IPv4 Addresses: Classless Addressing
• Example 1: A block of addresses is granted to a small organization. Let
one of the addresses is [Link]/28. What is the total number of
addresses, first address, and last address in the block?
• Solution
– The value of n is 28, which means that number of addresses is 2 32−28 or 16.
– The binary representation of the given address is: 11001101 00010000 00100101
00100111
– If we set 32−28 rightmost bits to 0, we get first address of a block, that is 11001101
00010000 00100101 0010000 or [Link].
– If we set 32 − 28 rightmost bits to 1, we get last address of a block, that is 11001101
00010000 00100101 00101111 or [Link]
8/17/2024 By: Tekendra Nath Yogi 45
4.3.4. IPv4 Addresses: Classless Addressing
Figure: A block of 16 addresses granted to a small organization
8/17/2024 By: Tekendra Nath Yogi 46
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM
• In Fixed length subnet mask subnetting (FLSM), all subnets are of equal
size and have equal number of hosts results in a wastage of IP addresses.
• Solution: Variable Length Subnet Mask (VLSM)
– A subnet design that uses more than one mask in the same network.
– It is used to increase the usability of subnets as they can be of variable size.
FLSM VLSM
8/17/2024 By: Tekendra Nath Yogi 47
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM Example
• Suppose there is an administrator that has four departments to manage. These
are sales department with 120 computers, development department with 50
computers, accounts department with 26 computers and management
department with 5 computers. If the administrator has IP [Link]/24,
department wise IPs can be allocated by following these steps:
• Given,
– IP: [Link] = 11000000.10101000.00000001.00000000
– Mask: [Link] ≡ 111111111.111111111.11111111.00000000
• Arrange all the subnets in descending order based on the subnet size as:
– Sales: 120
– Development: 50
– Accounts: 26
– Management: 5
8/17/2024 By: Tekendra Nath Yogi 48
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM Example
• For sales department number of users (hosts or computers) : 120
• For 120 users 7 host bits required so, subnet mask will become
111111111.111111111.11111111.10000000 = = [Link]
• IP range for sales department: [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 49
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM Example
• For development department number of users (hosts) : 50
• For 50 users 6 host bits required so, subnet mask will become
111111111.111111111.11111111.11000000 = = [Link]
• For development department IP Range: [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 50
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM Example
• For account department number of users (hosts) : 26
• For 26 users 5 host bits required so, subnet mask will become
111111111.111111111.11111111.11100000 == [Link]
• For account department IP Range: [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 51
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM Example
• For management department number of users (hosts) : 5
• For 5 users 3 host bits required so, subnet mask will become
111111111.111111111.11111111.11111000 = = [Link]
• For management department IP Range [Link] to [Link]
– Network address : [Link]
– Valid host addresses: [Link] to [Link]
– Broadcast address: [Link]
– Subnet mask: [Link]
8/17/2024 By: Tekendra Nath Yogi 52
4.3.5. IPv4 Addresses: IPv4 Sub-netting – VLSM class work
• Suppose there is an administrator that has six departments to manage.
These are sales department with 100 computers, development department
with 45 computers, accounts department with 25 computers management
department with 12 computers library department with 5 computers and
security department with 2 computers. If the administrator has IP
[Link]/24, How the administrator allocate IP to each department by
using VLSM.
8/17/2024 By: Tekendra Nath Yogi 53
4.3.6. IPv4 Addresses: NATing
• Possible to use multiple private addresses within organization network and
single public address to access the internet by using the concept of NATing.
Figure: A NAT implementation
8/17/2024 By: Tekendra Nath Yogi 54
4.3.6. IPv4 Addresses: NATing
• When a packet traverse outside the local network, then NAT converts that
private IP address to a public IP address. When a packet enters the local
network, the public IP address is converted to a private IP address.
Figure: Addresses in a NAT
8/17/2024 By: Tekendra Nath Yogi 55
4.3.6. IPv4 Addresses: NATing
8/17/2024 By: Tekendra Nath Yogi 56
4.3.6. IPv4 Addresses: NATing
• Advantages of NAT:
– NAT conserves legally registered IP addresses.
– It provides privacy as the device’s IP address, sending and receiving the traffic, will be
hidden.
– Eliminates address renumbering when a network evolves.
• Disadvantage of NAT:
– Translation results in switching path delays.
– Certain applications will not function while NAT is enabled.
– Complicates tunneling protocols.
8/17/2024 By: Tekendra Nath Yogi 57
4.4. IPv4 Datagram Formats and
fragmentation.
4.4.1 IPV4 Datagram Formats
4.4.2. Fragmentation and Reassembly of
Datagrams
8/17/2024 By: Tekendra Nath Yogi 58
4.4.1 IPv4 Datagram Formats
Figure: IPv4 datagram format
8/17/2024 By: Tekendra Nath Yogi 59
4.4.1 IPv4 Datagram Formats
• VER: Defines the Version of IP.
• HLEN: Header Length
• Service: Defines Quality of Service.
• Total Length: Length of Data = Total Length-Header Length.
• Identification:
• When datagram is Fragmented => Identification copied to all.
• All Fragments have the same Identification.
• Helps in Reassembling the datagram.
• Flags:
• 3 Bits: Reserved, MF and DF
• DF : Don't Fragment.
• MF: More Fragment.
8/17/2024 By: Tekendra Nath Yogi 60
4.4.1 IPv4 Datagram Formats
• Fragmentation Offset: Offset value of Fragment.
• TTL: Time To Live. If TTL =0 Then Packet is discarded.
• Protocol:
• Defines Higher Layer Protocols.
• Higher Layer Protocols : TCP, UDP.
• Checksum: Computes Checksum
• Source IP Address: IP Address of Source Machine.
• Destination IP Address: IP Address of Destination Machine.
• Option: Optional Field Used for Network Testing and debugging.
8/17/2024 By: Tekendra Nath Yogi 61
4.4.2 Fragmentation and Reassembly of Datagrams
• Network links have MTU (Max Transfer Unit) - largest possible link-level frame.
– different link types, different MTUs
MTU =
2000 host
router
router MTU = 1500
host
MTU = 4000
• Don’t know MTUs of all intermediate networks in advance
• Solution: When hit network with small MTU, fragment packets
• That is, large IP datagram divided (“fragmented”) within network.
– one datagram becomes several datagrams
– “reassembled” only at final destination
– IP header bits used to identify and order related fragments
8/17/2024 By: Tekendra Nath Yogi 62
4.4.2 Fragmentation and Reassembly of Datagrams
Figure: Fragmentation and Reassembly of Datagrams
8/17/2024 By: Tekendra Nath Yogi 63
4.4.2 Fragmentation and Reassembly of Datagrams
• IP header has identification length ID fragflag offset
(x), flag, and fragmentation =4000 =x =0 =0
fields
One large datagram becomes
• Example: 4000byte
several smaller datagrams
datagram (20byte header +
3980 IP payload).
length ID fragflag offset
• MTU = 1500bytes =1500 =x =1 =0
• Frag 1: 1480bytes +
20byte header length ID fragflag offset
=1500 =x =1 =1480
• Frag 2: 1480bytes +
20byte header
length ID fragflag offset
• Frag 3: 3980-2*1480 bytes =1040 =x =0 =2960
+ 20byte header
8/17/2024 By: Tekendra Nath Yogi 64
4.4.2 Fragmentation and Reassembly of Datagrams-- Pros
• Decentralized
– Every network can choose MTU
• Connectionless
– Each (fragment of) packet contains full routing information
– Fragments can proceed independently and along different routes
• Best effort
– Fail by dropping packet
– Destination can give up on reassembly
– No need to signal sender that failure occurred
• Complex endpoints and simple routers
– Reassembly at endpoints
8/17/2024 By: Tekendra Nath Yogi 65
4.4.2 Fragmentation and Reassembly of Datagrams -- Cons
• Uses resources poorly
– Forwarding costs per packet
– Best if we can send large chunks of data
– Worst case: packet just bigger than MTU
• Poor end-to-end performance
– Loss of a fragment
8/17/2024 By: Tekendra Nath Yogi 66
4.5. IPv6 Address structure and
advantages over IPV4
4.5.1. IPv6 Address structure
4.5.2. IPv6 advantages over IPv4
8/17/2024 By: Tekendra Nath Yogi 67
4.5.1. IPv6 Address structure
• IPv6 is designed to be the successor to IPv4. IPv6 has a larger 128-bit
address space, providing 340 undecillion (i.e., 340 followed by 36 zeroes)
possible addresses.
• The depletion of IPv4 address space has been the motivating factor for
moving to IPv6.
8/17/2024 By: Tekendra Nath Yogi 68
4.5.1. IPv6 Address structure
• IPV6 address format: e.g., fe80 : 0000 : 0000 : 0000 : 0123 : 4567 : 89ab: cdef
8/17/2024 By: Tekendra Nath Yogi 69
4.5.1. IPv6 Address structure - Abbreviating IPv6 Address
• Rule 1 – Omit Leading Zeros
– The first rule to help reduce the notation of IPv6 addresses is to omit any leading 0s
(zeros) in any hextet. Here are four examples of ways to omit leading zeros:
• 01ab can be represented as 1ab
• 09f0 can be represented as 9f0
• 0a00 can be represented as a00
• 00ab can be represented as ab
– E.g., Given IPV6 address
• 2001 : 0db8 : 0000 : 1111 : 0000 : 0000 : 0000 : 0200
– Written as
• 2001 : db8 : 0 : 1111 : 0: 0: 0 : 200
8/17/2024 By: Tekendra Nath Yogi 70
4.5.1. IPv6 Address structure -- Abbreviating IPv6 Address
• Rule 2- Double Colon
– The second rule to help reduce the notation of IPv6 addresses is that a double colon (::)
can replace any single, contiguous string of one or more 16-bit hextets consisting of all
zeros.
– For example, 2001:db8:cafe:1:0:0:0:1 (leading 0s omitted) could be represented as
2001:db8:cafe:1::1. The double colon (::) is used in place of the three all-0 hextets
(0:0:0).
– The double colon (::) can only be used once within an address, otherwise there would be
more than one possible resulting address
– If an address has more than one contiguous string of all-0 hextets, best practice is to use
the double colon (::) on the longest string. If the strings are equal, the first string should
use the double colon (::).
8/17/2024 By: Tekendra Nath Yogi 71
4.5.1. IPv6 Address structure -- Abbreviating IPv6 Address
• IPv6 Prefix Length: In IPv6 subnet mask is only called the prefix length.
IPv6 does not use the dotted-decimal subnet mask notation.
• Like IPv4, the prefix length is represented in slash notation and is used to
indicate the network portion of an IPv6 address.
8/17/2024 By: Tekendra Nath Yogi 72
4.5.2. IPv6 advantages over IPv4
• Expanded Addressing: IP address size increases from 32 bits in IPv4 to
128 bits in IPv6.
• Address Autoconfiguration and Neighbour Discovery: The Neighbour
Discovery (ND) protocol facilitates the IPV6 hosts to autoconfiguration of
its own IPv6 addresses.
• Header Format Simplification: Even though IPv6 addresses are four
times longer than IPv4 addresses, the IPv6 header is only twice the size of
the IPv4 header.
• Stronger security through IPSec
• No Broadcast but Anycast Support
• Greater extensibility
8/17/2024 By: Tekendra Nath Yogi 73
Homework
• What are the major functions of the network layer? Explain in detail.
• What is IP Address? Explain the features of IPV4 address.
• What is classful and classless addressing? Explain the various classes of
IPv4 address.
• What is CIDR? Explain the features of CIDR.
• What is subnetting? Create the subnet containing 12 host each by splitting
the network with IP address [Link]/24.
• Create the subnets containing 1500 host each by splitting the network with
IP address [Link]/16.
• What is NAT? How does it work? What are its benefits?
8/17/2024 By: Tekendra Nath Yogi 74
Contd…
• What is IP? Explain the IPv4 datagram format in detail.
• What is IPv6? Explain the features of IPV6 addressing in detail.
• Compare between IPV4 and IPV6 addressing. List the advantages of IPv6
over IPv4.
• In a block of addresses, we know the IP address of one host is
[Link]/28. What are the first address (network address) and the last
address (broadcast address) in this block?
• Given the CIDR representation [Link]/20. Find the range of IP
Addresses in the CIDR block.
8/17/2024 By: Tekendra Nath Yogi 75
Thank You !
8/17/2024 By: Tekendra Nath Yogi 76