Identification 16 -ii
Used to help reassembled fragmented packets(指定IP包的标识号,用来帮助重新组装分段的IP 包)
-ifr 1 bit: reserved, should be 0
-ifd 1 bit: don't fragment(可指定-ifd x,下可为0、1 或r) Flags 3 -ifm 1 bit: more fragmets(可指定-ifm x,下可为0、1 或r) Fragment offset 13 -if
Where in the reconstructed datagram this fragment belongs, measured in 64bit words starting from 0(以8字节长度为单位,指定段偏移量) Time to Live 8 -it
Number of routers the packet can pass through before being discarded(值的范围从0 到255,指定TTL,表示该包可通过的路由器的数目,用于防止包在循环路径上无休止地传递) Protocol 8 -ip
Protocol associated with the data. See iana for an uptodate list of assigned numbers(用于定义IP 包内部封装的上层协议的协议号,如TCP 为6,可在IANA的网站上
http://www.iana.org/assignments/protocol-numbers 获得最新的协议号表) Header checksum 16 -ic
Checksum of the IP header data (with checksum set to zero)(可指定IP 首部校验和的值,通常由SENDIP 自动生成,不指定该参数,除非要发出带有错误校验和的包)
Source Address 32 -is Duhh...(源地址,以点分十进制方式表示) Destination Address 32 -id Cabbage(目的地址,以点分十进制方式表示) Options Variable -io...
No options are required. Any number can be added. Seebelow for details(定义各种IP 选项,如果定义了IP选项,则前面的IP 头的长度值要包括IP 选项的长度,不带IP 选项时,该值为20,带IP 选项时,可设定该值,如果要故意制造不匹配的包,可不符合规范。)
如果有IP 选项,还可指定IP 选项的值,SENDIP 支持的IP 选项如下表所示。 Name SendIP option
RFC Copy Class Number Type (see above) Length (0 not present) Description
EOL -ioeol 791 0 0 0 0 0 Used as padding if needed (使用该选项后,会自动在IP 头 中未用到的位补0) NOP -ionop 791 0 0 1 1 0
Do nothing. Often used as padding so the next option starts on a 32 bit boundary
RR -iorr 791 0 0 7 7 variable Used to record the route of a
packet.(记录包走过的每个路由 器,通常用法是: -iorr
0f:ff.ff.ff.ff:10.0.0.234 –ioeol,其中 iorr表示记录路由,此时系统会自 动将IP 选项号置为07,0f 表示指 针,即记录的最后一个IP 地址的 指针,系统会自动运算该IP 选项 的长度)
TS -iots 791 0 2 4 68 variable Used to record the time at which a packet was processed by an intermediate system
LSR -iolsr 791 1 0 3 131 vairable Loose Source Route - let the source specify the route for a packet.
SID -iosid 791 1 0 8 136 4 Rarely used, carries the SATNET stream identifier.
SSR -iossr 791 1 0 9 137 variable Strict Source Route - same as LSR, but extra hops are not allowed. SEC 791, 1108
1 0 2 130 variable Security, rarely used
E-SEC 1108 1 0 5 133 variable Extended Security, rarely used
通常在SENDIP 中指定IP 选项时,格式比较特别,下面我们以RR 记录路由选项为例
介绍一下,如果要发送一个记录三个IP 的数据包,需要考虑如下,一是指定IP 头的长度要
包括IP 选项的长度,而是要指定RR 记录路由选项的指针位置和IP 地址(本来是由系统自
动记录IP 和更新指针位置,但现在必须手工指定),那么记录三个IP 包后,指针的位置应
是3+4×3+1=16,造好后,数据包的格式应该如下:
IP 头07 15 16 10.0.0.234(IP1) 20.0.0.234(IP2) 30.0.0.234(IP3) 00(ioeol) tcp
20B RR lenptr 4bytes 4bytes4bytesPtr 具体命令行如下:
#sendip –d r64 –p ipv4 –iv 4 –ih 10 –il 128 –is 10.0.0.1 –id 30.0.0.1 –iorr 10:10.0.0.234:20.0.0.234:30.0.0.234 –ioeol –p tcp –ts 1379 –td 23 –tt 8 30.0.0.1
-ih 10 表示IP 头的长度为10×4 为40 个字节,去除标准的20 个字节长度,为IP 选项预留为20 个字节
-iorr 10:10.0.0.234:20.0.0.234:30.0.0.234 中第一个10 表示用16 进制表示的指针的
位置,后面为用冒号分隔的三个用点分十进制表示的IP 地址
-ioeol表示用00 结束IP 选项,并用随机数填充后面未用的IP 头位置
以上部分只是以RR 记录路由IP 选项为例,介绍了sendip中指定IP 选项的方法,当然
也可以根据自己的要求发送IP 选项不符合常规的数据包。其他的IP 选项与此雷同,
但发送
AntPower版权所有© 2003 技术文章 http://www.antpower.org 第7 页共14 页
前需要详细了解IP 选项的格式,才可正确发送。
TCP 数据包的格式:
根据TCP 数据包的格式,SENDIP 有如下命令行参数可以指定对应的TCP 数据包中参 数的值。 Field name Size (bits) SendIP option Description Source port 16 -ts
Source port number for the connection (以十进制的方式指定TCP 原端口) Destination port 16 -td Destination port number
(以十进制的方式指定TCP 目的端口) Sequence number 32 -tn
Number of the first data octet in this packet. If SYN bit is set, this is the number of the first data octet of the stream too.(指定TCP 序列号,如果不指定则随机产生)