Department of CSE (AI & ML)
Academic Year 2024-25
Course: Computer Networks
Course Code:BCS502
MODULE – 03
Dr. Pavithra G S,
Associate Professor
Dept. of CSE(AIML), RNSIT
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Content
NETWORK-LAYER SERVICES
PACKET SWITCHING
NETWORK-LAYER PERFORMANCE
IPv4 ADDRESSES
FORWARDING OF IP PACKETS
18.2
Communication at the network layer
18.3
DATA AND SIGNALS
Figure: shows a
scenario in which a
scientist working in a
research company, Sky
Research, needs to
order a book related to
her research from an
online bookseller,
Scientific Books.
3.4 Communication at the physical layer
Communication at the data-link layer
9.5
Packetizing
The first duty of the network layer is definitely
packetizing: encapsulating the payload in a
network-layer packet at the source and
decapsulating the payload from the network-layer
packet at the destination.
Thus, one duty of the network layer is to carry a
payload from the source to the destination without
changing it or using it.
The network layer is doing the service of a carrier
such as the postal office, which is responsible for
delivery of packages from a sender to a receiver
without changing or using the contents.
18.6
Routing and Forwarding
Other duties of the network layer, which are as
important as the first, are routing and forwarding,
which are directly related to each other.
Routing involves finding the best route to send
packets from source to destination by running
routing protocols and creating and updationg
forwarding/routing tables
Forwarding involves actions applied by each router
when a packet arrives at one of its interface
18.7
Forwarding process
18.8
Other Services
Other services expected from the network layer.
Error Control
Flow Control
Congestion Control
Quality of Service (QoS)
Security
18.9
PACKET SWITCHING
A router, in fact, is a switch that creates a
connection between an input port and an
output port (or a set of output ports), just as an
electrical switch connects the input to the
output to let electricity flow.
18.10
Datagram Approach
When the Internet started, to make it simple, the
network layer was designed to provide a
connectionless service in which the network-layer
protocol treats each packet independently, with each
packet having no relationship to any other packet.
The idea was that the network layer is only
responsible for delivery of packets from the source to
the destination. In this approach, the packets in a
message may or may not travel the same path to
their destination.
18.11
A connectionless packet-switched network
18.12
Forwarding process in a router when used in a connectionless network
18.13
Virtual-Circuit Approach
In a connection-oriented service (also called
virtual-circuit approach), there is a relationship
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. After connection setup, the
datagrams can all follow the same path. In this type
of service, not only must the packet contain the
source and destination addresses, it must also
contain a flow label, a virtual circuit identifier that
defines the virtual path the packet should follow.
18.14
A virtual-circuit packet-switched network
18.15
Forwarding process in a router when used in a virtual circuit network
18.16
Sending request packet in a virtual-circuit network
18.17
Sending acknowledgments in a virtual-circuit network
18.18
IPv4 ADDRESSES
The identifier used in the IP layer of the
TCP/IP protocol suite to identify the
connection of each device to the Internet is
called the Internet address or IP address. An
IPv4 address is a 32-bit address that uniquely
and universally defines the connection of a
host or a router to the Internet. The IP address
is the address of the connection, not the host or
the router.
18.19
Address Space
A protocol like 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
b bits to define an address, the address space is 2b
because each bit can have two different values (0 or
1). IPv4 uses 32-bit addresses, which means that the
address space is 232 or 4,294,967,296 (more than
four billion). If there were no restrictions, more than
4 billion devices could be connected to the Internet.
18.20
Three different notations in IPv4 addressing
18.21
Hierarchy in addressing
18.22
Classful Addressing
When the Internet started, an IPv4 address was
designed with a fixed-length prefix, but to
accommodate both small and large networks, three
fixed-length prefixes were designed instead of one (n
= 8, n = 16, and n = 24). The whole address space
was divided into five classes (class A, B, C, D, and
E), as shown in Figure. This scheme is referred to
as classful addressing. Although classful addressing
belongs to the past, it helps us to understand
classless addressing, discussed later.
18.23
Occupation of the address space in classful addressing
18.24
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
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
18.25
Classless Addressing
With the growth of the Internet, it was clear that a
larger address space was needed as a long-term
solution. The larger address space, however,
requires that the length of IP addresses also be
increased, which means the format of the IP packets
needs to be changed. Although the long-range
solution has already been devised and is called IPv6,
a short-term solution was also devised to use the
same address space but to change the distribution of
addresses to provide a fair share to each
organization. The short-term solution still uses IPv4
addresses, but it is called classless addressing.
18.26
Variable-length blocks in classless addressing
18.27
Slash notation (CIDR)
18.28
Information extraction in classless addressing
Set all
suffix bits
to 0s
Set all
suffix bits
to 1s
18.29
Example
A classless address is given as 167.199.170.82/27. We can
find the above three pieces of information as follows. The
number of addresses in the network is 232− n = 25 = 32
addresses. The first address can be found by keeping the
first 27 bits and changing the rest of the bits to 0s.
The last address can be found by keeping the first 27 bits
and changing the rest of the bits to 1s.
18.30
Example
We repeat Example using the mask. The mask in
dotted-decimal notation is 256.256.256.224 The AND, OR,
and NOT operations can be applied to individual bytes using
calculators and applets at the book website.
18.31
Example
In classless addressing, an address cannot per se define the
block the address belongs to. For example, the address
230.8.24.56 can belong to many blocks. Some of them are
shown below with the value of the prefix associated with
that block.
18.32
Default masks for classful addressing
18.33
Network address
18.34
Example
An ISP has requested a block of 1000 addresses. Since 1000
is not a power of 2, 1024 addresses are granted. The prefix
length is calculated as n = 32 − log21024 = 22. An available
block, 18.14.12.0/22, is granted to the ISP. It can be seen
that the first address in decimal is 302,910,464, which is
divisible by 1024.
18.35
Example
An organization is granted a block of addresses with the
beginning address 14.24.74.0/24. The organization needs to
have 3 subblocks of addresses to use in its three subnets: one
subblock of 10 addresses, one subblock of 60 addresses, and
one subblock of 120 addresses. Design the subblocks.
Solution
There are 232– 24 = 256 addresses in this block. The first
address is 14.24.74.0/24; the last address is 14.24.74.255/24.
To satisfy the third requirement, we assign addresses to
subblocks, starting with the largest and ending with the
smallest one.
18.36
Example
a. The number of addresses in the largest subblock, which
requires 120 addresses, is not a power of 2. We allocate 128
addresses. The subnet mask for this subnet can be found as
n1 = 32 − log2 128 = 25. The first address in this block is
14.24.74.0/25; the last address is 14.24.74.127/25.
b. The number of addresses in the second largest subblock,
which requires 60 addresses, is not a power of 2 either. We
allocate 64 addresses. The subnet mask for this subnet can
be found as n2 = 32 − log2 64 = 26. The first address in this
block is 14.24.74.128/26; the last address is
14.24.74.191/26.
18.37
Example
c. The number of addresses in the largest subblock, which
requires 120 addresses, is not a power of 2. We allocate 128
addresses. The subnet mask for this subnet can be found as
n1 = 32 − log2 128 = 25. The first address in this block is
14.24.74.0/25; the last address is 14.24.74.127/25.
If we add all addresses in the previous subblocks, the result
is 208 addresses, which means 48 addresses are left in
reserve. The first address in this range is 14.24.74.208. The
last address is 14.24.74.255. We don’t know about the prefix
length yet. Figure 18.23 shows the configuration of blocks.
We have shown the first address in each block.
18.38
Solution to Example
18.39
Example
Figure shows how four small blocks of addresses are
assigned to four organizations by an ISP. The ISP combines
these four blocks into one single block and advertises the
larger block to the rest of the world. Any packet destined for
this larger block should be sent to this ISP. It is the
responsibility of the ISP to forward the packet to the
appropriate organization. This is similar to routing we can
find in a postal network. All packages coming from outside
a country are sent first to the capital and then distributed to
the corresponding destination.
18.40
Example of address aggregation
18.41
DHCP
After a block of addresses are assigned to an
organization, the network administration can
manually assign addresses to the individual hosts or
routers. However, address assignment in an
organization can be done automatically using the
Dynamic Host Configuration Protocol (DHCP).
DHCP is an application-layer program, using the
client-server paradigm, that actually helps TCP/IP at
the network layer.
18.42
DHCP message format
18.43
Option format
18.44
Operation of DHCP
18.45
FSM for the DHCP client
18.46
NAT
In most situations, only a portion of computers in a
small network need access to the Internet
simultaneously. A technology that can provide the
mapping between the private and universal
addresses, and at the same time support virtual
private networks, is Network Address Translation
(NAT). The technology allows a site to use a set of
private addresses for internal communication and a
set of global Internet
addresses (at least one) for communication with the
rest of the world.
18.47
NAT
18.48
Address translation
18.49
Translation
18.50
Table: Five-column translation table
18.51
FORWARDING OF IP PACKETS
18.52
Destination Address Forwarding
This is a traditional approach, which is prevalent
today. In this case, forwarding requires a host or a
router to have a forwarding table. When a host has a
packet to send or when a router has received a
packet to be forwarded, it looks at this table to find
the next hop to deliver the packet to.
18.53
Simplified forwarding module in classless address
18.54
Example
Make a forwarding table for router R1 using the
configuration in Figure .
Solution
Table shows the corresponding table.
Table : Forwarding table for router R1 in Figure 4.46
18.55
Configuration for Example
18.56
Example
Instead of Table, we can use Table, in which the network
address/mask is given in bits.
Table Forwarding table for router R1 using prefix bits
When a packet arrives whose leftmost 26 bits in the
destination address match the bits in the first row, the packet
is sent out from interface m2. And so on.
18.57
Example
Show the forwarding process if a packet arrives at R1 in
Figure with the destination address 180.70.65.140.
Solution
The router performs the following steps:
1. The first mask (/26) is applied to the destination address.
The result is 180.70.65.128, which does not match the
corresponding network address.
2. The second mask (/25) is applied to the destination
address. The result is 180.70.65.128, which matches the
corresponding network address. The next-hop address
and the interface number m0 are extracted for
forwarding the packet.
18.58
Address aggregation
18.59
Longest mask matching
18.60
Example
As an example of hierarchical routing, let us consider Figure
18.36. A regional ISP is granted 16,384 addresses starting
from 120.14.64.0. The regional ISP has decided to divide
this block into 4 subblocks, each with 4096 addresses. Three
of these subblocks are assigned to three local ISPs, the
second subblock is reserved for future use. Note that the
mask for each block is /20 because the original block with
mask /18 is divided into 4 blocks.
The figure also shows how local and small ISPs have
assigned addresses.
18.61
Hierarchical routing with ISPs
18.62
Forwarding Based on Label
In the 1980s, an effort started to somehow change
IP to behave like a connection-oriented protocol in
which the routing is replaced by switching. As we
discussed earlier In a connection-oriented network
(virtual-circuit approach), a switch forwards a
packet based on the label attached to the packet.
Routing is normally based on searching the contents
of a table; switching can be done by accessing a
table using an index. In other words, routing
involves searching; switching involves accessing..
18.63
Example
Figure shows a simple example of searching in a forwarding
table using the longest mask algorithm. Although there are
some more efficient algorithms today, the principle is the
same.
When the forwarding algorithm gets the destination address
of the packet, it needs to delve into the mask column. For
each entry, it needs to apply the mask to find the destination
network address. It then needs to check the network
addresses in the table until it finds the match. The router
then extracts the next-hop address and the interface number
to be delivered to the data-link layer.
18.64
Forwarding based on destination address
18.65
Forwarding based on label
18.66
MPLS header added to an IP packet
18.67
MPLS header made of a stack of labels
18.68
Routers as Packet Switches
The packet switches that are used in the network
layer are called routers. Routers can be configured
to act as either a datagram switch or a virtual-circuit
switch.
18.69
IPv6 ADDRESSES
Despite all short-term solutions, address depletion is
still a long-term problem for the Internet. This and
other problems in the IP protocol itself have been the
motivation for IPv6.
Structure
Address Space
19.70
Note
An IPv6 address is 128 bits long.
19.71
IPv6 address in binary and hexadecimal colon notation
19.72
Abbreviated IPv6 addresses
19.73
19.11
Expand the address 0:15::1:12:1213 to its original.
Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find
how many 0s we need to replace the double colon.
This means that the original address is.
19.74
Type prefixes for IPv6 addresses
19.75
Type prefixes for IPv6 addresses (continued)
19.76
Prefixes for provider-based unicast address
19.77
Multicast address in IPv6
19.78
Reserved addresses in IPv6
19.79
Local addresses in IPv6
19.80