TCP 连接持续状态
是否有任何字段/选项/任何我可以放入 TCP 数据包中的内容(无论是 syn 还是 ack 或者只是普通数据),我可以确定另一端会完好无损地返回?
例如。我想用一个数字“标记”一个特定的连接(src、srcport、dst、dstport),我总是可以从属于该连接的数据包中读取该数字。这意味着我可以在不使用 4 元组的情况下识别连接(如上所述)。
Is there any field/option/anything that I can put in a TCP packet (be it a syn or an ack or just plain data) that I can be sure will be returned by the other end intact?
For eg. I want to "tag" a particular connection (src, srcport, dst, dstport) with a number that I can always read from a packet belonging to that connection. That means I can identify the connection without using the 4-tuple (as given above).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的:它被称为封装在TCP服务器协议中的客户端协议。
换句话说:定义客户端协议来满足您的需求。不要试图在 TCP 开销中“塞入”额外的位。
TCP 中当然有“选项”开销,但我怀疑您会找到一个简单的方法访问这些的方法...无论如何,您不应该这样做。
Yes: it is called a Client protocol encapsulated in the TCP server protocol.
In other words: define the Client protocol to meet your needs. Don't try to "shove" extra bits in the TCP overhead.
There are of course the 'options' overhead in TCP but I doubt you'll find an easy way to access these... and in any case, you shouldn't.
您可能会为此滥用 TCP 时间戳选项。不过,这似乎不是一个好主意。
You could possibly abuse the TCP Timestamp option for this. It does not seem like a great idea, though.
您可以在应用程序中使用一个查找表,将标签与套接字关联起来。
You can have a lookup table in your application where you associate your tag with the socket.
不,没有任何设施可以满足您所描述的情况。
通常,如果您正在编写与其他系统有多个连接的套接字应用程序,那么您要做的就是跟踪属于每个远程系统的套接字句柄。接收数据时,您正在使用套接字句柄(以某种形式,不知道您正在使用哪种操作系统或语言),因此您可以根据哪个套接字句柄采取适当的操作。
我从未见过基于地址/端口四元组来跟踪连接的服务器应用程序。这看起来工作量太大了。
重读您的问题时,您似乎是从 TCP 驱动程序级别的角度提出这个问题的。你在这里写什么类型的软件?
No, there isn't any facility for what you describe.
Typically what you would do if you're writing a socket application with multiple connections to other systems, is keep track of the socket handle that belongs to each remote system. When receiving data, you are using the socket handle (in some form, don't know which OS or language you're using) so you can take appropriate action based on whichever socket handle that is.
I've never seen a server application that keeps track of connections based on the 4-tuple of address/ports. That seems like way too much work.
On rereading your question, it seems like you may be asking this from the point of view of the TCP driver level. What sort of software are you writing here?
在 UDP 中,目标 IP 和目标端口号用于解复用数据包,但在 TCP 中,目标 IP、源 IP、目标端口号和源端口号(4 元组)都需要用于区分连接,这是为什么要使用这种用法的原因。
In UDP, destination IP and destination port number are used to demultiplex the packets, but in TCP destination IP, source IP, destination port number and source port numbers (4-tuple) all needed to distinguish between the connections why reasoning for this usage.