重组TCP流的一些问题
我正在实现一个IPS系统,在观察wireshark重新组装TCP流的过程时我有点困惑。
例如,服务器向客户端传输HTML页面。页面分为4部分,并由TCP数据包封装。然后服务器将另外 4 个 TCP 数据包推送到客户端以获取 JavaScript 文本。
我的问题是,我知道我可以通过测量它们的 Seq 和 Len 来确定它们的序列,但是我如何确定 HTML 文本的结尾?我如何知道 HTML 包含 4 个 TCP 数据包而不是 5 个?
I'm implementing an IPS system, and I'm a little confused when observing the procesure of TCP stream reassembling by wireshark.
For example, the server transfer a HTML page to the client. The page is divided into 4 parts and encapsulated by TCP packet. Then the server push another 4 TCP packets to the client for a JavaScript text.
My question is, I know I can determine their sequences by measuring their Seq and Len, but how can I determine the end of the HTML text? How can I know the HTML contains 4 TCP packets but not 5?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RFC 2616 第 4.4 节 规定消息长度可以是有多种方式给出:
Content-Length
标头(如果已定义)。 (这可能就是您所看到的情况,并且相对简单。如果您知道正文开始的位置(seq+数据包内的偏移量)和消息长度,则只需添加即可获得结束位置。 )multipart/byteranges
(除非客户要求,否则您不会看到它,而且 HTML 文档可能不会)。FIN
数据包从服务器发送到客户端,这仅发生在完全关闭时;否则您会看到RST
。)RFC 2616 section 4.4 states that the message length could be given in several ways:
Content-Length
header if one is defined. (This is probably the case you're seeing, and it's relatively simple. If you know the position (seq+offset within packet) of the start of body and the message length, you can just add to get the position of the end.)multipart/byteranges
(which you won't see unless the client asked for it, and it probably won't for an HTML document).FIN
packet is sent from the server to the client, which only happens on a clean close; you'd see anRST
otherwise.)