HTTP 演進

Kola (Yan-Hao Wang)
5 min readApr 12, 2023

--

http 跟 web page 有很密切的關係,其中一個 page 會有多個 object,每個 object 都有可能存在不同的 web server上。object可以為 HTML file,jpg image 等。網頁其實就是一個基本的 HTML 檔案,上面有許多 object,這些object都有自己的 URL,可以被 URL 存取。

HTTP採用Client and server model,也稱客戶端/伺服器架構C/S架構,是一種分散式架構,它把客戶端伺服器分割開來[2]。每一個客戶端軟體的實例都可以向一個伺服器或應用程式伺服器發出請求。有很多不同類型的伺服器,例如檔案伺服器遊戲伺服器等。 (維基百科)
另一種常見的架構為 peer to perr model,他們的差別可以參考以下文章。
筆記一下學習網路五層#2.1.1 2.1.2 — iT 邦幫忙- iThome
P2P網路基礎知識 — iT 邦幫忙
Difference between Client-Server and Peer-to-Peer Network

HTTP使用TCP協定,所以在傳輸的時候,會先建立 TCP connection(也就是創建 socket),,整個步驟為,1. client 發起 tcp connection to server(server 的 80 port) 2. server 接受 tcp connection 3. http message開始傳送 4. tcp connection closed

Definition: A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. An endpoint is a combination of an IP address and a port number.

Do all sockets use TCP?
Network based stream sockets typically use the Transmission Control Protocol (TCP) to encapsulate and transmit data over a network interface

HTTP 是 stateless protocol,也就是他不會儲存之前的狀態,每次連線都是第一次認識,相關的介紹文章如下
Stateful vs. Stateless: Understanding the Key Differences

HTTP request message format

HTTP response message format

HTTP 0.9 1.0(1.1之前)

採用Non-persistent connection,也就是每個object都需要自己開一個 tcp connection,一個網頁中有多少個object,你就要開多少個tcp connection(at most one object sent over TCP connection)。

總體步驟為

  1. client 開啟tcp connection
  2. server接受tcp connection,告訴client端建立了 tcp了
  3. client 再傳輸 request message
  4. server收到requset,傳response message回去+他想要的資訊(ex html file),關閉tcp connection(是server關喔)。

再1-2 3-4總共有2個RTT,一個是TCP CONNECTION,另一個是http 的 request 跟 response(header),注意在第四步時是一起把response messge 跟 file一起傳回去,所以那一整個回傳的東西,前幾個byte 是 http response message(http response header),剩下的才是file(http response payload)。

所以總結來說 non-persisten http response time = 2RTT + file transmission time(http response payload)

Non-persistent http會對 client os 造成大量的overhead,因為有多個 tcp connection,並且瀏覽器長開啟多個平行的 tcp connectino。

來回通訊延遲(Round-trip delay time),在通訊(Communication)、電腦網路(Computer network)領域中,意指:在雙方通訊中,發訊方訊號(Signal)傳播(Propagation)到收訊方的時間(意即:傳播延遲(Propagation delay)),加上收訊方回傳訊息到發訊方的時間(如果沒有造成雙向傳播速率差異的因素,此時間與發訊方將訊號傳播到收訊方的時間一樣久)

When request the resources of HTML page will open new TCP connections?

HTTP cookie

Web cache(proxy server)

using conditional get?

--

--

Kola (Yan-Hao Wang)
Kola (Yan-Hao Wang)

Written by Kola (Yan-Hao Wang)

在系統軟體跟資安領域學習的學生

No responses yet