Definition of Computer Networks
• Computer network is defined as interconnection of
autonomous computer. Autonomous means no master
or slave relationship.
Purpose of computer network
• Sharing resources
• Reliability
• Communication
• Saving money
IPV4 Addresses
• Why we are having names… like Rama, Sita
• Similarly computer has names
• An IP address is a 32-bit address that uniquely and
universally defines the connection of a device to the
internet.
Internet Protocol version 4 (IPv4)
is the fourth version in the
development of the Internet Protocol
(IP)
• 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.
• The IPv4 addresses are unique and universal.
• They are unique in the sense that each address defines
one, and only one, connection to the Internet.
• The IPv4 addresses are universal in the sense that the
addressing system must be accepted by any host that
wants to be connected to the Internet.
Note:
An IP address is a 32-bit
address.
Note:
The IP addresses are unique
and universal.
Address space
• An address space is the total number of addresses used
by the protocol.
• For example if one bit used , then 0 and 1
• If two bits are used , then 2^2=00,01,10,11 = 4
• If three bits are used, then 2^3=000,001,010…111 = 8
• If N bits are used , then 2^N addresses are possible.
• If 32 bits are used , then 2^32 = 4.294,967,296 ( More
than 4 billion)
An address space is the total number of addresses used
by the protocol.
IPv4 allows 2^32 unique address
which section of IP address show the network id & which
section show the machine or host id depend on the class
network.
IPv4 uses 32-bit addresses, which means that the
address space is 232 or 4,294,967,296.
This means that, if there were no restrictions, more than
4 billion devices could be connected to the Internet.
Notations
• There are two types of notations are used
1. Binary
2. Dotted-decimal
Figure 19.9 Dotted-decimal notation
Rules for Ipv4 notations
There must be no leading zero (045).
Each number needs to be less than or equal to 255.
There can be no more than four numbers in an IPv4 address.
A mixture of binary notation and dotted-decimal notation is not allowed.
Example 1
Change the following IP addresses from binary
notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111
Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation:
a. 129.11.11.239
b. 249.155.251.15
Example 2
Change the following IP addresses from dotted-
decimal notation to binary notation.
a. 111.56.45.78
b. 75.45.34.78
Solution
We replace each decimal number with its binary
equivalent (see Appendix B):
a. 01101111 00111000 00101101 01001110
b. 01001011 00101101 00100010 01001110
Classful Addressing
• IP4 addressing, at its inception, used the concept of
classes.
• This architecture is called classful addressing.
• Today it is obsolete.
Note:
In classful addressing, the
address space is divided into
five classes: A, B, C, D, and E.
Figure 19.10 Finding the class in binary
notation
Figure 19.11 Finding the address class
Example 3
Find the class of each address:
a. 00000001 00001011 00001011 11101111
b. 11110011 10011011 11111011 00001111
Solution
See the procedure in Figure 19.11.
a. The first bit is 0; this is a class A address.
b. The first 4 bits are 1s; this is a class E address.
Figure 19.12 Finding the class in decimal
notation
Example 4
Find the class of each address:
a. 227.12.14.87
b. 252.5.15.111
c. 134.11.78.56
Solution
a. The first byte is 227 (between 224 and 239); the class is
D.
b. The first byte is 252 (between 240 and 255); the class is
E.
c. The first byte is 134 (between 128 and 191); the class is
B.
Class A- If the 32 bit binary address starts with a bit 0, then IP
Address belongs to class A.
In class A IP Address,
The first 8 bits are used for the Network ID.
The remaining 24 bits are used for the Host ID.
Class A
The first byte is a network id (8 bits) & the last 3 bytes are for host id
(24 bits).
The first bit is '0’.
Range of network number-1.0.0.0 to 126.0.0.0
Number of possible networks-127(1-126 usable, 127 is reserve)
Number of possible values in the host portion-16,777,216 It is used for
large network.
Class B
• The first 2 bytes are a network id (16 bits) & the last 2 bytes are for host id
(16 bits).
• The first 2 bits are '10’.
• Range of network number- 128.0.0.0 to 191.255.0.0 Number of possible
networks- 16,384
• Number of possible values in the host portion- 65536
• Used for medium size network.
Class C
The first 3 bytes are a network id (24 bits) & the last 1 byte are for host id (8 bit).
The first 3 bits are '110’.
Range of network number- 192.0.0.0 to 223.255.255.0
Number of possible networks- 2,097,152
Number of possible values in the host portion- 256
Used in local area network(LAN).
CLASS D
An IP address which belong to class D has the first octet has its 4bit
set to '1110’.
Range of network number- 224.0.0.0 to 239.255.255.255
Used for multicasting
CLASS E
It reserved for experimental & for future testing
purpose.
Range of network number- 240.0.0.0 to
255.255.255.254
Classes and Blocks
• One problem with classful addressing is that each class
is divided into a fixed number of blocks with each block
having a fixed size as shown in the following table
IPv4 ADDRESSES
IPv4 ADDRESSES
•In classful addressing, the address space is
divided
•into five classes: A, B, C, D, and E.
•Addresses in Classes A, B and C are uniast
addresses
•A host needs to have at least one unicast
address to be able to send packet (Source).
• Addresses in Class D are for multicast
address: used only for destination.
• Addresses in class E are reserved
IPv4 ADDRESSES
One problem is that each class is divided into fixed
number of blocks with each block having a fixed size
In classful addressing, a large part of the available addresses were wasted.
IPv4 ADDRESSES
Class A address: designed for large organizations
with a
large number of attached hosts or routers. (most of
the
addresses were wasted and not used)
Class B address: designed for midsize
organizations with ten
of thousands of attached hosts or routers( too large
for many
organizations)
Class C address: designed for small organizations
with a
small number of attached hosts or routers (too
small for
Classes and blocks
• Class A addresses were designed for large organizations with a
large number of attached hosts or routers.
• Class B addresses were designed for midsize organizations with tens
of thousands of attached hosts or routers.
• Class C addresses were designed for small organizations with a
small number of attached hosts or routers.
Disadvantage
Class A addresses is too large for almost any organization. That
means addresses in class A were wasted and were not used.
Class B is almost too large for many of the organization that received
a class B block.
A block in class C is probably too small for many organizations.
Netid and Hostid
• In classful addressing, an IP address in class A,B and C
is divided into netid and hostid.
• These parts are of varying lengths, depending on the
class of the address.
MASK
• 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 concept does not apply to classes D and E.
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.
The last column of Table shows the mask in the form /n
where n can be
8, 16, or 24 in classful addressing. This notation is also
called slash notation or Classless Interdomain Routing
(CIDR) notation.
IPv4 ADDRESSES
NetId and HostId
•The address is divided into Netid and
Hostid.
•These part are of varying lengths,
depending on the class.
Dose not apply to classes D and E
Classful Addressing: Classes and Blocks
Mask (default mask)
• Help us to find the NetId and HostId
• Mask: 32-bit made of 1s followed by 0s.
• Dose not apply to classes D and E.
• CIDR(Classless Interdomain Routing): used to show the
mask in the form /n (n=8,16,24)
CIDR Dotted-decimal Binary Class
8/ 255.0.0.0 11111111 00000000 00000000 A
00000000
16/ 255.255.0.0 11111111 11111111 00000000 B
00000000
24/ 255.255.255.0 11111111 11111111 11111111 C
00000000
Classful Addressing: Network address
The network address is an address that define the
network itself to the reset of the internet
The network address has the following properties:
1. All hostid bytes are 0’s
2. It is the first address in the block
3. It cannot be assigned to a host
4. Given the network address, we can find
the class of the address
Classful Addressing: Network address
Find the network address for the following:
a. 132.6.17.85
b. 23.56.7.91
a. The class is B. The first 2 bytes defines the Netid.
We can find the network address by replacing the hostid
bytes (17.85) with 0s.
Therefore, the network address is 132.6.0.0
b. The class is A. Only the first byte defines the
Netid. We can find the network address by replacing the
hostid bytes (56.7.91) with 0s.
Therefore, the network address is 23.0.0.0
Classful Addressing: Network address
Classful addressing : subnetting
IP addresses are designed with two
levels of hierarchy.
Figure 19.21 Addresses in a network with and without
subnetting
Figure 19.22 Hierarchy concept in a telephone
number
A network with two levels of hierarchy
Classful Addressing:
Subnetting
If an organization was granted a large block in classes A or B
It could divide the addresses into several contiguous groups
and assign each group to smaller networks ( subnets)
It increases the number of 1s in the mask
• Number of 1s in a subnet mask is more than the number of 1s
in the corresponding mask.
• To make a subnet mask , we change some of the leftmost 0s in
mask to 1s
The number of subnets is determine by the number of extra1s.
• If the number of extra 1 is n, the number of subnets is 2 n.
• If the number of subnets is N, the number of extra 1s is log2N
Classful Addressing: Subnet Mask
Class B address
mask : 255.255.0.0 or /16
00000000 00000000 11111111 11111111
For 4 subnets : (log 2 4 = 2; need 2-extra bits )
Subnet mask: 255.255. 192.0 or /18
00000000 000000 11 11111111 11111111
For 8 subnets: (log 2 8 = 3; need 3-extra bits )
subnet mask : 255.255.224.0 or /19
00000000 00000 111 11111111 11111111
Classful Addressing:
Subnetting
Example:
A router receives a packet with destination address
190.240.33.91. Show how it finds the network and the
subnetwork address toroute the packet. Assume the subnet
mask is /19
The router follows steps:
1. The router looks at the first byte of the address to find the
class. It is class B.
2. The mask for class B is (/16)The router ANDs this mask
with the address to get the network address :190.240.0.0.
3. The router applies the subnet mask (/19) to the address,
190.240.33.91.
190.240.001 00001. 91
The subnet address is 190.240.32.0.
4. The router looks in its routing table to find how to route the
packet to this destination
Figure 19.14 Blocks in class A
Note:
Millions of class A addresses
are wasted.
Classful Addressing
supernetting
Huge demand for midsize blocks.
• Although class A and B addresses are almost depleted,
class C addresses are still available( size of block= 256
address did not satisfy the needs).
• In supernetting, an organization can combine several class
C blocks to create a larger range of addresses.
• Several networks are combined to create a supernetwork (
supernet). e.g. Organization needs 1000 address can be
granted 4 contiguous class C blocks to create one
supernetwork.
• Decreases the number of 1s in the mask. E.g. The mask
changes from /24 to /22 for 4 class C block
Classful Addressing: supernetting
Address Depletion
• Near depletion of the available address because of the fast
growth of the Internet.
• Run out of classes A and B address.
• Classes C block is too small for most mid size organizations.
Solution: Classless addressing
Classless Addressing
• A large organization is given with large number of
addresses.
• A Home may be given with two address.
• ISP may be given with thousands of address.
Classless Address
Classless IP address
The use of classful IP addressing has created many problems.
The main of these is that the range of addresses in class A, B, and C is multiples of 256. Thus the
size of an address block is usually fixed.
So, since 1996 Internet authorities announce another addressing architecture.
This architecture overcomes the problems of classful IP addressing.
Here the address space is divided into blocks of different sizes.
An organization (for example) is given (usually by an ISP) a block of addresses that is suitable for its
needs.
The block belongs to no class and thus this addressing architecture is named classless IP
addressing.
Number of addresses in the block is a power of 2
but the main restriction in classless IP addressing is that the first address in the block (block address
Example
Mask
Mask
Finding the block
To find the block of addresses in classless addressing.
It is necessary to find the followings:
First address in the block: It can be found by ANDing any address in the
block with the subnet mask
Number of addresses in the block: Actual number of addresses in the
block is while the useable number of addresses in the block equals the
actual number of addresses in the block minus two.
Last address in the block: It can be found by adding the 1st address in
Example: Find the block if one of the addresses is 190.87.140.202 /
29.
Finding the first address: is found by ANDing the address
(190.87.140.202) with the subnet mask (255.255.255.248).
The first address in the block is (190.87.140.200 / 29)
Number of addresses in the block
Last address in the block can be found by adding the 1st
address in the block (190.87.140.200) with the complement
of the subnet mask (0.0.0.7)
The last address in the block is (190.87.140.207 /
29)
Example
Example
Example
Example
Example
Example (Try yourself)
Network address
Network Address Translation
The number of home users and small businesses that want to use the Internet is ever
increasing.
In the beginning, a user was connected to the Internet with a dial-up line, which means
that she was connected for a specific period of time.
An ISP with a block of addresses could dynamically assign an address to this user. An
address was given to a user when it was needed.
But the situation is different today. Home users and small businesses can be connected
by an ADSL line or cable modem.
In addition, many are not happy with one address; many have created small networks
with several hosts and need an IP address for each host.
With the shortage of addresses, this is a serious problem. A quick solution to this
problem is called network address translation (NAT).
Network Address Translation
A quick solution to this problem is called network address
translation (NAT).
NAT enables a user to have a large set of addresses internally
and one address, or a small set of addresses, externally.
The traffic inside can use the large set; the traffic outside, the
small set.
To separate the addresses used inside the home or business
and the ones used for the Internet, the Internet authorities have
reserved three sets of addresses as private addresses
Network Address Translation
Any organization can use an address out of this set without
permission from the Internet authorities.
Everyone knows that these reserved addresses are for
private networks.
They are unique inside the organization, but they are not
unique globally.
No router will forward a packet that has one of these
addresses as the destination address.
The site must have only one single connection to the
global Internet through a router that runs the NAT software.
Network Address Translation
Network Translation Table (NAT)
Translation Table
Using one IP address
Example
Using Both IP address and Port
numbers (NAT..)
Translation Table
IPV6 addresses
Structure
IPV6 address
Address Space
Type prefixes for IPv6 address
INTERNETWORKING
INTERNETWORKS
INTERNETWORKS
INTERNETWORKS
Routing Table
Routing Table
Internet as a Datagram Network
Connection oriented Vs connection
less network
Connection oriented Vs connection
less network
IPV4
Best effort delivery
Datagram
Fragmentation
Checksum
IPV6
Transition from IPv4 to IPv6
Dual Stack
Tunneling
Header Translation
THANK YOU
Classless IP address
Limitations of Classful Addressing
• A block in class A address is too large for almost any
organization. This means most of the addresses in class A were
wasted and were not used.
• A block in class B is also very large, probably too large for many
of the organizations that received a class B block.
• A block in class C is probably too small for many organizations.
• Class D addresses were designed for multicasting. Each address
in this class is used to define one group of hosts on the Internet.
• The Internet authorities wrongly predicted a need for
268,435,456 groups.
• This never happened and many addresses were wasted
here too.
• And lastly, the class E addresses were reserved for future
use; only a few were used, resulting in another waste of
addresses.
Address Depletion Problem
The fast growth of the Internet led to the near depletion of the
available addresses in classful addressing scheme.
Yet the number of devices on the Internet is much less than the
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.
Classful addressing, which is almost obsolete, is replaced with
classless addressing.
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 hundreds of thousands based on the number of customers it
may serve.
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.
• 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.
Mask
A better way to define a block of addresses is to select any address in the block and
the mask.
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 notation).
In 1Pv4 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.
The address and the /n notation completely define the whole block (the first address,
the last address, and the number of addresses).
• First Address:
The first address in the block can be found by setting the 32 - n
rightmost bits in the binary notation of the address to 0s.
Example:1
A block of addresses is granted to a small organization. We know that one of the
addresses is 205.16.37.39/28. What is the first address in the block?
First address
205.16.37.39/28.
The binary representation of the given address is
11001101 00010000 00100101 00100111.
If we set 32 - 28 rightmost bits to 0,
we get
11001101 0001000 00100101 0010000 or 205.16.37.32.
This is actually the block shown in Figure
Last Address
The last address in the block can be found by setting the
32 - n rightmost bits in the binary notation of the address
to 1s
Find the last address for the block
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
0010 1111 or 205.16.37.47. This is actually the block shown in Figure
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
Find the number of addresses in Example
Example
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 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 c. The number of
addresses