Home > OS >  Why destination IP is included in the TCP socket identifier?
Why destination IP is included in the TCP socket identifier?

Time:10-13

We know that TCP sockets can be identified by origin IP, origin PORT, destination IP, and destination PORT.

  • The origin IP is required to distinguish between requests from different clients
  • The origin PORT is required to distinguish between requests from different processes of one client
  • Destination PORT is required to distinguish which processes receive requests from a server.

However, destination IP seems to be only needed up to the network layer, so I wonder why it is included in the TCP socket identifier.

CodePudding user response:

Given that: "The client is the one who sends the request to the server and makes the connection through a socket at first."

The destination IP should be specified to distinguish which server this request is for. So, the request will be routed through the network to arrive at the server.

CodePudding user response:

A given server machine could be running multiple server sockets, potentially bound to different networks. So, once the network delivers a packet to the server machine, the OS's socket stack would still need to know the source IP/Port and destination IP/Port to deliver the packet to the correct socket buffer.

  • Related