How do auxiliary data work in sendmsg ()?

sendmsg () allows you to send auxiliary data to another socket, I wonder how it works.

1) Does it contain supporting data along with a regular message?

2) If so, how can the remote receive socket parse this?

3) How can a remote recipient receive this auxiliary data?

Thanks.

+4
source share
2 answers

Auxiliary data is not sent to the wire - NEVER. For Unix Domain sockets, additional data is used to send or receive file descriptors between processes for sharing or task balancing. Note. Unix domain sockets transfer information between processes running on the same computer, and not between processes running on different machines.

Again, in the case of processes running on different machines: your package without using any auxiliary concept will be exactly the same as the package when the auxiliary concept is applied to the sending machine (or the receiving machine). Therefore, supporting data is not part of your package.

Auxiliary data is used to receive services / information related to the EXTRA package from the kernel to a user space application that is otherwise inaccessible. For example, let's say machine B receives some packet on the wire, and you want to know the incoming interface from which the packet was received? How do you know that? Supporting data comes to the rescue.

The auxiliary data is the flags set in the auxiliary control buffer and is passed to the kernel when sendmsg () / recvmsg () is called, which tells the kernel that when a packet is being sent or received, what additional services / information should be provided to the calling application .

Ancillary data is a means of communication between the kernel and user space. Or between processes on the same machine in the case of UNIX sockets. This is not something that has a package on the wiring.

For reference, download the sample code here , which works fine on my ubuntu machine. The concept of supporting data is shown in src/igmp_pkt_reciever.c .

+3
source

You can use auxiliary data in only a few ways:

  • You can use it to get receive interface (IPv4)
  • You can use it to specify a transition limit (for IPv6)
  • You can use it to indicate the class of traffic (again, IPv6)
  • ....
  • You can use it to send / receive file descriptors or user credentials (Unix domain)

Three cases are only artificial API methods for obtaining control information from the kernel land via recvmsg(2) . The last most interesting thing: the only case where the actual data is actually sent is Unix sockets, where everything happens in the kernel, so nothing happens on the wire.

+2
source

All Articles