If the TCP segment does not contain the destination IP in its header, how does the(first) network layer decide the first link to traverse, to get closer to the destination IP.

I have learnt that the network layer prepares a header that has the source and destination IP, adds it to the TCP segment to make the IP packet.

The application layer which decides to send a message, should provide the destination IP. It doesn't make sense for the application layer to delegate this to the network layer which doesn't care about the end to end communication but does routing and forwarding alone. We resolve the host name to IP address using DNS, but how is this "IP address" information passed down to the lower Network layer without the TCP segment having mention this explicitly in its header.

I hope the Operating System, providing a socket as an abstraction to end to end communication does this. I have seen a socket getting created with parameters as follows,

Socket socket = new socket("destination IP: port", "transport protocol")

Is it true that the application/transport/end to end layer drops the message into this socket and the Network layer obtains the "destination IP" information from this socket? I hope it goes as follows,

1> Resolve host name to IP address using a default DNS entry (to solve the "chicken egg" problem)

2> Create a socket with the IP address so obtained and some suitable transport protocol as parameters

3> Use this socket for further communication with the remote system

I'm missing a lot of details as I'm new to socket programming and networks. Help me understand this process. Will be glad if someone can cite a detailed material that gives a complete walk-through of this process.

  • $\begingroup$ Google for "sockets tutorial" and you'll find plenty of help, both conceptual and programming language specific. $\endgroup$
    – Kyle Jones
    Oct 3, 2016 at 6:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.