久久综合九色综合97婷婷-美女视频黄频a免费-精品日本一区二区三区在线观看-日韩中文无码有码免费视频-亚洲中文字幕无码专区-扒开双腿疯狂进出爽爽爽动态照片-国产乱理伦片在线观看夜-高清极品美女毛茸茸-欧美寡妇性猛交XXX-国产亚洲精品99在线播放-日韩美女毛片又爽又大毛片,99久久久无码国产精品9,国产成a人片在线观看视频下载,欧美疯狂xxxx吞精视频

有趣生活

當前位置:首頁>職場>tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)

發(fā)布時間:2024-01-19閱讀(17)

導讀引言1、搞定文章所有的TODO2、翻譯文章的英文部分不會深入介紹算法細節(jié),因為???//TODO使網(wǎng)絡層工作的3個重要組件本文中會涉及很多關于網(wǎng)絡層用到的技....引言

1、搞定文章所有的 TODO

2、翻譯文章的英文部分

不會深入介紹算法細節(jié),因為???// TODO

使網(wǎng)絡層工作的3個重要組件

本文中會涉及很多關于網(wǎng)絡層用到的技術,為了讓大家不被這些細節(jié)所累,對網(wǎng)絡層有個整體的認識,我列出3個重要的網(wǎng)絡層組件,最后你會發(fā)現(xiàn),基本上所有的技術細節(jié)都是圍繞它們展開的。

  1. The Internet Protocol (IP)
  • The creation of IP datagrams.
  • Hop-by-hop delivery from end to end.
  1. Routing Tables
  • Algorithms to populate Router forwarding tables.
  1. Internet Control Message Protocol (ICMP)
  • Communicates network layer information between end hosts and routers.
  • Reports error conditions.
  • Helps s diagnose problems.

如果你不明白上面的內(nèi)容,不要緊,這里你只需要記住它們3個對于網(wǎng)絡層來說要非常重要,下文中,我會詳細解釋它們在網(wǎng)絡層扮演的角色。

網(wǎng)絡層的組織

網(wǎng)絡層中有2種類型的組織:

  1. datagram organisation
  2. virtual circuits organisation

connectionless 服務 VS connection-oriented 服務

類似于傳輸層,傳輸層在2個進程之間提供 connectionless 服務或 connection-oriented 服務,而網(wǎng)絡層可以在2個 hosts 之間提供 connectionless 服務或 connection-oriented 服務。但是,網(wǎng)絡層不像傳輸層那樣,可以同時提供2個服務。在目前所有的計算機網(wǎng)絡架構(Internet, ATM, frame relay, and so on) 中,網(wǎng)絡層要么提供 host-to-host connectionless 服務,要么提供 host-to-host connection-oriented 服務,但是不能同時提供2個!我們把只提供 connection-oriented 服務的計算機網(wǎng)絡叫做 virtual-circuit (VC) 網(wǎng)絡; 把只提供 connectionless 服務的計算機網(wǎng)絡叫做 datagram 網(wǎng)絡.

由于下文中重點介紹的 Internet 屬于 datagram 網(wǎng)絡,這里我只介紹 datagram organisation,想了解 VC 網(wǎng)絡的童鞋請參考 Virtual circuit organisation

Router 用 routing table 來存儲 next hop 的位置,當一個 packet 到達 router 時,它會查詢它的 routing table,然后決定出這個 packet 應該去的下一個 router. 因此,一個給定的 router 只知道整個從 source 到 destination 路徑的一步,即 next hop。下圖是 Router 的內(nèi)部結(jié)構:

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)(1)

The data plane contains all the protocols and algorithms that are used by hosts and routers to create and process the packets that contain user data.The data plane, and in particular the forwarding algorithm used by the routers, depends on the routing tables that are maintained on reach router.

These routing tables can be maintained by using various techniques (manual configuration, distributed protocols, centralised computation, etc). These techniques are part of the control plane of the network layer. The control plane contains all the protocols and mechanisms that are used to compute and install routing tables on the routers.

One of the objectives of the control plane in the network layer is to maintain the routing tables that are used on all routers. As indicated earlier, a routing table is a data structure that contains, for each destination address (or block of addresses) known by the router, the outgoing interface over which the router must forward a packet destined to this address. The routing table may also contain additional information such as the address of the next router on the path towards the destination or an estimation of the cost of this path.

維護 Routing Table 的技術

// TODO

在這個小節(jié)中,Hierarchical routing 是不是維護 Routing Table 的技術???涉及算法細節(jié)嗎???

In this section, we discuss the three main techniques that can be used to maintain the routing tables in a network.

Static routing

The simplest solution is to pre-compute all the routing tables of all routers and to install them on each router. Several algorithms can be used to compute these tables.

A simple solution is to use shortest path routing and to minimise the number of intermediate routers to reach each destination. More complex algorithms can take into account the expected load on the links to ensure that congestion does not occur for a given traffic demand

The main drawback of static routing is that it does not adapt to the evolution of the network. When a new router or link is added, all routing tables must be recomputed. Furthermore, when a link or router fails, the routing tables must be updated as well.

Link state routing

Link state routing

Distance vector routing

Distance vector routing

Hierarchical routing

1、書中379頁

2、在 http://cnp3book.info.ucl.ac.be/1st/html/network/network.html 搜索 Hierarchical Routing 關鍵字

routing and non-routing

大部分的 networks 都是用分組交換(packet switching)把一個機器上的數(shù)據(jù)帶到另一個機器上。簡而言之,傳送的數(shù)據(jù)被拆分成很多個小的 packets,每個 packet 都有目標地址和返回地址(就像給我們寫信給別人 一樣),然后把這些 packets 放到 network 中,然后會根據(jù)地址找到目標機器,從而實現(xiàn)機器之間交換數(shù)據(jù)的目的。

假設你想要建造一個小的網(wǎng)絡(local network),non-routable protocol(它的本質(zhì)就是用地址 identify the destination,但是并不會說明如何去找到 destination) 就可以做到。你只需要一個交換機(switch,它只維護地址與直接連接它的機器之間的映射 destination,但是并),然后把所有的機器與它相連,每個機器都有一個地址,這個地址可以任何隨機的數(shù),然后交換機來維護地址與機器之間的映射,這樣機器之間就可以交換數(shù)據(jù)了。這個過程實際上就是一個 ethernet connection 工作的過程,Ethernet 地址(也叫 MAC address)被分配到 network adaptor cards,這個地址可以就是一個隨機數(shù)。

但是,當要你想把一個 local network 中的 packets 發(fā)送到另一個 local network 中,這就變得困難了。Internet 可以做到:把從一個 local network 中得到的 packets 發(fā)送到另一個 local network 中,這2個 local network 很有可能分別在世界的2邊。下面是維基百科給出的關于 Internet 的定義:

The Internet is the global system of interconnected computer networks that use the Internet protocol suite (TCP/IP) to link devices worldwide. It is a network of networks that consists of private, public, academic, business, and government networks of local to global scope, linked by a broad array of electronic, wireless, and optical networking technologies. The Internet carries a vast range of information resources and services, such as the inter-linked hypertext documents and applications of the World Wide Web (WWW), electronic mail, telephony, and file sharing.

從上面的定義可知,Internet 把各種各樣的 local networks 互聯(lián)起來,形成一個更大的網(wǎng)絡,要想讓如何巨大的網(wǎng)絡有效地工作起來,我們需要 routing protocol.

TCP/IP networks 本質(zhì)上是 router-based 的,Internet 是用 TCP/IP 連接世界各地的設備,因此 Internet 也是 router-based 的。上文中已經(jīng)說明了 router 中的 routing table 是用算法來配置的,讓 router tracks 整個 Internet 中的設備是不現(xiàn)實的。那么問題來了:router 是如何在如此巨大的 Internet 中發(fā)揮作用的呢?另外 Router 是如何知道哪個地址是 local 的,哪個需要 routing 呢?想知道這些問題的答案,我們就需要詳細了解 IP 協(xié)議了。

IP 協(xié)議

http://cnp3book.info.ucl.ac.be/1st/html/network/network.html#internet-protocol

DHCP

Firewalls

NAT

ICMPIntradomain routingInterdomain routingBroadcast 和 MulticastRouter VS Switch
classful network

大家平常見到的 IP 地址都是以十進制形式表示的,比如:168.212.226.204,但是對于下面一些概念的理解,我們必須要把它還原成本來的樣子,即二進制的形式,對于這個例子來說,它的二進制形式是 10101000.11010100.11100010.11001100

classful network 是從 1981 年開始使用的,但是到 1993 年就被 Classless Inter-Domain Routing 取替了。這個方法把 IP 地址的空間分成幾個類別,每個類別下可以容納不同數(shù)量的 hosts. 下圖中詳細的描述了在各個類別的信息:

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)(2)

從上圖可以看到,不同類別的 networks 有不同的 leading bits,根據(jù)這個,你就可以知道每個類別 IP 地址的范圍。通過觀察 IP 地址的高 8 位,你就可以知道各個類別高8位的范圍:Class A = 0~127,Class B = 128~191,Class C = 192~223 等,因此,如果某人給你一個 IP 地址,你完全可以根據(jù)它的高位地址就可以判斷出它屬于哪個類別。

從上圖我們也看到,各個類別要求 network number (即 Network ID )為8,16,和 24 位,這樣的劃分地址空間存在一個很大的問題。比如:一個 class C 的網(wǎng)絡只可以容納 2

8

?2=254

28?2=254 (減去 2 是因為全 0 或 全 1 的地址被保留,不能被 hosts 所用) 個 hosts,這對很多企業(yè)來說太少了; 然而,對于 class B的網(wǎng)絡來說,它可以容納 65634 個 hosts,這太大了。在這種地址空間的劃分下,比如,現(xiàn)在有個需要 2000 hosts 的企業(yè),我們要只能分配給它 class B 的網(wǎng)絡,這導致大量的地址沒有利用上。由于 Internet 的快速增長,而這個方法又大量浪費本來就十分寶貴的地址,所以它就被新的方式替代了。

Classless Inter-Domain Routing

CIDR 的出現(xiàn)就是解決 classful network 存在的問題。上面我已經(jīng)提到了 IPv4 地址實際上是由 32 位的二進制組成,表面上看起來它就是一堆煩人的,沒有意義的數(shù)字,實際上它有更深層的意義可以解讀。

這 32 位二進制分為2組:the most significant bits 是網(wǎng)絡前綴(network ID),它用來標識整個網(wǎng)絡或子網(wǎng); the least significant 是 host identifier(host ID),它指定了這個網(wǎng)絡或子網(wǎng)中的 host,這樣的劃分是 IP 網(wǎng)絡之間 traffic routing 和 地址分配策略的基礎。上面的介紹的 Classful network 是把網(wǎng)絡前綴分為 8 位,16 位,和 24 位,從而產(chǎn)生 Class A,B,或者 C 類型的網(wǎng)絡,這樣劃分非常不靈活; 而對于 CIDR 來說,我們可以在任何位置劃分地址,比如,我們可以有 3 位,9 位,或任何你想要的前綴。

聰明的伙伴們可能會想,那么給定一個 IP 地址,如何找出哪一部分是 network ID,哪一部分是 host ID 呢?答案是 subnet mask. 它由 32 個 bits 組成,a sequence of ones (1) followed by a block of zeros (0). The trailing block of zeros designates that part as being the host identifier. 把它與 IP 地址應用 bitwise AND 操作,我們就可以得到 network ID 了。下圖是維基百科給出的例子:

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)(3)

接下來,我把上面的例子再進行子網(wǎng)劃分,即從 host 部分拿出 2 bits 用于子網(wǎng)劃分,這樣我們就又多出了4個子網(wǎng),從下圖我們也看出全為 1 的 host ID 被用作 Broadcast,有興趣的伙伴們可以用 IP Calculator 來玩一玩,自己動手劃分一下子網(wǎng)。

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)(4)

從上圖中,我們也看到了 a.b.c.d/x 這種形式的地址,它是 CIDR 表示 IP 地址的新方法。The x most significant bits 構成了 IP 地址的網(wǎng)絡部分(即網(wǎng)絡 ID),它通常叫做地址的 prefix (or network prefix).

說了這么多,現(xiàn)在讓我們總結(jié)一下吧。classful network 分為幾個類別,每個類別都有不同的 network prefix,剩下的部分全是 host number,這種方法的問題就是不能更好地利用 IP 地址; CIDR 通過 variable-length subnet masking (VLSM)技術可以指定任意長度的 network prefix,同時它也用一種新的方式,a.b.c.d/x,來表示 IP 地址,其中的 “/x” 是一種簡便方法表示 subnet mask,它定義了 network ID 的位數(shù)。

tcpip四層參考模型功能(TCPIP之網(wǎng)絡層是如何工作的)(5)

因此,現(xiàn)在我們應該知道 router 是如何判斷 packets 是到同一個網(wǎng)絡的機器或者是到其它網(wǎng)絡中的機器。每一個 router 都會有它的 IP 地址和 subnet mask,它用 subnet mask 就可以判斷到來的 packets 是屬于同一個 local network 或是其它的網(wǎng)絡。舉個例子,比如我們家里的 router 的 IP 地址為 192.168.1.1,子網(wǎng)掩碼為 255.255.255.0,這樣當一個 packet 的目標地址為 192.168.1.x 時,x 可以是要任何數(shù),router 會把它轉(zhuǎn)發(fā)到要內(nèi)部的網(wǎng)絡,而其它任何的 packet 都會被發(fā)送到外部網(wǎng)絡。你可以用你的 chrome 瀏覽器試一試,比如分別輸入一個外部網(wǎng)絡(192.168.3.6)和內(nèi)部網(wǎng)絡(192.168.1.6)的地址,當然了這2個地址并不存在,你可以觀察瀏覽器都給你什么樣的錯誤。

TAGS標簽:  tcpip  四層  參考  模型  功能

歡迎分享轉(zhuǎn)載→http://www.avcorse.com/read-31447.html

Copyright ? 2024 有趣生活 All Rights Reserve吉ICP備19000289號-5 TXT地圖HTML地圖XML地圖