1. IP数据包格式
IP数据包格式如下图所示,其中每个短横线的长度代表1个比特位:
1.1 Version
取值为常量4.
1.2 IHL
- 即Internet Header Length,给出头部的长度,即指向数据部分的开始。
- 单位为32位(4字节),最小取值为5。
1.3 Type of Service
描述该数据包的传输需求,8个比特位可划分为以下几个字段:
1.3.1 Bit 0~2: Precedence
Precedence字段的取值列表如下:
取值 | 含义 |
111 | Network Control |
110 | Internetwork Control |
101 | CRITIC/ECP |
100 | Flash Override |
011 | Flash |
010 | Immediate |
001 | Priority |
000 | Routine |
1.3.2 Bit 3~5
比特位索引 | unset含义 | set含义 |
3 | 普通时延 | 低时延 |
4 | 普通吞吐量 | 高吞吐 |
5 | 普通可靠性 | 高可靠 |
除非极端情况,以上3个状态位最多2个set。
1.3.3 Bit 6、7
暂未使用。
1.4 Total Length
- 数据包的总长度(包括头部),单位为字节
- 2字节最大取值为65536字节,推荐单个数据包长度为576字节
1.5 Identification
Identification用于分段标识,使得接收端可以重新组装分段的数据包。分为2部分,3位的Flag和13位的offset。
1.5.1 Flag
共3位:
- bit 0:必须为0
- bit 1: 0=可以分段, 1 = 不可分段
- bit 2: 0 = 最后一个分段, 1 = 还有更多分段
1.5.2 Offset
13位的offset,单位为8字节,用于标识本分段位于整个数据包的第几个8字节。同时意味着IP数据包的分段长度必须是8字节的整数倍。
1.6 Time to Live
数据包的剩余存活时间,TTL为0的数据包必须被丢弃。单位为秒,且每次被处理至少减1.
1.7 Protocol
This field indicates the next level protocol used in the data portion of the internet datagram.
1.8 Header Checksum
数据包头部的checksum。
1.9 Source Address和Destination Address
略
1.10 Options
Options可以出现或不出现在头部中(由头部长度字段可判别),长度可变,主要包含control、安全、debug方面的option,详略。
2. IP数据包发送过程
如下图的结构中,两个应用程序通过IP协议交换数据包,其中通过1个IP Gateway.
其中Gateway用于在不同的网络之间转发数据包:
具体发送过程如下:
- The sending application program prepares its data and calls on its local internet module to send that data as a datagram and passes the destination address and other parameters as arguments of the call.
- The internet module prepares a datagram header and attaches the data to it. The internet module determines a local network address for this internet address, in this case it is the address of a gateway.
- It sends this datagram and the local network address to the localnetwork interface.
- The local network interface creates a local network header, and attaches the datagram to it, then sends the result via the local network.
- The datagram arrives at a gateway host wrapped in the local network header, the local network interface strips off this header, and turns the datagram over to the internet module. The internet module determines from the internet address that the datagram is to be forwarded to another host in a second network. The internet module determines a local net address for the destination host. It calls on the local network interface for that network to send the datagram.
- This local network interface creates a local network header and attaches the datagram sending the result to the destination host.
- At this destination host the datagram is stripped of the local net header by the local network interface and handed to the internet module.
- The internet module determines that the datagram is for an application program in this host. It passes the data to the application program in response to a system call, passing the source address and other parameters as results of the call.
- 大小: 104.5 KB
- 大小: 27.5 KB
- 大小: 46.7 KB
- 大小: 48.1 KB
- 大小: 27.8 KB
分享到:
相关推荐
IP协议-RFC791 中文版.doc
IP协议标准规范、接口..
RFC791 IP协议
ip protocol RFC791.INTERNET PROTOCOL DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION September 1981
rfc791 Internet Protocol IP协议标准 PDF,英文版
RFC 791,Internet Protocol,IP协议规范,学习IP协议的参考
初学者学协议的好帮助,
RFC791 INTERNET PROTOCOL DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION September 1981
IPv4_Specification-rfc791: This document specifies the DoD Standard Internet Protocol.
rfc791,里面写了很多规范,向深入学习网络知识的同学可以下载来看看
TCP/IP协议中RFC标准文档
本文档详细说明国防部(DoD)的标准互联网协议.文档基于APRA互联网协议的前六个早期版本.很多人对规范的概念以及正文作出过贡献.这个版本对寻址(addressing),错误处理(error handling ),选项编码(option codes),以及...
2. 查找与无线局域网有关的信息,写一份报告。 3. 查找路由器和交换机市场上主流厂家的信息,就他们公司及其产品写一份报告。(要求不少于3家公司) 4. 查找与IEEE802项目相关的资料,写一篇报告。...
网络协议的最常见的txt文档表示 常见网络协议RFC文档
IP protocol
RDP协议RFC英文文档