自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
測試多部裝置的連線情形
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
背景
如要執行多個 Cuttlefish 虛擬裝置,請執行下列指令:
launch_cvd --num_instances=n
使用 --num_instances
標記執行兩個以上的執行個體時,執行個體會共用 Wi-Fi 和藍牙的連線媒介。這項設定可讓 Cuttlefish 例項透過藍牙和 Wi-Fi 相互偵測及連線,無須額外採取任何動作。
不過,如果您使用 --base_instance_num
旗標和多個 launch_cvd
叫用來執行多個執行個體,就必須指定 wmediumd
的 vhost 伺服器路徑,以便共用 Wi-Fi 媒介,並防止為 AP 啟動多個 VM 執行個體。
多裝置啟動範例
以下命令說明如何啟動兩個共用 Wi-Fi 介面的 Cuttlefish 例項,並使用 launch_cvd
的逐一執行功能。
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
藍牙
rootcanal 支援 Cuttlefish 藍牙實作,可透過網頁版 UI 指令列控制台進行控制。
在控制台中,您可以使用多個指令控制訪客裝置上的藍牙:
指令 |
說明 |
list |
列出目前的裝置和物理裝置 |
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 |
刪除 `device from phy |
add_remote HOSTNAME PORT PHY_TYPE |
將遠端 Rootcanal 新增為裝置,並將其註冊至 phy |
裝置類型和 args |
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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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 |"]]