数据包碎片通过SSLStream发送数据时 [英] Packet fragmentation when sending data via SSLStream

查看:724
本文介绍了数据包碎片通过SSLStream发送数据时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用SSLStream发送数据的大块(1 MEG)到(已通过身份验证)的客户端,分组分片/ dissasembly我看到的是 FAR 大于在使用一个正常的NetworkStream。

When using an SSLStream to send a 'large' chunk of data (1 meg) to a (already authenticated) client, the packet fragmentation / dissasembly I'm seeing is FAR greater than when using a normal NetworkStream.

使用客户端上的异步读(即的BeginRead()),该ReadCallback反复调用完全一样大小的数据块,直到最后的数据包(该数据的其余部分)。随着我送(这是一个zip文件)的数据,该段正好是16363字节长。 注意:我的接收缓冲区比这大得多,改变它的大小没有任何影响

Using an async read on the client (i.e. BeginRead()), the ReadCallback is repeatedly called with exactly the same size chunk of data up until the final packet (the remainder of the data). With the data I'm sending (it's a zip file), the segments happen to be 16363 bytes long. Note: My receive buffer is much bigger than this and changing it's size has no effect

据我所知,SSL加密块中的数据不大于18Kb的,但由于SSL坐落在TCP之上,我不认为SSL块的数目必须的TCP报文分片任何关联?

I understand that SSL encrypts data in chunks no bigger than 18Kb, but since SSL sits on top of TCP, I wouldn't think that the number of SSL chunks would have any relevance to the TCP packet fragmentation?

本质上,数据被取约20倍的时间才能完全由客户机读比标准的NetworkStream(均在localhost!)

Essentially, the data is taking about 20 times longer to be fully read by the client than with a standard NetworkStream (both on localhost!)

我在想什么?

编辑:

我开始怀疑,接收(或发送)的SSLStream缓冲区的大小是有限的。即使我使用同步读取(即SSLStream.Read()),没有更多的数据永远可用,无论我尝试读取之前等待多长时间。这将是相同的行为就好像我是要限制接收缓冲区为16363字节。设置底层的NetworkStream的SendBufferSize(在服务器上),并且ReceiveBufferSize(在客户端上)没有效果。

I'm beginning to suspect that the receive (or send) buffer size of an SSLStream is limited. Even if I use synchronous reads (i.e. SSLStream.Read()), no more data ever becomes available, regardless of how long I wait before attempting to read. This would be the same behavior as if I were to limit the receive buffer to 16363 bytes. Setting the Underlying NetworkStream's SendBufferSize (on the server), and ReceiveBufferSize (on the client) has no effect.

推荐答案

这看起来像由一个私有定义的SslStream应用于分组数据大小限制:

This looks like a packet-data-size limitation applied by the SslStream defined by a private member:

SSLStream._SslState.MaxDataSize

我挣扎明白为什么这个限制被应用,或者如果它是可以改变的,并且已经提出这样的问题这里

这篇关于数据包碎片通过SSLStream发送数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆