How UDP checksum get IP address to make pseudo header in transport layer

ipv4layer3layer4tcpudp

We know that UDP checksum's pseudo header contains the most important parts of the IP header, that is, source and destination address, protocol number and data length.

I hope that the concept of IP addresses is present in the network layer and the transport layer is above it, so how does the transport layer know the IP address at the sending side because at the sender side, first the transport layer header is first encapsulated around the data coming from application layer and then the IP header is attached. I mean, how does the transport layer get to know the IP address when this facility is present at the bottom layer (Network layer) to make pseudo header ?

Best Answer

These layers are just abstract concepts. They don't actively do anything by their own. Instead such models are a tool to deal with complexity, get a common understanding of the functionality and to structure the code in a way which can also be understood and managed by others.

This means there is no "transport layer know ...". There is instead a specific implementation (usually in the OS) dealing with all the different layers and which can also easily exchange information between these layers, like the IP address.