简体   繁体   English

在ip数据包中发送多个tcp数据包

[英]sending multiple tcp packets in an ip packet

is it possible to send multiple tcp or udp packets on a single ip packet? 是否可以在单个IP数据包上发送多个tcp或udp数据包? are there any specifications in the protocol that do not allow this. 协议中是否有任何规范不允许这样做。

if it is allowed by the protocol but is generally not done by tcp/udp implementations could you point me to the relevant portion in the linux source code that proves this. 如果协议允许但通常不是通过tcp / udp实现,你可以指向linux源代码中的相关部分来证明这一点。

are there any implementations of tcp/udp on some os that do send multiple packets on a single ip packet. 在某个操作系统上是否有任何tcp / udp实现,它们会在单个IP数据包上发送多个数据包。 (if it is allowed). (如果允许的话)。

It is not possible . 这是不可能的

The TCP seqment header does not describe its length. TCP seqment标头不描述其长度。 The length of the TCP payload is derived from the length of the IP packet(s) minus the length of the IP and TCP headers. TCP有效负载的长度是从IP数据包的长度减去IP和TCP报头的长度得出的。 So only one TCP segment per IP packet. 因此每个IP数据包只有一个TCP段。

Conversely, however, a single TCP segment can be fragmented over several IP packets by IP fragmentation. 然而,相反,可以通过IP分段在单个IP分组上分割单个TCP分段。

Tcp doesn't send packets: it is a continuous stream. Tcp不发送数据包:它是一个连续的流。 You send messages. 你发送消息。
Udp, being packet based, will only send one packet at a time. Udp是基于数据包的,一次只发送一个数据包。

The protocol itself does not allow it. 协议本身不允许它。 It won't break, it just won't happen. 它不会破裂,它不会发生。

The suggestion to use tunneling is valid, but so is the warning. 使用隧道的建议是有效的,但警告也是如此。

You might want to try tunneling tcp over tcp, although it's generally considered a bad idea . 你可能想尝试通过tcp隧道化tcp,虽然它通常被认为是一个坏主意 Depending on your needs, your mileage may vary. 根据您的需要,您的里程可能会有所不同。

You may want to take a look at the Stream Control Transmission Protocol which allows multiple data streams across a single TCP connection. 您可能需要查看流控制传输协议 ,该协议允许跨单个TCP连接的多个数据流。

EDIT - I wasn't aware that TCP doesn't have it's own header field so there would be no way of doing this without writing a custom TCP equivalent that contains this info. 编辑 - 我不知道TCP没有自己的头字段,所以如果不编写包含此信息的自定义TCP等效项,就无法做到这一点。 SCTP may still be of use though so I'll leave that link. SCTP可能仍然有用,所以我将保留该链接。

TCP is a public specification, why not just read it? TCP是一个公共规范,为什么不只是阅读它?

RFC4164 is the roadmap document, RFC793 is TCP itself, and RFC1122 contains some errata and shows how it fits together with the rest of the (IPv4) universe. RFC4164是路线图文档, RFC793是TCP本身, RFC1122包含一些勘误表,并显示它如何与(IPv4)Universe的其余部分组合在一起。

But in short, because the TCP header (RFC793 section 3.1) does not have a length field, TCP data extends from the end of the header padding to the end of the IP packet. 但简而言之,因为TCP标头(RFC793第3.1节)没有长度字段,所以TCP数据从标头填充的末尾延伸到IP数据包的末尾。 There is nowhere to put another data segment in the packet. 无处可在数据包中放入另一个数据段。

You cannot pack several TCP packets into one IP packet - that is a restriction of specification as mentioned above. 您无法将多个TCP数据包打包到一个IP数据包中 - 这是上面提到的规范限制。 TCP is the closest API which is application-oriented. TCP是最接近面向应用程序的API。 Or you want to program sending of raw IP messages? 或者您想编程发送原始IP消息? Just tell us, what problem do you want to solve. 只需告诉我们,您想解决什么问题。 Think about how you organize the delivery of the messages from one application to another, or mention that you want to hook into TCP/IP stack. 考虑如何组织从一个应用程序到另一个应用程序的消息传递,或者提到您想要挂钩到TCP / IP堆栈。 What I can suggest you: 我可以建议你:

  1. Consider packing whatever you like into UDP packet. 考虑将您喜欢的内容打包到UDP数据包中。 I am not sure, how easy is to initiate routing of "unpacked" TCP packages on remote side. 我不确定,在远程端启动“解压缩”TCP包的路由是多么容易。
  2. Consider using PPTP or similar tunnelling protocol. 考虑使用PPTP或类似的隧道协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM