欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

TCP发送过程 数据包

程序员文章站 2022-04-24 14:18:44
...
[size=medium]发送数据[/size]

13:18:29.402741 IP 10.217.12.22.3745 > 10.210.214.51.8080: P 1:11(10) ack 1 win 65535
0x0000: 4500 0032 d97b 4000 3d06 6c56 0ad9 0c16 E..2.{@.=.lV....
0x0010: 0ad2 d633 0ea1 1f90 3ace 1c34 c00a d97b ...3....:..4...{
0x0020: 5018 ffff c745 0000 3131 3131 3131 3131 P....E..11111111
0x0030: 0d0a ..

13:18:29.402888 IP 10.210.214.51.8080 > 10.217.12.22.3745: . ack 11 win 183
0x0000: 4500 0028 6142 4000 4006 e199 0ad2 d633 E..([email protected]@......3
0x0010: 0ad9 0c16 1f90 0ea1 c00a d97b 3ace 1c3e ...........{:..>
0x0020: 5010 00b7 f80e 0000 P.......

13:18:29.404078 IP 10.210.214.51.8080 > 10.217.12.22.3745: P 1:11(10) ack 11 win 183
0x0000: 4500 0032 6143 4000 4006 e18e 0ad2 d633 [email protected]@......3
0x0010: 0ad9 0c16 1f90 0ea1 c00a d97b 3ace 1c3e ...........{:..>
0x0020: 5018 00b7 f818 0000 6161 6161 6161 6161 P.......aaaaaaaa
0x0030: 6161 aa

13:18:29.521480 IP 10.217.12.22.3745 > 10.210.214.51.8080: . ack 11 win 65525
0x0000: 4500 0028 d97d 4000 3d06 6c5e 0ad9 0c16 E..(.}@.=.l^....
0x0010: 0ad2 d633 0ea1 1f90 3ace 1c3e c00a d985 ...3....:..>....
0x0020: 5010 fff5 991c 0000 P.......


客户端发送8个1和CR,LF一共10个字节
服务端返回10个a,也是10个字节


首先客户端发送数据,服务端返回一个ack:
1.客户端发送的***,和确认***:
3ace 1c34 c00a d97b

2.服务端返回的ack,包含的***和确认***:
c00a d97b 3ace 1c3e

可以看到就是对发送的***+收到的字节数
所以1c34 + A = 1c3e


3.服务端再发送一个数据给客户端,***和确认***:
c00a d97b 3ace 1c3e

4.客户端返回的ack,***和确认***:
3ace 1c3e c00a d985

d97b + A = d985

2,3两个数据包都是服务端返回的,
可以看到ack的确认*** 和 发送数据包的确认***都是同一个



[size=medium]发送数据[/size]

10:56:08.994391 IP 127.0.0.1.50007 > 127.0.0.1.8080: P 1:37(36) ack 1 win 1025 
<nop,nop,timestamp 64997372 64997325>
0x0000: 4500 0058 a67d 4000 4006 9620 7f00 0001 E..X.}@[email protected]
0x0010: 7f00 0001 c357 1f90 b9d6 61b7 b985 7b84 .....W....a...{.
0x0020: 8018 0401 fe4c 0000 0101 080a 03df c7fc .....L..........
0x0030: 03df c7cd 3131 3131 3131 3131 3131 3131 ....111111111111
0x0040: 3131 3131 3131 3131 3131 3131 3131 3131 1111111111111111
0x0050: 3131 11

10:56:08.994527 IP 127.0.0.1.8080 > 127.0.0.1.50007: . ack 37 win 1024
<nop,nop,timestamp 64997372 64997372>
0x0000: 4500 0034 bc49 4000 4006 8078 7f00 0001 [email protected]@..x....
0x0010: 7f00 0001 1f90 c357 b985 7b84 b9d6 61db .......W..{...a.
0x0020: 8010 0400 fe28 0000 0101 080a 03df c7fc .....(..........
0x0030: 03df c7fc ....


10:56:18.995191 IP 127.0.0.1.50007 > 127.0.0.1.8080: P 37:73(36) ack 1 win 1025
<nop,nop,timestamp 65007373 64997372>
0x0000: 4500 0058 a67e 4000 4006 961f 7f00 0001 [email protected]@.......
0x0010: 7f00 0001 c357 1f90 b9d6 61db b985 7b84 .....W....a...{.
0x0020: 8018 0401 fe4c 0000 0101 080a 03df ef0d .....L..........
0x0030: 03df c7fc 3232 3232 3232 3232 3232 3232 ....222222222222
0x0040: 3232 3232 3232 3232 3232 3232 3232 3232 2222222222222222
0x0050: 3232 22

10:56:18.995354 IP 127.0.0.1.8080 > 127.0.0.1.50007: . ack 73 win 1024
<nop,nop,timestamp 65007373 65007373>
0x0000: 4500 0034 bc4a 4000 4006 8077 7f00 0001 [email protected]@..w....
0x0010: 7f00 0001 1f90 c357 b985 7b84 b9d6 61ff .......W..{...a.
0x0020: 8010 0400 fe28 0000 0101 080a 03df ef0d .....(..........
0x0030: 03df ef0d ....


10:56:28.995560 IP 127.0.0.1.50007 > 127.0.0.1.8080: P 73:109(36) ack 1 win 1025
<nop,nop,timestamp 65017373 65007373>
0x0000: 4500 0058 a67f 4000 4006 961e 7f00 0001 [email protected]@.......
0x0010: 7f00 0001 c357 1f90 b9d6 61ff b985 7b84 .....W....a...{.
0x0020: 8018 0401 fe4c 0000 0101 080a 03e0 161d .....L..........
0x0030: 03df ef0d 3333 3333 3333 3333 3333 3333 ....333333333333
0x0040: 3333 3333 3333 3333 3333 3333 3333 3333 3333333333333333
0x0050: 3333 33

10:56:28.995704 IP 127.0.0.1.8080 > 127.0.0.1.50007: . ack 109 win 1024
<nop,nop,timestamp 65017373 65017373>
0x0000: 4500 0034 bc4b 4000 4006 8076 7f00 0001 [email protected]@..v....
0x0010: 7f00 0001 1f90 c357 b985 7b84 b9d6 6223 .......W..{...b#
0x0020: 8010 0400 fe28 0000 0101 080a 03e0 161d .....(..........
0x0030: 03e0 161d ....



17:54:38.604179 IP 10.217.12.22.peport > vm11100049.webcache: . 1:1461(1460) ack 1 win 65535
17:54:38.604217 IP vm11100049.webcache > 10.217.12.22.peport: . ack 1461 win 274
17:54:38.604303 IP 10.217.12.22.peport > vm11100049.webcache: . 1461:2921(1460) ack 1 win 65535
17:54:38.604310 IP vm11100049.webcache > 10.217.12.22.peport: . ack 2921 win 365
17:54:38.605012 IP 10.217.12.22.peport > vm11100049.webcache: . 2921:4381(1460) ack 1 win 65535
17:54:38.605025 IP vm11100049.webcache > 10.217.12.22.peport: . ack 4381 win 457
17:54:38.605086 IP 10.217.12.22.peport > vm11100049.webcache: . 4381:5841(1460) ack 1 win 65535
17:54:38.605098 IP vm11100049.webcache > 10.217.12.22.peport: . ack 5841 win 548
17:54:38.605209 IP 10.217.12.22.peport > vm11100049.webcache: . 5841:7301(1460) ack 1 win 65535
17:54:38.605217 IP vm11100049.webcache > 10.217.12.22.peport: . ack 7301 win 639
17:54:38.605335 IP 10.217.12.22.peport > vm11100049.webcache: . 7301:8761(1460) ack 1 win 65535
17:54:38.605343 IP vm11100049.webcache > 10.217.12.22.peport: . ack 8761 win 730
17:54:38.605816 IP 10.217.12.22.peport > vm11100049.webcache: . 8761:10221(1460) ack 1 win 65535
17:54:38.605827 IP vm11100049.webcache > 10.217.12.22.peport: . ack 10221 win 822
17:54:38.605842 IP 10.217.12.22.peport > vm11100049.webcache: . 10221:11681(1460) ack 1 win 65535
17:54:38.605846 IP vm11100049.webcache > 10.217.12.22.peport: . ack 11681 win 913
17:54:38.605939 IP 10.217.12.22.peport > vm11100049.webcache: . 11681:13141(1460) ack 1 win 65535
17:54:38.605947 IP vm11100049.webcache > 10.217.12.22.peport: . ack 13141 win 1004
17:54:38.606052 IP 10.217.12.22.peport > vm11100049.webcache: . 13141:14601(1460) ack 1 win 65535
17:54:38.606057 IP vm11100049.webcache > 10.217.12.22.peport: . ack 14601 win 1095
17:54:38.606138 IP 10.217.12.22.peport > vm11100049.webcache: . 14601:16061(1460) ack 1 win 65535
17:54:38.606144 IP vm11100049.webcache > 10.217.12.22.peport: . ack 16061 win 1187
17:54:38.606326 IP 10.217.12.22.peport > vm11100049.webcache: . 16061:17521(1460) ack 1 win 65535
17:54:38.606339 IP vm11100049.webcache > 10.217.12.22.peport: . ack 17521 win 1278
17:54:38.606374 IP 10.217.12.22.peport > vm11100049.webcache: . 17521:18981(1460) ack 1 win 65535
17:54:38.606379 IP vm11100049.webcache > 10.217.12.22.peport: . ack 18981 win 1369
17:54:38.606513 IP 10.217.12.22.peport > vm11100049.webcache: . 18981:20441(1460) ack 1 win 65535
17:54:38.606518 IP vm11100049.webcache > 10.217.12.22.peport: . ack 20441 win 1457
17:54:38.606670 IP 10.217.12.22.peport > vm11100049.webcache: . 20441:21901(1460) ack 1 win 65535
17:54:38.606680 IP vm11100049.webcache > 10.217.12.22.peport: . ack 21901 win 1414
17:54:38.606798 IP 10.217.12.22.peport > vm11100049.webcache: . 21901:23361(1460) ack 1 win 65535
17:54:38.606806 IP vm11100049.webcache > 10.217.12.22.peport: . ack 23361 win 1372


可以看到接收端的 窗口大小在不断变化
第二个数据包,也就是服务端返回的ack,其中win为274,表示当前最多还能接收274个字节