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

…衆ロ難τιáo~ 提交于 2019-12-02 23:25:05

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.

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.

Specifically in linux when packets are transmitted on the loopback interface the kernel raises a "software" interrupt for each packet. From that point on the packet reception is identical to the packet reception flow for a physical device. So you are correct in your assumption that communication over the loopback interface would be much slower than alternate IPC mechanisms such as unix sockets.

I guess the kernel code path can be optimized. For e.g., we could call the receive code path directly from the transmit code path of loopback interface.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!