Transcript Net_notes_3

Behrouz A. Forouzan
TCP/IP Protocol Suite, 3rd Ed.
Delivery, Forwarding
and Routing of Packets
Basic Concepts
Delivery refers to the way a packet is handled
by the underlying Networks under the control of
the network layer.
Forwarding refers to the way a packet is
delivered to the next station.
Routing refers to the way routing tables are
created to help in forwarding.
2
Delivery
Delivery of a packet in the network layer is
accomplished using either a connection-oriented
service or a connectionless service.
IP is a connectionless protocol.
The delivery of a packet to its final destination is
accomplished using two different methods:
Direct delivery
Indirect delivery.
3
Direct Delivery
In a direct delivery, the final destination of the
packet is a host connected to the same physical
network.
The sender can easily determine if the delivery
is direct.
It can extract the network address of the destination.
Compare it with the addresses of the networks to
which its connected.
If a match is found, the delivery is direct.
4
Direct Delivery
5
Indirect Delivery
If the destination host is not on the same
network, the packet is delivered indirectly.
In an indirectly delivery, the packet goes from
router to router until it reaches the one
connected to the same physical network.
In an indirect delivery, the sender uses the
destination IP address and a routing table to
find the IP address of the next router.
6
Indirect Delivery
7
Forwarding
Forwarding means to place the packet in its
route to its destination.
Requires a host or a router to have a routing
table.
When a host has a packet to send or when a router
has received a packet to be forwarded, it looks at this
table to find the route to the final destination.
 This simple solution is inefficient today in an
internetwork such as the Internet because the number
of entries needed in the routing table would make table
lookups inefficient.
8
Forwarding Techniques
Next-hop method
To reduce the contents of a routing table.
In this technique, the routing table holds only the
address of the next hop instead of information about
the complete route.
Network-specific method
To reduce the routing table and simplify the
searching process.
Instead of having an entry of every destination host
connected to same physical network, we have only
one entry that defines the address of the destination
network itself.
9
Next-hop method
10
Network-specific method
11
Forwarding Techniques
Host-specific method
In the host-specific method, the destination host
address is given in the routing table.
More control over the routing
Here efficiency is sacrificed for other advantages:
Although it is not efficient to put the host address in
the routing table, there are occasions in which the
administrator wants to have more control over
routing
Host-specific routing is used for purposes such as
checking for route or providing security measure.
12
Host-specific method
13
Forwarding Techniques
 Default method
 Host A is connected to a network with two routers.
 Router R1 routes the packets to hosts Connected to
network N2. However, for the rest of the Internet,
router R2 is used.
 Instead of listing all networks in the entire Internet, host
A can just have one entry called the default (normally
defined as network address 0.0.0.0).
14
Default method
15
Forwarding with Classful Addressing
In classful addressing, most of the routers in the
global Internet are not involved in subnetting.
Subnetting happens inside the organization.
A typical forwarding module in this case can be
designed using three tables, One for each
unicast class (A, B, C).
If the router supports multicasting, another
table can be added to handle class D addresses.
16
Forwarding with Classful Addressing
Each routing table has a minimum of three
columns:
The network address of the destination network tell
us where the destination host is located.
Network specific forwarding is used.
The next hop address tell us to which router the
packet must be delivered for an indirect delivery.
The column is empty for a direct delivery.
The interface number defines the outgoing port from
which the packet is sent out.
17
Simplified forwarding module
18
Forwarding Module
The forwarding module follows these steps:
The destination address of the packet is extracted.
A copy of destination address is used to find the
class of the address.
Shifting the copy of the address 28 bits to the right.
The result is s four bit number between 0 and 15.
•
•
•
•
•
0 to 7, the class is A.
8 to 11, the class is B.
12 or 13, the class is C.
14, the class is D.
15, the class is E.
19
Forwarding Module
The result of step 2 for class A, B or C and the
destination address are used to extract te network
address.
The class of address and the network address are
used to find next hop information.
The class determine the table to be searched.
The module searches this table for the network address.
• If a math is found, the next hop address and the interface
number of the output port are extracted from the table.
• If no match is found, the default is used.
The ARP module uses the next hop address and the
interface number to find the physical address of the
next router.
20
Example 1
Show the routing tables for router R1
21
Solution
The following three tables are used by router
R1.
Note that some entries in the next-hop address
column are empty because in these cases, the
destination is in the same network to which the
router is connected (direct delivery).
In these cases, the next-hop address used by
ARP is simply the destination address of the
packet as we will see in the next Chapter.
22
Tables for Example 1
23
Example 2
Router R1 in the previous figure receives a packet with
destination address 192.16.7.14. Show how the packet
is forwarded.
Solution
The destination address in binary is 11000000 00010000 00000111
00001110. A copy of the address is shifted 28 bits to the right. The
result is 00000000 00000000 00000000 00001100 or 12.
The destination network is class C.
The network address is extracted by masking off the leftmost 24
bits of the destination address; the result is 192.16.7.0.
The table for Class C is searched.
The network address is found in the first row. The next-hop address
111.15.17.32. and the interface m0 are passed to ARP.
24
Example 3
Router R1 receives a packet with destination address
167.24.160.5. Show how the packet is forwarded.
Solution
The destination address in binary is 10100111 00011000 10100000
00000101. A copy of the address is shifted 28 bits to the right. The
result
is
00000000
00000000
00000000
00001010 or 10. The class is B. The network address can be found
by masking off 16 bits of the destination address, the result is
167.24.0.0. The table for Class B is searched. No matching network
address is found. The packet needs to be forwarded to the default
router (the network is somewhere else in the Internet). The nexthop address 111.30.31.18 and the interface number m0 are passed
to ARP.
25
Forwarding with subnetting
In classful addressing, subnetting happens
inside the organization.
If the organization is using variable-length
subnetting, we need several tables; otherwise,
we need only one table.
26
Simplified forwarding module
for fixed-length subnetting
27
Simplified forwarding module for
fixed-length subnetting
28
Example 4
 The figure below shows a router connected to four
subnets. Note several points:
First, the site address is 145.14.0.0/16 (a class B address).
Every packet with destination address in the range 145.14.0.0
to 145.14.255.255 is delivered to the interface m4 and
distributed to the final destination subnet by the router.
Second, we have used the address x.y.z.t/n for the interface m4
because we do not know to which network this router is
connected.
Third, the table has a default entry for packets that are to be
sent out of the site. The router is configured to apply the mask
/18 to any destination address.
29
Example 4
(cont.)
30
Example 5
The router in previous figure receives a packet
with destination address 145.14.32.78. Show
how the packet is forwarded.
Solution
The mask is /18. After applying the mask, the subnet
address is 145.14.0.0. The packet is delivered to ARP
with the next-hop address 145.14.32.78 and the
outgoing interface m0.
31
Example 6
A host in network 145.14.0.0 in previous figure
has a packet to send to the host with address
7.22.67.91. Show how the packet is routed.
Solution
The router receives the packet and applies the mask
(/18). The network address is 7.22.64.0. The table is
searched and the address is not found. The router uses
the address of the default router (not shown in figure)
and sends the packet to that router.
32
Forwarding with classless
addressing
 In classless addressing, the whole address space is one entity;
there are no classes.
 This means that forwarding requires one row of information for
each block involved.
 The table needs to be searched based on the network address (first
address in the block).
 Unfortunately, the destination address in the packet gives no clue
about the network address (as it does in classful addressing).
 To solve the problem, we need to include the mask (/n) in the
table; we need to have an extra column that includes the mask for
the corresponding block.
33
Forwarding with classless addressing
In classless addressing we can have a routing
table with three columns; in classless
addressing, we need at least four columns.
34
Example 7
Make a routing table for router R1 using the
configuration in the figure.
35
Solution
36
Example 8
Show the forwarding process if a packet arrives
at R1 in the previous figure with the destination
address 180.70.65.140.
Solution
The router performs the following steps:
1. The first mask (/26) is applied to the destination address. The
result is 180.70.65.128, which does not match the corresponding
network address.
2. The second mask (/25) is applied to the destination address. The
result is 180.70.65.128, which matches the corresponding network
address. The next-hop address (the destination address of the
packet in this case) and the interface number m0 are passed to ARP
for further processing.
37
Example 9
Show the forwarding process if a packet arrives at R1
with the destination address 201.4.22.35.
Solution
The router performs the following steps:
1. The first mask (/26) is applied to the destination address. The
result is 201.4.22.0, which does not match the corresponding
network address (row 1).
2. The second mask (/25) is applied to the destination address. The
result is 201.4.22.0, which does not match the corresponding
network address (row 2).
3. The third mask (/24) is applied to the destination address. The
result is 201.4.22.0, which matches the corresponding network
address. The destination address of the package and the interface
number m3 are passed to ARP.
38
Example 10
Show the forwarding process if a packet arrives
at R1 with the destination address 18.24.32.78.
Solution
This time all masks are applied to the destination
address, but no matching network address is found.
When it reaches the end of the table, the module gives
the next-hop address 180.70.65.200 and interface
number m2 to ARP. This is probably an outgoing
package that needs to be sent, via the default router, to
some place else in the Internet.
39
Example 11
Now let us give a different type of example. Can
we find the configuration of a router, if we know
only its routing table? The routing table for
router R1 is given in the table. Can we draw its
topology.
40
Solution
Router R1 has three interfaces:
m0, m1, and m2.
Three networks directly connected to router R1.
Two networks indirectly connected to R1.
There must be at least three other routers
involved (see next-hop column).
These routers are connected by looking at their IP
addresses. So we can put them at their appropriate
place.
The default router, is connected to the rest of
the Internet.
41
Solution
(cont.)
But there is some missing information. We do
not know if network 130.4.8.0 is directly
connected to router R2 or through a point-topoint network (WAN) and another router. We do
not know if network140.6.12.64 is connected to
router R3 directly or through a point-to-point
network (WAN) and another router. Point-topoint networks normally do not have an entry in
the routing table because no hosts are
connected to them.
42
Solution
(cont.)
43
Address Aggregation
 When we use classful addressing, there is only one
entry in the routing table for each site outside the
organization.
 The entry defines the site even if that site is subnetted.
When a packet arrives at the router, the router checks
the corresponding entry and forwards the packet
accordingly.
 When we use classless addressing, it is likely that the
number of routing table entries will increase. This is
because the intent of classless addressing is to divide up
the whole address space into manageable blocks.
44
Address Aggregation
The increased size of the table results in an
increase in the amount of time needed to search
the table.
To alleviate the problem, the idea of address
aggregation was designed.
45
Address Aggregation
In the figure below we have two routers. R1 is
connected to networks of four organizations
that each use 64 addresses.
R2 is somewhere far from R1. R1 has a longer
routing table because each packet must be
correctly routed to the appropriate organization.
R2, on the other hand, can have a very small
routing table.
46
Address Aggregation
For R2, any packet with destination 140.24.7.0
to 140.24.7.255 is sent out from interface m0
regardless of the organization number.
This is called address aggregation because the
blocks of addresses for four organizations are
aggregated into one larger block.
R2 would have a longer routing table if each
organization had addresses that could not be
aggregated into one block.
47
Address Aggregation
48
Longest Mask Matching
49
Routing
Routing deals with the issues of creating and
maintaining routing tables.
A host or router has a routing table with an
entry for each destination or a combination of
destinations, to route IP packets.
The routing table can be either static or
dynamic.
50
Static Routing Table
The information in table is entered manually.
The administrator enters
destination into the table.
the
route
for
each
When there is a change in the internet, the
table can not be update automatically.
The table must
administrator.
be
manually
altered
by
th
A static routing table can be used in a small
internet that does not change very often.
51
Dynamic Routing Table
A dynamic routing table is updated periodically
using one of the dynamic routing protocols such
as RIP, OSPF, or BGP.
Whenever there is a change in the Internet, such as
a shutdown of a router or breaking of a link, te
dynamic routing protocols update all of the tables in
the routers automatically.
52
Routing Table
Mask.
This field defines the mask applied for the entry.
Network address.
Defines the network address to which the packet is
finally delivered.
Next hop address.
Defines the address of the next hop router.
53
Routing Table
Interface.
Shows the name of the interface.
Flags.
Flags are on/off switches that signify either presence
or absence.
U (up) – indicates the router is up and running.
G (gateway) – means that the destination is in another
network (indirect delivery).
H (host specific) – indicates that the entry in the network
address field is a host-specific address.
54
Routing Table
D (added by redirection) – indicates that routing information
for this destination has been added to the host routing table
by a redirection message from ICMP.
M (modified by redirection) – indicates that the routing
information for this destination has been modified by a
redirection message from ICMP.
Reference count
Gives the number of users that are using this route
at the moment.
Use
Shows the number of packets transmitted through
this router for the corresponding destination.
55