Why does TCP need a destination IP address to perf

2019-09-02 18:17发布

问题:

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?

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?

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?

回答1:

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.

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.

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.

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.



回答2:

There may be multiple processes listening at the same port, all bound to different local IP addresses. The destination address is needed to disambiguate that situation.



标签: tcp