扭曲的Python:最大封包大小?嵌入式插座? [英] Twisted Python: Max Packet Size? Flush socket?

查看:113
本文介绍了扭曲的Python:最大封包大小?嵌入式插座?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在针对服务器端实现基于Twisted的客户端-服务器解决方案,例如和Android手机(用于客户端). 因为Andoird仿真器不接受大于1500b(或小于1500b)的TCP数据包,所以我需要能够在服务器端对数据包进行分块. Twisted在每次"transport.write"之后都没有刷新套接字的情况下,Twisted会缓冲传出的数据,因此如果没有某种手动或自动刷新/maxpacketsize函数,则分块将毫无用处.如何在Twisted中执行此操作? 我熟悉"reactor.doSelect(1)"功能,但是由于我使用的是EPoll反应器(出于可伸缩性和性能的原因),因此无法使用doSelect.是否可以为Twisted中的某些连接更改maxPacketValue?

I'm implementing a client-server solution based on Twisted for the server side and e.g. and Android phone for the client side. Because the Andoird emulator takes no TCP Packets larger then 1500b (or less?), I need to be able to chunk packets on the server side. Without flushing the socket after each "transport.write", Twisted buffers the outgoing data so the chunking would be useless without somekind of manual or automatic flushing / maxpacketsize function. How do I do this in Twisted? I'm familiar with the "reactor.doSelect(1)" function, but since I'm using the EPoll reactor (for scalability and performance reasons), I cannot use doSelect. Is it possible to change the maxPacketValue for certain connections within Twisted?

希望有人可以给我看光...

Hoping that someone can show me the light...

推荐答案

TCP数据包由操作系统自动分块,所有应用程序所能做的就是提示何时刷新.除此之外,应用程序只能读取和写入流.

TCP packets are automatically chunked by the OS, all the application can do is give hints when to flush. Apart from that, an application can just read and write to a stream.

两个通信对等方的操作系统将基于具有路径的链接上的MTU自动配置最大数据包大小MTU发现.确保您没有阻止ICMP数据包使之正常工作.

The OSs of two communicating peers will automatically configure the maximum packet sizes based on the MTU on the links with Path MTU discovery. Make sure you don't block ICMP packets to get that to work.

由于错误的MTU极不可能是问题所在(并且无论如何通常都会将MTU设置为1500以下),因此您应该重新诊断问题,例如使用诸如

Since it is extremely unlikely that a wrong MTU is the problem (and an MTU of 1500 or less is often set anyway), you should re-diagnose your problem, for example with a packet tracer such as wireshark.

这篇关于扭曲的Python:最大封包大小?嵌入式插座?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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