HTTP响应未分段但请求碎片化的情况

时间:2015-07-15 07:44:06

标签: networking tcp ip

在我们的应用程序中,我们使用的是运行于8081的apache tomcat webserver。

我们观察到一种行为,其中来自客户端的HTTP POST请求正在碎片化,而HTTP响应“200 OK”未得到碎片化。我们通过收集iptraces来观察。

我们的ETH MTU值为1500字节。

碎片化的示例POST请求:

===( 331 bytes received on interface en0 )==== 13:50:01.040393849
ETHERNET packet : [ 00:26:cb:eb:df:7f -> 00:1a:64:47:3c:02 ]  type 800  (IP)
IP header breakdown:
    < SRC =   172.30.17.142 >  
    < DST =      10.16.0.72 >  (un51sv01_if0)
    ip_v=4, ip_hl=20, ip_tos=0, ip_len=317, ip_id=57225, ip_off=0 DF
    ip_ttl=62, ip_sum=942d, ip_p = 6 (TCP)
TCP header breakdown:
    <source port=43795, destination port=8081 >
    th_seq=2849969884, th_ack=3790782429
    th_off=5, flags<PUSH | ACK>
    th_win=49680, th_sum=ba63, th_urp=0
00000000     504f5354 202f6973 61736f61 702f656e     |POST /isasoap/en|
00000010     64706f69 6e742f49 6e766f6b 65417070     |dpoint/InvokeApp|
00000020     53657276 69636549 46204854 54502f31     |ServiceIF HTTP/1|
00000030     2e310d0a 436f6e74 656e742d 54797065     |.1..Content-Type|
00000040     3a207465 78742f78 6d6c3b20 63686172     |: text/xml; char|
00000050     7365743d 7574662d 380d0a41 63636570     |set=utf-8..Accep|
00000060     743a2074 6578742f 786d6c2c 20746578     |t: text/xml, tex|
00000070     742f6874 6d6c2c20 696d6167 652f6769     |t/html, image/gi|
00000080     662c2069 6d616765 2f6a7065 672c202a     |f, image/jpeg, *|
00000090     3b20713d 2e322c20 2a2f2a3b 20713d2e     |; q=.2, */*; q=.|
000000a0     320d0a53 4f415041 6374696f 6e3a2022     |2..SOAPAction: "|
000000b0     220d0a55 7365722d 4167656e 743a204a     |"..User-Agent: J|
000000c0     6176612f 312e362e 305f3831 0d0a486f     |ava/1.6.0_81..Ho|
000000d0     73743a20 31302e31 362e302e 37323a38     |st: 10.16.0.72:8|
000000e0     3038310d 0a436f6e 6e656374 696f6e3a     |081..Connection:|
000000f0     206b6565 702d616c 6976650d 0a436f6e     | keep-alive..Con|
00000100     74656e74 2d4c656e 6774683a 20333634     |tent-Length: 364|
00000110     390d0a0d 0a                             |9....           |

现在碎片化的第二个数据包开始:

====( 1434 bytes received on interface en0 )==== 13:50:01.040697474
ETHERNET packet : [ 00:26:cb:eb:df:7f -> 00:1a:64:47:3c:02 ]  type 800  (IP)
IP header breakdown:
    < SRC =   172.30.17.142 >  
    < DST =      10.16.0.72 >  (un51sv01_if0)
    ip_v=4, ip_hl=20, ip_tos=0, ip_len=1420, ip_id=57227, ip_off=0 DF
    ip_ttl=62, ip_sum=8fdc, ip_p = 6 (TCP)
TCP header breakdown:
    <source port=43795, destination port=8081 >
    th_seq=2849970161, th_ack=3790782429
    th_off=5, flags<ACK>
    th_win=49680, th_sum=f8e9, th_urp=0
00000000     3c3f786d 6c207665 7273696f 6e3d2231     |<?xml version="1|
00000010     2e302220 656e636f 64696e67 3d225554     |.0" encoding="UT|
00000020     462d3822 3f3e0a3c 656e763a 456e7665     |F-8"?>.<env:Enve|
00000030     6c6f7065 20786d6c 6e733a65 6e763d22     |lope xmlns:env="|
00000040     68747470 3a2f2f73 6368656d 61732e78     |http://schemas.x|
00000050     6d6c736f 61702e6f 72672f73 6f61702f     |mlsoap.org/soap/|
00000060     656e7665 6c6f7065 2f222078 6d6c6e73     |envelope/" xmlns|
00000070     3a787364 3d226874 74703a2f 2f777777     |:xsd="http://www|
00000080     2e77332e 6f72672f 32303031 2f584d4c     |.w3.org/2001/XML|
00000090     53636865 6d612220 786d6c6e 733a7873     |Schema" xmlns:xs|

与上面类似,还有另一个数据包。

现在是~950八位字节的最终数据包:

====( 943 bytes received on interface en0 )==== 13:50:01.040713619
ETHERNET packet : [ 00:26:cb:eb:df:7f -> 00:1a:64:47:3c:02 ]  type 800  (IP)
IP header breakdown:
    < SRC =   172.30.17.142 >  
    < DST =      10.16.0.72 >  (un51sv01_if0)
    ip_v=4, ip_hl=20, ip_tos=0, ip_len=929, ip_id=57229, ip_off=0 DF
    ip_ttl=62, ip_sum=91c5, ip_p = 6 (TCP)
TCP header breakdown:
    <source port=43795, destination port=8081 >
    th_seq=2849972921, th_ack=3790782429
    th_off=5, flags<PUSH | ACK>
    th_win=49680, th_sum=32ac, th_urp=0
00000000     74612069 643d2249 44313122 20787369     |ta id="ID11" xsi|
00000010     3a747970 653d226e 73313a49 6e766f6b     |:type="ns1:Invok|
00000020     65417070 44617461 223e3c64 61746154     |eAppData"><dataT|
.....

经过我们的应用程序的一些内部处理后,我们发送200 OK和HTTP Response。

HTTP 200 OK响应

====( 3209 bytes transmitted on interface en0 )==== 13:50:01.041804849
ETHERNET packet : [ 00:1a:64:47:3c:02 -> 00:00:0c:07:ac:32 ]  type 800  (IP)
IP header breakdown:
    < SRC =      10.16.0.72 >  (un51sv01_if0)
    < DST =   172.30.17.142 >  
    ip_v=4, ip_hl=20, ip_tos=0, ip_len=3195, ip_id=60324, ip_off=0
    ip_ttl=60, ip_sum=ffff, ip_p = 6 (TCP)
TCP header breakdown:
    <source port=8081, destination port=43574 >
    th_seq=3486085705, th_ack=3771812741
    th_off=5, flags<PUSH | ACK>
    th_win=65535, th_sum=564, th_urp=0
00000000     48545450 2f312e31 20323030 204f4b0d     |HTTP/1.1 200 OK.|
00000010     0a416363 6570743a 20746578 742f786d     |.Accept: text/xm|
00000020     6c2c2074 6578742f 68746d6c 2c20696d     |l, text/html, im|
00000030     6167652f 6769662c 20696d61 67652f6a     |age/gif, image/j|
00000040     7065672c 202a3b20 713d2e32 2c202a2f     |peg, *; q=.2, */|
00000050     2a3b2071 3d2e320d 0a436f6e 74656e74     |*; q=.2..Content|

从上面请注意,对于200 OK HTTP响应,en0上收到的数据包长度为“3209”,实际上是整个响应。但它超过了以太网的MTU ......

我们的MTU值是默认值 - 1500字节

un51sv01# lsattr -El en0 |grep mtu
mtu           1500          Maximum IP Packet Size for This Device     True

有人可以说明为什么会这样发生吗?

Change / Show Characteristics of an Ethernet Adapter

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                    [Entry Fields]
Ethernet Adapter                                    ent0
Description                                         Logical Host Ethernet Port (lp-hea)
Status                                              Available
Location
Request Transmit and Receive Jumbo Frames           no                                                                                      +
Enable hardware Transmit TCP segmentation           yes                                                                                     +
Enable receive TCP segment aggregation              yes                                                                                     +
Enable hardware Transmit checksum                   yes                                                                                     +
Enable hardware Receive checksum                    yes                                                                                     +
Requested media speed                               Auto_Negotiation                                                                        +
Enable ALTERNATE ETHERNET address                   no                                                                                      +
ALTERNATE ETHERNET address                         [0x000000000000]                                                                         +
Apply change to DATABASE only                       no                                                                                      +

以上表示未启用巨型帧。

谢谢, Sashi

0 个答案:

没有答案
相关问题