Faculty of
Engineering
Computer Network
Network Layer: IP Protocol
(Part “I” IPv4 Addressing)
Computer Network
Dr. Ahmed Abdel Halim @ Helwan University
Fall 2019
Dr. Ahmed M. Abd El-Haleem
Assistant Professor in
Communication and Electronic Department
Faculty of Engineering, Helwan University
E-mail: dr.ahmed.m.abd.elhaleem@gmail.com
OSI Reference Model
3
OSI Reference Model
4
Layers with TCP/IP and OSI
5
Model
Network layer functions
6
The network layer, or OSI
Layer 3, provides services to
allow end devices to
exchange data across the
network. To accomplish this
end-to-end transport, the
network layer uses four
basic processes:
Addressing end device
Routing
Encapsulation
Decapsulation
Network Layer Functions.
Network layer Protocols
7
Common network layer protocols include:
IP version 4 (IPv4)
IP version 6 (IPv6)
Legacy network layer protocols include:
AppleTalk
Novell Internetwork Packet Exchange (IPX)
Connectionless Network Service
(CLNS/DECNet)
Routing protocols include:
RIP, OSPF, IGRP,
EIGRP and BGP
Characteristics of IP Protocol
8
IP Services
9
Delivery service of IP is minimal
IP provides an unreliable connectionless best effort
service (also called: “datagram service”).
Unreliable: IP does not make an attempt to recover
lost packets.
Connectionless: Each packet (“datagram”) is handled
independently. IP is not aware that packets between
hosts may be sent in a logical sequence.
Best effort: IP does not make guarantees on the
service (no throughput guarantee, no delay guarantee,…)
Consequences:
1) Higher layer protocols have to deal with losses or with
duplicate packets.
2) Packets may be delivered out-of-sequence.
IP Service
10
IP supports the following services:
◼ one-to-one (unicast)
◼ one-to-all (broadcast)
◼ one-to-several (multicast)
unicast
broadcast multicast
IP multicast also supports a many-to-many service.
Different Layer Addressing
11
Destination port no. TCP can maintain a logical connection
& between two ports on different systems.
Sequence number File
Segment
Packet
Frame
Destination address
&
Facilities requests
(priority,….)
Addressing levels
12
Refers to the level in the communications
architecture at which an entity is named.
Application Level Address
e.g. Specific Address.
Transport Level Address
e.g. Port Address.
Network Level Address
e.g. internet address or IP address.
Data link Level Address
e.g. Physical address.
Addressing levels
13
Addressing mode
14
Unicast address: refers to a single system
or port.
Broadcast address: address for multiple
recipients, intended for all entities within a
domain.
Multicast address: address for multiple
recipients, intended for a specific subset of
entities.
Network Layer: IPv4 Addressing
15
IPv4 Addresses
IP address is a logical (Software) address.
Uniquely and universally defines the device.
An IPv4 address is a 32-bit address.
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.
The address space of IPv4 is 232 or
4,294,967,296.
IPv4 Addresses
16
There are two prevalent notations to show an IPv4
address:
Binary notation
Dotted decimal notation
In Binary Notation, the IPv4 address is displayed as
32 bits.
In Dotted-Decimal Notation addresses are usually
written in decimal form with a decimal point (dot)
separating the bytes.
IPv4 Addresses (Cont.)
17
IPv4 Addresses (Example)
18
Change the following IPv4 addresses from binary notation
to dotted-decimal notation.
a) 10000001 00001011 00001011 11101111
b) 11000001 10000011 00011011 11111111
c) 11100111 11011011 10001011 01101111
d) 11111001 10011011 11111011 00001111
Solution
We replace each group of 8 bits with its equivalent
decimal number and add dots for separation:
a) 129.11.11.239 b) 193.131.27.255
c) 231.219.139.111 d) 249.155.251.15
IPv4 Addresses (Example)
19
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
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.
IPv4 Addressing
20
The 32 bits of the IP address are divided into
Network and Host portions.
Each Network is assigned a network address &
Every device or interface (such as a router
port) on the network is assigned a host
address.
A host address cannot be designated by all
zeros or all ones: These are special addresses
that are reserved for special purposes.
IPv4 Addresses (Cont.)
21
Older technology - Classful IP Addressing
Value of first octet determines the network
portion and the host portion.
Newer technology - Classless IP Addressing
The subnet mask determines the network
portion and the host portion.
Value of first octet does NOT matter.
Classless IP Addressing is what is used within
the Internet and in most internal networks.
IPv4 Address Classes: Classful Addressing
22
The IPv4 address space is divided into five
classes, each of which is designated with the
alphabetic letters : A, B, C, D, and E.
Classes A, B and C addresses are used for unicast
services.
Class D addresses are used for multicast services.
Class E addresses are reserved for testing and
some mysterious future use.
IPv4 Classful Addressing
23
Network & Host Representation
By IP Address Class
Class Octet1 Octet2 Octet3 Octet4
Class A Network Host Host Host
Class B Network Network Host Host
Class C Network Network Network Host
IPv4 Classful Addressing: Example
24
Find the class of each address:
a. 227.12.14.87 → The first byte is 227 (between 224
and 239); the class is D.
b. 193.14.56.22 → The first byte is 193 (between 192
and 223); the class is C.
c. 14.23.120.8 → The first byte is 14 (between 0
and 127); the class is A.
d. 00000001 00001011 00001011 11101111 → The
first bit is 0. This is a class A address.
e. 11000001 10000011 00011011 11111111 → The
first 2 bits are 1; the third bit is 0. This is a class C
address.
IPv4 Classful Addressing
25
Network Id (Net Id) and Host Id
netid 000 ... 0
First address
to compute the number of hosts available in any of
the class addresses, where “h=32-n” represents the
number of bits in the host portion:
(2h – 2) = Number of available hosts.
IPv4 Address Classes: Class A
26
Class A IP addresses use the 1st 8 bits (1st
Octet) to designate the Network address.
The 1st bit which is always a 0 and the remaining 7
bits are used to designate the Network.
There are 128 Class A Network Addresses, but
◼ all zeros aren’t used &
◼ address 127 is a special purpose address,
◼ So, (27 – 2) = 126 Class A Networks are available.
The other 3 octets contain the Host address.
There are: 224 – 2 or 16,777,214 hosts.
Half of all IP addresses are Class A addresses.
IPv4 Address Classes: Class A
27
IPv4 Address Classes: Example
28
An address in a block is given as 73.22.17.25. For this block find : a) the
number of host addresses. b) the first address. c)the last address.
Solution
Class A IP addresses use the 1st 8 bits (1st Octet) to designate the
network address.
The other 3 octets contain the Host address.
a) For a Class A network, there are: (232-8 – 2 ) = 224 – 2 or 16,777,214
hosts.
b) To find the first address, we keep the leftmost 8 bits and set the
rightmost 24 bits all to 0s. The first address is 73.0.0.0.
c) To find the last address, we keep the leftmost 8 bits and set the
rightmost 24 bits all to 1s. The last address is 73.255.255.255.
Note
The first host address is 73.0.0.1 and the last is 73.255.255.254
IPv4 Address Classes: Class B
29
Class B addresses use the 1st 16 bits (two
octets) for the Network address.
The 1st 2 bit, which are always 10, designate the
address as a Class B address and
14 bits are used to designate the Network. This
leaves 16 bits (two octets) to designate the Hosts.
The last 2 octets are used for the Host address.
Using our formula, (214), there can be 16,384 Class
B Networks and each Network can have (216 – 2)
Hosts, or 65,534 Hosts.
IPv4 Address Classes: Class B
30
IPv4 Address Classes: Class C
31
Class C addresses use the 1st 24 bits
(three octets) for the Network address.
the 1st 3 bits of all class C addresses are set
to 110, leaving 21 bits for the Network
address
2,097,150 (221) Class C Networks,
only the last octet for Host addresses.
254 (28 – 2) Hosts per Network.
IPv4 Address Classes: Class C
32
IPv4 Subnet Mask
33
A subnet mask, which contains a binary bit pattern
of ones and zeros.
The function of a subnet mask is to determine
whether an IP address exists on the local
network or whether it must be routed outside
the local network.
It is applied to a message’s destination address
to extract the network address.
If the extracted network address matches the local
network ID, the destination is located on the local
network.
However, if they don’t match, the message must be
routed outside the local network.
IPv4 Subnet Mask
34
To define the network and host portions of an address, a
devices use a separate 32-bit pattern called a subnet
mask.
The subnet mask does not actually contain the network or
host portion of an IPv4 address, it just says where to look
for these portions in a given IPv4 address.
/8
/16
/24
IPv4 Subnet Mask: Finding the
Network (Subnet) Address
35
We can find the network (subnet) address in two ways:
straight or short-cut.
1. Straight Method: In the straight method, we use binary
notation for both the address and the mask and then
apply the AND operation.
Bitwise
AND
Operation
IPv4 Subnet Mask: Finding the
Network (Subnet) Address
36
Example: What is the subnetwork address if the
destination address is 200.45.34.56 and the subnet mask
is 255.255.240.0?
Solution
IP Address 11001000 00101101 00100010 00111000
Subnet mask 11111111 11111111 11110000 00000000
ANDing -------------------------------------------------
Net. Add. 11001000 00101101 00100000 00000000
The subnetwork address is 200.45.32.0.
IPv4 Subnet Mask: Finding the
Network (Subnet) Address
37
2. Short-Cut Method:
If the byte in the mask is 255, copy the byte in
the address.
If the byte in the mask is 0, replace the byte in
the address with 0.
If the byte in the mask is neither 255 nor 0, we
write the mask and the address in binary and apply
the AND operation.
IPv4 Subnet Mask: Finding the
Network (Subnet) Address
38
Example: What is the subnetwork address if the
destination address is 19.30.84.5 and the mask is
255.255.192.0?
Solution
The solution is Shown in the Figure.
IPv4 Unicast, Multicast and
Broadcast Transmissions
39
1) Unicast 2) Broadcast
the process of sending a the process of sending a
packet from one host to packet from one host to
an individual host. all hosts in the network.
IPv4 Unicast, Multicast and Broadcast
Transmissions
40
3) Multicast – The process of sending a packet from one
host to a selected group of hosts, possibly in
different networks.
❑ Reduces traffic
❑ Reserved for addressing multicast groups –
224.0.0.0 to 239.255.255.255.
o Link local – 224.0.0.0 to 224.0.0.255 (Example:
routing information exchanged by routing protocols,
Routers must not forward these messages outside
the subnet in which they originate).
o Globally scoped addresses – 224.0.1.0 to
238.255.255.255 (Example: Internetwork control,
AD-HOC).
Public and Private IPv4 Addresses
41
Private address blocks are:
▪ Hosts that do not require access to the
Internet can use private addresses
▪ 10.0.0.0 to 10.255.255.255 (10.0.0.0/8)
▪ 172.16.0.0 to 172.31.255.255 (172.16.0.0/12)
▪ 192.168.0.0 to 192.168.255.255 (192.168.0.0/16)
Special Use of IPv4 Addresses
42
Network and Broadcast addresses – within each
network the first and last addresses cannot be
assigned to hosts
Loopback address – 127.0.0.1 a special address that
hosts use to direct traffic to themselves (addresses
127.0.0.0 to 127.255.255.255 are reserved)
Link-Local address – 169.254.0.0 to 169.254.255.255
(169.254.0.0/16) addresses can be automatically
assigned to the local host
Experimental addresses – 240.0.0.0 to
255.255.255.254 are listed as reserved
Example of IP Addressing
43
A router is necessary as a device to communicate between
different networks (subnets).
Each router interface must have an IP address that belongs to
the network or subnet that the router interface is connected.
Devices on a network and subnet use the router interface
attached to their LAN as their default gateway.
Subnetting an IPv4 Network
44
An IP address has 2 parts: the network
identification and the host identification.
If you know the address class, it’s easy to separate the
2 portions.
With the rapid growth of the internet and the
ever-increasing demand for new addresses, the
standard address class structure has been expanded
by borrowing bits from the host portion to allow
for more networks.
Under this addressing scheme, called Subnetting,
separating the network and host requires a special
process called Subnet Masking.
Subnetting an IPv4 Network
45
Subnetting is the process of segmenting a network
into multiple smaller network spaces called
subnetworks or subnets.
Creating smaller groups of devices and services to:
Control traffic by containing broadcast traffic
within each subnetwork.
Reduce overall network traffic and improve
network performance.
Planning requires decisions on each subnet in terms
of size, the number of hosts per subnet, and how
host IP addresses will be assigned.
Subnetting an IPv4 Network
46
IP Add.======= 141.14.2.5 Is not the default mask
Subnet mask=== 255.255.255.0
Subnet== 141.14.2.0
Basic Subnetting
47
Borrowing bits to create
subnets Network part Host part
Borrowing 1 bit 2 = 2
1
IP address
subnets Subnet
bits
Network part Host part
Borrowing 1 Bit from the host portion creates 2 subnets with the same
subnet mask
Basic Subnetting
48
Subnetting Formulas
Calculate number of
subnets
Calculate number of
hosts
Formula to determine number of usable hosts: 2^n-2
▪ 2^n (where n is the number of remaining host bits) is used to calculate
the number of hosts.
▪ -2 (The subnetwork ID and broadcast address cannot be used on each
subnet.)
Basic Subnetting
49
Creating 2 Subnets
Subnet 0
Network 192.168.1.0-127/25
Subnet 0
Mask: 255.255.255.128
Basic Subnetting
50
Creating 2 Subnets
Subnet 1
Network 192.168.1.128-255/25
Subnet 1
Mask: 255.255.255.128
Basic Subnetting
51
Borrowing 2 bits to create 4 subnets.
22 = 4 subnets
Basic Subnetting
52
Borrowing 3 bits to create 8 subnets. 23 = 8 subnets
Basic Subnetting
53
Borrowing 3 bits to create 8 subnets. 23 = 8 subnets
Basic Subnetting
54
Borrowing 3 bits to create 8 subnets. 23 = 8 subnets
Fixed and Variable Length
55
Subnet Mask
1. Fixed Length Subnet Masks (FLSM) → Traditional
Subnetting
Balance the required number of subnets and hosts for the
largest subnet.
Design the addressing scheme to accommodate the
maximum number of hosts for each subnet. Allow for
growth in each subnet.
Traditional Subnetting Wastes Addresses
Fixed and Variable Length
56
Subnet Mask
1. Fixed Length Subnet Masks (FLSM) → Traditional Subnetting
Fixed and Variable Length
57
Subnet Mask
1. Fixed Length Subnet Masks (FLSM) → Traditional
Subnetting
Unused addresses on
WAN subnets.
Fixed and Variable Length
58
Subnet Mask
Traditional Subnetting Wastes Addresses
Traditional subnetting – Uses the same number of
addresses is allocated for each subnet.
Subnets that require fewer
addresses have unused
(wasted) addresses; for
example, WAN links only
need two addresses.
Fixed and Variable Length
59
Subnet Mask
2. Variable Length Subnet Masks (VLSM)
VLSM or subnetting a subnet provides more efficient use of
addresses.
VLSM allows a network space to be divided in unequal parts.
Subnet mask varies, depending on
how many bits have been borrowed
for a particular subnet.
Network is first subnetted, and
then the subnets are resubnetted.
Subnetting a subnet, or using
VLSM was designed to avoid
wasting addresses.
Variable Length Subnet Mask
60
FLSM Subnetting Scheme. VLSM Subnetting Scheme.
Variable Length Subnet Mask
61
172.16.0.0/21
VLSM (Cont.)
62
VLSM (Cont.)
63
Calculate the address ranges for sub networks
Assignment of IP Addresses
64
Internet Assigned Numbers Authority (IANA) is
responsible for global coordination of the Internet
Protocol addressing systems, as well as the Autonomous
System Numbers used for routing Internet traffic.
Regional Internet Registries (RIRs)
Assignment of IP Addresses
65
Assigning a Static IPv4 Address to a Host
Assignment of IP Addresses
66
Assigning a Dynamic IPv4 Address to a Host
Dynamic Host Configuration Protocol version 4
(DHCPv4)
The preferred method of assigning IPv4 addresses to
hosts on large networks because it reduces the burden on
network support staff and virtually eliminates entry
errors.
DHCP allows a host to obtain an IP address dynamically.
DHCP used for general purpose hosts such as end user
devices, and
static addressing is used for network devices such as
gateways, switches, servers and printers.
Assignment of IP Addresses
67
Assignment of IP Addresses
68
DHCPv4 uses three different address allocation methods:
Manual Allocation – The administrator assigns a pre-
allocated IPv4 address to the client, and DHCPv4
communicates only the IPv4 address to the device.
Automatic Allocation – DHCPv4 automatically assigns a
static IPv4 address permanently to a device, selecting it
from a pool of available addresses.
Dynamic Allocation – DHCPv4 dynamically assigns, or
leases, an IPv4 address from a pool of addresses for a
limited period of time chosen by the server, or until the
client no longer needs the address. This method is the
most commonly used.
Assignment of IP Addresses
69
DHCP Operation:
DHCP server is
Contacted and
address requested
– chooses address
from a configured
range of addresses
called a pool and
“leases” it to the
host for a set
period.
Assignment of IP Addresses
70