Question : Encapsulation/ network layer question

Having a brain fart:

Say I am in the middle of a telnet session, and I type "a." Say "a" is one byte.

"a" gets encapsulated by the transport layer.  Once the transport layer encapsulates it, it becomes a segment. Just to re-state, it is so far at 21bytes (20 byte tcp header plus 1 byte data). The tcp header includes source and destination port number, options etc..

the transport layer passes down the "segment" to the network layer.

The network layer enapsulates the segment with it's own header (source IP and dest IP etc)

My question:
But how does the network layer know what destination IP to send it to? Where does it get this information from? I know it can pull my source address from the registry. But I'm confused as to how my machine, when building a packet, knows the proper dest IP and how it gets it.  Does the application layer tell it somehow?

Thanks

Answer : Encapsulation/ network layer question

The IP address is passed by an API from the application to the network layer.

http://www.tcpipguide.com/free/t_UnderstandingTheOSIReferenceModelAnAnalogy.htm
Here is a page that explains it a little bit. (ignore the snail mail analogy)



Random Solutions  
 
programming4us programming4us