Protocol¶
分层协议¶
TCP/IP 模型 | 常用协议 |
|---|---|
| 应用层 | DHCP,DNS,FTP,HTTP,IMAP,POP3,SMTP,SNMP,Telnet |
| 传输层 | TCP,UDP |
| 网络层 | IPv4,IPv6,ICMP,IGMP |
| 链路层 | 以太网,IEEE 802,ARP,RARP,PPP,SLIP |
| 硬件层 | --- |
链路层¶
以太网¶
| 目的地址 6 | 源地址 6 | 类型 2 | 数据 46~1500 | CRC 4 | |||
|---|---|---|---|---|---|---|---|
| 0x0800 2 | IP数据报 46~1500 | ||||||
| 0x0806 2 | ARP请求/应答 28 | PAD 18 | |||||
| 0x0835 2 | RARP请求/应答 28 | PAD 18 | |||||
IEEE 802.3¶
| 802.3 MAC | 802.2 LLC | 802.2 SNAP | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 目的地址 6 | 源地址 6 | 长度 1 | DASP 1 | SSAP 1 | cntl 1 | org code 3 | 类型 2 | 数据 38~1492 | CRC 4 | ||
| 0x0800 2 | IP数据报 38~1492 | ||||||||||
| 0x0806 2 | ARP请求/应答 28 | PAD 10 | |||||||||
| 0x0835 2 | RARP请求/应答 28 | PAD 10 | |||||||||
ARP¶
| HW type | Protocol type | HW size | Protocol size | Opcode | Sender MAC | Sender IP | Target MAC | Target IP |
|---|---|---|---|---|---|---|---|---|
| 2 | 2 | 1 | 1 | 2 | 6 | 4 | 6 | 4 |
说明:
HW代表硬件(Hardware)Opcode: 1 →ARP请求,2 →ARP应答,3 →RARP请求,4 →RARP应答
网络层¶
IPv4¶
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
说明:
- 8位
protocol: 1 →ICMP,2 →IGMP,6 →TCP,17 →UDP - 首部校验和:先将校验和置零,然后以
16bit为一个单元,对首部所有单元进行反码求和,结果存入校验和;接收端进行校验时同样对首部进行反码求和,求和结果应当为全1。
IPv6¶
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class | Flow Label |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Length | Next Header | Hop Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Source Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Destination Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
传输层¶
UDP¶
0 7 8 15 16 23 24 31
+--------+--------+--------+--------+
| Source | Destination |
| Port | Port |
+--------+--------+--------+--------+
| | |
| Length | Checksum |
+--------+--------+--------+--------+
|
| data octets ...
+---------------- ...
TCP¶
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
应用层¶
端口号¶
| Process | PORT |
|---|---|
| FTP Server | 21 |
| SSH, SCP | 22 |
| Telnet | 23 |
| SMTP Server | 25 |
| DNS Server | 53 |
| DHCP Server | 67, 68 |
| TFTP | 69 |
| HTTP Server | 80 |
| POP3 (Email) | 110 |
| HTPPS Server | 443 |