عرض المصدر على جيثب |
يتضمن OpenWeave مجموعة من أدوات سطر الأوامر لتكوين عمليات نشر OpenWeave وإدارتها واختبارها.
بناء أدوات النسيج
و weave-tools الهدف يبني أرشيف القطران في اختيار أدوات سطر الأوامر نسج للتوزيع. يتضمن الأدوات التالية:
| أداة | وصف | مستقل بناء موقع |
|---|---|---|
gen-qr-code | قم بإنشاء رمز الاستجابة السريعة | /src/tools/misc |
mock-device | نسج عام جهاز محاكاة | /src/test-apps |
weave | إنشاء وإدارة شهادات النسج | /src/tools/weave |
weave-device-descriptor | تشفير وفك تشفير سلاسل واصف جهاز Weave لإقران رموز QR | /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-toolstarget:make weave-tools - Check the root
openweave-coredirectory 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 لتوليد رمز الاستجابة السريعة لأغراض الاقتران الجهاز. يجب أن يكون إدخال الأداة موجودًا في ملف محلي. على سبيل المثال، لتوليد رمز الاستجابة السريعة التي ترسل للمستخدم https://www.google.com :
- إنشاء ملف مع سلسلة لرمز الاستجابة السريعة:
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.pngUse theweave-device-descriptortool 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:
./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 تشفير أداة أو يترجم سلسلة اصف الجهاز. تحتوي هذه السلاسل على معلومات تعريف لجهاز تم ترميزه في رمز الاستجابة السريعة الخاص به. استخدام --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 أداة لتوليد رمز الاستجابة السريعة.
فك تشفير
استخدام 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 وسيلة للإشارة إلى نشاط إحدى العقدة في العقد الأخرى في الشبكة ، أو للتحقق مما إذا كانت العقدة لا تزال متصلة بالنسيج.
يتطلب Heartbeat الناجح عقدة واحدة للعمل كخادم (الاستماع والاستجابة لـ Heartbeat) وعقدة واحدة للعمل كعميل (إرسال Heartbeat).
اختبار weave-heartbeat أداة باستخدام واجهة الاسترجاع إلى عقدتين تقليد:
- إضافة عناوين IPv6 لاستخدامها في كل عقدة نبضات ل
lo(الاسترجاع) واجهة:sudo ifconfig lo add fd00:0:1:1::1/64sudo ifconfig lo add fd00:0:1:1::2/64 Start the Heartbeat server on the
fd00:0:1:1::1address and assign it anode-idof 1:./weave-heartbeat --node-addr fd00:0:1:1::1 --node-id 1 --listenWEAVE: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::2IPv6 address with anode-idof 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 1WEAVE: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 instantiates على mock-device لكلا الخادم والعميل. يمكن البرهنة على وظائف نبضات نفسها باستخدام mock-device في مكان أول weave-heartbeat الخادم نبضات:
./mock-device -a fd00:0:1:1::1
نسج بينغ
استخدام weave-ping لإرسال واستقبال الصدى الرسائل الشخصية بين عقدتين نسج. تتكون حمولة Echo من البيانات التعسفية التي توفرها العقدة الطالبة ومن المتوقع أن يتم تكرارها حرفيًا في الاستجابة. يوفر Echo وسيلة لاختبار اتصال الشبكة والكمون.
يتطلب Echo الناجح عقدة واحدة للعمل كخادم (الاستماع والاستجابة لطلب Echo) وعقدة واحدة للعمل كعميل (إرسال طلب Echo).
اختبار weave-ping أداة باستخدام واجهة الاسترجاع إلى عقدتين تقليد:
- إضافة عناوين IPv6 لاستخدامها في كل عقدة صدى ل
lo(الاسترجاع) واجهة:sudo ifconfig lo add fd00:0:1:1::1/64sudo ifconfig lo add fd00:0:1:1::2/64 Start the Echo server on the
fd00:0:1:1::1address, assigning it anode-idof 1:./weave-ping --node-addr fd00:0:1:1::1 --node-id 1 --listenWEAVE: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::2IPv6 address with anode-idof 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 1WEAVE: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 instantiates على mock-device لكلا الخادم والعميل. يمكن البرهنة على وظائف صدى نفسها باستخدام mock-device في مكان أول weave-ping الخادم الصدى:
./mock-device -a fd00:0:1:1::1
عرض المصدر على جيثب