負責協調如何將位元串流 <bit stream> 輸送到實際的 Media 上 主要定義了最基礎的網路硬體標準, 包括各種網路線 各種無線連線方式, 各種設備規範 以及各種接頭的規則, 還有傳輸訊號的電壓等等 與硬體有關的標準大多都在這個層級當中定義
光纖通訊系統是由三個基本元件所組成, 即光源產生器 ( 半導體雷射或發光二極體 ) 將光傳輸到遠方的光纖維及接收由光纖維傳來的光之光電二極體 先將資訊轉變成具有強弱變化的電流訊號, 再將電流訊號導入發光器以產生不同強度變化的光 此光通入光纖中, 可依原有的強弱變化傳輸到遠方的光電二極體 光電二極體會將光的強弱變化轉變回電流訊號 傳輸數位或類比資料的差別就在於光電轉換的時候, 數位僅需定義一個強弱臨界值即可判分 與, 而類比就需要精密的感應器以重現強弱, 成本比較昂貴
將原始的傳輸設施 ( 實體層 ) 轉變為一個可靠的鏈結, 監督同一鏈結上兩節點間 Frame 的傳遞 將 & 的串流組織成各種網路型態的訊框 (frame) 本層制訂了網路媒體節點辨識規則 (Media Address) frame 的格式 通過網路媒體的方式 多節點共用網路媒體的方式 錯誤控制 流量控制 檢查資料傳輸錯誤的方法等等
Preamble Ethernet. packet Data FCS Destination Address Source Address EtherType Data ::: Preamble. bytes. Destination Address. bytes. The address(es) are specified for a unicast, multicast (subgroup), or broadcast (an entire group). Source Address. bytes. The address is for a unicast (single computer or device). EtherType. bits. Which upper layer protocol will utilized the Ethernet frame. Data. variable, - bytes. FCS, Frame Check Sequence. bytes. Error checking with a Cycle Redundancy Check (CRC) value
Value EtherTypes x x x xb xf x IP. ARP, Address Resolution Protocol. RARP, Reverse Address Resolution Protocol. AppleTalk. AppleTalk ARP. NetWare IPX/SPX.
當來源與目的地不在同一個網路媒體上時, 此層負責確保每一個封包 <Packet> 能從起源點轉送到最後的目的地 主要定義了廣域網路節點規則 ( 例如 IP 的 Address) 選徑規則 (Route) 壅塞控制 監督個別封包的來源到目的地之傳遞, 它不去了解這些封包之間真正的關係
MAC header IP header Data ::: Version IHL TOS Total length Identification Flags Fragment offset TTL Protocol Header checksum Source IP address Destination IP address Options and padding :::
Version : IP 版本 (v/v) Header Length : IP header 長度 Type of Service : 傳送品質的要求 Bits - : Precedence. ~. 資料傳送的優先順序 Bits : =Normal Delay, =Low Delay Bits : =Normal Throughput, =High Throughput Bits : =Normal Reliability =High Reliability Bits - : reserved Total Length : 本 segment 的大小 Identifier : 提供 segment 被 fragment 後的識別號碼
Flags : 關於 fragment 的控制 位元 : 保留 位元 : 表示可以 fragment, 表示不可 fragment 位元 : 表示是最後一個 fragment, 表示後面還有資料 Fragmented Offset : 表示分割後的 fragment 在原來 segment 中的相對位置, 以 個位元組為 offset 的單位 Time to Live : segment 在網路中保留的時間 Protocol : IP 上一層的網路協定 Header Checksum : IP header checksum Source Address : Source IP address Destination Address : Destination IP address Options : Segment 測試或除錯之用 Padding : 使 header 長度以 個位元結束
定義了發送端與接收端的連線技術 ( 如 TCP 技術 ), 同時包括該技術的封包格式, 資料封包的傳送 流程的控制 傳輸過程的偵測檢查與復原重新傳送等等, 以確保各個資料封包可以正確無誤的到達目的端 單獨看待每一個封包, 確保其正確到達, 但並不瞭解封包之間真正的關係
為每個 segment 編上序號, 可以利用序號調整亂掉的 segment 接收端的確認回應 (ACK), 總和檢查碼 (Checksum), 計時器 (Timer) 的配合使用, 提供穩定的服務品質 利用 Window Control 控制資料流量 因為 ACK 機制, 故傳輸速度受 RTT 影響極大, 接近反比關係
MAC header IP header TCP header Data ::: Source Port Destination Port Sequence Number Acknowledgment Number Data Offset reser ved ECN Control Bits Window Checksum Urgent Pointer Options and padding ::: Data :::
Sequence Number : The sequence number of the first data byte in this segment. If the SYN bit is set, the sequence number is the initial sequence number and the first data byte is initial sequence number +. Acknowledgment Number : If the ACK bit is set, this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established this is always sent Data Offset : TCP Header 的長度, 以 DWord(bits) 的數量表示 Reserved : 保留給未來使用 ECN: Explicit Congestion Notification Control Bits : 由 個 bits 所組成, 控制資料的傳輸與連結 URG : 緊急指標 ACK : 如果設定, 表示此封包有一個回應 PSH : push function RST : 重設連結 SYN : 建立順序號碼 FIN : 傳送資料到此為止 Window Size:The window size is used to record how many bytes of buffer space the host has available for receiving data. the maximum window size is, bytes. http://www.networksorcery.com/enp/protocol/tcp.htm
Three-Way Handshack 發送 SYN 序列號碼 (SEQ) 為 連結建立收到 SYN 並回應控制訊號 回應號碼 (ACK) 為 序列號碼 (SEQ) 為 發送資料 Client Server 收到 SYN 發送 SYN 序列號碼 (SEQ) 為 回應號碼 (ACK) 為 + 連結建立 回應 " 已收到資料 "
UDP Header (User Datagram Protocol) MAC header IP header UDP header Data ::: Source Port Destination Port Length Checksum Data :::
Source Port : 來源端通訊埠號碼 Destination Port : 發送端通訊埠號碼 UDP Length : 整個資料段的長度 Checksum : 選擇性的選項
MAC header ARP header Data ::: Hardware type Hardware address length Protocol address length Protocol type Opcode Source hardware address ::: Source protocol address ::: Destination hardware address ::: Destination protocol address ::: Data :::
Val Hardware Type Ethernet. Experimental Ethernet. Amateur Radio AX.. Proteon ProNET Token Ring. Chaos. IEEE. ARCNET. Hyperchannel. Lanstar. Autonet Short Address. LocalTalk. LocalNet (IBM PCNet or SYTEK LocalNET). Ultra link. SMDS. Frame Relay. ATM, Asynchronous Transmission Mode. HDLC. Fibre Channel. ATM, Asynchronous Transmission Mode. Value Ptotocol Type x IP. Value OPCode References Request. RFC Reply. RFC, RFC Request Reverse. RFC Reply Reverse. RFC DRARP Request. RFC DRARP Reply. RFC DRARP Error. RFC InARP Request. RFC InARP Reply. RFC ARP NAK. RFC
MAC header RARP packet Hardware type Protocol type Hardware address length Protocol address length Opcode Source hardware address ::: Source protocol address ::: Destination hardware address ::: Destination protocol address :::
錯誤偵測與回報機制 偵測遠端主機是否存在 建立及維護路由資料 重導資料傳送路徑 資料流量控制
MAC header IP header ICMP header Data ::: Type Code ICMP header checksum Data :::
TYPE 名稱 代表意思 Echo Reply 是一個回應信息 Destination Unreachable 表示目的地不可到達 Source Quench 當 router 負載過時,用來竭止來源繼續發送訊息 Redirect 用來重新導向路由路徑 Echo Request 請求回應訊息 Time Exceeded for a Datagram 當資料封包在某些路由現象中逾時,告知來源該封包已被忽略忽略 Parameter Problem on a Datagram Timestamp Request 當一個 ICMP 封包重複著之前的錯誤時,會回覆來源主機關於參數錯誤的訊息 要求對方送出時間訊息,用以計算路由時間的差異,以滿足同步性協定的要求 Timestamp Replay 此訊息純粹是回應 Timestamp Request 用的 Information Request 在 RARP 協定應用之前,此訊息是用來在開機時取得網路信息 Information Reply 用以回應 Information Request 訊息 Address Mask Request 這訊息是用來查詢子網路 mask 設定信息 Address Mask Reply 回應子網路 mask 查詢訊息的
甲 ping 乙 甲送出 ICMP type (Echo-Request) 給乙 沿路所有設備都沒過濾 ICMP type 封包 沿路所有設備都沒搞丟這封包 乙收到且願意回答 乙回送 ICMP type (Echo-Reply) 給甲 沿路所有設備都沒過濾 ICMP type 封包 沿路所有設備都沒搞丟這封包 Linux: echo "" > /proc/sys/net/ipv/icmp_echo_ignore_all
ICMP 型 :Microsoft 用 ICMP 實作 traceroute 起點發送 ICMP Echo-Request (type ) TTL = to N, 每次 + 沿路設備回覆 ICMP Time-Exceeded (type ) 終點回覆 ICMP Echo-Reply UDP 型 : 大部分皆為此型 起點發送 UDP,Port 指定高段數字 (>) TTL = to N, 每次 + 沿路設備回覆 ICMP Time-Exceeded (type ) 終點回覆 ICMP Unreachable (type, code )