1. 程式人生 > >計算機網路自頂向下方法之一一一第一章 之一

計算機網路自頂向下方法之一一一第一章 之一

Computer Networks and the Internet


第一章是呈現一個計算機網路和網際網路的廣泛的概述,在這裡,我們的目標是繪製出一個廣闊的圖譜並且為這本書剩下的內容做個鋪墊,to see the forest through the trees.(搜了下不知道咋翻譯),在這一章我們會涵蓋很多東西並且討論很多計算機網路的零碎東西,與此同時不能喪失全域性視野。

1.1 What Is the Internet?

關於什麼是網際網路可以有兩種闡述
1).基礎的軟硬體部件構成了網際網路
2).一種給分散式應用提供服務的網路基礎設施

1.1.1 第一種講法—基本軟硬體構成

網際網路是連線全球眾多網路裝置的計算機網路,網際網路術語中,所有的網路裝置都叫做hosts或者end system
終端是通過通訊鏈路和包交換機組成的網路連線在一起的。

包交換機從它的進入的通訊鏈路中取到包,然後把包傳送到它的送出鏈路中。當今兩個最傑出的包交換機型別是routers(路由器)和link-layer switches(鏈路層交換機)
Link-layer switches are typically used in access networks, while routers are typically used in the network core.
包從發出端到達目的地所經過的一系列通訊鏈路和包交換機叫做route或者path.
end systems通過ISPs(Internet Service Providers)接入網際網路.每個ISP都是一個包交換機和通訊鏈路組成的網路.ISPs為終端提供很多型別的接入,包括住宅寬頻接入例如cable modem或DSL 。高速區域網接入,無線接入,撥號接入。ISPs還為內容提供者提供網路接入,將網站直接接入網際網路。
網際網路就是把終端都連線起來,所以顯然ISPs也得相互連線,它們通過更高層次的ISPs連線在一起,更高層次的ISPs由高速光纖連線高速路由構成。
每一個ISP網路,無論層次,都是獨立管理的,執行IP協議,遵循確定的命名和地址規定。
終端,包交換機,以及其他網路裝置執行協議來控制網路內資訊的傳送和接收,TCP(Transmission Control Protocol)和IP(Internet Protocol)是網路中最重要的兩個協議。IP協議具體闡明於路由器和終端間所傳送和接收的包的格式。網路的主要協議統稱為TCP/IP .
網際網路標準由IETF(Internet Engineering Task Force)制定,IETF標準文件叫做request for comments (RFCs),其他組織也制定網路標準,大多在網際網路連線領域比較顯著,The IEEE 802 LAN/MAN Standards Committee, for example ,specifies the Enthernet and wireless WiFi standards .

1.1.2 第二種講法—–服務講法

as an infrustructure that provides services to applications .

網際網路應用運行於終端上,而不是運行於網際網路中心的包交換機。儘管包交換機促進了終端間的資料交換。
那麼一個終端上的程式是怎麼指示網際網路把資料傳輸到指定的另一臺終端上正在執行的程式那裡呢? 連線於網際網路的終端提供API來詳細說明這個問題。
API(Application Programming Interface)是傳送端程式必須遵循的一系列規矩,這樣網際網路才能把資料傳輸到指定的目標程式。
For now, let’s draw upon a simple analogy, one that we will frequently use in this book. Suppose Alice wants to send a letter to Bob using the postal service. Alice, of course, can’t just write the letter (the data) and drop the letter out her window. Instead, the postal service requires that Alice put the letter in an envelope; write Bob’s full name, address, and zip code in the center of the envelope; seal the envelope; put a stamp in the upper-right-hand corner of the envelope; and finally, drop the envelope into an official postal service mailbox. Thus, the postal service has its own “postal service API,” or set of rules, that Alice must follow to have the postal service deliver her letter to Bob. In a similar manner, the Internet has an API that the program sending data must follow to have the Internet deliver the data to the program that will receive the data.

1.1.3 What is a Protocol

A Human Analogy

Network Protocol

網際網路中所有涉及到兩個或以上遠端交流實體的活動都是被protocol來控制的。protocols執行在網際網路的方方面面,無處不在。

A protocol defines the format and the order of messages exchanged between two or more communicating entities, as well as the actions taken on the transmission and/or receipt of a message or other event.

1.2 The Network Edge

終端之所以被叫做終端,因為他們坐落於網際網路的邊緣。它們也被叫做host,因為它們是一些應用程式的宿主,比如web 瀏覽器 program,web 伺服器 program . host還通常分為client和server ,

1.2.1 Access Networks

Home Access: DSL,Cable ,FTTH , Dial-Up , and Statellite 。

DSL : digital subscriber line , 使用DSL時,你的電信公司就是你的ISP .

在消費者這裡,分路器將資料和電話訊號分離並且把資料送入DSL modem中,DSL modem還能在傳送資料時將數字訊號轉化為模擬訊號。在電信公司,DSLAM會分離這兩種資訊並將資料傳送到網際網路。很多終端公用一個DSLAM .

DSL適用短距離連線,大約在5-10英里之間 。因為上傳下載速率是不同的,所以是非對稱連線。

While DSL makes use of the telco’s existing local telephone infrastructure, cable Internet access makes use of the cable television company’s existing cable television infrastructure.

Cable :A residence obtains cable Internet access from the same
company that provides its cable television.


由於這個系統中既有光纖又有同軸電纜 , 所以通常叫做HFC(光纖-同軸電纜混合系統) 。此種連線方式需要特別的cable modem ,這種貓把HFC網路分為兩個通道,上傳通道和下載通道 。
這種連線的重要特點是它是shared broadcast medium ,即如果很多人都在用, 網速就會慢 , 如果用的人少就快些 。

FTTH : fiber to the home ,provide an optical fiber path from the CO directly to the home .
FTTH’s PON distribution architecture

The OLT, providing conversion between optical and electrical signals,connects to the Internet via a telco router .In the home, users
connect a home router (typically a wireless router) to the ONT and access the Internet via this home router.
In the PON architecture, all packets sent from OLT to the splitter are replicated at the splitter (similar to a cable head end).

In locations where DSL, cable, and FTTH are not available (e.g., in
some rural settings), a satellite link can be used to connect a residence to the Internet at speeds of more than 1 Mbps . Dial-up access over traditional phone lines is based on the same model as DSL—a home modem connects over a phone line to a modem in the ISP. Compared with DSL and other broadband access networks, dial-up access is excruciatingly
slow at 56 kbps.

Access in the Enterprise (and the Home) :Ethernet and WiFi

在公司或者大學校園 ,或者家裡 ,一般用LAN(local area network)來連線邊緣路由器 ,雖然有不少LAN技術型別 , 但是乙太網是目前最受歡迎的連線技術 。


乙太網使用者用雙絞線連線到乙太網交換機。
無線LAN接入以IEEE 802.11 技術為基礎 , 也就是通常所說的WiFi ,

This home network consists of a roaming laptop as well as a wired PC; a
base station (the wireless access point), which communicates with the wireless PC; a cable modem, providing broadband access to the Internet; and a router, which interconnects the base station and the stationary PC with the cable modem. This network allows household members to have broadband access to the Internet with one member roaming from the kitchen to the backyard to the bedrooms.

Wide-Area Wireless Access :3G and LTE

像iPhone , Android裝置用和cellular telephony一樣的無線基礎設施通過cellular網路提供商的基站來發送和接收資料包。範圍能達到基站周圍數十公里。

3G 4G LTE

1.2.2 Physical Media

物理媒介分為兩類:
guided media :the waves are guided along a solid medium .
unguided media : the waves propagate in the atmosphere and in outer space .
Twisted-Pair Copper Wire 雙絞線
最便宜最普及的物理媒介 。 已經在電話網路中使用了上百年 。兩根絕緣銅線絞在一起來減少附近相同雙絞線的電子干擾。

UTP(Unshielded twisted pair)通常被用作一幢建築內的網路連線 。

Coaxial Cable**同軸電纜**

同軸電纜也有兩根銅導線 ,但這兩根是同軸的,這種結構讓它獲得高速傳輸能力
Coaxial cable can be used as a guided shared medium. Specifically, a number of end systems can be connected directly to the cable, with each of the end systems receiving whatever is sent by the other end systems.,

Fiber Optics 光纖

光纖通過光脈衝傳輸資料,每個脈衝代表一位元,一根光纖可以支撐龐大的位元速率 ,對電磁干擾有免疫力 ,一百公里內訊號損失非常小,and are very hard to tap . 這些特點讓其成為遠途傳輸最理想的媒介,特別是跨海連線。

Terrestrial Radio Channels
radio channels 在電磁頻譜中運送訊號 ,它吸引人之處就是它不需要任何物理線路,能穿牆 , 向移動使用者提供連線 ,並且遠距離傳輸 。
The characteristics of a radio channel depend significantly on the propagation environment and the distance over which a signal is to be carried

Satellite Radio Channels**衛星廣播**
A communication satellite links two or more Earth-based microwave transmitter/receivers, known as ground stations.它接收是一個頻段 , 傳送是另一個頻段 。分為兩種:地球同步衛星和近地衛星

同步衛星相對地球是固定的, 由於距離原因 ,來回的資訊傳輸會產生280ms的延遲。
近地衛星

1.3 The Network Core

1.3.1 Packet Switching

從源頭終端傳送message到目標終端,源頭終端會把message分成許多小的packets,從source到destination,每個packet都要穿過通訊鏈路和包交換機(包括兩種:路由器和鏈路層交換機),包在通訊鏈路中傳輸都是full transmission rate 。

Store-and-Forward Transmission
這種方法要求在輸出資料之前包交換機必須接收到整個packet。


每個包為L bits

我們來算一下從傳送方傳送包開始到接收方收到全部包為止所用的時間 ,這裡我們忽略propagation delay ,也就是位元以近乎光速穿過線路的時間,0s開始傳送,L/Rs第一個包都已經發出,路由器也已經接收到並儲存了第一個包 ,此時,路由器便可以傳送第一個包,與此同時傳送方會發送第二個包 。2L/Rs,路由器接收到第二個包, 接收方收到第一個包,以此算下去, 所以總的延遲會是4L/Rs .

Queuing Dalays and Packet Loss
每個包交換機都有許多線路連線它 ,對於每一條線路 ,包交換機都有一個output buffer 也叫做 output queue ,用來儲存路由器將要傳送出的包 ,它在包交換中有很重要的地位 。
如果剛來到的包發現路由器繁忙 , 便需要在buffer中排隊等候 ,因此會有queuing delays ,如果發現buffer已經滿了 ,之後再到達的包便會引發packet loss ,會有新到達的包或者buffer中的包被丟棄 。

Forwarding Tables and Routing Protocols

網際網路中 ,每個終端都有一個IP地址 ,當傳送方想要傳送包到目的地時 ,傳送方會在包的header包含目的地的IP地址 。當包到達路由器 ,路由器會看IP地址的一部分 ,並且把包傳送到相鄰路由器 。 更準確的說 ,每一個路由器都有轉發地址表來指示目的地地址或者目的地地址的部分 ,當包到達路由器 ,路由器檢視包頭的地址並查詢轉發地址表 ,找到合適的匯出鏈路之後就把它傳送出去 。

我們已經知道路由器利用包中的地址來查詢轉發表來決定合適的匯出鏈路 ,但是這又產生另外一個問題 ,這張表是怎麼被設定的呢 ?這個在第四章講 ,但是告訴你網際網路有一些路由協議用來自動的生成轉發表 。