自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
测试多台设备的连接
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
背景
只需执行以下命令,即可运行多台 Cuttlefish 虚拟设备:
launch_cvd --num_instances=n
使用 --num_instances
标志运行两个或更多实例时,实例会共享 Wi-Fi 和蓝牙的连接媒介。此设置可让 Cuttlefish 实例通过蓝牙和 Wi-Fi 发现彼此并互相连接,而无需执行任何其他操作。
但是,如果您使用 --base_instance_num
标志和多个 launch_cvd
调用执行多个实例,则需要指定 wmediumd
的 vhost 服务器路径以共享 Wi-Fi 媒介,并且还需要防止针对 AP 启动多个虚拟机实例。
多设备启动示例
以下命令展示了如何使用 launch_cvd
的串行执行启动两个共享 Wi-Fi 媒介的 Cuttlefish 实例。
launch_cvd
launch_cvd --base_instance_num=2 \
--vhost_user_mac80211_hwsim=$HOME/cuttlefish_runtime.1/internal/vhost_user_mac80211 \
--ap_kernel_image="" --ap_rootfs_image="" #Prevent launching multiple VM instances for AP
蓝牙
Cuttlefish 蓝牙实现由 rootcanal 支持,可通过网页界面命令行控制台进行控制。
在控制台中,可通过几个命令控制访客设备上的蓝牙:
命令 |
说明 |
list |
列出当前设备和 PHY |
add DEVICE_TYPE [ARGS] |
创建类型为 DEVICE_TYPE 的新设备 |
del DEVICE_INDEX |
删除设备 |
add_phy PHY_TYPE |
添加类型为 PHY_TYPE 的新 PHY |
del_phy PHY_INDEX |
删除 PHY |
add_device_to_phy DEVICE_INDEX PHY_INDEX |
向 PHY 添加设备 |
del_device_from_phy DEVICE_INDEX PHY_INDEX |
从 PHY 删除设备 |
add_remote HOSTNAME PORT PHY_TYPE |
添加远程 Rootcanal 作为设备并将其注册到 PHY |
设备类型和参数 |
beacon [MAC_ADDRESS] [ADVERTISE_INTERVAL] |
scripted_beacon [MAC_ADDRESS] [CONFIG_PATH] [EVENTS_PATH] |
keyboard [MAC_ADDRESS] [ADVERTISE_INTERVAL] |
loopback [MAC_ADDRESS] [ADVERTISE_INTERVAL] |
sniffer |
Wi-Fi
wmediumd_control
wmediumd_control
是一种命令行工具,用于控制 Wi-Fi 连接媒介。该工具包含用于操控 Wi-Fi 的以下命令:
命令 |
说明 |
set_snr MAC_ADDR1
MAC_ADDR2
SNR_VALUE |
设置两个站点之间的 SNR 值 (0~255)
|
start_pcap PCAP_FILE_PATH
|
开始捕获所有无线传输的帧并将其存储到 .pcap 文件 |
stop_pcap
|
停止并最终确定当前数据包捕获 |
list_stations
|
列出附加到 wmediumd 的所有站点 |
reload_config
[CONFIG_FILE_PATH]
|
使用 CONFIG_FILE_PATH 重新加载 wmediumd 配置;如果省略了 CONFIG_FILE_PATH,则重新加载当前已加载的配置文件 |
set_position MAC_ADDR
X_POSITION
Y_POSITION |
设置站点在二维空间中的位置
|
OpenWRT
如果您想连接到 OpenWRT(接入点),可以使用 ssh
或管理员网页。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Test connectivity of multiple devices\n\nBackground\n----------\n\nRunning multiple Cuttlefish virtual devices can be done by executing the\nfollowing command: \n\n```\nlaunch_cvd --num_instances=n\n```\n\nWhen you are running two or more instances using `--num_instances` flag,\ninstances share the connectivity medium for Wi-Fi and Bluetooth. This setting\nallows the Cuttlefish instances to discover and connect to each other via\nBluetooth and Wi-Fi without additional action.\n\nHowever, if you are executing multiple instances by using the\n`--base_instance_num` flag and multiple `launch_cvd` invocations, you need\nto specify `wmediumd`'s vhost server path to share Wi-Fi medium, and also\nprevent launching multiple VM instances for AP.\n\nMulti-device launch example\n---------------------------\n\nThe following commands show how to launch two Cuttlefish instances that share\nthe Wi-Fi medium using serial execution of `launch_cvd`. \n\n```\nlaunch_cvd\n``` \n\n```\nlaunch_cvd --base_instance_num=2 \\\n --vhost_user_mac80211_hwsim=$HOME/cuttlefish_runtime.1/internal/vhost_user_mac80211 \\\n --ap_kernel_image=\"\" --ap_rootfs_image=\"\" #Prevent launching multiple VM instances for AP\n```\n\nBluetooth\n---------\n\nThe Cuttlefish bluetooth implementation is supported by rootcanal and can be\ncontrolled with the Web UI command line console.\n\nIn the console, there are several commands that allow for the control of\nbluetooth on the guest device:\n\n| Command | Description |\n|--------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|\n| `list` | List current devices and phys |\n| `add` \u003cvar translate=\"no\"\u003eDEVICE_TYPE\u003c/var\u003e \u003cvar translate=\"no\"\u003e[ARGS]\u003c/var\u003e | Create new device of type \u003cvar translate=\"no\"\u003eDEVICE_TYPE\u003c/var\u003e |\n| `del` \u003cvar translate=\"no\"\u003eDEVICE_INDEX\u003c/var\u003e | Delete a device |\n| `add_phy` \u003cvar translate=\"no\"\u003ePHY_TYPE\u003c/var\u003e | Add new phy with \u003cvar translate=\"no\"\u003ePHY_TYPE\u003c/var\u003e |\n| `del_phy` \u003cvar translate=\"no\"\u003ePHY_INDEX\u003c/var\u003e | Delete a phy |\n| `add_device_to_phy` \u003cvar translate=\"no\"\u003eDEVICE_INDEX\u003c/var\u003e \u003cvar translate=\"no\"\u003ePHY_INDEX\u003c/var\u003e | Add a device to phy |\n| `del_device_from_phy` \u003cvar translate=\"no\"\u003eDEVICE_INDEX\u003c/var\u003e \u003cvar translate=\"no\"\u003ePHY_INDEX\u003c/var\u003e | Delete a \\`device from phy |\n| `add_remote` \u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e \u003cvar translate=\"no\"\u003ePORT PHY_TYPE\u003c/var\u003e | Add a remote Rootcanal as device and register it to phy |\n\n| Device type and args |\n|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `beacon` \u003cvar translate=\"no\"\u003e[MAC_ADDRESS]\u003c/var\u003e \u003cvar translate=\"no\"\u003e[ADVERTISE_INTERVAL]\u003c/var\u003e |\n| `scripted_beacon` \u003cvar translate=\"no\"\u003e[MAC_ADDRESS]\u003c/var\u003e \u003cvar translate=\"no\"\u003e[CONFIG_PATH]\u003c/var\u003e \u003cvar translate=\"no\"\u003e[EVENTS_PATH]\u003c/var\u003e |\n| `keyboard` \u003cvar translate=\"no\"\u003e[MAC_ADDRESS]\u003c/var\u003e \u003cvar translate=\"no\"\u003e[ADVERTISE_INTERVAL]\u003c/var\u003e |\n| `loopback` \u003cvar translate=\"no\"\u003e[MAC_ADDRESS]\u003c/var\u003e \u003cvar translate=\"no\"\u003e[ADVERTISE_INTERVAL]\u003c/var\u003e |\n| `sniffer` |\n\nWi-Fi\n-----\n\n### wmediumd_control\n\n`wmediumd_control` is a command-line tool that controls Wi-Fi connectivity\nmedium. The tool has the following commands to manipulate Wi-Fi:\n\n| Command | Description |\n|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `set_snr` \u003cvar translate=\"no\"\u003eMAC_ADDR1\u003c/var\u003e \u003cvar translate=\"no\"\u003eMAC_ADDR2\u003c/var\u003e \u003cvar translate=\"no\"\u003eSNR_VALUE\u003c/var\u003e | Set SNR value (0\\~255) between two stations |\n| `start_pcap` \u003cvar translate=\"no\"\u003ePCAP_FILE_PATH\u003c/var\u003e | Start capturing all frames transmitted to air and stores it to .pcap file |\n| `stop_pcap` | Stop and finalize current packet capture |\n| `list_stations` | List all stations attached to wmediumd |\n| `reload_config` \u003cvar translate=\"no\"\u003e[CONFIG_FILE_PATH]\u003c/var\u003e | Reload wmediumd configuration with \u003cvar translate=\"no\"\u003eCONFIG_FILE_PATH\u003c/var\u003e, if \u003cvar translate=\"no\"\u003eCONFIG_FILE_PATH\u003c/var\u003e is omitted, reload currently loaded config file |\n| `set_position` \u003cvar translate=\"no\"\u003eMAC_ADDR\u003c/var\u003e \u003cvar translate=\"no\"\u003eX_POSITION\u003c/var\u003e \u003cvar translate=\"no\"\u003eY_POSITION\u003c/var\u003e | Set position of the station in two-dimensional space |\n\n### OpenWRT\n\nIf you want to connect to OpenWRT (Access Point), you can use either `ssh` or\nthe admin webpage.\n\n| Connection Type | Method |\n|-----------------|-------------------------------|\n| ssh | ``` ssh root@192.168.96.2 ``` |\n| Admin webpage | \u003chttps://192.168.96.2\u003e |"]]