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-389เราได้เรียนรู้ในบทก่อนหน้านี้ที่ชั้นของการขนส่งรูปแบบต่าง ๆกระบวนการกระบวนการสื่อสาร โดยอาศัยชั้นเครือข่ายของโฮสต์โฮสต์บริการสื่อสาร เรายังได้เรียนรู้ว่า ชั้นขนส่งไม่ได้โดยไม่ต้องมีความรู้เกี่ยวกับวิธีชั้นเครือข่ายจริงใช้บริการนี้ ดังนั้นบางทีคุณตอนนี้สงสัย มีอะไรภายใต้กระโปรงหน้ารถของการสื่อสารโฮสต์โฮสต์การบริการ สิ่งที่ทำให้ขีดในบทนี้ เราจะได้เรียนรู้ว่าวิธีชั้นเครือข่ายใช้ hostto-บริการโฮสต์การสื่อสาร เราจะเห็นว่าแตกต่างจากการขนส่งและโปรแกรมประยุกต์ชั้น มีชิ้นส่วนของเลเยอร์เครือข่ายในแต่ละโฮสต์และเราเตอร์ในตัวเครือข่าย ด้วยเหตุนี้ เครือข่ายเลเยอร์โพรโทคอลมีความท้าทายมากที่สุด(และนี่น่าสนใจมากที่สุด!) ในกองซ้อนของโพรโทคอลชั้นเครือข่ายยังเป็นหนึ่งในที่สุดชั้นในสแตกโพรโทคอลและ เพื่อเราจะมีดินกลบที่นี่ เราจะเริ่มเราศึกษากับการภาพรวมของชั้นเครือข่ายและบริการที่ช่วยให้สามารถ เราจะตรวจสอบแล้วสองวิธีสะดวกต่อการจัดโครงสร้างการจัดส่งแพคเก็ตเครือข่ายเลเยอร์ — เดตาแกรมและแบบเสมือนวงจร — ดูบทบาทพื้นฐานที่กำหนดเล่นในการส่งแพคเก็ตของโฮสต์ปลายทางในบทนี้ เราจะทำให้ความแตกต่างสำคัญระหว่างที่ส่งต่อและหน้าที่สายงานการผลิตของชั้นเครือข่าย ส่งการโอนย้ายที่เกี่ยวข้องกับการแพ็คเก็ตจากการเชื่อมโยงเข้ากับการเชื่อมโยงขาออกภายในเราเตอร์เดียว สายงานการผลิตเกี่ยวข้องกับเราเตอร์เครือข่าย การโต้ตอบรวมที่ผ่านโพรโทคอสายงานการผลิตทั้งหมดกำหนดเส้นทางที่แพคเก็ตบนตัวเดินจากต้นทางไปปลายทางโหน นี้จะมีความแตกต่างสำคัญต้องจำไว้เป็นคุณความคืบหน้าผ่านบทนี้การอย่างลึกซึ้งเข้าใจส่ง packet ของเรา เราจะมอง "ภายใน"เตอร์ซึ่งเป็นสถาปัตยกรรมฮาร์ดแวร์และองค์กร แล้วเราจะดูที่แพคเก็ตส่งต่อในอินเทอร์เน็ต พร้อมกับการเฉลิมฉลองอินเทอร์เน็ตโพรโทคอล (IP) เราจะตรวจสอบแก้ปัญหาชั้นเครือข่ายและรูปแบบดาต้าแกรมของ IPv4 เราพบแล้วสำรวจเครือข่ายที่อยู่การแปล (NAT), เดตาแกรมกระจายตัว อินเทอร์เน็ตควบคุมข้อความโพรโทคอล (ICMP), และ IPv6เราจะเปิดเราสนใจทำงานสายงานการผลิตของเลเยอร์เครือข่าย เราจะเห็นว่า งานของอัลกอริทึมการสายงานการผลิตจะกำหนดเส้นทางที่ดี (equivalently เส้นทาง)จากผู้ส่งถึงผู้รับ เราจะต้องศึกษาทฤษฎีของเส้นทางอัลกอริทึม concentratingบน 2 ชั้นแพร่หลายมากที่สุดของอัลกอริทึม: สถานะการเชื่อมโยงและ distancevectorอัลกอริทึมการ เนื่องจากความซับซ้อนของอัลกอริทึมสายเติบโตขึ้นมากจะเป็นหมายเลขของเครือข่ายเราเตอร์เพิ่มขึ้น วิธีลำดับสายงานการผลิตยัง จะน่าสนใจ เราจะเห็นแล้วว่าทฤษฎีอยู่ในการปฏิบัติเมื่อเราครอบคลุมการของอินเทอร์เน็ตระบบอิสระภายในสายงานการผลิตโพรโทคอล (RIP, OSPF และ IS IS) และรโทคอสายงานการผลิตระบบระหว่างอิสระ ปอนด์ เราจะปิดบทนี้ ด้วยการสนทนาออกอากาศและแบบหลายผู้รับสายในสรุป บทนี้มี 3 ส่วนหลัก ส่วนแรก ส่วน 4.1 และ4.2 ครอบคลุมเครือข่ายเลเยอร์ฟังก์ชันและบริการ ส่วนที่สอง 4.3 ส่วน และ4.4 ครอบคลุมการส่งต่อ สุดท้าย ส่วนสาม ส่วน 4.5 ถึง 4.7 ครอบคลุมสายงานการผลิต4.1 บทนำรูปที่ 4.1 แสดงเครือข่ายโฮสต์สอง H1 H2 และเราเตอร์หลายอย่างบนเส้นทางระหว่าง H1 และ H2 สมมติว่า H1 จะส่งข้อมูลไปยัง H2 และพิจารณาบทบาทของเลเยอร์เครือข่ายเหล่านี้โฮสต์ และเราเตอร์อยู่ระหว่างกลางชั้นเครือข่ายใน H1 จะเซ็กเมนต์จากชั้นการขนส่งใน H1, encapsulatesแต่ละเซกเมนต์เป็นดาต้าแกรม (นั่นคือ การแพคเก็ตเครือข่ายเลเยอร์), และจากนั้นส่งdatagrams ของเราเตอร์ใกล้เคียง R1 ที่รับโฮสต์ H2 ชั้นเครือข่ายรับ datagrams จากเราเตอร์ใกล้เคียงของ R2 แยกเซ็กเมนต์ของเลเยอร์ขนส่งและจัดส่งเซ็กเมนต์ถึงชั้นการขนส่งที่ H2 หน้าที่หลักของเราเตอร์จะส่ง datagrams จากการป้อนข้อมูลการเชื่อมโยงการเชื่อมโยงออก หมายเหตุว่าเราเตอร์ในรูป 4.1 จะมีสแต็คการโพรโทคอลตัด ที่เป็น มีบนชั้นเหนือชั้นเครือข่าย เนื่องจาก (ยกเว้นเพื่อวัตถุประสงค์ในการควบคุม) เราเตอร์เรียกใช้โปรแกรมประยุกต์ และขนส่งชั้นโพรโทคอลเช่นเราตรวจสอบในบทที่ 2 และ 3 4.1.1 ส่งต่อ และสายงานการผลิตบทบาทของเลเยอร์เครือข่ายเป็นคนง่าย — ย้ายแพ็คเก็ตจากการโฮสต์ที่ส่งไปยังโฮสต์รับ ดัง ฟังก์ชันสำคัญเครือข่ายชั้นสองสามารถระบุ:•ส่งต่อ เมื่อแพคเก็ตมาที่เชื่อมโยงสำหรับการป้อนค่าของเราเตอร์ ต้องย้ายเราเตอร์แพคเก็ตเพื่อเชื่อมโยงผลผลิตที่เหมาะสม ตัวอย่าง แพ็คเก็ตที่มาจากH1 โฮสต์การเราเตอร์ R1 ต้องถูกส่งต่อไปยังเราเตอร์ถัดไปบนเส้นทางไป H2 ในส่วน 4.3 ที่เราจะค้นหาภายในเราเตอร์ และตรวจสอบว่าแพคเก็ตจะส่งต่อจริงจากการเชื่อมโยงเข้ากับการเชื่อมโยงผลผลิตภายในเราเตอร์•เส้นทาง ชั้นเครือข่ายต้องกำหนดเส้นทางหรือเส้นทางที่ดำเนินการ โดยส่งข้อมูลเป็นจะไหลจากผู้ส่งถึงเครื่องรับ อัลกอริทึมที่คำนวณเส้นทางเหล่านี้อย่างเป็นอัลกอริทึมที่สายงานการผลิต จะกำหนดขั้นตอนวิธีการสายงานการผลิต การตัวอย่าง เส้นทางไปตามกระแสที่แพ็กเก็ตจาก H1 กับ H2เงื่อนไขการส่งต่อ และสายงานการผลิตมักจะใช้สลับกัน โดยผู้เขียนสนทนาชั้นเครือข่าย เราจะใช้เงื่อนไขเหล่านี้ชัดเจนมากในหนังสือเล่มนี้ส่งต่อหมายถึงการกระทำภายในเราเตอร์ของแพคเก็ตโอนย้ายจากการเชื่อมโยงสัญญาณอินเทอร์เฟซอินเทอร์เฟซสำหรับการเชื่อมโยงผลผลิตที่เหมาะสม สายงานการผลิตอ้างอิงถึงทั้งเครือข่ายกระบวนการที่กำหนดเส้นทางสุดท้ายที่แพคเก็ตจากต้นทางไปปลายทางใช้คำว่าขับ พิจารณาเดินทางจากรัฐเพนซิลวาเนียไปฟลอริด้าที่ดำเนินการโดยเราเดินทางกลับในส่วน 1.3.1 ในระหว่างการเดินทางนี้ เราควบคุมผ่านหลาย interchanges เส้นไปฟลอริด้า เราสามารถคิดเป็นกระบวนการที่ส่งต่อต่าง ๆ แลกเปลี่ยนที่เดียว: รถป้อนการแลกเปลี่ยนจากถนนหนึ่ง และกำหนดถนนใดก็ควรนำไปแลกเปลี่ยน เราสามารถคิดถึงสายงานการผลิตเป็นกระบวนการวางแผนการเดินทางจากรัฐเพนซิลวาเนียไปฟลอริด้า: ก่อนที่ล่วงการเดินทาง โปรแกรมควบคุมได้รับการพิจารณาแผนที่และเป็นไปได้หลายเส้นทาง ท่านหนึ่งด้วยแต่ละเส้นทางที่ประกอบด้วยชุดของส่วนถนนเชื่อมต่อที่ interchangesเราเตอร์ทุกตารางส่งต่อได้ เราเตอร์ส่งต่อแพคเก็ต โดยตรวจสอบค่าของฟิลด์ในแพ็คเก็ตเดินทางเข้ามาหัวข้อ และจากนั้น ใช้หัวข้อนี้ค่าดัชนีในตารางส่งของ ค่าที่เก็บอยู่ในการส่งต่อของขาเชื่อมโยงอินเทอร์เฟซเพื่อบ่งชี้รายการตารางในหัวข้อที่ซึ่ง packet นั้นจะถูกส่งต่อ ขึ้นอยู่กับโพรโทคอลเลเยอร์เครือข่ายค่าของส่วนหัวสามารถอยู่ปลายทางของแพคเก็ตหรือตัวบ่งชี้ของการเชื่อมต่อที่เป็นสมาชิกของแพคเก็ต รูปที่ 4.2 แสดงตัวอย่าง ในรูป 4.2 แพคเก็ตกับค่าฟิลด์หัวข้อ 0111 ถึงเราเตอร์ ที่เราเตอร์ดัชนีลงในตารางการส่งต่อ และกำหนดให้ผลผลิตที่เชื่อมโยงอินเทอร์เฟซสำหรับแพคเก็ตนี้มีอินเทอร์เฟส 2 เราเตอร์แล้วภายในส่งต่อแพคเก็ตการอินเทอร์เฟส 2 ส่วน 4.3 เราจะค้นหาภายในเราเตอร์ และตรวจสอบการส่งต่อฟังก์ชันรายละเอียดมากมากกว่า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 betweenrouting and forwarding. As shown in Figure 4.2, the routing algorithm determinesthe values that are inserted into the routers’ forwarding tables. The routing algorithmmay be centralized (e.g., with an algorithm executing on a central site and downloadingrouting information to each of the routers) or decentralized (i.e., with apiece of the distributed routing algorithm running in each router). In either case, arouter receives routing protocol messages, which are used to configure its forwardingtable. The distinct and different purposes of the forwarding and routing functionscan be further illustrated by considering the hypothetical (and unrealistic, buttechnically feasible) case of a network in which all forwarding tables are configureddirectly by human network operators physically present at the routers. In this case,no routing protocols would be required! Of course, the human operators would needto interact with each other to ensure that the forwarding tables were configured insuch a way that packets reached their intended destinations. It’s also likely thathuman configuration would be more error-prone and much slower to respond tochanges in the network topology than a routing protocol. We’re thus fortunate thatall networks have both a forwarding and a routing function!While we’re on the topic of terminology, it’s worth mentioning two other termsthat are often used interchangeably, but that we will use more carefully. We’ll reservethe term packet switch to mean a general packet-switching device that transfers apacket from input link interface to output link interface, according to the value in a fieldin the header of the packet. Some packet switches, called link-layer switches (examinedin Chapter 5), base their forwarding decision on values in the fields of the linklayerframe; switches are thus referred to as link-layer (layer 2) devices. Other packetswitches, called routers, base their forwarding decision on the value in the networklayerfield. Routers are thus network-layer (layer 3) devices, but must also implementlayer 2 protocols as well, since layer 3 devices require the services of layer 2 to implementtheir (layer 3) functionality. (To fully appreciate this important distinction, youmight want to review Section 1.5.2, where we discuss network-layer datagrams andlink-layer frames and their relationship.) To confuse matters, marketing literature oftenrefers to “layer 3 switches” for routers with Ethernet interfaces, but these are reallylayer 3 devices. Since
การแปล กรุณารอสักครู่..
