0% found this document useful (0 votes)
87 views

Module 4

This document discusses IPv4 addressing and classful addressing in networking. It covers IPv4 address representation in binary, decimal and hexadecimal notations. It also explains network addressing concepts like netid, hostid, classful addressing scheme that divides the IP address space into classes A, B, C, D and E. The document further describes how each class is divided into blocks and how to determine the number of addresses and range in each block. It provides examples of address classification and network/host extraction from IP addresses.

Uploaded by

Sai Silesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Module 4

This document discusses IPv4 addressing and classful addressing in networking. It covers IPv4 address representation in binary, decimal and hexadecimal notations. It also explains network addressing concepts like netid, hostid, classful addressing scheme that divides the IP address space into classes A, B, C, D and E. The document further describes how each class is divided into blocks and how to determine the number of addresses and range in each block. It provides examples of address classification and network/host extraction from IP addresses.

Uploaded by

Sai Silesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 127

1

Module – 4
Network Layer
By Mr. A. Swaminathan VIT Chennai

Mr. A. Swaminathan VIT Chennai


2

IPv4 Addressing

Mr. A. Swaminathan VIT Chennai


3

Introduction
▪32-bit address
▪Unique
▪Universal

Mr. A. Swaminathan VIT Chennai


Address Space 4

▪ IPv4 that defines addresses has an address space.


▪ An address space is the total number of addresses used by
the protocol.
▪ If a protocol uses N bits to define an address, the address
space is 2N
▪ IPv4 uses 32-bit addresses, which means that the address
space is 232 or 4,294,967,296 (more than 4 billion).

Mr. A. Swaminathan VIT Chennai


Notations 5

▪ Binary
▪ Dotted decimal
▪ Hexa decimal

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


Notations (ContcL.) 6

▪ 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 each octet (8 bits).
▪ Each octet is often referred to as a byte.
▪ Each number in the dotted-decimal notation is between 0
and 255.
▪ Each hexadecimal digit is equivalent to four bits.
▪ This means that a 32-bit address has 8 hexadecimal digits.
This notation is often used in network programming.
Mr. A. Swaminathan VIT Chennai
Simple Task 1
7

▪Change the following IPv4 addresses from binary


notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111

Mr. A. Swaminathan VIT Chennai


8

Simple Task 2
▪Change the following IPv4 addresses from dotted-
decimal notation to binary notation.
a. 111.56.45.78
b. 221.34.7.82

Mr. A. Swaminathan VIT Chennai


Simple Task 3 9

▪ Find the error, if any, in the following IPv4 addresses.


a. 111.56.045.78
b. 221.34.7.8.20
c. 75.45.301.14
d. 11100010.23.14.67

Mr. A. Swaminathan VIT Chennai


10

Simple Task 4

▪Change the following IPv4 addresses from


binary notation to hexadecimal notation.
a. 10000001 00001011 0000101111101111
b. 1100000110000011 0001101111111111

Mr. A. Swaminathan VIT Chennai


11

Bitwise Not Operation

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Bitwise AND Operation 12

▪ When at least one of the numbers is 0 or 255, the AND


operation selects the smaller byte (or one of them if equal).
▪ When none of the two bytes is either 0 or 255, we can write
each byte as the sum of eight terms, where each term is a
power of 2.
▪ We then select the smaller term in each pair (or one of
them if equal) and add them to get the result.

Mr. A. Swaminathan VIT Chennai


Bitwise AND Operation 13

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Bitwise OR Operation 14

Source: Data Communications and Networking – Behrouz A. Forouzan

1. When at least one of the two bytes is 0 or 255, the OR operation


selects the larger byte (or one of them if equal).
2. When none of the two bytes is 0 or 255, we can write each byte as
the sum of eight terms, where each term is a power of 2.
3.We then select the larger term in each pair (or one of them if equal)
and add them to get the result of OR operation.
Mr. A. Swaminathan VIT Chennai
Bitwise OR Operation 15

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


16

Classful Addressing

Mr. A. Swaminathan VIT Chennai


17

Classful Addressing

▪ Concept of classes
▪ In classful addressing, the address space is divided into
five classes:
Class A
Ciass B
Class C
Class D
Class E
Mr. A. Swaminathan VIT Chennai
18
Classful Addressing ( Contd..)

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
19

Classful Addressing ( Contd..)

▪ Find the class of each address:


a. 00000001 00001011 00001011 11101111
b.11000001 10000011 00011011 11111111
c.10100111 11011011 10001011 01101111
d.11110011 10011011 11111011 00001111

Mr. A. Swaminathan VIT Chennai


20

Classful Addressing (Contd..)


▪ Find the class of each address:
a. 227.12.14.87
b. 193.14.56.22
c. 14.23.120.8
d. 252.5.15.111

Mr. A. Swaminathan VIT Chennai


21
Netid and Hostid
▪In classful addressing, an IP address in classes
A, B, and C is divided into netid and hostid

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
22
Classes and Blocks

▪In classful addressing, each class is divided into


a fixed number of blocks with each block
having a fixed size.

Mr. A. Swaminathan VIT Chennai


Blocks in Class A
23

▪ Since only 1 byte in class A defines the netid and the


leftmost bit should be 0, the next 7 bits can be changed
to find the number of blocks in this class.
▪ Therefore, class A is divided into 27 = 128 blocks

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Blocks in Class B
24

▪ Since 2 bytes in class B define the class and the two leftmost bit
should be 10 (fixed), the next 14 bits can be changed to find the
number of blocks in this class.
▪ Therefore, class B is divided into 214 = 16,384 blocks

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Blocks in Class C 25

▪ Since 3 bytes in class C define the class and the three leftmost bits
should be 110 (fixed), the next 21 bits can be changed to find the
number of blocks in this class.
▪ Therefore, class C is divided into 221 = 2,097,152 blocks

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Two – Level Addressing 26

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Information Extraction ( Classful 27

addressing)
▪The number of addresses in the block, N, can be
found using N = 232_n.
▪To find the first address, we keep the n leftmost bits
and set the (32 - n) rightmost bits all to Os.
▪To find the last address, we keep the n leftmost bits
and set the (32 - n) rightmost bits all to Is.

Mr. A. Swaminathan VIT Chennai


Simple Task 5
28

▪ An address in a block is given as 73.22.17.25. Find the number


of addresses in the block, the first address, and the last
address.
▪ An address in a block is given as 200.11.8.45. Find the number
of addresses in the block, the first address, and the last
address.
▪ An address in a block is given as 180.8.17.9. Find the number
of addresses in the block, the first address, and the last
address
Mr. A. Swaminathan VIT Chennai
29

Mr. A. Swaminathan VIT Chennai


Source: Data Communications and Networking – Behrouz A. Forouzan
Network Address
30

▪ Network address is used in routing a packet to its destination


network.
▪ Assume that an internet is made of m networks and a router
with m interfaces.
▪ When a packet arrives at the router from any source host,
the router needs to know to which network the packet
should be sent;
▪ The router needs to know from which interface the packet
should be sent out.
Mr. A. Swaminathan VIT Chennai
Network Address ( Contd…) 31

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Network Mask 32

▪Network Mask - To extract the network address


from the destination address of a packet.
▪A network mask or a default mask in classful
addressing is a 32-bit number with n leftmost bits
all set to Is and (32 - n) rightmost bits all set to
Os.
Mr. A. Swaminathan VIT Chennai
33

Network Mask ( Contd..)

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Network Mask (Contd..)
34

▪ When the destination address (or any address in the


block)is ANDed with the default mask, the result is the
network address

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Simple Task 6 35

▪A router receives a packet with the destination


address 201.24.67.32. Show how the router finds
the network address of the packet.

Mr. A. Swaminathan VIT Chennai


36

Classful Addressing &


subnetting

Mr. A. Swaminathan VIT Chennai


37

Three – Level Addressing : Subnetting


▪ First, an organization that was granted a block in class A or B needed
to divide its large network into several subnetworks for better security
and management.
▪ Second, since the blocks in class A and B were almost depleted and
the blocks in class C were smaller than the needs of most
organizations, an organization that has been granted a block in class A
or B could divide the block into smaller subblocks and share them
with other organizations.
▪ In subnetting, a network is divided into several smaller subnetworks
(subnets) with each subnetwork having its own subnetwork address.

Mr. A. Swaminathan VIT Chennai


Subnetting 38

Source: Data Communications and Networking – Behrouz A. Forouzan Mr. A. Swaminathan VIT Chennai
Subnetting 39

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Subnetid 40

▪ Subnetting increases the length of the netid and decreases the length of
hostid.
▪ When we divide a network to s number of subnetworks, each of equal
numbers of hosts, we can calculate the subnetid for each subnetwork as

▪ n is the length of netid, nsub is the length of each subnetid, and s is the
number of subnets which must be a power of 2.

Mr. A. Swaminathan VIT Chennai


Source: Data Communications and Networking – Behrouz A. Forouzan
41

Subnetid ( Contd..)

▪Class B network into four subnetworks.


▪The value of n = 16
▪Calculate the subnet mask

Mr. A. Swaminathan VIT Chennai


42
Subnetid (Contd..)
▪ This means that the subnet mask has eighteen Is and
fourteen Os.
▪ In other words, the subnet mask is 255.255.192.0 which
is different from the network mask for class B
(255.255.0.0).

Mr. A. Swaminathan VIT Chennai


Subnetid ( Contd..) 43

▪we show that a network is divided into four


subnets, one of the addresses in subnet 2 is
141.14.120.77
▪Calculate the subnet address.

Mr. A. Swaminathan VIT Chennai


44

Subnetid (Contd..)

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Supernetting 45

▪Since class C blocks were still available but the size


of the block did not meet the requirement of new
organizations that wanted to join the Internet, one
solution was supernetting.
▪In supernetting, an organization can combine
several class C blocks to create a larger range of
addresses

Mr. A. Swaminathan VIT Chennai


46
Supernet Mask
▪A supernet mask is the reverse of a subnet mask.
▪A subnet mask for class C has more Is than the
default mask for this class.
▪A supernet mask for class C has less Is than the
default mask for this class.

Mr. A. Swaminathan VIT Chennai


47
Supernet Mask (Contd..)

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
48
Example 19.1

Change the following IPv4 addresses from binary notation to


dotted-decimal notation.

Mr. A. Swaminathan VIT Chennai


49

Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation.

Mr. A. Swaminathan VIT Chennai


50
Example 19.2

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Mr. A. Swaminathan VIT Chennai


51
Solution
We replace each decimal number with its binary
equivalent (see Appendix B).

Mr. A. Swaminathan VIT Chennai


Example 19.3 52

Find the error, if any, in the following IPv4


addresses.

Mr. A. Swaminathan VIT Chennai


53

Solution

a. There must be no leading zero (045).


b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.

Mr. A. Swaminathan VIT Chennai


54
Example 19.4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Mr. A. Swaminathan VIT Chennai


55

Solution

a. The first bit is 0. This is a class A address.


b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.

Mr. A. Swaminathan VIT Chennai


56

NOTE:
In classful addressing, the address
space is divided into five classes:
A, B, C, D, and E.

Mr. A. Swaminathan VIT Chennai


57

NOTE:

In classful addressing, a large part of the


available addresses were wasted.

Mr. A. Swaminathan VIT Chennai


58

NOTE:

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.

Mr. A. Swaminathan VIT Chennai


59

NOTE:

In IPv4 addressing, a block of


addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.

Usually, x.y.z.t is the first address in the address block

Mr. A. Swaminathan VIT Chennai


60

NOTE:

The first address in the block can be


found by setting the rightmost
32 − n bits to 0s.

Mr. A. Swaminathan VIT Chennai


Figure 19.3 A block of 16 addresses granted to a 61
small organization

We can see that the restrictions are applied to this block. The
addresses are contiguous. The number of addresses is a power of 2
(16 = 24). This block of IP addresses is represented by:
205.16.37.32/28
Source: Data Communications and Networking – Behrouz A. Forouzan Mr. A. Swaminathan VIT Chennai
62
Example 19.6

A /28 block of addresses is granted to a small


organization. We know that one of the addresses is
205.16.37.39. What is the first address in the block? What
is its x.y.z.t/n representation?

Mr. A. Swaminathan VIT Chennai


63

Solution
▪ The binary representation of the given address is
▪ 11001101 00010000 00100101 00100111
▪ If we set 32−28 rightmost bits to 0, we get
▪ 11001101 00010000 00100101 0010000 0
▪ or
205.16.37.32
▪ The block representation is 205.16.37.32/28

Mr. A. Swaminathan VIT Chennai


64

NOTES:
The last address in the block can be
found by setting the rightmost
32 − n bits to 1s.

Mr. A. Swaminathan VIT Chennai


65
Example 19.7

Find the last address for the block in Example 19.6.

Mr. A. Swaminathan VIT Chennai


Solution 66

▪ The binary representation of the given address is


▪ 11001101 00010000 00100101 00100111
▪ If we set 32 − 28 rightmost bits to 1, we get
▪ 11001101 00010000 00100101 00101111
▪ or
▪ 205.16.37.47
▪ This is actually the block shown in Figure 19.3.

Mr. A. Swaminathan VIT Chennai


67

NOTE:

The number of addresses in the block


can be found by using the formula
232−n.

Mr. A. Swaminathan VIT Chennai


Example 19.9
68
Another way to find the first address, the last address, and
the number of addresses is to represent the mask as a 32-
bit binary (or 8-digit hexadecimal) number. This is
particularly useful when we are writing a program to find
these pieces of information. In Example 19.5 the /28 can
be represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).

Find
a. The first address
b. The last address
Mr. A. Swaminathan VIT Chennai
Example 19.9 (continued) 69

Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
the result is 0 otherwise.

Mr. A. Swaminathan VIT Chennai


Example 19.9 (continued)
70

b. The last address can be found by ORing the given


addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; the result is 1 otherwise. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.

Mr. A. Swaminathan VIT Chennai


Figure 19.4 A network configuration for the block 205.16.37.32/28 71

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


72

NOTE:

The first address in a block is


normally not assigned to any device;
it is used as the network address that
represents the organization
to the rest of the world.

Mr. A. Swaminathan VIT Chennai


Figure 19.5 hierarchy in telephone numbers 73

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


74
Figure 19.6 hierarchy in IP addressing

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


75

NOTE:
Each address in the block can be
considered as a two-level
hierarchical structure:
the leftmost n bits (prefix) define
the network;
the rightmost 32 − n bits define
the host.

Mr. A. Swaminathan VIT Chennai


Figure 19.7 Configuration and addresses in a subnetted network 76

Source: Data Communications and Networking – Behrouz A. Forouzan Mr. A. Swaminathan VIT Chennai
77
Figure 19.8 Three-level hierarchy in an IPv4 address

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


Example 19.10 78

An ISP is granted a block of addresses starting with 190.100.0.0/16


(65,536 addresses). The ISP needs to distribute these addresses to
three groups of customers as follows:
a. The first group has 64 customers; each needs 256
addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs 64
addresses.
Assume the blocks of IPs are sequentially assigned. Design the
subblocks and find out how many addresses are still available after
these allocations.
Mr. A. Swaminathan VIT Chennai
Example 19.10 (continued) 79

Solution
Figure 19.9 shows the situation.
Group 1
For this group, each customer needs 256 addresses.
This means that 8 (log2 256) bits are needed to define
each host. The prefix length is then 32 − 8 = 24. The
addresses are

Mr. A. Swaminathan VIT Chennai


Example 19.10 (continued) 80

Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each
host. The prefix length is then 32 − 7 = 25. The addresses
are

Mr. A. Swaminathan VIT Chennai


Example 19.10 (continued)
81
Group 3
For this group, each customer needs 64 addresses. This
means that 6 (log264) bits are needed to each host. The
prefix length is then 32 − 6 = 26. The addresses are

Number of granted addresses to the ISP: 65,536


Number of allocated addresses by the ISP: 40,960
Number of available addresses: 24,576
Mr. A. Swaminathan VIT Chennai
Figure 19.9 An example of address allocation and distribution by an ISP 82

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Another Example on Subnetting 83

An ISP needs to allocate three subnets: Subnet 1, Subnet


2, and Subnet 3 with its acquired IP block of
223.1.17.0/24. Subnet 1 is required to support 63
interfaces, Subnet 2 is to support at least 40 interfaces,
and Subnet 3 is to support at least 95 interfaces. In
addition, values of IP addresses have the relationship:
Subnet 1 < Subnet 2 < Subnet 3.
Provide three network addresses ( of the form a.b.c.d/x)
that satisfy these constraints.

Mr. A. Swaminathan VIT Chennai


84
Subnetting

223.1.17.0/24, ip addresses are 2^(32-24) = 256

Subnet 1 needs 2^6=64, 223.1.17.0/26


last address: 223.1.17.63
Subnet 2 needs 2^6=64, 223.1.17.64/26
last address: 223.1.17.127

Subnet 3 needs 2^7 = 128, 223.1.17.128/25

Mr. A. Swaminathan VIT Chennai


19.84
85
Table 19.3 Addresses for private networks

Source: Data Communications and Networking – Behrouz A. Forouzan

Home used wireless router usually uses 192.168.1.0/24


or 192.168.0.0/24 IP block
Mr. A. Swaminathan VIT Chennai
Figure 19.10 A NAT implementation 86

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


87
Figure 19.11 Addresses in a NAT

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


NAT: Network Address Translation 88

NAT translation table


1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
sends datagram to
changes datagram
138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
source addr from
10.0.0.1, 3345 to …… ……
138.76.29.7, 5001,
S: 10.0.0.1, 3345
updates table D: 128.119.40.186, 80
10.0.0.1

1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2

138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345 4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: Reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
NAT: Network Address Translation 89

▪ 16-bit port-number field:


▪ 60,000 simultaneous connections with a single LAN-side address!
▪ NAT is controversial:
▪ violates end-to-end argument
▪ Internal computers not visible to outside
▪ Outside hosts have trouble to request service from local computers, e.g., P2P,
video conference, web hosting.
▪ address shortage should instead be solved by IPv6

Mr. A. Swaminathan VIT Chennai


90
Table 19.4 Five-column translation table

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


19-2 IPv6 ADDRESSES
91

Despite all short-term solutions, address depletion is


still a long-term problem for the Internet. This and other
problems in the IP protocol itself have been the
motivation for IPv6.

NOTE:
An IPv6 address is 128 bits long.
Mr. A. Swaminathan VIT Chennai
92

Classless addressing

Mr. A. Swaminathan VIT Chennai


Classless addressing 93

▪Variable-length blocks are used that belong to no classes.


▪ Block of 1 address, 2 addresses, 4 addresses, 128
addresses, and so on.

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Variable-length Blocks 94

▪The whole address space is divided into variable length


blocks.
▪Block of 20, 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.
Mr. A. Swaminathan VIT Chennai
Two-level Addressing 95

▪ When an organization is granted a block of addresses, the


block is actually divided into two parts, the prefix and the
suffix.
▪ The prefix plays the same role as the netid
▪ The suffix plays the same role as the hostid.
▪ All addresses in the block have the same prefix
▪ Each address has a different suffix.

Mr. A. Swaminathan VIT Chennai


Two-level Addressing 96

Source: Data Communications and Networking – Behrouz A. Forouzan


▪ The length of the prefix, n, depends on the size of the block
▪ The value of n is referred to as prefix length;
▪ The value of 32 − n is referred to as suffix length.
▪ The prefix length in classless addressing can be 1 to 32.

Mr. A. Swaminathan VIT Chennai


Simple Task 1 97

▪ What is the prefix length and suffix length if the whole


Internet is considered as one single block with 4,294,967,296
addresses?
▪ What is the prefix length and suffix length if the Internet is
divided into 4,294,967,296 blocks and each block has one
single address?
“The number of addresses in a block is inversely related to
the value of the prefix length, n. A small n means a larger
block; a large n means a small block”
Mr. A. Swaminathan VIT Chennai
Slash Notation 98

▪ The prefix length in classless addressing play a very important role when
we need to extract the information about the block from a given address in
the block.
▪ In classful addressing, the netid length is inherent in the address. Given an
address, we know the class of the address that allows us to find the netid
length (8,16, or 24).
▪ In classless addressing, the prefix length cannot be found if we are given
only an address in the block. The given address can belong to a block with
any prefix length.

Mr. A. Swaminathan VIT Chennai


Slash Notation 99

▪ In classless addressing, we need to include the prefix length to each address


if we need to find the block of the address.
▪ In this case, the prefix length, n, is added to the address separated by a
slash.
▪ The notation is informally referred to as slash notation.
▪ Classless Interdomain Routing or CIDR (pronounced cider) notation
▪ In classless addressing, we need to know one of the addresses in the block
and the prefix length to define the block.

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
Network Mask 100

▪ A network mask is a 32-bit number with the n leftmost bits


all set to 1s and the rest of the bits all set to 0s.

▪ 12.23.24.78/8, 130.11.232.156/16, 167.199.170.82/27

Mr. A. Swaminathan VIT Chennai


Extracting Block Information 101

▪ An address in slash notation (CIDR) contains all information: the first


address (network address), the number of addresses, and the last
address.
▪ The number of addresses in the block
N = 232 − n
▪ The first address (network address) in the block
First address = (any address) AND (network mask)
▪ The last address in the block can be found
Last address = (any address) OR [NOT (network mask)]
Mr. A. Swaminathan VIT Chennai
Simple Task 2 102

One of the addresses in a block is 167.199.170.82/27. Find the


number of addresses in the network, the first address, and the last
address.

One of the addresses in a block is 17.63.110.114/24. Find the number


of addresses, the first address, and the last address in the block.

One of the addresses in a block is 110.23.120.14/20. Find the number


of addresses, the first address, and the last address in the block.

Mr. A. Swaminathan VIT Chennai


Block Allocation 103

▪ The number of requested addresses, N, needs to be a


power of 2.
▪ The value of prefix length can be found from the number
of addresses in the block.
N = 232 − n,
then n = 32 − log2N.
▪ The beginning address needs to be divisible by the
number of addresses in the block.
Mr. A. Swaminathan VIT Chennai
Subnetting 104

▪Three levels of hierarchy can be created using


subnetting.
▪An organization (or an ISP) that is granted a range
of addresses may divide the range into several
subranges and assign each subrange to a
subnetwork (or subnet).

Mr. A. Swaminathan VIT Chennai


Designing Subnets 105

▪ Assume
N - the total number of addresses granted to the organization
n - the prefix length
Nsub - the assigned number of addresses to each subnetwork
nsub - The prefix length for each subnetwork
s - The total number of subnetworks

Mr. A. Swaminathan VIT Chennai


Subnetting (Contd…) 106

▪The number of addresses in each subnetwork should


be a power of 2.
▪The prefix length for each subnetwork
nsub = n + log2 (N/Nsub)
▪The starting address in each subnetwork should be
divisible by the number of addresses in that
subnetwork
Mr. A. Swaminathan VIT Chennai
Simple Task 3 107

▪An organization is granted the block 130.34.12.64/26.


The organization needs four subnetworks, each with
an equal number of hosts. Design the subnetworks
and find the information about each network.

Mr. A. Swaminathan VIT Chennai


Simple Task 4 108

▪ A n organization is granted ablock of addresses with the beginning address


14.24.74.0/24. The organization needs to have 3 subblocks of addresses to
use in its three subnets as shown below:
– One subblock of 120 addresses.
– One subblock of 60 addresses.
– One subblock of 10 addresses.

Mr. A. Swaminathan VIT Chennai


109

IPv4 Header Format

Mr. A. Swaminathan VIT Chennai


IPv4 datagram 110

▪variable-length packet
– header and payload (data)
▪The header is 20 to 60 bytes in length and
contains information essential to routing and
delivery.

Mr. A. Swaminathan VIT Chennai


111

IPv4 Packet Format

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 112

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
113

IPv4 Packet Format (Contd..)


▪ Version Number.
– The 4-bit version number (VER) field defines the version of the IPv4
protocol, which, obviously, has the value of 4.
▪ Header Length.
– The 4-bit header length (HLEN) field defines the total length of the
datagram header.
– The IPv4 datagram has a variable-length header.
– The total length is divided by 4 and the value is inserted in the field.
– The receiver needs to multiply the value of this field by 4 to find the
total length.

Mr. A. Swaminathan VIT Chennai


IPv4 Packet Format (Contd..) 114

▪ Service Type
– In the original design of the IP header, this field was
referred to as type of service (TOS), which define how the
datagram should be handled.

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 115

▪ Total Length.
– This 16-bit field defines the total length (header plus
data) of the IP datagram in bytes.
Length of data = total length − (HLEN) × 4
▪ Identification, Flags, and Fragmentation Offset.
– These three fields are related to the fragmentation of
the IP datagram when the size of the datagram is larger than
the underlying network can carry.
Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 116

Identification
▪This 16-bit field identifies a datagram originating from
the source host.
▪The combination of the identification and source IP
address must uniquely define a datagram as it leaves
the source host.
▪To guarantee uniqueness, the IP protocol uses a
counter to label the datagrams.
Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 117

Flags:
▪ The first bit is reserved (not used).
▪ The second bit is called the do not fragment bit.
▪ If its value is 1, the machine must not fragment the datagram. If it cannot
pass the datagram through any available physical network, it discards the
datagram and sends an ICMP error message to the source host.
▪ If its value is 0, the datagram can be fragmented if necessary.
▪ The third bit is called the more fragment bit.
▪ If its value is 1, it means the datagram is not the last fragment; there are
more fragments after this one.
▪ If its value is 0, it means this is the last or only fragment
Source: Data Communications and Networking – Behrouz A. Forouzan
Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 118

Fragmentation offset:

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 119

▪Fragmentation offset:

Source: Data Communications and Networking – Behrouz A. Forouzan Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 120

Time-To-Live
▪ (TTL) field is used to control the maximum number of hops (routers)
visited by the datagram.
▪ When a source host sends the datagram, it stores a number in this field.
▪ This value is approximately two times the maximum number of routers
between any two hosts.
▪ Each router that processes the datagram decrements this number by one.
▪ If this value, after being decremented, is zero, the router discards the
datagram.

Mr. A. Swaminathan VIT Chennai


IPv4 Packet Format (Contd..) 121

Protocol
▪ A datagram, for example, can carry a packet belonging to any
transport-layer protocol such as UDP or TCP.

Mr. A. Swaminathan VIT Chennai


Source: Data Communications and Networking – Behrouz A. Forouzan
IPv4 Packet Format (Contd..) 122

Header Checksum
▪ Checksum in IP covers only the header not the data.
▪ First, the value of the checksum field is set to 0.
▪ The entire header is divided into 16-bit sections and added
together.
▪ The result (sum) is complemented and inserted into the
checksum field.

Mr. A. Swaminathan VIT Chennai


IPv4 Checksum Calculation at the
Sender 123

Source: Data Communications and Networking – Behrouz A. Forouzan

Mr. A. Swaminathan VIT Chennai


IPv4 Checksum Calculation at the 124

Receiver

Source: Data Communications and Networking – Behrouz A. Forouzan


Mr. A. Swaminathan VIT Chennai
IPv4 Packet Format (Contd..) 125

Source and Destination Addresses


▪These 32-bit source and destination address
fields define the IP address of the source and
destination respectively.

Mr. A. Swaminathan VIT Chennai


IPv4 Packet Format (Contd..) 126

▪ An IPv4 packet has arrived with the first 8 bits as (01000010)2 The receiver
discards the packet. Why?
▪ In an IPv4 packet, the value of HLEN is (1000)2. How many bytes of options
are being carried by this packet?
▪ In an IPv4 packet, the value of HLEN is 5, and the value of the total length
field is (0028)16. How many bytes of data are being carried by this packet?
▪ An IPv4 packet has arrived with the first few hexadecimal digits as shown.
How many hops can this packet travel before being dropped. The data
belong to what upper layer protocol.
(45000028000100000102…)16
Mr. A. Swaminathan VIT Chennai
References 127

▪ Forouzan Behrouz, A. "Data Communication and networking." (2008).

▪ Peterson, Larry L., and Bruce S. Davie. Computer networks: a systems


approach. Elsevier, 2007.

▪ Stallings, William. Data and computer communications. Pearson Education


India, 2007.

▪ TCP/IP Protocol Suite, Behrouz A. Forouzan, McGraw-Hill Education, 4 Ed.,


2010

▪ Web Links as mentioned in source

▪ https://www.eecs.yorku.ca/course_archive/2015-
16/W/3214/CSE3214_10_PacketDelay_2016_posted.pdf
Mr. A. Swaminathan VIT Chennai

You might also like