在 GitHub 上查看源代碼 |
OpenWeave 包括一組用於配置、管理和測試 OpenWeave 部署的命令行工具。
構建編織工具
該weave-tools
目標機器的選擇編織的命令行工具,用於分發的tar歸檔。它包括以下工具:
工具 | 描述 | 獨立建造位置 |
---|---|---|
gen-qr-code | 生成二維碼 | /src/tools/misc |
mock-device | 通用 Weave 設備模擬器 | /src/test-apps |
weave | 生成和管理 Weave 證書 | /src/tools/weave |
weave-device-descriptor | 編碼和解碼用於配對二維碼的 Weave 設備描述符字符串 | /src/test-apps |
weave-device-mgr | 管理設備配對過程 | /src/device-manager/python |
weave-heartbeat | 發送和接收心跳的個人資料信息 | /src/test-apps |
weave-key-export | 發送密鑰導出請求 | /src/test-apps |
weave-ping | 發送和接收迴聲輪廓消息 | /src/test-apps |
要構建目標:
- 安裝所有建立的先決條件。
- 配置OpenWeave不支持的BlueZ:
cd <path-to-openweave-core>
./configure --without-bluez
- Make the
weave-tools
target:make weave-tools
- Check the root
openweave-core
directory for the tar archive:ls weave*
weave-tools-x86_64-unknown-linux-gnu-4.0d.tar.gz
gen-qr-code
The gen-qr-code
tool requires the Python qrcode
module. Use pip
to install
it:
pip install --user qrcode
使用gen-qr-code
來生成裝置配對目的的QR碼。該工具的輸入必須位於本地文件中。例如,為了生成發送該用戶的QR碼https://www.google.com :
- 創建一個字符串的QR代碼的文件:
echo "https://www.google.com" >> ~/ow_qrcode
- Generate a 64x64 QR code of that string:
./gen-qr-code -v 1 -s 64 < ~/ow_qrcode
- To save the QR code as an image, specify an output file:
./gen-qr-code -v 1 -s 64 < ~/ow_qrcode > ~/ow_qrcode.png
Use theweave-device-descriptor
tool to generate the device descriptor string for use in a Weave device's pairing QR code.
mock-device
The mock-device
tool simulates a generic Weave node. Other tools and test case
scripts use this tool to encapsulate Weave functionality. Instantiate mock
devices on individual Happy nodes to test Weave functionality in a simulated
topology.
For example, to start a Weave mock device listening on an IPv6 address of
fd00:0:1:1::1
, first add that IPv6 address to the lo
(loopback) interface:
sudo ifconfig lo add fd00:0:1:1::1/64
然後啟動 Weave 模擬設備:
./mock-device -a fd00:0:1:1::1
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095
WEAVE:ML: Listening on IPv6 TCP endpoint
WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095
WEAVE:IN: IPV6_PKTINFO: 92
WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo)
WEAVE:ML: Listening on general purpose IPv6 UDP endpoint
WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo)
WEAVE:ML: Listening on IPv6 multicast receive endpoint
WEAVE:EM: Cannot listen for BLE connections, null BleLayer
Weave Node Configuration:
Fabric Id: 1
Subnet Number: 1
Node Id: 1
WEAVE:SD: init()
Weave Node Configuration:
Fabric Id: 1
Subnet Number: 1
Node Id: 1
Listening Addresses:
fd00:0:1:1::1 (ipv6)
Pairing Server: fd00:0:1:1::1
Mock Time Sync is disabled and not initialized
Mock System Time Offset initialized to: 3.213773 sec
Listening for requests...
Weave Node ready to service events; PID: 256904; PPID: 251571
使用--help
標誌,查看所有可用的配置選項。
編織設備描述符
的weave-device-descriptor
工具編碼或解碼的設備描述符字符串。這些字符串包含編碼到其 Weave 配對二維碼中的設備的識別信息。使用--help
與標誌encode
或decode
方案的更多信息。
./weave-device-descriptor encode --help
./weave-device-descriptor decode --help
編碼
例如,要使用以下標識信息對設備描述符字符串進行編碼,請使用適當的標誌和值:
場地 | 旗幟 | 價值 |
---|---|---|
供應商編號 | -V | 1 |
產品編號 | -p | 1 |
產品修訂號 | -r | 2 |
序列號 | -s | 18B4300000000004 |
生產日期 | -m | 2018/05/02 |
802.15.4 MAC 地址(線程、BLE) | -8 | 000D6F000DA80466 |
配對碼 | -P | AB713H |
./weave-device-descriptor encode -V 1 -p 1 -r 2 -s 18B4300000000004 -m 2018/05/02 \
-8 000D6F000DA80466 -w 5CF370800E77 -P AB713H
1V:1$P:1$R:2$D:180502$S:18B4300000000004$L:000D6F000DA80466$W:5CF370800E77$C:AB713H$
使用此輸出字符串與gen-qr-code
工具生成的QR碼。
解碼
使用decode
選項設備描述符串的元素進行解碼。要解碼的元素具有以下語法:
1 + <device-descriptor-element> + $
例如,為了在解碼W:5CF370800E77
設備描述符元素:
./weave-device-descriptor decode 1W:5CF370800E77$
Primary WiFi MAC: 5C:F3:70:80:0E:77
編織心跳
使用weave-heartbeat
發送和接收心跳 2編織節點之間的個人資料信息。 Heartbeat 提供了一種方法來向網絡中的其他節點指示一個節點的活躍度,或者檢查一個節點是否保持連接到結構。
一個成功的 Heartbeat 需要一個節點作為服務器(監聽和響應 Heartbeat)和一個節點作為客戶端(發送 Heartbeat)。
測試weave-heartbeat
使用環回接口來模擬兩個節點的工具:
- 添加到用於每個心跳節點到IPv6地址
lo
(回送)接口:sudo ifconfig lo add fd00:0:1:1::1/64
sudo ifconfig lo add fd00:0:1:1::2/64
Start the Heartbeat server on the
fd00:0:1:1::1
address and assign it anode-id
of 1:./weave-heartbeat --node-addr fd00:0:1:1::1 --node-id 1 --listen
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 1 Listening Addresses: fd00:0:1:1::1 (ipv6) Listening for Heartbeats... Weave Node ready to service events; PID: 170883; PPID: 170418Open a second terminal window and start the Heartbeat client on the
fd00:0:1:1::2
IPv6 address with anode-id
of 2 and the first node's IPv6 address as the destination for the Heartbeat:./weave-heartbeat --node-addr fd00:0:1:1::2 --node-id 2 --dest-addr fd00:0:1:1::1 1
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::2]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::2]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:EM: Binding0: Allocated Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 2 Listening Addresses: fd00:0:1:1::2 (ipv6) Sending Heartbeats via UDP to node 1 (fd00:0:1:1::1) every 1000 ms Weave Node ready to service events; PID: 170932; PPID: 170608 WEAVE:EM: Binding0: Configuring WEAVE:EM: Binding0: Preparing WEAVE:EM: Binding0: Ready, peer 1 ([fd00:0:1:1::1]:11095) via UDPAfter a successful connection, node 2 sends Heartbeats to node 1, and node 1 logs Heartbeats received from node 2:
Node 1 <code></code> WEAVE:EM: Msg rcvd 00000013:1 1 0000000000000002 0000 C993 0 MsgId:1380A259 WEAVE:EM: ec id: 1, AppState: 0xb8e89790 Heartbeat from node 2 (fd00:0:1:1::2): state=1, err=No Error ### Node 2 <code></code> WEAVE:EM: ec id: 1, AppState: 0x0 WEAVE:EM: Msg sent 00000013:1 1 0000000000000001 0000 C993 0 MsgId:1380A259 Heartbeat sent to node 1: state=1
使用模擬設備的心跳
weave-heartbeat
實例化一個mock-device
用於服務器和客戶端。相同的心跳的功能可以通過使用證明mock-device
代替第一的weave-heartbeat
心跳服務器:
./mock-device -a fd00:0:1:1::1
織平
使用weave-ping
來發送和接收迴聲 2編織節點之間的個人資料信息。 Echo 有效負載由請求節點提供的任意數據組成,預計會在響應中逐字回顯。 Echo 提供了一種測試網絡連接和延遲的方法。
一個成功的 Echo 需要一個節點作為服務器(監聽和響應 Echo 請求)和一個節點作為客戶端(發送 Echo 請求)。
測試weave-ping
使用環回接口來模擬兩個節點的工具:
- 添加到用於每個迴聲節點到IPv6地址
lo
(回送)接口:sudo ifconfig lo add fd00:0:1:1::1/64
sudo ifconfig lo add fd00:0:1:1::2/64
Start the Echo server on the
fd00:0:1:1::1
address, assigning it anode-id
of 1:./weave-ping --node-addr fd00:0:1:1::1 --node-id 1 --listen
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:SD: init() Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 1 Listening Addresses: fd00:0:1:1::1 (ipv6) Listening for Echo requests... Iteration 0 Weave Node ready to service events; PID: 120927; PPID: 113768 WEAVE:ECH: Listening...Open a second terminal window and start the Echo client on the
fd00:0:1:1::2
IPv6 address with anode-id
of 2 and the first node's IPv6 address as the destination for the Echo request:./weave-ping --node-addr fd00:0:1:1::2 --node-id 2 --dest-addr fd00:0:1:1::1 1
WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::2]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:SD: init() Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 2 Listening Addresses: fd00:0:1:1::2 (ipv6) Sending Echo requests to node 1 at fd00:0:1:1::1 Iteration 0 Weave Node ready to service events; PID: 121125; PPID: 121017 WEAVE:ML: Con start 9A00 0000000000000001 0001 WEAVE:ML: Con DNS complete 9A00 0 WEAVE:ML: TCP con start 9A00 fd00:0:1:1::1 11095 WEAVE:ML: TCP con complete 9A00 0 WEAVE:ML: Con complete 9A00 Connection established to node 1 (fd00:0:1:1::1)After a successful connection, node 1 logs Echo Requests from node 2, and node 2 logs Echo Responses from node 1:
Node 1 <code></code> WEAVE:ML: Con rcvd AA00 fd00:0:1:1::2 41675 Connection received from node 2 (fd00:0:1:1::2) WEAVE:EM: Msg rcvd 00000001:1 15 0000000000000002 AA00 B8A5 0 MsgId:00000000 WEAVE:EM: ec id: 1, AppState: 0xfce0ca80 Echo Request from node 2 (fd00:0:1:1::2): len=15 ... sending response. WEAVE:EM: Msg sent 00000001:2 15 0000000000000002 AA00 B8A5 0 MsgId:00000000 WEAVE:EM: Msg rcvd 00000001:1 15 0000000000000002 AA00 B8A6 0 MsgId:00000001 ### Node 2 <code></code> WEAVE:EM: ec id: 1, AppState: 0xd239baa0 WEAVE:EM: Msg sent 00000001:1 15 0000000000000001 9A00 B8A5 0 MsgId:00000000 WEAVE:EM: Msg rcvd 00000001:2 15 0000000000000001 9A00 B8A5 0 MsgId:00000000 Echo Response from node 1 (fd00:0:1:1::1): 1/1(100.00%) len=15 time=0.228ms
使用模擬設備迴聲
weave-ping
實例化一個mock-device
用於服務器和客戶端。相同的迴聲的功能可以通過使用證明mock-device
代替第一的weave-ping
迴聲服務器:
./mock-device -a fd00:0:1:1::1