Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

A.Y.

1440-1441
Faculty of Sciences/Northern Borders University
2020-2021

Chapter IV

Network Layer

Salem.Belhaj@nbu.edu.sa
Computer Science Department

1
Network Layer

• The Network layer, or OSI Layer 3, provides services to


exchange the individual pieces of data over the network
between identified end devices
• To accomplish this end-to-end transport, Layer 3 uses
four basic processes:
– Addressing
– Encapsulation
– Routing
– Decapsulation
• The Internet Protocol (IPv4 and IPv6) is the most
widely-used Layer 3 data carrying protocol. Only IPV4
will be the focus of this course

Computer Networks 2
IPv4 basic characteristics

Computer Networks 3
IPv4 basic characteristics
• Connectionless: An example of connectionless communication
is sending a letter to someone without notifying the recipient in
advance. The sender doesn't know if the letter arrived
• Best Effort (unreliable): Unreliable means simply that IP does
not have the capability to manage, and recover from,
undelivered or corrupt packets
• Media Independent: IP packets can travel over different media

Computer Networks 4
IP v4 Packet Header
• Version: Contains the IP version number (4 or 6)
• Header Length (IHL): Specifies the size of the packet header
• Type-of-Service: Contains an 8-bit binary value that is used to
determine the priority of each packet. This value enables a
Quality-of-Service (QoS) mechanism to be applied to high priority
packets, such as those carrying telephony voice data
• Packet Length: This field gives the entire packet size, including
header and data, in bytes

Computer Networks 5
IPv4 Packet Header
• Identification: This field is primarily used for uniquely identifying
fragments of an original IP packet
• Time-to-Live (TTL) is an 8-bit binary value that indicates the
remaining "life" of the packet. Its value is decreased by at least one
each time the packet is processed by a router (each hop)
• Protocol: this 8-bit binary value indicates the Network layer to pass
the data to the appropriate upper-layer protocol (01 ICMP, 06 TCP,
17 UDP, etc.)
• Header Checksum: The checksum field is used for error
checking the packet header
• IP Destination Address: this field contains a 32-bit binary value that
represents the packet destination host address
• IP Source Address: this field contains a 32-bit binary value that
represents the packet source host address
• Options: There is provision for additional fields in the IPv4 header to
provide other services but these are rarely used

Computer Networks 6
IPv4 Address
• An Internet address consists of 4 bytes (32 bits)
• Value coded on 32 bits and represented in the form of four
integers in decimal writing eg: 192.168.4.8
• Need structure in IP Address
• The first part identifies the network (net_id)
• The second part identifies a Host on that network (host_id)

Class

Network ID. Host ID.

Computer Networks 7
IP address classes
byte 1 byte 2 byte 3 byte 4

Class A 0 Net-id. Host-id

Class B 1 0 Net-id Host-id

Class C 1 1 0 Net-id Host-id

Class D 1 1 1 0 multicast Group addresses

Class E 1 1 1 1 0 Reserved for future use

Example 1:

11000001 10010011 10001000 10111111

193.147.136.95
Computer Networks 8
IP address classes

byte 1 byte 2 byte 3 byte 4

Class A 0 Net-id Host-id

Class B 1 0 Net-id Host-id

Class C 1 1 0 Net-id Host-id

BYTE 1
00000000 01111111

From Until

Class A 0 .0.0.0 127.255.255.255


Net-id Host-id Net-id Host-id

Computer Networks 9
IP address classes

byte 1 byte 2 byte 3 byte 4

Class A 0 Net-id Host-id

Class B 1 0 Net-id Host-id

Class C 1 1 0 Net-id Host-id

BYTES 1 et 2
10000000 . 00000000 10111111 . 11111111

From Until

Class B 128.0.0.0 191.255.255.255


Net-id Host-id Net-id Host-id

Computer Networks 10
IP address classes

byte 1 byte 2 byte 3 byte 4

Class A 0 Net-id Host-id

Class B 1 0 Net-id Host-id

Class C 1 1 0 Net-id Host-id

BYTES 1, 2 et 3
11000000 . 00000000 . 00000000
11011111 . 11111111 . 11111111

From Until

Class C 192.0.0.0 223.255.255.255


Net-id Host-id Net-id Host-id

Computer Networks 11
IP address classes
Default Netmask
byte 1 byte 2 byte 3 byte 4

Class A 0 Net-id Host-id

Class B 1 0 Net-id Host-id

Class C 1 1 0 Net-id Host-id


• Netmask: move all Net-id bits to 1 and those of host to 0

Class Netmask Bits Netmask Notation

A 11111111 00000000 00000000 00000000 255.0.0.0 /8*

B 11111111 11111111 00000000 00000000 255.255.0.0 /16*

C 11111111 11111111 11111111 00000000 255.255.255.0 /24*


*Notation CIDR: Classless Inter-Domain Routing
Computer Networks 12
IP address classes
Example 2:
Get the network identifier and the identifier of the host of the
next IP address 194.74.21.46
BYTE 1: 194  11000010  CLASSE C

11000010 . 01001010 . 00010101 . 00101110 IP


AND 11111111 . 11111111 . 11111111 . 00000000 Netmask

11000010 . 01001010 . 00010101 00000000


Res_Id

194.74.21

00000000 . 00000000 . 00000000 00101110 Host_Id

46

194.74.21.46
13
Computer Networks res_id host_id 13
IP address classes
Special and private addresses
Adresses between 0.0.0.0 and 255.255.255.255 are not all
valid to identify a host (machine).
Net-id Host-id Signification
Identifies the host that sends the
All ‘0’
datagram (BOOTP, DHCP)
All ‘1’ Broadcast in each network
Net-id All ‘0’ Network Address
Net-id all ‘1’ Broadcast in the specified network
All ‘0’ Host-id Identifies a host in a network

127 Any value Loopback Adress

 Reserved adresses for LAN:


 Class A  [10.0.0.0 , 10.255.255.255]1 network
 Class B  [172.16.0.0 , 172.31.255.255 ]16 networks
 Class C  [192.168.0.0, 192.168.255.255]256
networks.
14
Computer Networks 14
IP address classes

From Until

Class A 1 .0.0.1 126.255.255.254


Net-id Host-id Net-id Host-id

Class B 128.0.0.1 191.255.255.254


Net-id Host-id Net-id Host-id

Class C 192.0.0.1 223.255.255.254


Net-id Host-id Net-id Host-id

15
Computer Networks 15
IP address classes
Taking Into account the reserved addresses, the number of networks and
hosts present in Each class is:

CLASS Network HOST


(7 bits) (24 bits)
A 27 – 3 = 125 224-2= 16.777.214 hosts
Nets.
(14 bits) (16 bits)
B 214 – 16 = 16.368 Nets. 216-2= 65.534 hosts
(21 bits) (8 bits)
C 221 – 256 = 2.096.896 Nets 28-2= 254 hosts

Computer Networks 16
IP address classes
Example 3
How many hosts can be defined in the network 194.74.21.0 ?

BYTE 1: 194  11000010  CLASS C


id_res id_host
Reserved for identifying the
194 . 74 . 21 . 0 network

194 . 74 . 21 . 1
194 . 74 . 21 . 2
194 . 74 . 21 . 3 28-2=
. 254
. possible hosts
.
194 . 74 . 21 . 254
Reserved for the broadcast
194 . 74 . 21 . 255

Computer Networks 17
IP address classes
Example 4

Can the following addresses to be assigned to a


host?

131.107.256.80 NO 256 > 255


222.222.255.222 Yes
231.200.1.1 NO 231 : class D
172.16.0.0 NO Network address
190.7.2.0 Yes
198.121.254.255 NO Broadcast

Computer Networks 18
IP address classes
Example 5 : how to interpret an address ?

0.0.0.0 An unknown host


255.255.255.255 All hosts
138.195.52.1 The host 52.1 from the network 138.195.0.0
193.75.199.3 host 3 from the network 193.75.199.0
193.75.199.0 the network 193.75.199.0
193.75.199.255 All hosts from the network 193.75.199.0
172.130.120.255 host @ not a broadcast
80.255.255.255 broadcast @
194.255.255.10 Host @ from the network 194.255.255.0
Computer Networks 19
The SubNet mask: Defining the network and host portions
Networks division into subnets:
• For IP range after the same network address
• Divide a network into subnets connected by a router
 Too many machines = poor performance
 Best ensured security
 Better structuring
• Example Class C subnet with sub_net_id 2 bits
– 22 =4 possible subnets
– Remaining 6 bits for host portion so 64 addresses
Without subnets Net_id id_host

With subnets Net_id sub_net_id id_host

• Hosts and routers need to know within this division

Computer Networks 20
Example: Subnetting
Division into 4 sub networks (class C)

4 Subnets  Snet_id 2 bits255.255.255.192


1st subnet
@ subnet : 192.44.77.0
@ host de192.44.77.1 à 192.44.77.62
@ broadcast: 192.44.77.63
2 subnet
@ subnet : 192.44.77.64
@ host de 192.44.77.65 à 192.44.77.126
@ broadcast :192.44.77. 127
3 subnet
@ subnet : 192.44.77.128
@ host de 192.44.77.129 à 192.44.77.190
@ broadcast :192.44.77. 191
4th subnet
@ subnet : 192.44.77.192
@ host de 192.44.77.193 à 192.44.77.254
@ broadcast :192.44.77. 255
Computer Networks 21
5.2. Netmask , example
Bits Nbr of subnets Nbr de s. res Bits host Nbr Netmask
subnet (theoretical) (real) hosts
0 0 0 16 65.534 255.255.0.0
1 2 0 15 32.766 255.255.128.0
2 4 2 14 16.382 255.255.192.0
3 8 6 13 8.190 255.255.224.0
4 16 14 12 4.094 255.255.240.0
5 32 30 11 2.046 255.255.248.0
6 64 62 10 1.022 255.255.252.0
7 128 126 9 510 255.255.254.0
8 256 254 8 254 255.255.255.0
9 512 510 7 126 255.255.255.128
10 1.024 1.022 6 62 255.255.255.192
11 2.048 2.046 5 30 255.255.255.224
12 4.096 4.094 4 14 255.255.255.240
13 8.192 8.190 3 6 255.255.255.248
14 16.384 16.382 2 2 255.255.255.252
15 32.768 32.766 1 0 255.255.255.254
16 65.536 65.534 0 0 255.255.255.255
22
Computer Networks 22
[RFC950]
5.2. Netmask / Subnet
Example 6

Let's address 129.146.82.204, which is the broadcast


address of the subnet if the netmask is 255.255.224.0?
10000001 . 10010010 . 010 10010 . 11001100 IP
AND 11111111 . 11111111 . 111 00000 . 00000000 netmask

10000001 . 10010010 010 00000 . 00000000


Transform to 1

10000001 . 10010010 010 11111 . 11111111

129. 146 . 95 . 255

129.146.95.255
Computer Networks 23

You might also like