Chapter Three
The Network Layer
1
Outline
Internetworking,
Unicast and multicast routing
IPV4 Addressing [Class full]
IPV4 Addressing [ Classless- VLSM addressing]
Network layer protocols
Introducing IPV6 Addressing
2
Network Layer (3rd OSI Layer)
Concerned with getting packets from source to destination.
The network layer must know the topology of the subnet and choose
appropriate paths through it.
When source and destination are in different networks, the
network layer must deal with these differences.
The network layer is responsible for the source-to-destination
delivery of a packet, possibly across multiple networks.
Whereas the data link layer oversees the delivery of the packet
between two systems on the same network, the network layer
ensures that each packet gets from its point of origin to its final
destination.
If two systems are connected to the same local network, there is
usually no need for a network layer. However, if the 3 two
Cntd…
4
Cntd…
5
Cntd…
6
Cntd…
7
Cntd…
8
Cntd…
9
Position of network layer
10
Network layer at the source
11
Network layer at the Router
12
Network layer at the Destination
13
Network Layer Protocols
IPv4 was not designed with this feature in mind, although
mobility extensions exist.
IPv6 has a better designed solution.
Network layer protocols include: IPv4/IPv6, DVMRP (Distance
Vector Multicast Routing Protocol), ICMP(Internet Control Message
Protocol), IGMP(Internet Group Multicast Protocol), PIM-
SM( Protocol Independent Multicast Sparse Mode), PIM-
DM(Protocol Independent Multicast Dense Mode), IPsec(Internet
Protocol Security), IPX(Internetwork Packet Exchange), RIP(Routing
Information Protocol), Interior Gateway routing protocol(IGRP),
14
Routing Basics
The network layer of the OSI model provides routing functions and
establishes the route between the source and destination through
intermediary nodes(routers).
Routing is one of the fundamental aspects of networking. The ability of
routers to learn possible routes (rather than make you manually configure
and constantly update the routes) is one of the primary reasons that ARPANET
which originally connected seven sites, scaled into the modern Internet in
only a few short years.
A router is connected to at least two networks, and forwards data packets
from a network to another.
When it receives an incoming packet, it decides the next router (hop) to which
the packet should be forwarded towards its destination.
15
A routing table maintains the best routes to various network destinations.
Cont…
The construction of routing tables is very important
for efficient routing, and any corruption of the table may
lead to significant routing problems.
To create and maintain a routing table, a router
communicates with other routers using routing protocols.
A routing protocol allows routers to share information
about networks and their proximity to each other.
The routing protocol running in a router will learn all
available paths to a network (based on the information
advertised from different routers), but only determine the
best path to be stored in the routing table.
Whenever the topology of a network changes (e.g., a new
16
What are the Routing activities?
10.120.2.0 172.16.1.0
Path determination occurs at
Layer 3, the network layer.
The path determination
function enables a router to
Routing involves two basic
evaluate the available paths to
activities:
a destination and to establish
1. determining optimal routing
paths and the best path.
To route,
2. transporting a through
packets routera Routing services use network
needs to know:
network. topology information when
1. Destination addresses evaluating network paths.
2. Sources it can learn
This information can be
17
Cntd.
Routed networks are often large and complex, and it would
be excessively difficult to manage and update network
information on all routers all the time.
Several algorithms have been developed to help address these
difficulties.
These algorithms allow the routers to learn about the network
and then make decisions based on that information.
To learn paths (or routes) through a network, and make
decisions on where to send packets, a router use:
Destination address - Typically the Internet Protocol (IP)
address of the data’s (packet) destination.
Source address - Where the information came from
(typically an IP address).
Possible routes - Routes that can get information from its
18
present location or source to some other location (the
What Exactly Does “Best” Mean?
Routers often make decisions about the best possible path to
get information from a source to a destination.
“Best,” however, is loosely defined, and it depends on
what is valued by the network.
These measurements of value are referred to as
metrics.
Several metrics are listed here:
– Hop count - Number of times a packet goes through a
router.
– Delay time - Time required to reach the destination.
– Reliability - Bit-error rate of each network link.
19
Which Router/ Routing to Use?
To forward network traffic to the proper locations, the
routers on your network must have the correct entries
in their routing tables.
To do so routers will use either static or dynamic routing
techniques.
With static routing, network administrators must manually
create and modify the routing table entries.
Dynamic routing uses a specialized routing protocol to
20
Static Routes
o Static routes use a programmed route that a network
administrator enters into the router.
o A network administrator configures information about
remote networks manually
Benefits
No overhead on the router CPU
No bandwidth usage between routers
Adds security
Disadvantage
Administrator must really understand the internetwork
If a network is added to the internetwork, the administrator
21
has to add a route to it on all routers
Dynamic Routing
o Dynamic route uses a route that a routing protocol adjusts
automatically for topology or/and traffic changes
o When routers use dynamic routing, this information is
learned from other routers
Benefits
scalability and adaptability
can grow more quickly and larger
adapt to changes in the network topology
Disadvantage
complex structure
Adds overhead on the router CPU
Routers uses bandwidth to send routing table updates 22
Overview of Internet Routing
The Internet comprises a large number of interconnected
heterogeneous routing domains called autonomous
system (AS).
AS is essentially a collection of IP networks and routers
under the same administration that share a common
routing strategy.
An Internet service provider (ISP) is the typical
example of an AS.
For the outside world, an AS is regarded as a single
routing entity.
23
Each AS must has a 16-bit AS number, which is unique
Interior Vs Exterior Routing Protocols
The routing protocols used within an AS are called interior
gateway protocols (IGPs), and the ones used between
ASs are called exterior gateway protocols (EGPs).
Their main difference is that IGPs provide information
on reachable interior destinations to the outside work,
whereas, inversely, EGPs provide information on
reachable exterior destinations to the interior routers.
EGPs are typically used between ISPs.
Another difference between them is the route
determination.
IGPs choose the best path through the network based on
24
Difference between IGP & EGP
IGP (Interior Gateway Protocol) :-
Within a single autonomous system
Single network administration
Unique routing policy
Make best use of network resource
IGP’s fall into two categories:
A. Distance Vector Protocols
Routing Information Protocol (RIP V1 and RIP V2, RIPng)
Interior Gateway Routing Protocol (IGRP)
Enhanced Interior Gateway Routing Protocol (EIGRP)
B. Link State Protocols
Open Shortest Path First (OSPF)
25
Intermediate System to Intermediate System (IS-IS)
Cntd…
EGP (Exterior Gateway Protocol ) :-
Among different autonomous systems
Independent administrative entities
Communication between independent network
infrastructures
EGP is commonly used between hosts on the Internet to
exchange routing table information.
Examples of an EGP:
– Border Gateway Protocol (BGP)
– Exterior Gateway Protocol (Replaced by BGP)
26
Cntd…
Fig. The Internet comprises a large number of autonomous
27
Classful Vs Classless Routing Protocols
A. Classful routing protocols do not include the
subnet mask with the route advertisement.
Within the same network, consistency of the subnet
masks is assumed.
Summary routes are exchanged between foreign
networks.
E.g., of classful routing protocols: RIP V1, IGRP
B. Classless routing protocols include the subnet
mask with the route advertisement.
28
Classifications of Routing Protocols
Different routing protocols use different algorithms and
approaches to gather and disseminate routing information
about their area.
Routing protocols are classified into the following categories:
29
Cntd…
A.Distance Vector
Idea:- The routers using the distance vector routing
protocol determine the direction and distance to any link
in an internetwork.
They have no knowledge about instant routers and
how they interconnect.
That is, they do not have the knowledge of the
network topology.
When there is more than one path available to a
destination, to determine which one is the “best”,
30
Advantage & Disadvantage of Distance
Vector Protocol
There are two Distance Vector Protocol, Both uses different
metric
1. RIP uses Hop count as metric
2. IGRP and EIGRP use composite Metrics such as
bandwidth, Delay, Load, Reliability and MTU
192.168.20.1
192.168.10.1
Advantage:- They are simple and efficient in all networks. 31
cntd…
B.Link-State Routing Protocol
Idea:- The routers using the link-state routing algorithm
have the knowledge of the complete topology of an
internetwork, that is, have the knowledge of distant
routers and how they interconnect.
With this knowledge, each router is able to
independently determine the best (shortest) path from
itself to every other router.
The best path calculation is typically based on the
32
Advantage & Disadvantage of Link-state
Protocol
Advantage:-
Introducing lower network overhead
The link-state database size can be minimized with careful
network design.
Fast convergence:- changes are reported immediately by the
source affected.
Routers know the topology
Link-state packets are sequenced and aged (old).
Disadvantage:-
link-state protocols are more complex (to learn, to implement
33
and to configure) and resource(memory & CPU) intensive.
Distance Vector Vs. Link State Routing
Protocols
Distance Vector Link State
• Updates frequently • Updates are event triggered
• Each router is "aware" of • Each router is "aware" of all
only its immediate other routers in the "area"
neighbors • Fast convergence
• Slow convergence • Less subject to routing loops
• Prone to routing loops • More difficult to configure
• Easy to configure • More router resource intensive
• Fewer router resources • Updates require less bandwidth
required • Has detailed knowledge of
• Updates require more distant networks and routers 34
Cntd…
C. Path Vector Routing Protocol
Idea:- The main characteristic of path vector protocols is that a
path of autonomous system numbers between the
source and destination (AS path) is maintained to detect
loops.
Are a class of distance vector protocols -> they also have
no knowledge about instant routers and how they
interconnect in the network.
It uses the Bellman-Ford algorithm when there is more than
one path available to a destination.
The operation is similar to that of distance vector
protocols. 35
Advantage & Disadvantage of Link-state
Protocol
Advantage:- path information can be used to enable
policy routing
Disadvantage:- policy routing could introduce a more
complex configuration.
36
Popular Routing Protocols
A routing protocol is a protocol that specifies how routers
communicate with each other.
It disseminating information that enables them to select
routes between any two nodes on a computer
network
The choice of the route being done by routing
algorithms.
Each router has a priori knowledge only of networks
attached to it directly.
A routing protocol shares this information first among
37
immediate neighbors, and then throughout the network.
Routing with RIP
The Routing Information Protocol (RIP) is a simple
and true distance vector routing protocol, and the
basic idea is that each router advertises the next hop and
hop count for each destination it can reach to its directly
connected neighbors.
It sends the complete routing table out to all active
interfaces every 30 seconds.
RIP prevents routing loops by implementing a limit on
the number of hops allowed in a path from the source to
38
a destination.
Cntd…
RIP comes with three versions:
1. RIP version 1 uses only classful routing, which means
that all devices in the network must use the same
subnet mask
2. RIP version 2 does send subnet mask information
with the route updates. This is called classless
routing.
3. RIP next generation: is the newest version of RIP,
designed to support IPv6.
39
Routing with Open Shortest Path First
(OSPF)
The OSPF protocol is a link-state routing protocol.
unlike RIP, each router within the network has a clear
picture of the network topology.
OSPF is an open standards routing protocol
This works by using the Dijkstra algorithm (SPF)
OSPF provides the following features:
Minimizes routing update traffic
Allows scalability (e.g. RIP is limited to 15 hops) (Has unlimited
hop count)
It allows multi-level routing hierarchy called area routing.
Supports VLSM/CIDR(Classless Inter-Domain Routing )
40
Allows multi-vendor deployment (open standard)
OSPF Tables
There are three type of tables
1. Neighbor:- Contain information about the neighbors
Neighbor is a router which shares a link on same network
2. Topology:- Contain information about all network and path
to reach any network
All link state advertisement (LSA’s) are entered in to
topology table
When topology changes LSA’s are generated and send
new LSA’s
On topology table an algorithm is run to create a shortest
41
Pros and Cons
OSPF is a more sophisticated routing protocol
Converges rapidly and accurately
Can use a metric calculation that effectively selects the
"best" route(s) primarily based on bandwidth,
although an OSPF cost can be administratively
assigned
Use of OSPF requires
More powerful routing hardware
More detailed knowledge by the administrator, especially
42
when large multi-area networks are used
Internet Protocol (IP)
IP is a protocol used for communicating data across a
packet-switched internetwork using the Internet Protocol
suite, also referred to as TCP/IP.
IP is the primary protocol in the Internet Layer of the
Internet Protocol Suite and has the task of delivering
datagrams (packets) from the source host to the
destination host based on their addresses.
For this purpose the IP defines addressing methods and
structures for datagram encapsulation.
The first major version of addressing structure, now
43
IPv4 Addresses
An IPv4 address is a 32-bit address.
It uniquely and universally defines the connection of a
device to the Internet.
IPv4 addresses are unique and universal.
They are unique in the sense that each address
defines one, and only one, connection to the
Internet.
Two devices on the Internet can never have the
same address at the same time.
44
Address Space
A protocol such as 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 N bits to define an address, the address
space is 2N because each bit can have two different values
(0 or 1) and N bits can have 2N values.
IPv4 uses 32-bit addresses, which means that the address
space is 232 or 4,294,967,296 (more than 4 billion).
This means that, theoretically, if there were no restrictions,
45
Notation
There are two prevalent notations to show an 1Pv4 address:
binary notation and dotted-decimal notation.
Binary Notation: In binary notation, the IPv4 address is displayed
as 32 bits. So it is common to hear an IPv4 address referred to as a
32-bit address or a 4-byte address. The following is an example
of an IPv4 address in binary notation: 01110101 10010101
00011101 00000010
Dotted-Decimal Notation : To make the IPv4 address more
compact and easier to read, Internet addresses are usually
Dotted-decimal
written in decimal form with a decimal point (dot)andseparating
notation binary the
notation for an IPv4
bytes. address
46
The following is the dotted-decimal notation of the above address:
Classful Addressing
IPv4 addressing, used the concept of classes. This
architecture is called classful addressing.
In classful addressing, the address space is divided into
five classes: A, B, C, D, and E. Each class occupies
some part of the address space.
47
Example
Find class of the following IP addresses?
1. 00000001 00001011 00001011 11101111
2. 11000001 10000011 00011011 11111111
3. 14.23.120.8
4. 252.5.15.111
• Solution
1. The first bit is 0. This is a class A address.
2. The first 2 bits are 1; the third bit is 0. This is a class C
address.
3. The first byte is 14; the class is A.
48
Classes and Blocks
One problem with classful addressing is that each
class is divided into a fixed number of blocks with
each block having a fixed size
Number of Blocks for class A = 27 Block size for class A = 224
Number of Blocks for class B = 214 Block size for class B = 216
Number of Blocks for class C = 221 Block size for class C = 28
49
Cntd…
Previously, when an organization requested a block of addresses, it
was granted one in class A, B, or C.
Class A addresses were designed for only large organizations
such as the military, government agencies, universities,
and large corporations with a large number of attached hosts
or routers.
Class B addresses were designed for midsize organizations with
tens of thousands of attached hosts or routers.
Class C addresses were designed for small organizations with a
small number of attached hosts or routers.
A block in class A address is too large for almost any organization.
This means most of the addresses in class A were wasted and were not used.
50
A block in class B is also very large, probably too large for many of
Network ID and Host ID
In classful addressing, an IP address in class A, B, or C is divided
into network ID and host ID.
These parts are of varying lengths, depending on the class of
the address.
In class A, 1 byte defines the network ID & 3 bytes define the
host ID.
In class B, 2 bytes define the network ID & 2 bytes define
1st octet 2nd octet 3rd octet 4th octet
the host ID.
Network Host Host Host
Class A
In class C, 3 bytes define the network ID & 1 byte defines
Network Network Host Host
the host ID.
Class C Network Network Network Host
51
Default Mask
The length of the network ID and host ID (in bits) is
predetermined in classful addressing,
we can also use a mask (also called the default mask), a 32-
bit number made of contiguous 1s followed by contiguous 0s.
The mask can help us to find the network ID and the host ID.
For example, the mask for a class A address has eight 1s, which
means the first 8 bits of any address in class A define the
network ID; the next 24 bits define the host ID.
52
IP address shortage
In the early days of the Internet, IP addresses were
allocated to organizations based on request rather than
actual need.
No medium size - Hosts:
Class A: 16 million
Class B: 65,536
Class C: 256
Subnet Mask
The solution to the IP address shortage was thought to be
the subnet mask. 53
Address Depletion
The flaws in classful addressing scheme combined
with the fast growth of the Internet led to the near
depletion of the available addresses.
Yet the number of devices on the Internet is much
less than the 232 address space.
We have run out of class A and B addresses, and a
class C block is too small for most midsize
organizations.
One solution that has alleviated the problem is the
54
idea of classless addressing.
Subnetting
During the era of classful addressing, subnetting was
introduced.
If an organization was granted a large block in class A
or B, it could divide the addresses into several contiguous
groups and assign each group to smaller networks (called
subnets) or, in rare cases, share part of the addresses
with neighbors.
Subnetting increases the number of 1s in the mask.
55
Cntd…
Network Network Host Host
172 16 0 0
Network Network Subnet Host
You lose two host IP Addresses for each subnet, and
perhaps one for the subnet IP address and one for the
subnet broadcast IP address.
You lose the last subnet and all of it’s hosts’ IP addresses
as the broadcast for that subnet is the same as the
broadcast for the network.
56
In older networks, you would have lost the first subnet,
Classless Addressing
To overcome address depletion and give more organizations
access to the Internet, classless addressing was designed and
implemented.
In this scheme, there are no classes, but the addresses are still
granted in blocks.
Address Blocks
In classless addressing, when an entity, small or large, needs to
be connected to the Internet, it is granted a block (range) of
addresses.
The size of the block (the number of addresses) varies based on
the nature and size of the entity.
For example, a household may be given only two addresses;
57 a
Restriction
To simplify the handling of addresses, the Internet authorities
impose three restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one
after another.
2. The number of addresses in a block must be a power
of 2 (1, 2, 4, 8 .... ).
3. The first address must be evenly divisible by the
number of addresses.
58
cntd…
The above figure shows a block of addresses, in both
binary and dotted-decimal notation, granted to a small
business that needs 16 addresses.
We can see that the restrictions are applied to this block.
The addresses are contiguous.
The number of addresses is a power of 2 (16 = 24), and the
first address is divisible by 16.
The first address, when converted to a decimal number,59 is
Classless addressing Mask
A better way to define a block of addresses is to select
any address in the block and the mask.
As we discussed before, a mask is a 32-bit number in
which the n leftmost bits are 1s and the 32 - n rightmost
bits are 0s.
However, in classless addressing the mask for a block
can take any value from 0 to 32.
It is very convenient to give just the value of n preceded
by a slash (CIDR – Classless Inter Domain Routing
notation).
60
First address
The first address in the block can be found by setting the
32 - n rightmost bits in the binary notation of the address
to 0s.
E.g. 1, A block of addresses is granted to a small
organization. We know that one of the addresses is
205.16.37.39/28. What is the first address in the block?
Solution: The binary representation of the given address is
11001101 00010000 00100101 00100111
• If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 00100000
61
Last address
The last address in the block can be found by setting the
32 - n rightmost bits in the binary notation of the address
to 1s.
E.g., Find the last address for the block in above E.g., 1.
Solution
• The binary representation of the given address is
11001101 00010000 00100101 00100111
• If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or 62
Number of Addresses
The number of addresses in the block is the difference
between the last and first address.
It can easily be found using the formula 232-n.
Example
Find the number of addresses in E.g., 1.
Solution
• The value of n is 28, which means that number of
63
addresses is 2 32−28
or 16
Method II
Another way to find the first address, the last address, and
the number of addresses is to represent the mask as a 32-
bit binary (or 8-digit hexadecimal) number.
This is particularly useful when we are writing a program
to find these pieces of information.
In the above example the /28 can be represented as:
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).
Find
a. The first address
64
Cntd…
65
Cntd…
The number of addresses can be found by
complementing the mask, interpreting it as a decimal
number, and adding 1 to it.
66
Address Allocation
The next issue in classless addressing is address
allocation. How are the blocks allocated?
The ultimate responsibility of address allocation is given to a
global authority called the Internet Corporation for
Assigned Names and Addresses (ICANN).
However, ICANN does not normally allocate addresses to
individual organizations.
It assigns a large block of addresses to an ISP.
Each ISP, in turn, divides its assigned block into smaller sub
blocks and grants the sub blocks to its customers.
In other words, an ISP receives one large block to 67be
Example
• An ISP is granted a block of addresses starting with
190.100.0.0/16 (65,536 addresses).
• The ISP needs to distribute these addresses to three
groups of customers as follows:
a. The first group has 64 customers; each needs 256
addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs 64
addresses.
68
Solution
69
Solution
70
Network Address Translation (NAT)
Many users start to have more hosts to be connected to
the internet
IP addresses are in depletion
Solution: NAT
NAT enables a user to have a large set of addresses
internally and one address, or a small set of addresses,
externally.
The traffic inside can use the large set; the traffic outside,
the small set.
71
IPv6 Addresses
Internet Protocol (IP) version 4 is the most commonly used
communication protocol for both the Internet and internal
network environments.
Although IPv4 is robust and scalable, new technologies and
higher demand have paved the way for the eventual
adoption of IPv6.
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.
An IPv6 address is 128 bits or 32 hexadecimal digits long.
72
Differences Between IPv4 and IPv6
73
Advantages of IPv6 Addressing Scheme
1.Large address space:- IPv6 uses a 128-bit address space,
which allows for 3.4x1038 or
340,282,366,920,938,463,463,374,607,431,768,211,456 possible
addresses.
2.Hierarchical addressing and routing infrastructure:- The
IPv6 address space is designed to be more efficient for routers,
which means that even though there are many more addresses,
routers can process data much more efficiently because of
address optimization.
3.Stateless and Stateful address configuration:- Stateless
address configuration refers to host IP configuration without a
74
DHCP server.
Cntd…
4. Built-in security:- IPv6 has built-in IP security, which facilitates
configuration of secure network connections.
5. Prioritized delivery:- IPv6 contains a field in the packet that
allows network devices to determine the specified rate at which
the packet should be processed.
This allows traffic prioritization or QoS. For example, when
streaming video traffic, it is critical that the packets arrive in a
timely manner. You can set this field to ensure that network
devices determine that the packet delivery is time-sensitive.
6. Neighbor detection:- IPv6 uses the Neighbor Discovery
protocol to manage the interaction between nodes within the
same network link. 75
IPv6 Address Space
76
Abbreviated IPv6 addresses
77
Example
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 the original address is:
78
Types of IPv6 Addresses
79
Cntd…
There are three main types of IPv6 addresses:
Unicast:- Identifies a single interface within the address
scope.
Packets that are addressed to this address are delivered
to a single interface.
Multicast:- Identifies multiple interfaces and delivers
packets to all interfaces that are identified by the address.
It is used for one-to-many communication over a network
80
infrastructure.
End of Chapter Three
Any question ???
81