我需要一个TCP选项(ioctl)立即发送数据 [英] I need a TCP option (ioctl) to send data immediately

查看:509
本文介绍了我需要一个TCP选项(ioctl)立即发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不寻常的情况:我在嵌入式情况下使用Linux系统(Intel盒,当前使用2.6.20内核.),该系统必须与具有部分中断的TCP实现的嵌入式系统进行通信.我现在可以告诉他们,他们希望从我们这里收到的每条消息都将在一个单独的以太网帧中!当消息跨以太网帧拆分时,它们似乎有问题.

I've got an unusual situation: I'm using a Linux system in an embedded situation (Intel box, currently using a 2.6.20 kernel.) which has to communicate with an embedded system that has a partially broken TCP implementation. As near as I can tell right now they expect each message from us to come in a separate Ethernet frame! They seem to have problems when messages are split across Ethernet frames.

我们与设备位于本地网络上,我们之间没有路由器(只有交换机).

We are on the local network with the device, and there are no routers between us (just a switch).

我们当然是在强迫他们修复他们的系统,但这可能最终并不可行.

We are, of course, trying to force them to fix their system, but that may not end up being feasible.

我已经在套接字上设置了TCP_NODELAY(我已连接到它们),但这仅在我一次不发送多个消息的情况下才有用.如果我连续有几条传出消息,这些消息往往会以一个或两个以太网帧结束,这会给另一个系统造成麻烦.

I've already set TCP_NODELAY on my sockets (I connect to them), but that only helps if I don't try to send more than one message at a time. If I have several outgoing messages in a row, those messages tend to end up in one or two Ethernet frames, which causes trouble on the other system.

我通常可以通过使用计时器来避免此问题,避免发送消息的距离太近,但这显然限制了我们的吞吐量.此外,如果我将时间降低得太低,则可能会导致网络拥塞,从而阻止数据包传输,并最终导致我的多个消息进入同一数据包.

I can generally avoid the problem by using a timer to avoid sending messages too close together, but that obviously limits our throughput. Further, if I turn the time down too low, I risk network congestion holding up packet transmits and ending up allowing more than one of my messages into the same packet.

有什么办法可以判断驱动程序是否有数据排队?有什么方法可以强制驱动程序在独立的传输层数据包中发送独立的写调用?我浏览了socket(7)和tcp(7)手册页,但没有找到任何东西.可能只是我不知道我在寻找什么.

Is there any way that I can tell whether the driver has data queued or not? Is there some way I can force the driver to send independent write calls in independent transport layer packets? I've had a look through the socket(7) and tcp(7) man pages and I didn't find anything. It may just be that I don't know what I'm looking for.

很明显,UDP是一种出路,但是,我不认为在这一点上我们不能使另一端发生太大变化.

Obviously, UDP would be one way out, but again, I don't think we can make the other end change anything much at this point.

任何帮助都将不胜感激.

Any help greatly appreciated.

推荐答案

IIUC,设置TCP_NODELAY选项应刷新所有数据包(即tcp.c通过调用tcp_push_pending_frames来实现NODELAY的设置).因此,如果您在每次发送呼叫后都设置了socket选项,那么您应该会得到所需的内容.

IIUC, setting the TCP_NODELAY option should flush all packets (i.e. tcp.c implements setting of NODELAY with a call to tcp_push_pending_frames). So if you set the socket option after each send call, you should get what you want.

这篇关于我需要一个TCP选项(ioctl)立即发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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