Chap 3 Network Layer

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 102

Network Layer

SWITCHING
• Circuit Switching: a physical circuit (or
channel) is established between the source
and destination of the message before the
delivery of the message
• Packet Switching: the message is first divided
into manageable packets at the source before
being transmitted, packets are assembled at
the destination
Packet Switching
• Packet at the source is divided into
manageable packets, normally called
datagrams
• Packet Switching services:
– Connectionless Service
– Connection-Oriented Service
Connectionless Service
• Treats each packet independently
• Packets in a message may or may not travel
the same path to their destination
• Network layer is only responsible for delivery
of packets from the source to the destination
Connectionless Service
Forwarding process in a router when used in
a connectionless network
Delay In Connectionless Network
In a connectionless packet-switched network, the
forwarding decision
is based on the destination address of the packet
Connection-Oriented Service
• There is a relation between all packets belonging
to a message
• Before all datagrams in a message can be sent, a
virtual connection should be set up to define the
path for the datagrams
• The datagrams follow the same path
• It must also contain a flow label, a virtual circuit
identifier that defines the virtual path the packet
should follow
Connection-Oriented Service
Virtual Path and Virtual Circuit
Virtual Path Identifier and Virtual Circuit
Identifier
Forwarding process in a router when used in
a connection-oriented network
Setup Phase: Request
Setup Phase: Acknowledgement
Data Transfer Phase
Teardown Phase
• Source A, after sending all packets to B, sends
a special packet called a teardown packet
• Destination B responds with a confirmation
packet
• Routers delete the corresponding entry from
their tables.
Delay In Connection-Oriented Network
Position of IP in TCP/IP protocol suite
DATAGRAM

• A packet in the IP layer is called a datagram, a


variable-length packet consisting of two parts:
header and data.
• The header is 20 to 60 bytes in length and contains
information essential to routing and delivery.
IP datagram
Note:

The precedence subfield was designed,


but never used in version 4.
Service type
Note:

The total length field defines the total


length of the datagram including the
header.
Multiplexing

PROTOCOL field specifies the final destination protocol to


which the IP datagram should be delivered
Example 1

An IP packet has arrived with the first 8 bits as shown:

01000010

The receiver discards the packet. Why?

Solution
There is an error in this packet. The 4 left-most bits (0100) show
the version, which is correct. The next 4 bits (0010) show the
header length; which means (2 × 4 = 8), which is wrong. The
minimum number of bytes in the header must be 20. The packet
has been corrupted in transmission.
Example 2

In an IP packet, the value of HLEN is 1000 in binary. How many


bytes of options are being carried by this packet?

Solution
The HLEN value is 8, which means the total number of bytes in
the header is 8 × 4 or 32 bytes. The first 20 bytes are the base
header, the next 12 bytes are the options.
Example 3

In an IP packet, the value of HLEN is 516


and the value of the total length field is 002816 . How
many bytes of data are being carried by this packet?

Solution
The HLEN value is 5, which means the total number of bytes in
the header is 5 × 4 or 20 bytes (no options). The total length is
40 bytes, which means the packet is carrying 20 bytes of data
(40 − 20).
Example 4

An IP packet has arrived with the first few hexadecimal digits as


shown below:

45000028000100000102 . . .

How many hops can this packet travel before being dropped?
The data belong to what upper layer protocol?

Solution
To find the time-to-live field, we skip 8 bytes (16 hexadecimal
digits). The time-to-live field is the ninth byte, which is 01. This
means the packet can travel only one hop. The protocol field is
the next byte (02), which means that the upper layer protocol is
IGMP
FRAGMENTATION:
The format and size of a frame depend on the protocol used by the
physical network. A datagram may have to be fragmented to fit the
protocol regulations.

The topics discussed in this section include:


Maximum Transfer Unit (MTU)
Fields Related to Fragmentation
MTU
MTUs for some networks
Fields related to fragmentation
• Identification: Identifies the datagram
originating from source host
– All packets have same identification number
• Flags: Three bit field used for fragmentation
• Fragmentation offset: Shows the relative
position of the fragment with respect to whole
datagram
Flags field
Fragmentation example
The value of offset is measured in units of 8 bytes
Length of the offset is 13 bits and cannot represent a sequence of bytes > 8191
Detailed fragmentation example
Example 5

A packet has arrived with an M bit value of 0. Is this the first


fragment, the last fragment, or a middle fragment? Do we know
if the packet was fragmented?

Solution
If the M bit is 0, it means that there are no more fragments; the
fragment is the last one. However, we cannot say if the original
packet was fragmented or not. A nonfragmented packet is
considered the last fragment.
Example 6

A packet has arrived with an M bit value of 1. Is this the first


fragment, the last fragment, or a middle fragment? Do we know
if the packet was fragmented?

Solution
If the M bit is 1, it means that there is at least one more
fragment. This fragment can be the first one or a middle one, but
not the last one. We don’t know if it is the first one or a middle
one; we need more information (the value of the fragmentation
offset)
Example 7

A packet has arrived with an M bit value of 1 and a


fragmentation offset value of zero. Is this the first fragment, the
last fragment, or a middle fragment?

Solution
Because the M bit is 1, it is either the first fragment or a middle
one. Because the offset value is 0, it is the first fragment.
Example 8

A packet has arrived in which the offset value is 100. What is the
number of the first byte? Do we know the number of the last
byte?

Solution
To find the number of the first byte, we multiply the offset value
by 8. This means that the first byte number is 800. We cannot
determine the number of the last byte unless we know the length
of the data.
Example 9

A packet has arrived in which the offset value is 100, the value of
HLEN is 5 and the value of the total length field is 100. What is
the number of the first byte and the last byte?

Solution
The first byte number is 100 × 8 = 800. The total length is 100
bytes and the header length is 20 bytes (5 × 4), which means that
there are 80 bytes in this datagram. If the first byte number is
800, the last byte number must be 879.
IP Addresses:
Classful Addressing
An IP address is a 32-bit address.

The IP addresses are unique

The address space of IPv4 is


232 or 4,294,967,296.
Dotted-decimal notation
Example 1

Change the following IP 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
Example 2

Change the following IP addresses from dotted-decimal


notation to binary notation.
a. 111.56.45.78 b. 221.34.7.82
c. 241.8.56.12 d. 75.45.34.78

Solution
We replace each decimal number with its binary equivalent:
a. 01101111 00111000 00101101 01001110
b. 11011101 00100010 00000111 01010010
c. 11110001 00001000 00111000 00001100
d. 01001011 00101101 00100010 01001110
Example 3

Find the error, if any, in the following IP 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 are no leading zeroes in dotted-decimal notation (045).
b. We may not have more than four numbers in an IP address.
c. In dotted-decimal notation, each number is less than or equal
to 255; 301 is outside this range.
d. A mixture of binary notation and dotted-decimal notation is not
allowed.
Example 4

Change the following IP addresses from binary notation to


hexadecimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111

Solution
We replace each group of 4 bits with its hexadecimal
equivalent Note that hexadecimal notation normally has no
added spaces or dots; however, 0X (or 0x) is added at the
beginning or the subscript 16 at the end to show that the
number is in hexadecimal.
a. 0X810B0BEF or 810B0BEF16
b. 0XC1831BFF or C1831BFF16
Finding the class in binary
notation
Example 6

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

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 bit is 0; the second bit is 1. This is a class B address.
d. The first 4 bits are 1s. This is a class E address..
Figure 4.5 Finding the class in decimal notation
Example 7

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 e.134.11.78.56

Solution
a. The first byte is 227 (between 224 and 239); the class is D.
b. The first byte is 193 (between 192 and 223); the class is C.
c. The first byte is 14 (between 0 and 127); the class is A.
d. The first byte is 252 (between 240 and 255); the class is E.
e. The first byte is 134 (between 128 and 191); the class is B.
Netid and hostid
Blocks in class A
Blocks in class B
Blocks in class C
Class D addresses are used for
multicasting; there is only one block in
this class.

Class E addresses are reserved for future


purposes; most of the block is wasted.
Example 9

Given the network address 17.0.0.0, find the class, the block,
and the range of the addresses.

Solution
The class is A because the first byte is between 0 and 127. The
block has a netid of 17. The addresses range from 17.0.0.0 to
17.255.255.255.
Example 10

Given the network address 132.21.0.0, find the class, the block,
and the range of the addresses.

Solution
The class is B because the first byte is between 128 and 191.
The block has a netid of 132.21. The addresses range from
132.21.0.0 to 132.21.255.255.
Example 11

Given the network address 220.34.76.0, find the class, the


block, and the range of the addresses.

Solution
The class is C because the first byte is between 192
and 223. The block has a netid of 220.34.76. The
addresses range from 220.34.76.0 to 220.34.76.255.
Example 12

Find the number of addresses in a range if the first


address is 146.102.29.0 and the last address is
146.102.32.255.

Solution
We can subtract the first address from the last
address in base 256 . The result is 0.0.3.255 in this
base. To find the number of addresses in the range
(in decimal), we convert this number to base 10 and
add 1 to the result.
Example 13

The first address in a range of addresses is


14.11.45.96. If the number of addresses in the range is
32, what is the last address?

Solution
We convert the number of addresses minus 1 to base
256, which is 0.0.0.31. We then add it to the
first address to get the last address
Extracting Information in a Block
• 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 0s.
• To find the last address, we keep the n
leftmost bits and set the (32 − n) rightmost
bits all to 1s.
Extracting Information in a Block
Example

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.
Masking concept
AND operation
Default masks
Example

Given the address 23.56.7.91, find the beginning address


(network address).

Solution
The default mask is 255.0.0.0, which means that only the first
byte is preserved and the other 3 bytes are set to 0s. The
network address is 23.0.0.0.
Example

Given the address 132.6.17.85, find the beginning address


(network address).

Solution
The default mask is 255.255.0.0, which means that the first 2
bytes are preserved and the other 2 bytes are set to 0s. The
network address is 132.6.0.0.
Example

Given the address 201.180.56.5, find the beginning address


(network address).

Solution
The default mask is 255.255.255.0, which means that the first 3
bytes are preserved and the last byte is set to 0. The network
address is 201.180.56.0.
Note:

Note that we must not apply the


default mask of one class to an address
belonging to another class.
Subnetting
• The idea of splitting a block to smaller blocks
is referred to as subnetting.
• In subnetting, a network is divided into
several smaller subnetworks (subnets) with
each subnetwork having its own subnetwork
address.
• Subnetid for each subnetwork is, n-network
mask length, s- number of subnets
CLASSLESS ADDRESSING
• In classless addressing, the prefix defines the
network and the suffix defines the host.
Slash Notation
• The slash notation is formally referred to as
classless interdomain routing or CIDR
(pronounced cider) notation.
• 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.
Special addresses
Special addresses
Network address
The first address in the block define the network address
Example of direct broadcast address
Example of limited broadcast address
Examples of “this host on this network”
Example of “specific host on this network”

Class A address
Example of loopback address
IP with first byte as 127 is used for the loopback address used
to test the software on a machine . Class A address.
Private Addresses

Addresses for private networks

These addresses are used either in isolation or in connection


with Network Address Translation techniques (NAT).
Network Address Translation
(NAT)
NAT
Address Translation
Translation
Translation table
Unicast, Multicast and Broadcast
Addresses
• Unicast Addresses
 One-to-one communication
 A,B or C classes
• Multicast Addresses
 One-to-many communication
 D class
• Broadcast Addresses
 One-to-all communication
 Allows broadcasting only at local level
 Limited broadcast address (all 1s)
 Direct broadcast address(netid:specific, hostid:all 1s)
Multicast Addresses: Category addresses
Multicast Addresses :Addresses for conferencing

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy