Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When doing IPC using TCP/IP sockets using the loopback address, do common networking stacks skip framing the message in lower-level PDUs?

In some environments such as Java, it's natural to use TCP/IP sockets to pass messages between processes on the same host using the 'localhost' address (127.0.0.1 in IPv4, or ::1 in IPv6). (Because Java tends not to expose other IPC mechanisms in its API).

Clearly, this has the potential to be a lot slower than IPC via message passing over pipes, or IPC using shared-memory.

On the other hand, if the TCP/IP networking stack realised that both ends of the connection were on the loopback interface, it might be able to do a fair bit of optimisation so that the efficiency might not differ much from using pipes.

But do common operating systems (Windows, Linux) implement such optimisations in their TCP/IP stacks?

like image 646
David Bullock Avatar asked Apr 04 '11 10:04

David Bullock


People also ask

What is the purpose of loopback IP address also identify the loopback address?

The IP address 127.0. 0.1 is called a loopback address. Packets sent to this address never reach the network but are looped through the network interface card only. This can be used for diagnostic purposes to verify that the internal path through the TCP/IP protocols is working.

Does loopback use TCP?

In TCP/IP networking, Loopback Address is the special IP address 127.0. 0.1. The loopback address is used to route outgoing IP packets to the TCP/IP protocol stack bound to the network interface card (NIC) and back to the source application without actually placing the packets on the network.

What is a commonly used loopback address?

The most commonly used IP address on the loopback network is 127.0. 0.1 for IPv4 and ::1 for IPv6. The standard domain name for the address is localhost.

What subnet mask should you use in loopback addresses?

You do not need to specify a network mask. A loopback interface uses the default subnet mask 255.255. 255.255.


2 Answers

Yes. When a packet/data to a Loopback address(127.x.x.x) is received, the IP layer of the TCP/IP uses the Loopback route to route the packet to itself.

Looback Route

Network Destination || Netmask || Gateway || Interface || Metric

127.0.0.0 |||||||||||||||||||||| 255.0.0.0 || 127.0.0.1|| 127.0.0.1 || 1

After routing it to itsef, at TCP/UDP layer with the help of protocol control blocks(per connection data structure) the corresponding socket and its owner process will be identified to deliver the packet/data.

Bottom line, All the tasks at Data Link layers and Physical layers(of OSI Model) will be avoided.

like image 103
Mani Avatar answered Nov 13 '22 04:11

Mani


Depends upon the OS, and the configuration being used. The answer is yes if you are asking for default behavior.

This is the reason why you are not able to use tools like wireshark to sniff local loopback scenarios.

like image 26
user210504 Avatar answered Nov 13 '22 02:11

user210504