Skip to content

Multicast packets (mDNS) are not sent out of VM

Host environment

  • Operating system: macOS BigSur 11.6
  • OS/kernel version: Darwin MBP-Anton-4.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
  • Architecture: x86_64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: QEMU emulator version 6.0.0
  • QEMU command line:
    qemu-system-x86_64 -m 512 -nic user -hda asvm-x86_64-hd.qcow2 -device vmxnet3,netdev=net0 -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::50051-:50051,hostfwd=tcp::50050-:50050 --nographic -monitor tcp::5555,telnet,server,nowait

Emulated/Virtualized environment

  • Operating system: Alpine Linux 3.14
  • OS/kernel version: Linux asvm-x86-64 5.10.78-0-virt #1-Alpine SMP Thu, 11 Nov 2021 14:31:09 +0000 x86_64 Linux
  • Architecture: x86_64

Description of problem

The app is sending multicast packets (mDNS), but they are not sent out of VM. Here is the configuration of the network: -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::50051-:50051,hostfwd=tcp::50050-:50050

Steps to reproduce

  1. Install arduino-cli from https://github.com/arduino/arduino-cli/releases (eg. 0.20.2)
  2. arduino-cli config init
  3. vi ~/.arduino15/arduino-cli.yaml
  4. edit it to have it as follows:
board_manager:
  additional_urls: ["http://arduino.esp8266.com/stable/package_esp8266com_index.json"]
daemon:
  port: "50051"
directories:
  data: /root/app/data
  downloads: /root/app/downloads
  user: /root/app/user
library:
  enable_unsafe_install: false
logging:
  file: ""
  format: text
  level: info
metrics:
  addr: :9090
  enabled: false
output:
  no_color: false
sketch:
  always_export_binaries: false
updater:
  enable_notification: true
  1. arduino-cli core update-index
  2. arduino-cli core install esp8266:esp8266
  3. arduino-cli board list -v

This will give an output similar to:

INFO[0000] Using config file: /root/.arduino15/arduino-cli.yaml 
INFO[0000] arduino-cli.x86_64 version git-snapshot      
INFO[0000] Checking if CLI is Bundled into the IDE      
INFO[0000] Adding libraries dir                          dir=/root/app/user/libraries location=user
INFO[0000] Checking signature                            index=/root/app/data/package_index.json signatureFile=/root/app/data/package_index.json.sig =
INFO[0000] Checking signature                            error="opening signature file: open /root/app/data/package_esp8266com_index.json.sig: no such file or d=
INFO[0000] Loading hardware from: /root/app/data/packages 
INFO[0000] Loading package builtin from: /root/app/data/packages/builtin 
INFO[0000] Checking existence of 'tools' path: /root/app/data/packages/builtin/tools 
INFO[0000] Loading tools from dir: /root/app/data/packages/builtin/tools 
INFO[0000] Loaded tool                                   tool="builtin:ctags@5.8-arduino11"
INFO[0000] Loaded tool                                   tool="builtin:mdns-discovery@1.0.2"
INFO[0000] Loaded tool                                   tool="builtin:serial-discovery@1.3.1"
INFO[0000] Loaded tool                                   tool="builtin:serial-monitor@0.9.1"
INFO[0000] Loading package esp8266 from: /root/app/data/packages/esp8266/hardware 
INFO[0000] Checking signature                            error="opening signature file: open /root/app/data/packages/esp8266/hardware/esp8266/3.0.2/installed.js=
INFO[0000] Adding monitor tool                           protocol=serial tool="builtin:serial-monitor"
INFO[0000] Loaded platform                               platform="esp8266:esp8266@3.0.2"
INFO[0000] Checking existence of 'tools' path: /root/app/data/packages/esp8266/tools 
INFO[0000] Loading tools from dir: /root/app/data/packages/esp8266/tools 
INFO[0000] Loaded tool                                   tool="esp8266:mklittlefs@3.0.4-gcc10.3-1757bed"
INFO[0000] Loaded tool                                   tool="esp8266:mkspiffs@3.0.4-gcc10.3-1757bed"
INFO[0000] Loaded tool                                   tool="esp8266:python3@3.7.2-post1"
INFO[0000] Loaded tool                                   tool="esp8266:xtensa-lx106-elf-gcc@3.0.4-gcc10.3-1757bed"
INFO[0000] Adding libraries dir                          dir=/root/app/data/packages/esp8266/hardware/esp8266/3.0.2/libraries location=platform
INFO[0007] Executing `arduino-cli board list`           
INFO[0007] starting discovery builtin:serial-discovery process 
INFO[0007] started discovery builtin:serial-discovery process 
INFO[0007] sending command HELLO 1 "arduino-cli git-snapshot" to discovery builtin:serial-discovery 
INFO[0007] starting discovery builtin:mdns-discovery process 
INFO[0007] started discovery builtin:mdns-discovery process 
INFO[0007] sending command HELLO 1 "arduino-cli git-snapshot" to discovery builtin:mdns-discovery 
INFO[0007] from discovery builtin:serial-discovery received message type: hello, message: OK, protocol version: 1 
INFO[0007] from discovery builtin:mdns-discovery received message type: hello, message: OK, protocol version: 1 
INFO[0007] sending command START to discovery builtin:serial-discovery 
INFO[0007] sending command START to discovery builtin:mdns-discovery 
INFO[0007] from discovery builtin:mdns-discovery received message type: start, message: OK 
INFO[0007] from discovery builtin:serial-discovery received message type: start, message: OK 
INFO[0008] sending command LIST to discovery builtin:serial-discovery 
INFO[0008] sending command LIST to discovery builtin:mdns-discovery 
INFO[0008] from discovery builtin:mdns-discovery received message type: list 
INFO[0008] from discovery builtin:serial-discovery received message type: list, ports: [/dev/ttyS0] 
INFO[0008] sending command STOP to discovery builtin:serial-discovery 
INFO[0008] sending command STOP to discovery builtin:mdns-discovery 
INFO[0008] from discovery builtin:mdns-discovery received message type: stop, message: OK 
INFO[0008] from discovery builtin:serial-discovery received message type: stop, message: OK 
Port       Protocol Type    Board Name FQBN Core
/dev/ttyS0 serial   Unknown                

Note builtin:mdns-discovery discovery started. It is expected to send the packets as follows (the screenshot from the host with Wireshark):

Снимок_экрана_2022-01-11_в_22.49.58

The screenshot is taken if running the same app (but for macOS) from the host and i can't see the packets sent if executed from the QEMU guest os. I believe i either configured it the wrong way (-netdev user,id=net0,...) or it's a QEMU bug.

Additional information

I've tested on macOS host with qemu 6.0.0 and on Linux (Android) host with qemu 6.1.0 and both were not working.

the network interface seems to be configured for multicasting:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:57  
          inet addr:10.0.2.15  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fec0::5054:ff:fe12:3457/64 Scope:Site
          inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:91955 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25203 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:119904373 (114.3 MiB)  TX bytes:1868274 (1.7 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

It might be easier to skip using arduino-cli and just use any mdns discovery app.

Edited by Anton Smirnov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information