Malformed Packet PNG investigation and analysis

1. Description of the problem:
He received a development project that pictures sometimes good, sometimes bad. Suspected transfer mode network triangulation problem, or Nginx configuration issues.
2, environment topology:

 

  3, which is caught at Nginx message information: HTTP and Porttable Network Graphics

 

 Malformed Packet PNG

Baidu search translation software translation means: "malformed packets PNG"
4, Ethereal issues reflected
Set-top box client requests jpeg images, jpeg after the server receives the request, response png image via Nginx to send the picture to the client, complete screen image loading. When PNG image transfer is complete, Nginx's TCP sends a TCP Flag: Fin ack end TCP connection, the client directly SYN: RST, directly reported to the packet format error. Then discard the packet, again establish a new TCP connection with Nginx, to obtain picture data. . . . . . . Cause the TV screen image loading failure.
5, problem analysis:
PNG image encoding and decoding process: The following chart

 

 


 

 6, PNG international standards

Detailed article : https://www.w3.org/TR/PNG/
PNG signature
PNG first eight bytes of the data stream will always contain (decimal):
137 80 78 71 13 10 26 10
This signature indicates the remaining portion of the data stream comprises a PNG image, a series of the start block IHDR block, and ends IEND block.
 
Calculated according to the foregoing chunk byte four-byte CRC (Cyclic Redundancy Code), and comprising a block type field chunk data fields, but does not include a length field. CRC can be used to check whether data corruption. CRC is always present, even for the block does not contain data as well.

 

       有效的PNG数据流应以PNG签名开头,紧随其后的是IHDR块,然后是一个或多个IDAT块,并应以IEND 块结束。PNG数据流中仅允许一个IHDR块和一个IEND

已知块,其中必须包括此国际标准中定义的所有关键块(IHDRPLTEIDATIEND
PNG签名不匹配,CRC不匹配或意外的流结束,都表示数据流已损坏,可能被视为致命错误。
简单一句话:“PNG数据流校验时,需要PNG信令,关键块(IHDRPLTEIDATIEND)”
7、那么造成机顶盒发送RST错误原因,就是PNG收到所有PNG数据流后,进行CRC校验时,并未收到IEND结束块,请求图片格式收到的格式不匹配,致使应用程序发送异常错误信息RST。

 

 

8、解决方法:将服务器的图片格式改成请求图片格式就行,比如:请求PNG就就响应PNG图片,请求JPEG就响应JEPG图片等等

 

 

Guess you like

Origin www.cnblogs.com/slyy/p/11774341.html