305-389
We learned in the previous chapter that the transport layer provides various forms of
process-to-process communication by relying on the network layer’s host-to-host
communication service. We also learned that the transport layer does so without any
knowledge about how the network layer actually implements this service. So perhaps
you’re now wondering, what’s under the hood of the host-to-host communication
service, what makes it tick?
In this chapter, we’ll learn exactly how the network layer implements the hostto-
host communication service. We’ll see that unlike the transport and application
layers, there is a piece of the network layer in each and every host and router in the
network. Because of this, network-layer protocols are among the most challenging
(and therefore among the most interesting!) in the protocol stack.
The network layer is also one of the most complex layers in the protocol stack,
and so we’ll have a lot of ground to cover here. We’ll begin our study with an
overview of the network layer and the services it can provide. We’ll then examine
two broad approaches towards structuring network-layer packet delivery—the datagram
and the virtual-circuit model—and see the fundamental role that addressing
plays in delivering a packet to its destination host.
In this chapter, we’ll make an important distinction between the forwarding
and routing functions of the network layer. Forwarding involves the transfer of a
packet from an incoming link to an outgoing link within a single router. Routing
involves all of a network’s routers, whose collective interactions via routing protocols
determine the paths that packets take on their trips from source to destination
node. This will be an important distinction to keep in mind as you progress through
this chapter.
In order to deepen our understanding of packet forwarding, we’ll look “inside”
a router—at its hardware architecture and organization. We’ll then look at packet
forwarding in the Internet, along with the celebrated Internet Protocol (IP). We’ll
investigate network-layer addressing and the IPv4 datagram format. We’ll then
explore network address translation (NAT), datagram fragmentation, the Internet
Control Message Protocol (ICMP), and IPv6.
We’ll then turn our attention to the network layer’s routing function. We’ll see
that the job of a routing algorithm is to determine good paths (equivalently, routes)
from senders to receivers. We’ll first study the theory of routing algorithms, concentrating
on the two most prevalent classes of algorithms: link-state and distancevector
algorithms. Since the complexity of routing algorithms grows considerably
as the number of network routers increases, hierarchical routing approaches will
also be of interest. We’ll then see how theory is put into practice when we cover the
Internet’s intra-autonomous system routing protocols (RIP, OSPF, and IS-IS) and its
inter-autonomous system routing protocol, BGP. We’ll close this chapter with a discussion
of broadcast and multicast routing.
In summary, this chapter has three major parts. The first part, Sections 4.1 and
4.2, covers network-layer functions and services. The second part, Sections 4.3 and
4.4, covers forwarding. Finally, the third part, Sections 4.5 through 4.7, covers
routing.
4.1 Introduction
Figure 4.1 shows a simple network with two hosts, H1 and H2, and several routers
on the path between H1 and H2. Suppose that H1 is sending information to H2, and
consider the role of the network layer in these hosts and in the intervening routers.
The network layer in H1 takes segments from the transport layer in H1, encapsulates
each segment into a datagram (that is, a network-layer packet), and then sends
the datagrams to its nearby router, R1. At the receiving host, H2, the network layer
receives the datagrams from its nearby router R2, extracts the transport-layer segments,
and delivers the segments up to the transport layer at H2. The primary role of
the routers is to forward datagrams from input links to output links. Note that the
routers in Figure 4.1 are shown with a truncated protocol stack, that is, with no
upper layers above the network layer, because (except for control purposes) routers
do not run application- and transport-layer protocols such as those we examined in
Chapters 2 and 3. 4.1.1 Forwarding and Routing
The role of the network layer is thus deceptively simple—to move packets from a
sending host to a receiving host. To do so, two important network-layer functions
can be identified:
• Forwarding. When a packet arrives at a router’s input link, the router must move
the packet to the appropriate output link. For example, a packet arriving from
Host H1 to Router R1 must be forwarded to the next router on a path to H2. In
Section 4.3, we’ll look inside a router and examine how a packet is actually forwarded
from an input link to an output link within a router.
• Routing. The network layer must determine the route or path taken by packets as
they flow from a sender to a receiver. The algorithms that calculate these paths
are referred to as routing algorithms. A routing algorithm would determine, for
example, the path along which packets flow from H1 to H2.
The terms forwarding and routing are often used interchangeably by authors discussing
the network layer. We’ll use these terms much more precisely in this book.
Forwarding refers to the router-local action of transferring a packet from an input link
interface to the appropriate output link interface. Routing refers to the network-wide
process that determines the end-to-end paths that packets take from source to destination.
Using a driving analogy, consider the trip from Pennsylvania to Florida undertaken
by our traveler back in Section 1.3.1. During this trip, our driver passes through
many interchanges en route to Florida. We can think of forwarding as the process of
getting through a single interchange: A car enters the interchange from one road and
determines which road it should take to leave the interchange. We can think of routing
as the process of planning the trip from Pennsylvania to Florida: Before embarking on
the trip, the driver has consulted a map and chosen one of many paths possible, with
each path consisting of a series of road segments connected at interchanges.
Every router has a forwarding table. A router forwards a packet by examining
the value of a field in the arriving packet’s header, and then using this header
value to index into the router’s forwarding table. The value stored in the forwarding
table entry for that header indicates the router’s outgoing link interface to
which that packet is to be forwarded. Depending on the network-layer protocol,
the header value could be the destination address of the packet or an indication of
the connection to which the packet belongs. Figure 4.2 provides an example. In
Figure 4.2, a packet with a header field value of 0111 arrives to a router. The
router indexes into its forwarding table and determines that the output link
interface for this packet is interface 2. The router then internally forwards the
packet to interface 2. In Section 4.3, we’ll look inside a router and examine the
forwarding function in much greater detail.
You might now be wondering how the forwarding tables in the routers are configured.
This is a crucial issue, one that exposes the important interplay between
routing and forwarding. As shown in Figure 4.2, the routing algorithm determines
the values that are inserted into the routers’ forwarding tables. The routing algorithm
may be centralized (e.g., with an algorithm executing on a central site and downloading
routing information to each of the routers) or decentralized (i.e., with a
piece of the distributed routing algorithm running in each router). In either case, a
router receives routing protocol messages, which are used to configure its forwarding
table. The distinct and different purposes of the forwarding and routing functions
can be further illustrated by considering the hypothetical (and unrealistic, but
technically feasible) case of a network in which all forwarding tables are configured
directly by human network operators physically present at the routers. In this case,
no routing protocols would be required! Of course, the human operators would need
to interact with each other to ensure that the forwarding tables were configured in
such a way that packets reached their intended destinations. It’s also likely that
human configuration would be more error-prone and much slower to respond to
changes in the network topology than a routing protocol. We’re thus fortunate that
all networks have both a forwarding and a routing function!
While we’re on the topic of terminology, it’s worth mentioning two other terms
that are often used interchangeably, but that we will use more carefully. We’ll reserve
the term packet switch to mean a general packet-switching device that transfers a
packet from input link interface to output link interface, according to the value in a field
in the header of the packet. Some packet switches, called link-layer switches (examined
in Chapter 5), base their forwarding decision on values in the fields of the linklayer
frame; switches are thus referred to as link-layer (layer 2) devices. Other packet
switches, called routers, base their forwarding decision on the value in the networklayer
field. Routers are thus network-layer (layer 3) devices, but must also implement
layer 2 protocols as well, since layer 3 devices require the services of layer 2 to implement
their (layer 3) functionality. (To fully appreciate this important distinction, you
might want to review Section 1.5.2, where we discuss network-layer datagrams and
link-layer frames and their relationship.) To confuse matters, marketing literature often
refers to “layer 3 switches” for routers with Ethernet interfaces, but these are really
layer 3 devices. Since
305-389We learned in the previous chapter that the transport layer provides various forms ofprocess-to-process communication by relying on the network layer’s host-to-hostcommunication service. We also learned that the transport layer does so without anyknowledge about how the network layer actually implements this service. So perhapsyou’re now wondering, what’s under the hood of the host-to-host communicationservice, what makes it tick?In this chapter, we’ll learn exactly how the network layer implements the hostto-host communication service. We’ll see that unlike the transport and applicationlayers, there is a piece of the network layer in each and every host and router in thenetwork. Because of this, network-layer protocols are among the most challenging(and therefore among the most interesting!) in the protocol stack.The network layer is also one of the most complex layers in the protocol stack,and so we’ll have a lot of ground to cover here. We’ll begin our study with anoverview of the network layer and the services it can provide. We’ll then examinetwo broad approaches towards structuring network-layer packet delivery—the datagramand the virtual-circuit model—and see the fundamental role that addressingplays in delivering a packet to its destination host.In this chapter, we’ll make an important distinction between the forwardingand routing functions of the network layer. Forwarding involves the transfer of apacket from an incoming link to an outgoing link within a single router. Routinginvolves all of a network’s routers, whose collective interactions via routing protocolsdetermine the paths that packets take on their trips from source to destinationnode. This will be an important distinction to keep in mind as you progress throughthis chapter.In order to deepen our understanding of packet forwarding, we’ll look “inside”a router—at its hardware architecture and organization. We’ll then look at packetforwarding in the Internet, along with the celebrated Internet Protocol (IP). We’llinvestigate network-layer addressing and the IPv4 datagram format. We’ll thenexplore network address translation (NAT), datagram fragmentation, the InternetControl Message Protocol (ICMP), and IPv6.We’ll then turn our attention to the network layer’s routing function. We’ll seethat the job of a routing algorithm is to determine good paths (equivalently, routes)from senders to receivers. We’ll first study the theory of routing algorithms, concentratingon the two most prevalent classes of algorithms: link-state and distancevectoralgorithms. Since the complexity of routing algorithms grows considerablyas the number of network routers increases, hierarchical routing approaches willalso be of interest. We’ll then see how theory is put into practice when we cover theInternet’s intra-autonomous system routing protocols (RIP, OSPF, and IS-IS) and itsinter-autonomous system routing protocol, BGP. We’ll close this chapter with a discussionof broadcast and multicast routing.In summary, this chapter has three major parts. The first part, Sections 4.1 and4.2, covers network-layer functions and services. The second part, Sections 4.3 and4.4, covers forwarding. Finally, the third part, Sections 4.5 through 4.7, coversrouting.4.1 IntroductionFigure 4.1 shows a simple network with two hosts, H1 and H2, and several routerson the path between H1 and H2. Suppose that H1 is sending information to H2, andconsider the role of the network layer in these hosts and in the intervening routers.The network layer in H1 takes segments from the transport layer in H1, encapsulateseach segment into a datagram (that is, a network-layer packet), and then sendsthe datagrams to its nearby router, R1. At the receiving host, H2, the network layerreceives the datagrams from its nearby router R2, extracts the transport-layer segments,and delivers the segments up to the transport layer at H2. The primary role ofthe routers is to forward datagrams from input links to output links. Note that therouters in Figure 4.1 are shown with a truncated protocol stack, that is, with noupper layers above the network layer, because (except for control purposes) routersdo not run application- and transport-layer protocols such as those we examined inChapters 2 and 3. 4.1.1 Forwarding and RoutingThe role of the network layer is thus deceptively simple—to move packets from asending host to a receiving host. To do so, two important network-layer functionscan be identified:• Forwarding. When a packet arrives at a router’s input link, the router must movethe packet to the appropriate output link. For example, a packet arriving fromHost H1 to Router R1 must be forwarded to the next router on a path to H2. InSection 4.3, we’ll look inside a router and examine how a packet is actually forwardedfrom an input link to an output link within a router.• Routing. The network layer must determine the route or path taken by packets asthey flow from a sender to a receiver. The algorithms that calculate these pathsare referred to as routing algorithms. A routing algorithm would determine, forexample, the path along which packets flow from H1 to H2.The terms forwarding and routing are often used interchangeably by authors discussingthe network layer. We’ll use these terms much more precisely in this book.Forwarding refers to the router-local action of transferring a packet from an input linkinterface to the appropriate output link interface. Routing refers to the network-wideprocess that determines the end-to-end paths that packets take from source to destination.Using a driving analogy, consider the trip from Pennsylvania to Florida undertakenby our traveler back in Section 1.3.1. During this trip, our driver passes throughmany interchanges en route to Florida. We can think of forwarding as the process ofgetting through a single interchange: A car enters the interchange from one road anddetermines which road it should take to leave the interchange. We can think of routingas the process of planning the trip from Pennsylvania to Florida: Before embarking onthe trip, the driver has consulted a map and chosen one of many paths possible, witheach path consisting of a series of road segments connected at interchanges.Every router has a forwarding table. A router forwards a packet by examiningthe value of a field in the arriving packet’s header, and then using this headervalue to index into the router’s forwarding table. The value stored in the forwardingtable entry for that header indicates the router’s outgoing link interface towhich that packet is to be forwarded. Depending on the network-layer protocol,the header value could be the destination address of the packet or an indication ofthe connection to which the packet belongs. Figure 4.2 provides an example. InFigure 4.2, a packet with a header field value of 0111 arrives to a router. Therouter indexes into its forwarding table and determines that the output linkinterface for this packet is interface 2. The router then internally forwards thepacket to interface 2. In Section 4.3, we’ll look inside a router and examine theforwarding function in much greater detail.You might now be wondering how the forwarding tables in the routers are configured.
This is a crucial issue, one that exposes the important interplay between
routing and forwarding. As shown in Figure 4.2, the routing algorithm determines
the values that are inserted into the routers’ forwarding tables. The routing algorithm
may be centralized (e.g., with an algorithm executing on a central site and downloading
routing information to each of the routers) or decentralized (i.e., with a
piece of the distributed routing algorithm running in each router). In either case, a
router receives routing protocol messages, which are used to configure its forwarding
table. The distinct and different purposes of the forwarding and routing functions
can be further illustrated by considering the hypothetical (and unrealistic, but
technically feasible) case of a network in which all forwarding tables are configured
directly by human network operators physically present at the routers. In this case,
no routing protocols would be required! Of course, the human operators would need
to interact with each other to ensure that the forwarding tables were configured in
such a way that packets reached their intended destinations. It’s also likely that
human configuration would be more error-prone and much slower to respond to
changes in the network topology than a routing protocol. We’re thus fortunate that
all networks have both a forwarding and a routing function!
While we’re on the topic of terminology, it’s worth mentioning two other terms
that are often used interchangeably, but that we will use more carefully. We’ll reserve
the term packet switch to mean a general packet-switching device that transfers a
packet from input link interface to output link interface, according to the value in a field
in the header of the packet. Some packet switches, called link-layer switches (examined
in Chapter 5), base their forwarding decision on values in the fields of the linklayer
frame; switches are thus referred to as link-layer (layer 2) devices. Other packet
switches, called routers, base their forwarding decision on the value in the networklayer
field. Routers are thus network-layer (layer 3) devices, but must also implement
layer 2 protocols as well, since layer 3 devices require the services of layer 2 to implement
their (layer 3) functionality. (To fully appreciate this important distinction, you
might want to review Section 1.5.2, where we discuss network-layer datagrams and
link-layer frames and their relationship.) To confuse matters, marketing literature often
refers to “layer 3 switches” for routers with Ethernet interfaces, but these are really
layer 3 devices. Since
การแปล กรุณารอสักครู่..
