chapter 4-LECT 2- Network Layer and Routing_Modified
chapter 4-LECT 2- Network Layer and Routing_Modified
Part II
(SE 3051)
Network Layer (3rd OSI Layer)
2
Network Layer (3rd OSI Layer)
Concerned with sending 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.
If two systems are connected to the same local
network, there is usually no need for a network
layer.
3
Contd.
The network layer is responsible for the delivery of individual
packets from the source host to the destination host.
4
Other responsibilities of the network layer
include the following:
1.Logical addressing:- The physical
addressing implemented by the data link
layer handles the addressing problem locally.
If a packet passes the network boundary,
designed solution.
Network layer protocols include: IPv4/IPv6, DVMRP (Distance Vector Multicast Routing
Level 1), that carries heavy traffic, hardware routers are preferable.
When the WAN connection is a relatively slow one, such as an ISDN
networks manually
Benefits
No overhead on the router CPU
Adds security
Disadvantage
Administrator must really understand the internetwork
must configure the static route on the router using the ip route
command.
interface: connection
between host/router 223.1.1.3
223.1.3.27
223.1.2.2
and physical link
routers typically have
multiple interfaces 223.1.3.1 223.1.3.2
host typically has one
active interface (e.g.,
wired Ethernet, wireless
223.1.1.1 = 11011111 00000001 00000001 00000001
802.11)
one IP address 223 1 1 1
associated
4-
16
with each
Network Layer
interface
IP addressing: introduction
223.1.1.1
that in chapter 6
223.1.3.27
223.1.1.3
223.1.2.2
They are unique in the sense that each address defines one,
Two devices on the Internet can never have the same 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
21
Example 1
Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.
22
Example 2
Solution
We replace each decimal number with its binary equivalent.
23
Example 3
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
24
Classful Addressing
IPv4 addressing, at its inception, used the concept of
25
Example 4
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.
26
Classes and Blocks
27
Contd.
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
28 A were wasted and were not used.
Network ID and Host ID
In class C, Network
3 bytes Network
define the network
Host ID & 1 byte
Host
Class B
defines the Network
host ID. Network Network Host
Class C
29
Default Mask
Although the length of the network ID and host ID (in bits) is
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.
30
IP address shortage
In the early days of the Internet, IP addresses were allocated
Class A: 16 million
Class B: 65,536
Class C: 256
Subnet Mask
The flaws in classful addressing scheme combined with the fast growth of
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
One solution that has alleviated the problem is the idea of classless
addressing.
32
?
Next class
33
Subnetting
divide the addresses into several contiguous groups and assign each
group to smaller networks (called subnets) or, in rare cases, share part
Subnetting does NOT give you more hosts, but actually costs you
34 hosts.
Contd.
Network Network Host Host
172 16 0 0
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.
In older networks, you would have lost the first subnet, as the subnet
IP address is the same as the network IP address. (This subnet can be
used in most networks.)
35
Analogy 10 barrels x 10 apples = 100
apples
10 10 10
100 Apples
(10 * 10) 10 10
10
10 10 10
8 8 8
(less 2) (less 2) (less 2)
80 Apples 10 * 8 8 8
(10 - 2)
(less 2) (less 2) (less 2)
8 8 8
---
8
X
(less 2)
8
(less 2)
8
(less 2)
64 Apples 8* 8 8 8
(10 - 2)
(less 2) (less 2) (less 2)
8 8 8
X
We “might” also lose the last basket of
---
8
apples, subnet, as it contains the
broadcast address for the entire
network.
39 In older networks, we “might” also lost
Classless Addressing
To overcome address depletion and give more organizations access to the
blocks.
Address Blocks
after another.
2. The number of addresses in a block must be a
number of addresses.
41
Contd.
42
Classless addressing Mask
A better way to define a block of addresses is to select any
the n leftmost bits are 1s and the 32 - n rightmost bits are 0s.
However, in classless addressing the mask for a block can
block (the first address, the last address, and the number of
addresses).
43
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.
Example 5
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
44
or
205.16.37.32.
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.
Example 6
Find the last address for the block in Example 5.
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
205.16.37.47
45
Number of Addresses
Example 7
Find the number of addresses in Example 5.
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
46
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
b. The last address
c. The number of addresses.
47
Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
otherwise the result is 0.
48
b. The last address can be found by ORing the given
addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; otherwise the result is 1. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.
49
c. The number of addresses can be found by
complementing the mask, interpreting it as a decimal
number, and adding 1 to it.
50
Network Addresses
address.
When an organization is given a block of addresses, the
levels of hierarchy.
the next three digits (011, for example) define the area,
subscriber number.
52
Two-Level Hierarchy: No Subnetting
An IP address can define only two levels of hierarchy when
not subnetted.
The n leftmost bits of the address x.y.z.t/n define the
the prefix; the part that defines the host is called the suffix.
The prefix is common to all addresses in the network; the
53
suffix changes from one device to another.
Three-Levels of Hierarchy: Subnetting
An organization that is granted a large block of addresses
1. Suppose the mask for the first subnet is n1, then 232-n1 must
Group 2
For this group, each customer needs 128
addresses. This means that 7 bits are needed
to define each host. The prefix length is then
32 − 7 = 25. The addresses are
60
Contd.
Group 3
For this group, each customer needs 64
addresses. This means that 6 bits are needed
to each host. The prefix length is then 32 − 6
= 26. The addresses are
to the internet
IP addresses are in depletion
Solution: NAT
NAT enables a user to have a large set of addresses
62
63
Reading Assignment:
1. Read how NAT works
2. Investigate the global IP address scheme
of Bule Hora University and how they
used it in NAT
64
Subnets
IP address: 223.1.1.1
subnet part - high
223.1.1.2 223.1.2.1
order bits 223.1.1.4 223.1.2.9
host part - low
223.1.2.2
order bits 223.1.1.3 223.1.3.27
what’s a subnet ? subnet
device interfaces
223.1.3.2
with same subnet 223.1.3.1
part of IP address
can physically
network consisting of 3 subnets
reach each other
without intervening
4- router
Network Layer
65
Subnets
223.1.1.0/24
223.1.2.0/24
223.1.1.1
recipe
to determine the 223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
subnets, detach
each interface from 223.1.2.2
223.1.1.3 223.1.3.27
its host or router,
subnet
creating islands of
isolated networks 223.1.3.1 223.1.3.2
each isolated
network is called a
223.1.3.0/24
subnet
subnet mask: /24
4- Network Layer
66
Example
67
Contd.
68
Configuring default route forwarding
Default routes are used to route packets with destinations that
format:
ip route 0.0.0.0 0.0.0.0 [next-hop-address | outgoing
interface]
Use the following steps to configure default route on routers
2. Type the ip route command with 0.0.0.0 for the destination network
address and 0.0.0.0 for the subnet mask. The gateway for the
default route can be either the local router interface that connects to
69 the outside networks or the IP address of the next-hop router.
Example
70
Contd.
71
Dynamic Routing
o Dynamic route uses a route that a routing protocol adjusts
other routers
Benefits
scalability and adaptability
Disadvantage
complex structure
72
Routers uses bandwidth to send routing table updates
Overview of Internet Routing
The Internet comprises a large number of interconnected
decisions.
73
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
IGPs choose the best path through the network based on some metrics
Therefore, how the metrics are used is an important design issue for IGPs.
Examples of an EGP:
Border Gateway Protocol (BGP)
assumed.
route advertisement.
A. Distance Vector
There are two Distance Vector Protocol, Both uses different metric
1. RIP uses Hop count as metric, IGRP and EIGRP use Composite Metric
2. IGRP and EIGRP use composite Metrics such as bandwidth, Delay, Load, Reliability
and MTU
192.168.20.1
192.168.10.1
other router.
network design.
Each router advertises its local BGP routing table to its neighbors.
routing
complex configuration.
87
autonomous systems that are traversed in order to
reach the destination system.
Popular Routing Protocols
A routing protocol is a protocol that specifies how routers communicate
routes between any two nodes on a computer network, the choice of the
directly.
The term routing protocol may refer specifically to one operating at layer
Among a large number of routing protocols, RIP, OSPF, and BGP have
been widely deployed and evolved to become the de facto standards.
But OSPF and EIGRP are the most widely used Interior Gateway
89 routing protocols
Routing with RIP
vector routing protocol, and the basic idea is that each router
advertises the next hop and hop count for each destination it can reach
It sends the complete routing table out to all active interfaces every
30 seconds.
1. RIP version 1 uses only classful routing, which means that all
2. RIP version 2 does send subnet mask information with the route
support IPv6.
91
RIP Generations (RIP v1, RIP v2 and RIPng)
92
RIP Version 2
interoperability adjustments.
broadcast.
5. RIPv2 encodes the next-hop into each route entries, RIPng requires
94 specific encoding of the next hop for a set of route entries.
RIP Operation
1. Each router initially has a list of locally connected networks in its routing table.
2. Each router periodically advertises its routing table to its directly connected
neighbors.
shown in the advertisement into its own routing table and updates the
corresponding metrics.
RIP uses hop count as the metric for route selection, and it chooses the route
with a smaller number of hop count when there are more than one route
available.
4. In the next periodical advertisement, the router advertises its neighbors this
Router(config)#router rip
Router(config-router)#network 172.16.0.0
The network numbers are based on the network class addresses, not
192.168.20.1 192.168.30.1
S0
S0 S1
192.168.10.1 E0 S0
192.168.30.2 E0 192.168.40.1
192.168.20.2
R2# config t
R2(config)#router rip
192.168.40.2
192.168.10.2
A R2(config)#network 192.168.20.0
R2(config)#network 192.168.30.0 B
R1# config t
R1(config)# )#router rip R3# config t
R1(config)#network 192.168.10.0 R3(config)# )#router rip
R1(config)#network 192.168.20.0 R3(config)#network 192.168.30.0
R3(config)#network 192.168.40.0
R1# config t
R1(config)# )#router rip RIP v2
R1(config)#network 192.168.10.0 Configurat
R1(config)#network 192.168.20.0
97 R1(config)#version 2 ion
Verifying RIP Configuration
98
Displaying the IP Routing Table
99
debug ip rip Command
10
0
Passive Interface
being sent out a defined interface, but same interface can still
R1#config t
R1(config)#router rip
R1(config-router)#network 192.168.10.0
R1(config-router)#passive-interface serial 0
RIP router with a passive interface will still learn about the networks
Allows scalability (e.g. RIP is limited to 15 hops) (Has unlimited hop count)
any network
When topology changes LSA’s are generated and send new LSA’s
10
5
Contd.
10
6
Contd.
10
7
Neighbours
Neighbours are two or more routers that have an interface on a common
network
E.g. two routers connected on a serial link
Communication takes place between / among neighbours
neighbours form "adjacencies"
Adjacency
Is a relationship between two routers that permits the direct
exchange of route updates
Not all neighbours will form adjacencies. If the two routers are the
only routers on the network, an adjacency should form.
If there are more than two routers on the network, adjacencies
only form with the designated router (DR) and backup designated
10 router (BDR).
8
OSPF Design
All routers in the same area have the same topology database
OSPF routers and links are grouped logically into areas that are
identified by assigned numbers.
All OSPF networks have at least one area with the default being
area 0.
11
0
If more than one area exists, area 0 is defined as the backbone area
Why Areas?
1.Decreases routing overhead
2.Speeds convergence
Confines network instability (e.g. route "flapping") to single area of the network
LSAs in Areas
LSAs communicate with adjacent routers in the same OSPF area
Based on detailed knowledge of every link in the area and the OSPF
11
More detailed knowledge by the administrator, especially
3
Basic OSPF Configuration
Router(config)# router ospf 1
The number 1 in this example is a process-id # that begins
A 255 indicates that you don’t care what the corresponding octet is
20.0.0.2 30.0.0.1
R2
R1 S0
R3
S0
30.0.0.2 40.0.0.1
E0
10.0.0.1 E0 20.0.0.1
40.0.0.2
10.0.0.2
A B
R1#config t
Enter configuration commands, one per line. End with
CNTL/Z.
R1(config)#router ospf 1
R1(config-router)#network 10.0.0.0 0.255.255.255
area 0
R1(config-router)#network 20.0.0.0 0.255.255.255
area 0 R2#config t
R1(config-router)#^Z Enter configuration commands, one per line. End with
CNTL/Z.
R2(config)#router ospf 2
R2(config-router)#network 20.0.0.0 0.255.255.255
11
7 area 0
R2(config-router)#network 30.0.0.0 0.255.255.255