0% found this document useful (0 votes)
5 views

chapter 4-LECT 2- Network Layer and Routing_Modified

Chapter Four discusses the Network Layer, which is responsible for sending packets from source to destination, routing, and logical addressing. It covers the functions of the network layer, including the selection of the best path for data transmission and the protocols involved like IPv4 and IPv6. Additionally, it addresses static and dynamic routing techniques, the structure of IP addresses, and the challenges of classful addressing.

Uploaded by

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

chapter 4-LECT 2- Network Layer and Routing_Modified

Chapter Four discusses the Network Layer, which is responsible for sending packets from source to destination, routing, and logical addressing. It covers the functions of the network layer, including the selection of the best path for data transmission and the protocols involved like IPv4 and IPv6. Additionally, it addresses static and dynamic routing techniques, the structure of IP addresses, and the challenges of classful addressing.

Uploaded by

bonsamohammed99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 117

Chapter Four

Network Layer and Routing

Part II

Data Communication and


Computer Networks

(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,

we need another addressing system to


distinguish the source and destination
systems.
 The network layer adds a header to the

packet coming from the upper layer that,


5 among other things, includes the logical
Other responsibilities of the network layer
include the following:
2. Routing:- When independent networks or
links are connected to create internetworks
(network of networks) or a large network, the
connecting devices (called routers or switches)
route or switch the packets to their final destination.
 One of the functions of the network layer is to

provide this mechanism.


3. Best path selection:- Best path is selected by a
routing protocol based on the value or metric it uses
to determine the distance to reach a network.
6
4. Defines how data is packaged (Packets)
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), Enhanced IGRP(EIGRP), Open Shortest Path

First(OSP), DDP(Datagram Delivery Protocol), BGP(Border Gateway Protocol), IS-IS


7
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).
 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


connected seven sites, was 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.


8
 A routing table maintains the best routes to various network destinations.
Contd.
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.
 It will learn all available paths to a network , but only
determine the best path to be stored in the routing table.
 Whenever the topology of a network changes (e.g., a new
link is added or removed), the routing protocol will
determine another best path (if needed) and update the
routing table accordingly for the routing in the updated
topology.
9
What is Routing?
Path determination occurs at
Routing involves two basic Layer 3, the network layer.
activities: The path determination function
o determining optimal routing enables a router to evaluate the
paths and
To route, a router needs to know: available paths to a destination
o transporting packets through
1. Destination addresses and to establish the best path.
a network.
2. Sources it can learn from
Routing services use network
3. Possible routes
topology information when
4. Best route
evaluating network paths.
10.120.2.0 172.16.1.0
This information can be
configured by the network
administrator (static routes) or

10 collected through dynamic


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.

 Value determined by the network administrator.

 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.

 Maximum transmission unit (MTU) - Maximum message length

(or packet size) allowed on the path.


 Cost - Arbitrary value based on a network- administrator‘
11
determined value. Usually some combination of other metrics.
Which Router/ Routing to Use?
 When you have a high-speed WAN connection, such as a T-1(T-Carrier

Level 1), that carries heavy traffic, hardware routers are preferable.
 When the WAN connection is a relatively slow one, such as an ISDN

link(Integrated Services Digital Network), or does not carry heavy traffic,


a software router can function adequately, usually with far less
expense.
 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.


12  Dynamic routing uses a specialized routing protocol to update the
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

13  If a network is added to the internetwork, the administrator has to


Static Route Operation
o Static route operations can be divided into these three parts:

 Network administrator configures the route

 Router installs the route in the routing table

 Packets are routed using the static route

o Since a static route is manually configured, the administrator

must configure the static route on the router using the ip route
command.

o Sometimes static routes are used for backup purposes.

o A static route can be configured on a router that will only be

14 used when the dynamically learned route has failed.


Static Route Configuration
Use the following steps to configure static routes:
1. Determine all desired destination networks, their subnet

masks, and their gateways. A gateway can be either a local


interface or a next hop address that leads to the desired
destination.
2. Enter global configuration mode.

3. Type the ip route command with a destination address and

subnet mask followed by their corresponding gateway from


Step one. Including an administrative distance is optional.
4. Repeat Step three for as many destination networks as were

defined in Step one.


5. Exit global configuration mode.
15
6. Save the active configuration to NVRAM by using the copy
IP addressing: introduction
223.1.1.1
IP address: 32-bit
223.1.2.1
identifier for host,
router interface 223.1.1.2
223.1.1.4 223.1.2.9

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

Q: how are interfaces 223.1.2.1


actually connected?
223.1.1.2
A: we’ll learn about 223.1.1.4 223.1.2.9

that in chapter 6
223.1.3.27
223.1.1.3
223.1.2.2

A: wired Ethernet interfaces


connected by Ethernet switches
223.1.3.1 223.1.3.2

A: wireless WiFi interfaces


connected by WiFi base station
4- Network Layer
17
IPv4 Addresses

 An IPv4 address is a 32-bit address that uniquely and

universally defines the connection of a device (for example, a

computer or a router) 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.


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, more than 4 billion
devices could be connected to the Internet.
 We will see shortly that the actual number is much less because of
19
the restrictions imposed on the addresses.
Notations
 There are two prevalent notations to show an IPv4 address:
binary notation and dotted-decimal notation.
 Binary Notation
 In binary notation, the IPv4 address is displayed as 32 bits.
Each octet is often referred to as a byte. 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 written in decimal form with
a decimal point (dot) separating the bytes. The following is
the dotted-decimal notation of the above address:
20 117.149.29.2
Example: Dotted-decimal notation and
binary notation for an IPv4 address

21
Example 1

Change the following IPv4 addresses from binary notation


to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.

22
Example 2

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Solution
We replace each decimal number with its binary equivalent.

23
Example 3

Find the error, if any, in the following IPv4 addresses.

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

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.

25
Example 4

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.
26
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

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 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
1st octet 2nd octet 3rd octet 4th octet
define
Class Athe host ID.
Network Host Host Host

 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

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 masks for classes
A, B, and C are shown below
 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.

30
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.


 Formalized in 1985 (RFC 950), the subnet mask breaks a
31
single class A, B or C network in to smaller pieces.
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 idea of classless

addressing.
32
 ?
Next class

33
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.

 Subnetting is the process of borrowing bits from the HOST bits, in

order to divide the larger network into small subnets.

 Subnetting does NOT give you more hosts, but actually costs you

34 hosts.
Contd.
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.
 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

 It is the same as taking a barrel of 10

100 apples and dividing it into 10


36 barrels of 10 apples each.
Contd.
100 – 2 apples = 98 Usable
Apples
Before subnetting:
 In any network (or subnet) we can
98 Apples (100
– 2) not use all the IP addresses for host
addresses.
 We lose two addresses for every
network or subnet.
 Network Address:- One address
is reserved to that of the network.
 Broadcast Address:- One address
37
is reserved to address all hosts in
Contd. 10 barrels x 8 apples = 80
apples

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

(less 2) (less 2) (less 2)

 In subnetting we will see that we 8

continue to lose two apples per


subnet, one for the address and
38
one for the broadcast.
Contd. 10 barrels x 8 apples = 80
apples

---
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

(less 2) (less 2) (less 2)

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

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; a large

organization may be given thousands of addresses.


 An ISP, as the Internet service provider, may be given thousands or

40 hundreds of thousands based on the number of customers it may serve.


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.

41
Contd.

 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) ..

42
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).
 The address and the /n notation completely define the whole

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

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 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

 A very important concept in IP addressing is the network

address.
 When an organization is given a block of addresses, the

organization is free to allocate the addresses to the devices


that need to be connected to the Internet.
 The first address in the class, however, is normally (not

always) treated as a special address.


 The first address is called the network address and defines

the organization network.


 It defines the organization itself to the rest of the world.

 The first address is the one that is used by routers to direct


51 the message sent to the organization from the outside.
Hierarchy

 IP addresses, like other addresses or identifiers we

encounter these days, have levels of hierarchy.

 For example, a telephone network in Ethiopia has three

levels of hierarchy.

 The leftmost three digits (251) define the country code,

the next three digits (011, for example) define the area,

the last seven digits (1112343, for example) define the

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

network (organization network); the 32 – n rightmost bits


define the particular host (computer or router) to the
network.
 The two common terms are prefix and suffix.

 The part of the address that defines the network is called

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

may want to create clusters of networks (called subnets) and


divide the addresses between the different subnets.
 The rest of the world still sees the organization as one entity;

however, internally there are several subnets.


 All messages are sent to the router address that connects the

organization to the rest of the Internet; the router routes the


message to the appropriate subnets.
 The organization, however, needs to create small sub blocks

of addresses, each assigned to specific subnets. The


organization has its own mask; each subnet must also have
54 its own.
Example 7
 Suppose an organization is given the block 17.12.14.0/26, which

contains 64 addresses. The organization has three offices and


needs to divide the addresses into three sub blocks of 32, 16,
and 16 addresses.
 We can find the new masks by using the following arguments:

1. Suppose the mask for the first subnet is n1, then 232-n1 must

be 32, which means that n1 = 27.


2. Suppose the mask for the second subnet is n2, then 232-n2

must be 16, which means that n2 = 28.


3. Suppose the mask for the third subnet is n3, then 232-n3 must

be 16, which means that n3 = 28.


 This means that we have the masks 27, 28, 28 with the
55
organization mask being 26.
56
More Levels of Hierarchy
 The structure of classless addressing does not restrict the
number of hierarchical levels.
 An organization can divide the granted block of addresses into
sub blocks.
 Each sub block can in turn be divided into smaller sub blocks.
And so on.
 One example of this is seen in the ISPs. A national ISP can
divide a granted large block into smaller blocks and assign each
of them to a regional ISP. A regional ISP can divide the block
received from the national ISP into smaller blocks and assign
each one to a local ISP.
 A local ISP can divide the block received from the regional ISP
into smaller blocks and assign each one to a different
organization.

57Finally, an organization can divide the received block and make
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 be
58
distributed to its Internet users. This is called address
Example 8
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
59 addresses.
Group 1
solution

For this group, each customer needs 256 addresses.


This means that 8 bits are needed to define each host.
The prefix length is then 32 − 8 = 24. The addresses
are

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

Number of granted addresses to the ISP:


65,536
Number of allocated addresses by the ISP:
40,960
61
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.

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

do not match any of the other routes in the routing table.


 A default route is actually a special static route that uses this

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

1. Enter global configuration mode.

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

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

72
 Routers uses bandwidth to send routing table updates
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.

o 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.

 Some routing protocols require the AS number to make routing

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

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 some metrics

such as distance, delay, or bandwidth.

 Therefore, how the metrics are used is an important design issue for IGPs.

74 EGPs choose routes commonly according to a routing policy.


Difference between IGP & EGP
IGP:- Within a single autonomous system
 Single network administration

 Unique routing policy

 Make best use of network resource

 An IGP (Interior Gateway Protocol) is a protocol for exchanging

routing information between gateways (hosts with routers) within


an autonomous network.
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
75  Open Shortest Path First (OSPF)
Contd.
EGP:- Among different autonomous systems

Independent administrative entities

Communication between independent network infrastructures

Exterior Gateway Protocol (EGP) is a protocol for exchanging


routing information between two neighbor gateway hosts (each
with its own router) in a network of autonomous systems.

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)


76
Contd.

Fig. 4.2.1The Internet comprises a large number of autonomous systems


77
Classful Vs. Classless Routing Protocols

 Classful routing protocols do not include the subnet

mask(NT ID) with the route advertisement.

 Within the same network, consistency of the subnet masks is

assumed.

 Summary routes are exchanged between foreign networks.

o Examples of classful routing protocols: RIP V1, IGRP

 Classless routing protocols include the subnet mask with the

route advertisement.

 Classless routing protocols support variable-length subnet


78
masking (VLSM) and subnetting.
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:

A. Distance Vector

 Idea:- The routers using the distance vector routing protocol


determine the direction and distance to any link in an
79 internetwork.
Contd.
 When there is more than one path available to a destination, to
determine which one is the “best”, typically based on hop count,
an algorithm has to be used.
 Distance vector routing protocols commonly use the Bellman-Ford
algorithm to perform the best path determination.

Operation:- The operation of distance routing protocols is simple.


o Initially, each router only knows its directly connected neighbors.
o Each router sends to its neighbor its own current idea of the
distance from itself to other routers.
o The neighbor routers will examine the information and update its
knowledge of distance to others.
o Over time, the routers will discover to which direction provides the
80
shortest distance to reach the destinations.
Advantage & Disadvantage of Distance
Vector Protocol

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

 Advantage:- They are simple and efficient in all networks.

 Disadvantage:- It does not scale well and has poor


81
Contd.

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


82
Dijkstra algorithm.
Contd.
Operation:- With this knowledge, each router is able to
independently determine the best (shortest) path from itself to
every other router.
 To recreate the topology of an entire internetwork, each router
regularly floods the entire network with the state of its links, and
the information about what other routers it can connect to.
 When a router starts up, it only knows about itself in the topology.

 It will learn other nodes in the topology as it receives the


information from its neighbors.
 Over the time, the router will discover all nodes in the topology and
be able to build the complete map of the network topology.
 With the map, the routing table can be constructed based on the

83 result of a shortest path algorithm.


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.

 Disadvantage:- link-state protocols are more complex (to

learn, to implement and to configure) and resource(memory &


84
CPU) intensive.
Distance Vector Vs. Link State
Routing Protocols

Distance Vector Link State

 Updates frequently  Updates are event triggered

 Each router is "aware" of only its  Each router is "aware" of all

immediate neighbors other routers in the "area"


 Slow convergence  Fast convergence

 Prone to routing loops  Less subject to routing loops

 Easy to configure  More difficult to configure

 Fewer router resources required


 More router resource intensive
 Updates require more bandwidth
 Updates require less bandwidth
 Does not "understand" the
 Has detailed knowledge of
topology of the network
85
distant networks and routers
Contd.
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.

 Each router advertises its local BGP routing table to its neighbors.

 As routers relay the advertisements, they add new routes to its


86
own local routing table based on the contents of the
Advantage & Disadvantage of Path Vector Protocol

 Advantage:- path information can be used to enable policy

routing

 Disadvantage:- policy routing could introduce a more

complex configuration.

Fig. Path Vector Protocol: It maintains the path of

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

with each other, 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 immediate

neighbors, and then throughout the network.


 This way, routers gain knowledge of the topology of the network.

 The term routing protocol may refer specifically to one operating at layer

three of the OSI model, which similarly disseminates topology


88 information between routers.
Contd.

Although there are many types of routing protocols, three major


classes are in widespread use on IP networks:

1. Interior gateway routing via link-state routing protocols,


such as OSPF and IS-IS.

2. Interior gateway routing via path vector or distance


vector protocols, such as RIP, IGRP and EIGRP

3. Exterior gateway routing. BGPv4 is the routing protocol used


by the public Internet.

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

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.

 The hold down time is 180 seconds.

 RIP prevents routing loops by implementing a limit on the number of

hops allowed in a path from the source to a destination.

 The maximum (distance) number of hops allowed for RIP is 15.

90  Uses Bellman-ford algorithm


Contd.

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.

91
RIP Generations (RIP v1, RIP v2 and RIPng)

 RIP version 1 uses classful routing.

 The periodic routing updates do not carry subnet information, lacking


support for variable length subnet masks (VLSM).
 This limitation makes it impossible to have different-sized subnets inside
of the same network class.
 In other words, all subnets in a network class must have the same size.

 There is also no support for router authentication, making RIP


vulnerable to various attacks.
 The RIP version 1 works when there is only 15 hop counts. If there are
more than 15 hops between two routers it fails to send data packets to
the destination address.

92
RIP Version 2

 RIP version 2 (RIPv2) included the ability to carry subnet information,

thus supporting Classless Inter-Domain Routing (CIDR).

 To maintain backward compatibility, the hop count limit of 15 remained.

 RIPv2 has facilities to fully interoperate with the earlier

 In addition, a compatibility switch feature allows fine-grained

interoperability adjustments.

 In an effort to avoid unnecessary load on hosts that do not participate

in routing, RIPv2 multicasts the entire routing table to all adjacent

routers at the address 224.0.0.9, as opposed to RIPv1 which uses

broadcast.

93 Unicast addressing is still allowed for special applications.


RIPng (RIP Next Generation)

 RIPng is an extension of RIP v2 which will support IPV6.

 The main differences between RIPv2 and RIPng are:

1. Support of IPv6 networking.

2. While RIPv2 supports RIPv1 updates authentication, RIPng does


not.

3. IPv6 routers were, at the time, supposed to use IPsec for


authentication where as RIP V2 uses MD5 Authentication.

4. RIPv2 allows attaching arbitrary tags to routes, RIPng does not;


 This functionality allows for routes to be distinguished from
internal routes to external redistributed routes from EGP protocols.

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.

3. When a router receives such an advertisement, it puts the appropriate routes

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

95 “enriched” routing table.


Configuration of RIP on a Router
RIP v2
Basic commands Configuration. No
need of using this
Router(config)#router rip if it is RIP V1
configuration
Router(config)#version 2

Router(config-router)#network [network address]

 An example of a routing configuration is:

Router(config)#router rip

Router(config-router)#network 172.16.0.0

 The network numbers are based on the network class addresses, not

subnet addresses or individual host addresses.

 In the next periodical advertisement, the router advertises its neighbors

96 this “enriched” routing table.


Example

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

 Passive-interface command prevents RIP update broadcasts from

being sent out a defined interface, but same interface can still

receive RIP updates

R1#config t

R1(config)#router rip

R1(config-router)#network 192.168.10.0

R1(config-router)#passive-interface serial 0

 Passive-interface command depends upon the routing protocol

 RIP router with a passive interface will still learn about the networks

advertised by other routers


10
1  EIGRP, a passive-interface will neither send nor receive updates.
Routing with OSPF
 The Open Shortest Path First (OSPF) protocol is a link-state routing
protocol and the basic idea is that, 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 )

 Allows multi-vendor deployment (open standard)

 Routing updates are flooded when there is a network topology change.


10  Uses more complex route selection metrics.
2
OSPF Packets
There are five types of Packets:.
Discover OSPF
neighbors & establish
adjacencies
Describes the content of
the link-state database
on an OSPF router
LSR packet is used to
request pieces of the
neighbor’s database
that are more up to date
carries a collection of link
state advertisements,
which updates and
maintains the database,
one hop further from its
origin
Acknowledgment is
accomplished through the
sending and receiving of
10 LSack packets
3
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 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 path.

3. Routing:- Also knows as forwarding database

 Generated when an algorithm is run on the topology database

10  Routing table for each router is unique.


4
OSPF Neighbor States

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

 Each router is connected to the backbone called Area 0, or the backbone


area.
 Routers that connect other areas to the backbone within an AS are called
Area Border Routers (ABRs). One interface must be in area 0.
 OSPF runs inside an autonomous system, but can also connect multiple
autonomous systems together. The router that connects these ASes together
is called an Autonomous System Boundary Router (ASBR).
 Backbone Router has an interface connected to the backbone (Area 0)
 ABR has interfaces in multiple areas with at least one interface in area 0. It
connects other areas to the back bone and maintains routing information for
10 each connected area.
9
OSPF Areas
 An OSPF area is a grouping of contiguous networks and routers

 Share a common area ID

 A router can be a member of more than one area (area border


router)

 All routers in the same area have the same topology database

 When multiple areas exist, there must always be an area 0 (the


backbone) to which other areas connect

 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

 Compare to multiple smaller broadcast domains instead of one large one

2.Speeds convergence

 Confines network instability (e.g. route "flapping") to single area of the network

 Adds considerably to the complexity of setting up OSPF

LSAs in Areas
 LSAs communicate with adjacent routers in the same OSPF area

 Subsequently, a change in a link state is "flooded" to all area


routers via LSAs
 In larger networks, multiple areas may be created. "Area border

11 routers" connect areas, passing summarized route information


1
Path Calculation

 Changes to the topological database of a router trigger a

recalculation to re-establish the best route(s) to known networks

 Uses the SPF (shortest path first) algorithm developed by a

computer scientist named Dijkstra.

 This is done by each individual router using its detailed

"knowledge" of the whole network

 Leads to rapid and accurate convergence

 Based on detailed knowledge of every link in the area and the OSPF

11 "cost" of each builds an OSPF tree with itself at the route.


2
Pros and Cons

 Note that 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

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

an OSPF process in the router

 More than one process can be launched in a router, but

this is rarely necessary

 Usually the same process-id is used throughout the entire

network, but this is not required

 The process-id # can actually be any value from 1 to

"very large integer“


11
4  The process-id # cannot be ZERO
Configuring OSPF Areas
 After identifying the OSPF process, you need to identify the

interfaces that you want to activate OSPF communications


Lab_A#config t
Lab_A(config)#router ospf 1
Lab_A(config-router)#network 10.0.0.0 0.255.255.255 area ?

<0-4294967295> OSPF area ID as a decimal value

A.B.C.D OSPF area ID in IP address format

Lab_A(config-router)#network 10.0.0.0 0.255.255.255 area


0
 Every OSPF network must have an area 0 (the backbone area) to

which other areas connect


 So in a multiple area network, there must be an area 0
11  The wildcard mask represents the set of hosts supported by the
5
Contd.
 OSPF Process ID number is irrelevant. It can be the same on every

router on the network.

 The arguments of the network command are the network number

(10.0.0.0) and the wildcard mask (0.255.255.255)

 Wildcards - A 0 octet in the wildcard mask indicates that the

corresponding octet in the network must match exactly

 A 255 indicates that you don’t care what the corresponding octet is

in the network number

 A network and wildcard mask combination of 1.1.1.1 0.0.0.0 would

match 1.1.1.1 only, and nothing else.


11
6  The network and wildcard mask combination of 1.1.0.0 0.0.255.255
S0
Example S1

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

You might also like