When a browser wants to access a Web server, it uses the address and port of the Web server to make a request to the operating system.
This request takes the form of an Application Program Interface (API).
In a TCP/IP network, the API call for a Web page from a Web server causes the operating system to generate an HTTP request.
HTTP does not operate in the lower layers of the network model.
Instead, it hands data over to TCP, which resides in the Transport layer.
API packages the data using HTTP format, which will include a HTTP header.
HTTP delivers the package to TCP, giving the destination IP address and port.
TCP hands data off to IP.
IP breaks data into individual packets, adds its own IP header, and passes packet off to the hardware.
When data leaves the host to go onto the network, it can have a header for each of the seven OSI layers and will have a trailer for the Data Link layer put there by the firmware on the network card.
When data reaches its destination, each layer removes its corresponding header and trailer and passes data up to the next layer above it.
IP reassembles packets at the destination.
IP passes one data and header stream to the TCP layer, which removes its header information and sends an acknowledgment back to the TCP layer on the client.
HTTP server receives the data, removes the header, decompresses and decrypts, and passes data on to the web server.