200 likes | 465 Views
Ethernet Frame. Preamble. 8 bytes. Destination Address. 6 bytes. The address(es) are specified for a unicast, multicast (subgroup), or broadcast (an entire group). Source Address. 6 bytes. The address is for a unicast (single computer or device).
E N D
Ethernet Frame Preamble. 8 bytes. Destination Address. 6 bytes.The address(es) are specified for a unicast, multicast (subgroup), or broadcast (an entire group). Source Address. 6 bytes.The address is for a unicast (single computer or device). EtherType. 16 bits.Which upper layer protocol will utilized the Ethernet frame. Data. variable, 46-1500 bytes. FCS, Frame Check Sequence. 4 bytes.Error checking with a Cycle Redundancy Check (CRC) value
IP Header (cont.) • Version : IP版本 (v4/v6) • Header Length : IP header長度 • Type of Service : 傳送品質的要求 • Bits 0-2 : Precedence. 0~7.資料傳送的優先順序 • Bits 3: 0=Normal Delay, 1=Low Delay • Bits 4: 0=Normal Throughput, 1=High Throughput • Bits 5: 0=Normal Reliability 1=High Reliability • Bits 6-7 : reserved • Total Length : 本segment的大小 • Identifier : 提供segment被fragment後的識別號碼
IP Header (cont.) • Flags : 關於fragment的控制 • 位元 0 : 保留 • 位元 1 : 0表示可以fragment,1表示不可fragment • 位元 2 : 0表示是最後一個fragment,1表示後面還有資料 • Fragmented Offset : 表示分割後的fragment在原來segment中的相對位置,以8個位元組為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長度以32個位元結束
TCP的基本機制 • 為每個segment編上序號,可以利用序號調整亂掉的segment • 接收端的確認回應(ACK), 總和檢查碼(Checksum), 計時器(Timer)的配合使用,提供穩定的服務品質 • 利用Window Control控制資料流量 • 因為ACK機制,故傳輸速度受RTT影響極大,接近反比關係
TCP Header (cont.) • Sequence Number : 表示此資料段在訊息中的序號,接收端依序組合資料段 • Acknowledgment Number : 接收端希望下次收到的序號,也是回應已收到封包 • Header Length : TCP Header的長度 • Reserved : 保留給未來使用 • Flags : 由6個bits所組成,控制資料的傳輸與連結 • URG : 緊急指標 • ACK : 如果設定,表示此封包有一個回應 • PSH : push function • RST : 重設連結 • SYN : 建立順序號碼 • FIN : 傳送資料到此為止
TCP Header (cont.) • Window Size : 使用於流量控制,表示能接收資料的數目(以8個位元組為單位) • Checksum : 錯誤偵測號碼 • Urgent Pointer : 緊急指標。URG flag為1時,此欄位才生效 • Options : 此資料段的發送者告訴對方能接受的最大資料段長度 • Padding : 使header長度以32個位元結束
UDP Header (User Datagram Protocol)
UDP Header (Cont) • Source Port : 來源端通訊埠號碼 • Destination Port : 發送端通訊埠號碼 • UDP Length : 整個資料段的長度 • Checksum : 選擇性的選項
ICMP • 錯誤偵測與回報機制 • 偵測遠端主機是否存在 • 建立及維護路由資料 • 重導資料傳送路徑 • 資料流量控制
ICMP - Ping • 甲 ping 乙 • 甲送出 ICMP type 8 (Echo-Request) 給乙 • 沿路所有設備都沒過濾 ICMP type 8 封包 • 沿路所有設備都沒搞丟這封包 • 乙收到且願意回答 • 乙回送 ICMP type 0 (Echo-Reply) 給甲 • 沿路所有設備都沒過濾 ICMP type 0 封包 • 沿路所有設備都沒搞丟這封包 • Linux: • echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
ICMP - Traceroute • ICMP型:Microsoft用ICMP實作traceroute • 起點發送 ICMP Echo-Request (type 8) • TTL = 1 to N,每次+1 • 沿路設備回覆 ICMP Time-Exceeded (type 11) • 終點回覆 ICMP Echo-Reply • UDP型:大部分皆為此型 • 起點發送UDP,Port 指定高段數字(>32768) • TTL = 1 to N,每次+1 • 沿路設備回覆 ICMP Time-Exceeded (type 11) • 終點回覆 ICMP Unreachable (type 3, code 3)