The TCP/IP protocols
The IP protocol and IP addresses
One of the most important protocols in the TCP/IP suite is the IP
protocol.
This is used at the Internet layer of TCP/IP (i.e. the Network
layer in the OSI model) and is used to attach network addresses
to packets.
The IP protocol provides best effort delivery between network
stations.
IP routes packets on the network by using IP addresses.
1
Cont.
IPv4 Addressing Scheme and Notations:
Classful IP Addressing Vs. Classless IP addressing
Network Address Translation (NAT)
IPv6 Addressing Scheme and Notation:
Addressing Mapping
Mapping Logical to Physical Addressing:- ARP
Mapping Physical to Logical Addressing:- RARP
Internet Control Message Protocol (ICMP) Vs. Internet Group
Management Protocol (IGMP)
2
Cont.
The Internet Protocol (IP) is a protocol used for communicating data across
a packet-switched internetwork using the Internet Protocol suite, also referred
to as TCP/IP.
IP is the primary protocol in the Internet Layer of the Internet Protocol Suite
and has the task of delivering distinguished protocol datagrams (packets)
from the source host to the destination host solely based on their addresses.
For this purpose the Internet Protocol defines addressing methods and
structures for datagram encapsulation.
The first major version of addressing structure, now referred to as Internet
Protocol Version 4 (IPv4) is still the dominant protocol of the Internet,
although the successor, Internet Protocol Version 6 (IPv6), is being deployed
actively worldwide (128
bits).
3
Contd.
Communication at the network layer is host-to-host
(computer-to-
computer); a computer somewhere in the world needs to communicate
with another computer somewhere else in the world.
Usually, computers communicate through the Internet.
The packet transmitted by the sending computer may pass
through
several LANs or WANs before reaching the destination computer.
For this level of communication, we need a global addressing scheme;
we use the term IP address to mean a logical address in the network
layer of the TCP/IP protocol suite. 4
IPv4 Addresses
An IPv4 address is a 32-bit address that uniquely and universally
defines the connection of a device (for example, a computer or a
router) to the Internet.
IPv4 addresses are unique and universal.
They are unique in the sense that each address defines one, and only
one, connection to the Internet.
Two devices on the Internet can never have the same address at the
same time.
5
Address Space
A protocol such as 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
because each bit can have two different values (0 or 1) and N bits can
have 2N values.
IPv4 uses 32-bit addresses, which means that the address space is 232 or
4,294,967,296 (more than 4 billion). This means that, theoretically, if
there were no restrictions, more than 4 billion devices could be
connected to the Internet.
We will see shortly that the actual number is much less because of the
restrictions imposed on the addresses.
6
There
Notations
are two prevalent notations to show an 1Pv4 address:
binary
notation and dotted-decimal notation.
Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. Each octet
is often referred to as a byte. So it is common to hear an IPv4 address
referred to as a 32-bit address or a 4-byte address. The following is an
example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
Dotted-Decimal Notation
To make the IPv4 address more compact and easier to read, Internet
addresses are usually
(dot) separating thewritten
[Link] decimal form with
following is athe
decimal point
dotted-decimal
The notation of the above
address: 7
[Link]
Example: Dotted-decimal notation and
binary notation for an IPv4 address
8
Example 1
Change the following IPv4 addresses from binary notation
to dotted-decimal notation.
Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.
9
Example 2
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Solution
We replace each decimal number with its binary equivalent.
10
Example 3
Find the error, if any invalid IP is set , in the
following IPv4 addresses.
Solution
a. There must be no leading zero (045).
b. They 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. 11
Classful Addressing
IPv4 addressing, at its inception, used the concept of classes. This
architecture is called classful addressing.
In classful addressing, the address space is divided into five classes:
A, B, C, D, and E. Each class occupies some part of the
address
space.
12
Example 4
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. [Link]
d. [Link]
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.
13
Network ID and Host ID
In classful addressing, an IPaddress in class
A, B, or C is divided into
network ID and host ID.
These parts are of varying lengths, depending on the
class of the address.
In class A, 1 byte defines the network ID & 3 bytes
define the host ID.
In class B, 2 bytes define the network ID & 2 bytes
define the host ID.
Network Host Host Host
In class C, 3 bytes define the network ID & 1 byte
host ID. Network
defines the Network Host Host
Network Network Network Host
1 octet
st 2 octet
nd 3rd octet14
4th octet
Default Mask
Although the length of the network ID and host ID (in bits) is
predetermined in classful addressing, we can also use a mask (also called
the default mask), a 32-bit number made of contiguous 1s followed by
contiguous 0s. The masks for classes A, B, and C are shown below
The mask can help us to find the network ID and the host ID. For
example, the mask for a class A address has eight 1s, which means the
first 8 bits of any address in class A define the network ID; the next 24
bits define the host ID.
15
Address Depletion
The flaws in classful addressing scheme combined with the fast growth of
the Internet led to the near depletion of the available addresses.
Yet the number of devices on the Internet is much less than the
232 address space.
We have run out of class A and B addresses, and a class C block is too
small for most midsize organizations.
One solution that has alleviated the problem is the idea of
classless addressing.
16
Subnetting
During the era of classful addressing, subnetting was introduced.
If an organization was granted a large block in class A or B, it could
divide the addresses into several contiguous groups and assign each group
to smaller networks (called subnets) or, in rare cases, share part of the
addresses with neighbors.
Subnetting increases the number of 1s in the mask.
Subnetting is the process of borrowing bits from the HOST bits, in
order to divide the larger network into small subnets.
Subnetting does NOT give you more hosts, but actually costs you hosts.
17
Contd.
Network Network Host Host
172 16 0 0
Network Network Subnet Host
You lose two host IP Addresses for each subnet, and perhaps one
for the subnet IP address and one for the subnet broadcast IP
address.
You lose the last subnet and all of it’s hosts’ IP addresses as the
broadcast for that subnet is the same as the broadcast for the
network.
In older networks, you would have lost the first subnet, as the
subnet IP address is the same as the network IP address. (This
subnet can be used in most networks.)
18
Classless Addressing
To overcome address depletion and give more organizations access to the
Internet, classless addressing was designed and implemented.
In this scheme, there are no classes, but the addresses are still granted in
blocks.
Address Blocks
In classless addressing, when an entity, small or large, needs to be
connected to the Internet, it is granted a block (range) of
addresses.
The size of the block (the number of addresses) varies based on the
nature and size of the entity.
For example, a household may be given only two addresses; a large
organization may be given thousands of addresses.
An ISP, as the Internet service provider, may be given thousands or
Restriction
To simplify the handling of addresses, the Internet authorities
impose three restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one after another.
2. The number of addresses in a block must be a power of 2 (1, 2, 4, 8 .... ).
3. The first address must be evenly divisible by the number of addresses.
20
Contd.
The above figure shows a block of addresses, in both binary and
dotted-decimal notation, granted to a small business that needs
16 addresses.
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), and the first address is divisible by 16. The first
address, when converted to a decimal number, is 3,440,387,360,
which when divided by 16 results in 215,024,210.
21
Classless addressing Mask
A better way to define a block of addresses is to select any address in the block and
the mask.
As we discussed before, a mask is a 32-bit number in which the n leftmost bits are 1s
and the 32 - n rightmost bits are 0s.
However, in classless addressing the mask for a block can take any value from 0 to
32. It is very convenient to give just the value of n preceded by a slash (CIDR –
Classless Inter Domain Routing notation).
2𝑛 to calculate the number of subnet mask n no of 1s ne subnet
2𝑛 -2 to calculate the number of host b/c 2 bites are reserved
mask
n
Represent number of zeros in subnet mask
The address and the /n notation completely define the whole block (the first address,
the last address, and the number of addresses). 22
Q1:Find the number subnet and valid
host
The given network [Link] and mask
[Link]/28
subnet
I. What is the class of the given network?
II. Find the subnet Mask?
III. find valid host?
Answer
Change in two binary notion
11111111 11111111 11111111 11110000
II. to find subnet Mask 2𝑛 , 24
I. Class C Network because the first binary is 111
=16
IV. 2𝑛 -2 , 24 -2 = 16-2 = 14
III. to find valid host
Q2:Find the number subnet and valid
hostThe given network [Link] and subnet
mask
[Link]/30
I. What is the class of the given network?
II. Find the subnet Mask?
III. findvalid host?
Answer
Change in two binary notion
Mask 2𝑛 ,
11111111 11111111 11111111 11111100
IV.
V. Class
to findB subnet
Network
214
=16384
VI. to find valid host
First
The first address in theAddress
block can be found by setting the 32 - n
rightmost bits in the binary notation of the address to 0s.
Example 5
A block of addresses is granted to a small organization. We know
that one of the addresses is [Link]/28. What is the first
address in the block?
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 00100000
or
[Link].
25
Last
The last address in the block can be found by setting
Address
the 32 - n rightmost bits in the binary notation of
the address to 1s.
Example 6
Find the last address for the block in Example 5.
Solution
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
[Link]
26
Number of Addresses
The number of addresses in the block is the difference between the
last and first address. It can easily be found using the formula 232-n.
Example 7
Find the number of addresses in Example 5.
Solution
The value of n is 28, means that number
which
of addresses is 2 32−28 or 16.
27
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 the above example the /28 can be
represented as
1111111111111111 11111111 11110000
(twenty-eight 1s and four 0s).
Find
a. The first address
b. The last address
c. The number of addresses.
28
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.
29
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.
30
c. The of addresses can be found by
number
complementing the mask, interpreting it as a decimal
number, and adding 1 to it.
31
Examples
There are three types of Subnetting examples
I. Subnetting when given a required number
of networks
II. Subnetting when given a required number of clients
III. Given an IP address & Subnet Mask, finding
original network range (reverse engineering a
subnet problem)
32
Subnetting when given a required number of networks
Example 1: A service provider has given you the Class C network
range [Link]. Your company must break the network into 20
separate subnets.
Step 1. Determine the number of subnets and convert to binary
In this example, the binary representation of 20 = 00010100.
Step 2. Reserve required bits in subnet mask and find incremental value
The binary value of 20 subnets tells us that we need at least 5 network bits to
satisfy this requirement (since you cannot get the number 20 with any less than 5
bits – 10100)
Our original subnet mask is [Link] (Class C subnet)
The full binary representation of the subnet mask is as follows:
[Link] = 11111111.11111111.11111111.00000000
33
Cont…
We must “convert” 5 of the client bits (0) to network bits (1) in order
to satisfy the requirements:
New Mask = 11111111.11111111.11111111.11111000
If we convert the mask back to decimal, we now have the subnet mask
that will be used on all the new networks – [Link]
Our increment bit is the last possible network bit, converted back to a
binary number:
New Mask = 11111111.11111111.11111111.1111(1)000 – bit with the
parenthesis is your increment bit.
If you convert this bit to a decimal number, it becomes the number “8”
34
Cont…
Step 3) Use increment to find network ranges
Start with your given network address and add your increment to the sub
netted octet: [Link]
[Link]
[Link] …etc
You can now fill in your end ranges, which is the last possible IP address
before you start the next range. [Link] – [Link]
[Link] – [Link]
[Link] – [Link] …etc
You can then assign these ranges to your networks! Remember the first and
last address from each range (network / broadcast IP) are unusable.
35
3
6
?