为什么TCP需要一个目的IP地址来进行解复用? [英] Why does TCP need a destination IP address to perform demultiplexing?

查看:33
本文介绍了为什么TCP需要一个目的IP地址来进行解复用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据一些书籍,TCP 使用 4 个元组(src ip, src port , dest ip, dest port)来执行复用/解复用,但我不明白为什么 TCP 需要 dst IP执行解复用的地址?

According to some books, TCP uses 4 tuples (src ip, src port , dest ip, dest port) to perform the multiplexing/demultiplexing but I don't understand why TCP needs the dst IP address to perform the demultiplex?

我可以理解解复用需要src IP和端口,因为它需要识别客户端应用程序,而dest端口用于识别目标应用程序.但是 dst IP 有什么用?

I can understand that the demultiplexing will need the src IP and port, as it need to identify the client application, and the dest port is for the identification of destination application. But what is the dst IP for?

我认为底层的 IP 层已经进行了一种基于 IP 的解复用",提交给 TCP 的每个 IP 数据包都是属于这个主机的,为什么我们还需要目标 IP 地址?

I think the underlying IP layer already performed kind of "demultiplexing" based on IP and each IP packet submitted to TCP is the ones which belongs to this host so why do we still need destination IP address?

推荐答案

从技术上讲,它是网络级别的 5 元组:协议、src ip、src 端口、dst ip、dst 端口.但是由于您的问题仅限于 TCP,因此只有最后 4 个是可变的.

Technically, it's a 5-tuple at the network level: protocol, src ip, src port, dst ip, dst port. But since you're limiting your question to TCP, only the last 4 are variable.

在源机器上出于显而易见的原因需要目标 ip/port,因为它定义了数据包的去向.您可以关闭一个 TCP 连接并从同一本地端口打开一个新的出站连接,但到达不同的目的地,因此能够区分它们很重要.

The destination ip/port is needed for obvious reasons on the source machine because that defines where the packets are to go. You could close one TCP connection and open a new outbound one from the same local port but to a different destination so it's important to be able to differentiate them.

至于目标机器,请记住它可以有多个网络接口.即使端口空间"可能相同,每个接口的 IP 地址也不同.到一个接口的连接与到另一个接口的连接不同,即使它们访问相同的端口.

As for the destination machine, remember that it can have multiple network interfaces. The IP address of each interface is different even though the "port space" is likely the same. A connection to one interface is distinct from a connection to another interface even if they access the same port.

从 TCP 的有状态会话的角度来看,存在一些冗余.您可能可以从元组中省略目标 IP 并仍然唯一地标识已建立的会话.但是,元组用于网络层的路由,不能保证其他协议不需要添加的消歧.

From a TCP point-of-view with it's stateful sessions, there is some redundancy. You could probably omit the destination IP from the tuple and still uniquely identify the established session. The tuple, though, is used for routing at the network layer and there is no guarantee that other protocols will not need the added disambiguation.

这篇关于为什么TCP需要一个目的IP地址来进行解复用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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