First off, even though we learn the OSI model as a basis for understanding the layered approach, most of the actual technologies developed by OSI aren't implemented. Hence, it is more appropriate to use TCP/IP model as this is what the industry actually uses. That said I understand your intent.On a PC when you ping your Loopback the NIC is involved down to the NDIS(network driver interface specification), which is the driver software for the NIC and resides between Internet/Data Link layer. This driver is responsible for allowing multiple protocol stacks i.e. IPX/SPX, TCP/IP to coexist. So the ping doesn't actually get framed and sent out on the wire. It simply "polls" the appropriate stack driver to see if it is configured and able to respond to requests.On a router if you ping your loopback address the ping does go out on the wire to the next hop and then returns to you. So in this case all Layers are involved.
Here is a link to HP that discusses two loopback tests...1. Which is the normal Network level loopback "ping 127.0.0.1" will test your TCP/IP stack and thus layers 4 down..2. Transport level loopback using internet services such as a browser, FTP or telnet etc. and this is how you will test the application layer!http://docs.hp.com/en/B2355-90748/ch04s05.htmlNOTE: They actually list a network loopback test as validating layers 1-3! This is true with the exception that you have verified the TCP stack as well which in my mind justifies layer 4 but technically I guess you have to establish a TCP connection to validate that 4 is up and thus need to perform the transport loopback test! The diagram is somewhat confusing so just read through the info! Good troubleshooting information here!