问题
While transmiting data via localhost address or 127.0.0.1 which layers are used in the OSI model?
I believe communication starts through application layer and goes down till some layer but no data goes through physical layer, or does any?
回答1:
Traffic to 127.0.0.1 will be looped back by the internet layer of the TCP/IP model, which is matched in the OSI model by the Network layer. This is the layer where routing and address resolution take place.
回答2:
I believe (although I'd be happy to be corrected) that data may actually go down as far as Layer 2 ("Datalink Layer").
There's no need to add any protocol headers or encoding to handle loopback interfaces, but never-the-less the operating system will normally treat the loopback interfaces as if they were real interfaces, each with their own packet counters, etc.
There's no reason at all why a loopback interface can't be used for non-IPv4 protocols - indeed many current systems automatically put an IPv6 address on the loopback interfaces.
In that sense a loopback interface is just a "null" Layer 2 device.
来源:https://stackoverflow.com/questions/415832/during-transmissions-over-localhost-which-layers-are-used-in-osi-model