Life of a Packet
sendto (UDP)

- The application calls
sendto socket API in FDIO. - Libfdio calls
sendmsg in zxio, which calls a machine-generated FIDL proxy code. - The FIDL proxy code calls
channel_call with a fuchsia.posix.socket/DatagramSocket.SendMsg FIDL request on a zircon channel. - Go FIDL stub code (machine-generated) receives the FIDL request from a zircon channel.
- Go FIDL stub dispatches
SendMsg API in netstack. - Netstack calls
SendMsg code in gVisor TCP/IP. - IP layer in gVisor TCP/IP calls
Eth Link Endpoint in netstack.- 8a.
Eth Link Endpoint puts a packet into FIFO. - 9a. Ethernet driver gets the packet from FIFO, and transmits it into the wire.
- The control returns to gVisor.
- The return values (or an error) return from gVisor.
- The control returns to Go FIDL stub.
- Go FIDL stub replies to
channel_call. - FIDL proxy code receives the reply.
- Returns to
sendto. - The application receives the return values (or the error).
recvfrom (UDP)

- The application calls
recvfrom socket API in FDIO. - FDIO calls
recvmsg in zxio, which calls a machine-generated FIDL proxy code. - The FIDL proxy code calls
channel_call with a fuchsia.posix.socket/DatagramSocket.RecvMsg FIDL request on a zircon channel. - Go FIDL stub code (machine-generated) receives the FIDL request from a zircon channel.
- Go FIDL stub dispatches
RecvMsg API in netstack. - Netstack calls
RecvMsg code in gVisor. - gVisor returns
tcpip.ErrWouldBlock as there is no data is available in the UDP layer. - Returns to Go FIDL stub.
- Go FIDL stub replies to
channel_call. - FIDL proxy code receives the reply.
- Returns to
recvfrom. recvfrom calls fidl_wait to wait for an incoming data event, which is signaled through a zircon eventpair shared between FDIO and netstack.

- Ethernet driver receives a packet, and puts it into FIFO.
Eth Link Endpoint receives the packet from FIFO.Eth Link Endpoint sends the packet to gVisor's IP layer. gVisor delivers the packet to its UDP layer and stores it in the queue for the destination port.- gVisor executes a callback preset by netstack, which signals incoming-data-available event on the eventpair.
recvfrom returns from fidl_wait as the event is signaled.

- FDIO calls the FIDL proxy code again.
- The FIDL proxy code calls
channel_call. - Go FIDL stub code receives a
RecvMsg request. - Go FIDL stub dispatches
RecvMsg API. RecvMsg calls gVisor.- The data in the packet and the return values (or an error) return from gVisor.
- Returns to Go FIDL stub.
- Go FIDL stub replies to
channel_call. - FIDL proxy code receives the reply.
- Returns to
recvfrom. - The application receives the return values (or the error).