0% found this document useful (0 votes)
13 views61 pages

1 Module 1 Notes

The document provides an overview of the network layer, detailing its responsibilities such as host-to-host delivery, packetizing, routing, and forwarding, along with additional services like error control and quality of service. It discusses IPv4 addressing, including the structure of addresses, classful and classless addressing, and the challenges of address depletion, as well as subnetting and supernetting strategies. The document also explains how to extract information from classless addresses using prefix length and address masks.

Uploaded by

prajwalas572
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views61 pages

1 Module 1 Notes

The document provides an overview of the network layer, detailing its responsibilities such as host-to-host delivery, packetizing, routing, and forwarding, along with additional services like error control and quality of service. It discusses IPv4 addressing, including the structure of addresses, classful and classless addressing, and the challenges of address depletion, as well as subnetting and supernetting strategies. The document also explains how to extract information from classless addresses using prefix length and address masks.

Uploaded by

prajwalas572
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NETWORK LAYER

• The network layer is responsible for the host-to-


host delivery of datagrams.
• It provides services to the transport layer and
receives services from the data-link layer
NETWORK-LAYER SERVICES
Packetizing, Routing and Forwarding
Other Services
Error Control; Flow Control; Congestion
Control; Quality of Service; Security
A Scenario: Communication at the Network Layer
Packetizing
• Encapsulating the payload in a packet at the source and
decapsulating the payload from the packet at another end
• At source host receives the payload from an upper-layer
protocol, adds a header that contains the source and
destination addresses and some other information and
delivers the packet to the data-link layer.
• At destination host receives the packet from its data-link
layer, decapsulates the packet, and delivers the payload to
the corresponding upper-layer protocol
• If the packet is fragmented the network layer is responsible
for waiting until all fragments arrive, reassembling them,
and delivering them to the upper-layer protocol
Routing and Forwarding
Routing: routing the packet from its source to the
destination
• There is more than one route from the source to
the destination
• The network layer is responsible for finding the
best one among these possible routes.
• The network layer needs to have some specific
strategies for defining the best route
Forwarding
• If routing is applying strategies and running some
routing protocols to create the decision-making
tables for each router, forwarding by each router
when a packet arrives at one of its interfaces.
• Decision-making table called the forwarding
table or routing table: a router normally uses this
table to forward the packet based on the
destination address/label
Other Services
• Error Control: implemented in the network layer
• The designers of the network layer added a
checksum field to the datagram to control any
corruption in the header, but not in the whole
datagram.
• This checksum may prevent any changes or
corruptions in the header of the datagram
• The network layer in the Internet does not
directly provide error control, the Internet uses
an auxiliary protocol, ICMP, that provides some
kind of error control if the datagram is discarded
or has some unknown information in the header.
Flow Control
• Regulates the amount of data a source can send
without overwhelming the receiver.
• If the source computer produces data faster than
the destination computer can consume it, the
receiver will be overwhelmed with data.
• To control the flow of data, the receiver needs to
send some feedback to the sender
• Network layer in the Internet, does not directly
provide any flow control. The datagrams are sent by
the sender when they are ready, without any
attention to the readiness of the receiver
Congestion Control
• Congestion in the network layer is a situation in
which too many datagrams are present in an area of
the Internet
• Congestion may occur if the number of datagrams
sent by source computers is beyond the capacity of
the network or routers
• In this situation, routers may drop some of the
datagrams. As more datagrams are dropped, the
situation may become worse
• Due to the error control mechanism at the upper
layers, the sender may send duplicates of the lost
packets.
• If the congestion continues, sometimes a situation
may reach a point where the system collapses and no
datagrams are delivered.
Quality of Service
• As the Internet allowed new applications,
multimedia (real-time communication of audio
and video), the quality of service (QoS) become
more and more important
• The Internet developed by providing better
quality of service to support these applications
Security
• Security not a concern when the Internet was
originally designed because it was used by a small
number of users at universities for research
activities;
• The network layer was designed with no security
provision.
• Today, security is a big concern. To provide
security for a connectionless network layer, we
need to have another virtual level that changes
the connectionless service to a connection-
oriented service. This virtual layer, called IPSec.
IPV4 ADDRESSES
• The identifier used in the IP layer 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.
• IP address is the address of the connection because
if the device is moved to another network, the IP
address may be changed.
• IPv4 addresses are unique. If a device has two
connections, it has two IPv4 addresses.
Address Space
• A protocol 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 are no restrictions, more than
4 billion devices can be connected to the Internet.
Notation
• Three common notations to show an IPv4 address:
binary notation (base 2), dotted-decimal notation (base
256), and hexadecimal notation (base 16).
• Binary notation: An IPv4 address is displayed as 32 bits.
• Dotted-decimal notation: To make the IPv4 address
more compact and easier to read, it is usually written
in decimal form with a decimal point (dot) separating
the bytes
• Hexadecimal notation: Each hexadecimal digit is
equivalent to four bits. So 32-bit address has 8
hexadecimal digits. This notation is often used in
network programming.
Three Different Notation in IPv4 Addressing
Hierarchy in Addressing
• In any communication network, the addressing
system is hierarchical.
• In a postal network, the postal address (mailing
address) includes the country, state, city, street,
house number, and the name of the mail recipient.
• A telephone number is divided into the country
code, area code, local exchange, and the
connection.
• A 32-bit IPv4 address is also hierarchical, but
divided only into two parts. The first part of the
address, called the prefix, defines the network; the
second part of the address, called the suffix, defines
the node (connection of a device to the Internet)
Prefix and Suffix of a 32-bit IPv4 address
• The prefix length is n bits and the suffix length is
(32 − n) bits
• A prefix can be fixed length or variable length. The
network identifier in the IPv4 was first designed as
a fixed-length prefix. This scheme is now obsolete,
is called as classful addressing. The new scheme,
classless addressing, uses a variable-length
network prefix
Hierarchy in
Addressing
Classful Addressing
• An IPv4 address designed with a fixed-
length prefix
• To accommodate both small and large
networks, three fixed-length prefixes are
designed instead of one (n = 8, n = 16, and
n = 24).
• The whole address space divided into five
classes (A, B, C, D, and E). This scheme is
called as classful addressing.
Occupation of the address space in
classful addressing
• Class A: The network length is 8 bits, but since the first bit,
which is 0, defines the class, remaining seven bits as the
network identifier. This means there are only 27 = 128
networks in the world that can have a class A address.
• Class B: the network length is 16 bits, first two bits are(10)2,
define the class, only 14 bits as the network identifier. So
only 214 = 16,384 networks in the world that can have a
class B address.
• Class C: All addresses that start with (110)2, the network
length is 24 bits, only 21 bits as the network identifier.
There are 221 = 2,097,152 networks in the world that can
have a class C address.
• Class D: not divided into prefix and suffix, used for
multicast addresses.
• Class E is not divided into prefix and suffix and is used as
reserve. All addresses that start with 1111 belong to class
E.
Address Depletion
• The classful addressing has become obsolete is address
depletion. Since the addresses were not distributed properly
• Let us consider class A. This class assigned to only 128
organizations in the world, but each organization needs to
have a single network with 16,777,216 nodes ; Since there
may be only a few organizations needs this large, most of the
addresses in this class are wasted (unused).
• Class B addresses designed for midsize organizations, but
many of the addresses in this class also remained unused.
• Class C addresses have a completely different in design. The
number of addresses used in each network (256) is so small,
most companies are not comfortable using a block in this
address class.
• Class E addresses almost never used, wasting the whole class.
Subnetting and Supernetting
• To avoid address depletion, two strategies
proposed : Subnetting and Supernetting
• Subnetting: Class A/Class B block is divided into several subnets.
Each subnet has a larger prefix length than the original network.
• Example: if a network in class A is divided into four subnets,
each subnet has a prefix of nsub= 10. At the same time, if all of
the addresses in a network are not used, subnetting allows the
addresses to be divided among several organizations. This idea
did not work because most large organizations were not happy
about dividing the block and giving some of the unused
addresses to smaller organizations.
• While subnetting is to divide a large block into smaller
ones, supernetting is to combine several class C blocks
into a larger block to be attractive to organizations that
need more than the 256 addresses available in a class C
block. This idea did not work either because it makes the
routing of packets more difficult.
Advantage of Classful Addressing
• Although classful addressing had several
problems and became obsolete
• It had one advantage: Given an address, we can
easily find the class of the address and, since the
prefix length for each class is fixed, we can find
the prefix length immediately
Classless Addressing
• Subnetting and supernetting in classful addressing did
not really solve the address depletion problem.
• With the growth of the Internet, it was clear that a
larger address space needed as a long-term solution.
• Requires 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
• The short-term solution still uses IPv4 addresses, but it
is called classless addressing. In other words, the class
privilege was removed from the distribution to
compensate for the address depletion.
• Another motivation for classless addressing. During the 1990s,
Internet Service Providers (ISPs) came into prominence and
provides Internet access for individuals, small businesses, and
midsize organizations
• An ISP is granted a large range of addresses and then subdivides the
addresses (in groups of 1, 2, 4, 8, 16, and so on), giving a range of
addresses to a household or a small business.
• The customers are connected via a dial-up modem, DSL, or cable modem
to the ISP. However, each customer needs some IPv4 addresses.
• In 1996, the Internet authorities announced a
new architecture called classless addressing.
• In classless addressing, variable-length blocks are used
that belong to no classes: block of 1 address, 2
addresses, 4 addresses, 128 addresses, and so on.
• The whole address space is divided into variable length blocks. The prefix
in an address defines the block (network); the suffix defines the node
(device). Theoretically, we can have a block of 20, 21, 22, . . . , 232
addresses. the number of addresses in a block needs to be a power of 2.
An organization can be granted one block of addresses.
The division of the whole address space
into no overlapping blocks.

Variable-length blocks in classless addressing


• In classless addressing, a prefix length that ranges
from 0 to 32. The size of the network is inversely
proportional to the length of the prefix.
• A small prefix means a larger network; a large
prefix means a smaller network.
• The idea of classless addressing can be easily
applied to classful addressing.
• An address in class A can be a classless address in
which the prefix length is 8.
• An address in class B can be a classless address in
which the prefix is 16, and so on.
Prefix Length: Slash Notation
• How to find the prefix length if an address is
given. Prefix length is not inherent in the address,
separately give the length of the prefix(n)
• Prefix length n, is added to the address,
separated by a slash
• The notation is informally referred to as slash
notation and formally as Classless interdomain
routing or CIDR strategy

Slash notation (CIDR)


Extracting Information from an Address
• Given any address in the block, we normally like to know three
pieces of information about the block address : the number of
addresses, the first address in the block, and the last address.
Since the value of prefix length, n, is given, easily find these
three pieces of information
1. The number of addresses in the block is found as N = 232−n.
2. To find the first address, we keep the n leftmost bits and set the
(32 − n) rightmost bits all to 0s.
3. To find the last address, we keep the n leftmost bits and set the
(32 − n) rightmost bits all to 1s.

Information extraction in classless addressing


Example 1: A classless address is given as [Link]/27. Find the
number of addresses, the first address, and the last
address in the block
1. The number of addresses in the network is 232 − n = 25 = 32 addresses.

2. The first address can be found by keeping the first 27 bits and changing the
rest of the bits to 0s.
Address: [Link]/27 10100111 11000111 10101010 01010010
First address: [Link]/27 10100111 11000111 10101010 01000000

[Link] last address can be found by keeping the first 27 bits and changing the
rest of the bits to 1s.
Address: [Link]/27 10100111 11000111 10101010 01010010
Last address: [Link]/27 10100111 11000111 10101010 01011111
Address Mask
• Another way to find the first and last addresses in the block is to
use the address mask.
• The address mask is a 32-bit number in which the n leftmost bits
are set to 1s and the rest of the bits (32−n) are set to 0s. A computer
can easily find the address mask because it is the complement of
(232-n − 1). The reason for defining a mask in this way is that it can
be used by a computer program to extract the information in a
block, using the three bit-wise operations NOT, AND, and OR.
1. The number of addresses in the block N = NOT (mask) + 1.
2. The first address in the block = (Any address in the block) AND
(mask).
3. The last address in the block = (Any address in the block) OR
[(NOT (mask)].
Example2: A classless address is given as
[Link]/27. Find the number of addresses, the
first address in the block, and the last address using the
Address mask. The mask in dotted-decimal notation is
[Link].

Number of addresses in the block: N = NOT


(mask) + 1= [Link] + 1 = 32 addresses
First address: First = (address) AND (mask) =
[Link]
Last address: Last = (address) OR (NOT mask) =
[Link]
Example 3: In classless addressing, an address cannot define the
block the address belongs to. For example, the address [Link]
can belong to many blocks. Some of them are shown below with the
value of the prefix associated with that block.

• Prefix length:16 → Block: [Link] to [Link]


• Prefix length:20 → Block: [Link] to [Link]
• Prefix length:26 → Block: [Link] to [Link]
• Prefix length:27 → Block: [Link] to [Link]
• Prefix length:29 → Block: [Link] to [Link]
• Prefix length:31 → Block: [Link] to [Link]
Network Address
• The first address, the network address, is particularly important
because it is used in routing a packet to its destination network
• When a packet arrives at the router from any source host, the router
needs to know to which network the packet should be sent: from
which interface the packet should be sent out.
• After the network address found, the router consults its forwarding
table to find the corresponding interface from which the packet
should be sent out.
• The network address is actually the identifier of the network; each
network is identified by its network address.
Block Allocation
• The issue in classless addressing is block allocation. How
are the blocks allocated?
• The ultimate responsibility of block allocation is given to a
global authority : Internet Corporation for Assigned
Names and Numbers (ICANN).
• ICANN does not normally allocate addresses to individual
Internet users. It assigns a large block of addresses to an ISP
• For the proper operation of the CIDR, two restrictions
need to be applied to the allocated block.
1. The number of requested addresses, N, needs to be a power
of 2. The reason is that N = 2 32 − n or n = 32 − log2N.
2. The requested block needs to be allocated where there is
an adequate number of contiguous addresses available in
the address space.
• Restriction on choosing the first address in the
block.
• The first address needs to be divisible by the
number of addresses in the block.
• The reason is that the first address needs to be the
prefix followed by (32 − n) number of 0s.
• The decimal value of the first address
= (prefix in decimal) × 2 32 − n
= (prefix in decimal) × N.
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, [Link]/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.
Subnetting
• More levels of hierarchy can be created
using subnetting. An organization (or an ISP)
that is granted a range of addresses may divide
the range into several subranges and assign
each subrange to a subnetwork (or subnet).
Note : A subnetwork can be divided into
several sub-subnetworks. A sub-
subnetwork can be divided into several sub-
sub-subnetworks, and so on.
Designing Subnets
• Assume total no. of addresses granted=N, prefix length
is n, assigned no of addresses to each subnet is Nsub and
prefix length for each subnet is nsub
• The subnetworks in a network carefully designed to
enable the routing of packets.
Steps followed to operation of the subnetworks
1. Number of addresses in each subnetwork , power of 2.
2. Prefix length for each subnetwork found using the
following formula: nsub = 32 − log2Nsub
3. Starting address in subnetwork divisible by the number
of addresses.
Finding Information about Each Subnetwork: After
designing the subnetworks, the information about each
subnetwork, such as first and last address
Example : An organization is granted a
block of addresses with the beginning
address [Link]/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: Addresses in this block: 232 – 24 = 256.
The first address is [Link]/24; the last address is
[Link]/24. To satisfy the third requirement, we
assign addresses to subblocks, starting with the largest
and ending with the smallest one.
a. The number of addresses in the largest subblock,
requires 120 addresses, is not a power of 2. Allocate
128 addresses. The subnet mask for this subnet can be
found as n1 = 32 − log2128 = 25. The first address in
this block is [Link]/25; the last address is
[Link]/25.
b. No of addresses in the second largest subblock,
requires 60 addresses, is not a power of 2 either.
Allocate 64 addresses. The subnet mask is n2 = 32 −
log264 = 26. The first address is [Link]/26; the
last address is [Link]/26.
c. No of addresses in the smallest subblock,
requires 10 addresses, is not a power of 2
either. Allocate 16 addresses.
The subnet mask is n3 = 32 − log216 = 28.
The first address is [Link]/28;
The last address is [Link]/28.
Total (128+64+16) 208 addresses, i.e. 48
addresses are left in reserve.
The first address is [Link]. The last
address is [Link]. We don’t know about
the prefix length yet.
Configuration of blocks and first address
in each block
Address Aggregation
• One of the advantages of the CIDR strategy is
address aggregation; When blocks of addresses are
combined to create a larger block, routing can be
done based on the prefix of the larger block.
• ICANN assigns a large block of addresses to an ISP.
Each ISP divides its assigned block into smaller
subblocks and grants the subblocks to its
customers.
Example: 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. All packages coming from outside a
country are sent first to the capital and then distributed to the
corresponding destination.
Special Addresses
• Five special addresses that are used for special purposes:
1. This-host Address: The only address in the block [Link]/32 is called the
this-host address. It is used whenever a host needs to send an IP datagram
but it does not know its own address to use as the source address.
2. Limited-broadcast Address: The only address in the block
[Link]/32 is called the limited-broadcast address. It is used
whenever a router or a host needs to send a datagram to all devices in a
network. The routers in the network, however, block the packet having this
address as the destination; the packet cannot travel outside the network.
3. Loopback Address: The block [Link]/8 is called the loopback address.
A packet with one of the addresses in this block as the destination address
never leaves the host; it will remain in the host. Any address in the block is
used to test a piece of software in the machine.
4. Private Addresses: Four blocks are assigned as private addresses:
[Link]/8, [Link]/12, [Link]/16, and [Link]/16. applications
of these addresses using in NAT
5. Multicast Addresses: The block [Link]/4 is reserved for multicast
addresses.
Dynamic Host Configuration Protocol (DHCP)
• A large organization or an ISP can receive a block of addresses
directly from ICANN and a small organization can receive a
block of addresses from an ISP. After a block of addresses are
assigned to an organization, the network administration can
manually assign addresses to the individual hosts or routers.
• Address assignment in an organization can be done
automatically using the Dynamic Host Configuration Protocol
(DHCP).
• DHCP has found such widespread use in the Internet that it is
often called a plug and-play protocol.
• Configure DHCP to assign permanent IP addresses to the host
and routers
• DHCP can also be configured to provide temporary, on demand,
IP addresses to hosts.
• In addition to its IP address, a computer also
needs to know the network prefix
• Most computers also need two other pieces of
information, address of a default router to
communicate with other networks and the
address of a name server
• Four pieces of information are normally needed:
the computer address, the prefix, the address of
a router, and the IP address of a name server.
• DHCP can be used to provide these pieces of
information to the host
DHCP Message Format
• DHCP is a client-server protocol in which the
client sends a request message and the server
returns a response message.
Option Format
• The 64-byte option field has a dual purpose.
• It can carry either additional information or some specific
vendor information.
• An option is composed of three fields: a 1-byte tag field, a
1-byte length field, and a variable-length value field.
• There are several tag fields that are mostly used by
vendors. If the tag field is 53, the value field defines one of
the 8 message types
Operation of DHCP
Operation of DHCP
1. The joining host creates a DHCPDISCOVER message in which only
the transaction- ID field is set to a random number. This message is
encapsulated in a UDP user datagram with the source port set to 68
and the destination port set to 67. The user datagram is
encapsulated in an IP datagram with the source address set to
[Link] (“this host”) and the destination address set to
[Link] (broadcast address). The reason is that the joining
host knows neither its own address nor the server address.
2. The DHCP server or servers (if more than one) responds with a
DHCPOFFER message in which the your address field defines the
offered IP address for the joining host and the server address field
includes the IP address of the server.
3. The joining host receives one or more offers and selects the best of
them. The joining host then sends a DHCPREQUEST message to the
server that has given the best offer. The fields with known value
are set.
4. Finally, the selected server responds with a DHCPACK message to
the client if the offered IP address is valid. If the server cannot
offer, the server sends a DHCPNACK message and the client needs
to repeat the process.
• Two Well-Known Ports: DHCP uses two well-
known ports (68 and 67) instead of one well-
known and one Regular. The well-known port 68
is using for broadcast
• Using FTP: In the DHCPACK message, the server
defines the pathname of a file in which the client
can find the address of the DNS server and use a
file transfer protocol to obtain the rest of the
needed information.
• Error Control: To provide error control, DHCP uses
two strategies. First, DHCP requires that UDP use
the checksum. Second, the DHCP client uses
timers and a retransmission policy if it does not
receive the DHCP reply to a request..
Network Address Resolution (NAT)
• The distribution of addresses through ISPs has created
a new problem.
• Assume that an ISP has granted a small range of
addresses to a small business or a household.
• If the business grows or the household needs a larger
range, the ISP may not be able to grant the demand
because the addresses before and after the range may
have already been allocated to other networks.
• In most situations, only a portion of computers in a
small network need access to the Internet
simultaneously.
• This means that the number of allocated addresses
does not have to match the number of computers in
the network.
• 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.
• The site must have only one connection to the
global Internet through a NAT-capable router
that runs NAT software.
A simple implementation of NAT

In this Figure, private network uses private addresses. The


router that connects the network to the global address
uses one private address and one global address. The
private network is invisible to the rest of the Internet; the
rest of the Internet sees only the NAT router with the
address [Link].
Address Translation: All outgoing packets go
through the NAT router, which replaces the source
address with the global NAT address. All incoming
packets also pass through the NAT router, which
replaces the destination address with the
appropriate private address
Translation Table
How does the NAT router know the destination
address for a packet coming from the Internet?
There may be tens or hundreds of private IP
addresses, each belonging to one specific host.
The problem is solved if the NAT router has a
translation table.
Translation table has only two columns: the
private address and the external address
(destination address of the packet).
Translation Using One IP
When the router translates the source address of the outgoing packet,
it also makes note of the destination address, where the packet is
going. When the response comes back from the destination, the router
uses the source address of the packet (as the external address) to find
the private address of the packet.

58
• NAT is used mostly by ISPs that assign a single
address to a customer.
• The customer, may be a member of a private
network that has many private addresses.
• Communication with the Internet is always
initiated from the customer site, using a client
program such as HTTP, TELNET, or FTP to access
the corresponding server program.
Using a Pool of IP Addresses
• The use of only one global address by the NAT
router allows only one private-network host to
access a given external host.
• To remove this restriction, the NAT router can use
a pool of global addresses. For example, instead of
using only one global address ([Link]), the
NAT router can use four addresses ([Link],
[Link], [Link], and [Link]).
• In this case, four private-network hosts can
communicate with the same external host at the
same time because each pair of addresses defines
a separate connection.
Using both IP Address and Port Address
To allow a many-to-many relationship between private-network hosts and
external server programs, we need more information in the translation table
Example: suppose two hosts inside a private network with addresses [Link]
and [Link] need to access the HTTP server on external host [Link]. If the
translation table has five columns, instead of two, that include the source and
destination port addresses and the transport-layer protocol, the ambiguity is
eliminated
Below Table: Five-column translation table

61

You might also like