OpenWeave 도구

GitHub에서 소스보기

OpenWeave에는 OpenWeave 배포를 구성, 관리 및 테스트하기위한 일련의 명령 줄 도구가 포함되어 있습니다.

직조 도구 만들기

weave-tools 대상 배포를 선택 위브 명령 줄 도구의 tar 아카이브를 구축합니다. 여기에는 다음 도구가 포함됩니다.

수단 기술 독립 빌드 위치
gen-qr-code QR 코드 생성 /src/tools/misc
mock-device Generic Weave 소자 시뮬레이터 /src/test-apps
weave Weave 인증서 생성 및 관리 /src/tools/weave
weave-device-descriptor QR 코드 페어링을위한 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

타겟을 빌드하려면 :

  1. 모든 설치 빌드 전제 조건을 .
  2. BlueZ 지원하지 않는 구성 OpenWeave :
    cd <path-to-openweave-core>
    ./configure --without-bluez
  3. Make the weave-tools target:
    make weave-tools
  4. 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를 :

  1. 다음 QR 코드에 대한 문자열을 가진 파일 만들기
    echo "https://www.google.com" >> ~/ow_qrcode
  2. Generate a 64x64 QR code of that string:
    ./gen-qr-code -v 1 -s 64 < ~/ow_qrcode
  3. 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 the weave-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-device-descriptor 도구 인코딩 또는 디코딩 장치 설명 문자열입니다. 이러한 문자열에는 Weave 페어링 QR 코드로 인코딩 된 장치에 대한 식별 정보가 포함됩니다. 사용 --help 플래그 encode 이나 decode 자세한 내용은 옵션을.

./weave-device-descriptor encode --help
./weave-device-descriptor decode --help

인코딩

예를 들어, 다음 식별 정보로 장치 설명자 문자열을 인코딩하려면 적절한 플래그와 값을 사용하십시오.

깃발
공급 업체 ID -V 1
제품 ID -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 전송하고 수신하는 하트 비트를 두 위브 노드간에 프로필 메시지를. Heartbeat는 한 노드의 활성 상태를 네트워크의 다른 노드에 표시하거나 노드가 패브릭에 계속 연결되어 있는지 확인하는 수단을 제공합니다.

하트 비트가 성공하려면 하나의 노드가 서버 역할을하고 (하트 비트를 수신하고 응답) 클라이언트 역할을 할 노드 하나 (하트 비트 전송)가 필요합니다.

시험 weave-heartbeat 모방 두 노드에 루프백 인터페이스를 사용하여 도구를 :

  1. 받는 각 하트 비트 노드에 사용될 IPv6 주소 추가 lo (루프백) 인터페이스
    sudo ifconfig lo add fd00:0:1:1::1/64
    sudo ifconfig lo add fd00:0:1:1::2/64
  2. Start the Heartbeat server on the fd00:0:1:1::1 address and assign it a node-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: 170418

  3. Open a second terminal window and start the Heartbeat client on the fd00:0:1:1::2 IPv6 address with a node-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 UDP

  4. After 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 전송 및 수신하는 에코 두 위브 노드간에 프로필 메시지를. Echo 페이로드는 요청 노드에서 제공하는 임의의 데이터로 구성되며 응답에서 그대로 다시 에코 될 것으로 예상됩니다. Echo는 네트워크 연결 및 대기 시간을 테스트하는 수단을 제공합니다.

Echo가 성공하려면 하나의 노드가 서버 역할을하고 (Echo 요청을 수신하고 응답하는) 클라이언트 역할을하는 노드 하나 (Echo 요청 전송)가 필요합니다.

시험 weave-ping 모방 두 노드에 루프백 인터페이스를 사용하여 도구를 :

  1. 에코받는 각 노드에 대해 사용되는 IPv6 주소 추가 lo (루프백) 인터페이스
    sudo ifconfig lo add fd00:0:1:1::1/64
    sudo ifconfig lo add fd00:0:1:1::2/64
  2. Start the Echo server on the fd00:0:1:1::1 address, assigning it a node-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...

  3. Open a second terminal window and start the Echo client on the fd00:0:1:1::2 IPv6 address with a node-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)

  4. 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