# 網際網路規約筆記 ## ch.1 ### What is the Internet 1. 讓設備之間進行通訊和資訊交流的基礎架構。 2. protocols: 定義網路實體之間發送和接收的訊息順序、格式以及對訊息傳輸、接收採取的操作 ### Network edge 1. applications and hosts * 終端(host) * client-server model * peer-peer (P2P) 2. access networks, physical media * 有限連接、無線連接或手機網路 * 會受到網路頻寬、網路為共享或專用影響 * 撥接網路 (Dial-up Modem) * Digital Subscriber Line (DSL) * cable modems 3. network core * circuit switching * packet-switching * network structure 4. Delay, loss and throughput in packet-switched networks 5 ## ch.2 ### 總目標: * 網路應用協定的實作面 * 透過檢查流行的應用程式級協議來了解協議 * programming network applications ### Principles of network applications Client-server(data center)/ P2P/ Hybird(skype) #### Processes communicating 1. 同一個host下使用 inter-process communication 2. 不同host下使用message exchange 3. client process = initiates communication 4. Server process = waiting to be contacted * P2P也是有client-server precess #### Socket 1. 訊息交換的手段 #### addressing process 1. To receive messages, process must have identifier 2. Host device has unique 32-bit IP address 3. Identifier includes both "IP address" and "port numbers" associated with process on host. * HTTP server : 80, Mail server: 25 #### App-layer protocol defines 1. 訊息交換類 2. 訊息語法 3. 訊息語意 4. precess send/respond規則 * public-domain portcol: 定義於RFCs並允許共通性,如HTTPs * Proprietary protocols: 如skype #### What transport service does an app need? 1. 資料遺失 2. 吞吐量 3. 定時 4. 安全性 #### Internet transport protocols services 1. TCP * connection-oriented * 可靠傳輸(reliable transport) * flow control * 壅塞控制(congestion control) * does not provide timing, minimum throughput guarantees, security 2. UCP * unreliable data transfer between sending and receiving process * 不可靠的資料傳輸 ### Web and HTTP * HTTP: hypertext transfer protocol * client/server model * overview: * 發起: client initiates TCP connection (creates socket) to server, port 80 * 同意: server accepts TCPconnection from client * 交換: HTTP messages (applicationlayer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server) * 結束: TCP connection closed * HTTP is “stateless”, 因為很複雜 * server maintains no information about past client requests * Nonpersistent HTTP * 單一TCP連線最多一個物件 * persistent HTTP * 可以透過客戶端和伺服器之間的單一 TCP 連線發送多個物件 #### HTTP request message 1. request, response 2. HTTP request message: GET /somedir/page.html HTTP/1.1 (request line) Host: url User-agent: Mozilla/4.0 Connection: close Accept-language:fr (header lines) #### Uploading form input 1. post method 2. url method #### Method type 1. HTTP/1.0 2. HTTP/1.1 * HTTP/1.1比HTTP/1.0多PUT跟DELETE #### HTTP response message HTTP/1.1 200 OK (status line) Connection close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html (header line) data data data data data ... (data) #### HTTP response status codes 1. 200 OK 2. 301 Moved Permanently 3. 400 Bad Request 4. 404 Not Found 5. 505 HTTP Version Not Supported #### User-server state: cookies 1. HTTP回應封包的cookie頭行 2. HTTP請求訊息中的cookie頭行 3. 儲存在使用者主機上的cookie文件,由使用者的瀏覽器管理 4. 網站後台資料庫 * what cookies can bring: 1. authorization 2. shopping carts 3. recommendations 4. user session state(Web e-mail) * cookies: http messages carry state * Cookies and privacy #### Web caches (proxy server) * satisfy client request without involving origin server * 不用再去向伺服器請求,本地端可以先提供 * 優點 1. reduce response time for client request 2. reduce traffic on an institution’s access link 3. 網路密集的快取: Internet dense with caches: enables “poor” content providers to effectively deliver content (but so does P2P file sharing) #### Caching example 計算先跳過 #### Conditional GET 目標: don’t send object if acache has up-to-date cached version * 只傳送date去server端以確認是否更新,不需更新會得到304 ### FTP (file transfer protocol) 1. 與遠端主機傳輸文件 2. client/server model 3. ftp: RFC 959 4. ftp server: port 21 ### Electronic Mail * Three major components 1. user agents (mail reader) 2. mail servers (包含使用者收到的信,處理待發送的訊息queue,在mail server間發送SMTP protocol) 3. simple mail transfer protocol: SMTP * 傳送過程: 握手 -> 傳送 -> 關閉 * 訊息必須用ASCII編碼 * 回應包含status code和描述詞語 | Command | Reply Code | | ----------------- |:----------:| | DATA | 354 | | HELO | 250 | | MAIL FROM | 250 | | QUIT | 221 | | RCPT TO | 250 | | reply from server | 220 | ### DNS (Domain Name System) 1. 轉換域名和IP地址 2. 提供服務器位置信息 3. 分散式架構優點 1. 分散性 2. 提高效能 3. 可靠性與容錯性 4. 全球分布 5. 網路附載均衡 #### TLD and Authoritative Servers * TLD: 頂級域名伺服器 (全球) * 負責管理頂級域名 * 每個TLD都有相應的TLD伺服器,管理該頂級域名下的註冊信息和相關的下級域名 * 權威DNS伺服器 (組織) * 提供特定組織內部域名的正式解析資訊 #### DNS name resolution example 1. iterated query * 當DNS伺服器收到迭代式查詢時,它將會回覆所知道的最佳答案,或者指示客戶端向其他更高級的DNS伺服器發送進一步的查詢。 * 要求伺服器指示客戶端向其他伺服器發送查詢 2. recursive query * DNS伺服器收到遞歸式查詢後,如果自己沒有所需的解析信息,則會向其他伺服器發送迭代式查詢,然後將所收到的結果返回給客戶端。 * 要求伺服器負責整個查詢過程,並返回最終的解析結果 ### P2P applications 1. 去中心化 2. 平等性與共享性 3. 資源共享 4. 去中介化 5. 節點協作 #### Bitturrent 1. 分散式檔案共享 2. 種子(Seed)和同行(Peer), Seed為擁有完整檔案的用戶 3. 位元圖(Bitfield)和分塊下載,利用bitfield追蹤用戶擁有的檔案部分。下載者能夠選擇從不同同行處下載不同檔案塊,從而加速整體下載速度。 4. 優化頻寬利用 5. 健壯性和彈性 * 簡單說就是通過分散式架構與P2P得到更快的速度和更高的效率共享和下載檔案。 #### Distributed Hash Table (DHT) 1. 分散式資料儲存 2. hash function 3. 節點路由和查詢 4. 健壯性和可擴展性 5. 支援分散式應用 * 通過分散存儲和查詢方式,在P2P網絡和分散式系統中提供了可靠的資料管理和訪問機制。 ### 總結 應用架構: 客戶端-伺服器(Client-Server)架構 點對點(P2P)架構 混合(Hybrid)架構 應用服務需求: 可靠性、頻寬、延遲等服務要求 Internet傳輸服務模型: 連接導向、可靠的TCP協定 不可靠的數據包、UDP協定 已研究的網絡應用和特定協議: HTTP(超文本傳輸協定) FTP(文件傳輸協定) SMTP、POP、IMAP(郵件相關協議) DNS(域名系統) P2P:BitTorrent、Skype等 套接字編程: 套接字是允許應用程序通過網絡進行通信的抽象接口,它是實現網絡應用的關鍵。 典型的請求/回覆消息交換方式: 客戶端發出信息或服務的請求。 伺服器回應請求,提供數據或狀態碼等信息。 消息格式: 消息通常包含頭部和數據兩個部分: 頭部包含有關數據的信息的字段。 數據則是被傳輸的具體信息。 #### 重要主題: 控制消息和數據消息: 控制消息是用於傳遞系統控制信息的消息,而數據消息則是具體的應用數據。 有時控制消息可以在數據消息之外傳遞(out-of-band)。 集中式和分散式: 關於系統結構,可以是集中式或分散式的架構。 無狀態和有狀態: 有些協議是無狀態的,而有些則是有狀態的。有狀態的協議會記住先前的狀態信息。 可靠和不可靠的消息傳遞: 有些協議確保消息傳遞的可靠性,而其他協議則可能是不可靠的。 網絡邊緣的複雜性: 強調了網絡邊緣的複雜性,意味著許多複雜的功能和處理在用戶端或者接近用戶端的地方發生。
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.