是否可以在丢包的情况下强制 TCP 套接字发送 0 字节 - python [英] Is it is possible to force TCP socket to send 0 bytes in case of packet losses - python

查看:67
本文介绍了是否可以在丢包的情况下强制 TCP 套接字发送 0 字节 - python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个简单的文件客户端-服务器通信来使用 TCP 传输文件.我想使用python套接字编程来实现它的代码.我遵循这个示例.我想知道是否可以控制丢包和重传.例如,当数据包被丢弃时,我可以发送大小丢失的零字节而不是重新传输实际丢失的段吗?

I am writing a simple file client-server communication to transfer a file with TCP. The code I want to implement it using python socket programming. I follow this example. I am wondering if possible to control the packet loss and retransmission. For instance, can I send zero bytes of size lost when packets are dropped instead of retransmitting the actual lost-segments?

推荐答案

不,发送 0 字节表示套接字已正确关闭,这是 TCP 协议的一部分.您要做的是更改已经处理数据包丢失的 TCP 协议.您当然可以发送指示数据包丢失的数据,但是对于之前丢失的数据,在重试尝试完成后会收到该数据,并且对您没有帮助.听起来您尝试做的事情更适合使用 UDP 并编写自己的有关丢包的逻辑,但是您还必须处理乱序数据.

No, sending 0 bytes is an indicator that the socket has been properly closed and this is part of the TCP protocol. What you're trying to do is alter the TCP protocol which already handles packet loss. You can certainly send data that indicates packet loss, but it would be received after the retry attempts were completed for data that was previously lost and would not help you. It sounds like what you're trying to do would be better suited by using UDP and writing your own logic around packet loss, but then you have to handle out of order data as well.

这篇关于是否可以在丢包的情况下强制 TCP 套接字发送 0 字节 - python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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