किसी थ्रेड नेटवर्क से जुड़ने के लिए, OpenThread बॉर्डर राऊटर (OTBR) के लिए, Thread RCP नोड ज़रूरी है. OTBR डॉकर फ़िज़िकल RCP (OpenThread डॉंगल) या सिम्युलेटेड RCP, दोनों के लिए सहायता उपलब्ध कराता है.
अगर आपको OTBR डॉकर को दूसरे थ्रेड के अन्य डिवाइसों से कनेक्ट करना है, तो आरसीपी का इस्तेमाल करें. सिम्युलेट की गई थ्रेड नेटवर्क की मदद से, बॉर्डर रूटिंग की जांच करने के लिए, सिम्युलेटेड आरसीपी का इस्तेमाल करें.
फ़िज़िकल आरसीपी
आरसीपी के लिए, काम करने वाले OpenThread प्लैटफ़ॉर्म का इस्तेमाल करें. ज़्यादा जानकारी के लिए, OpenThread बॉर्डर राऊटर बिल्ड और कॉन्फ़िगरेशन गाइड में, बिल्ड और फ़्लैश RCP का तरीका देखें.
आरसीपी अटैच करें
- बनाने और फ़्लैश करने के बाद, RCP डिवाइस को USB के ज़रिए OTBR डॉकर चलाने वाली मशीन पर लगाएं.
/dev
की जांच करके, आरसीपी डिवाइस का सीरियल पोर्ट नाम तय करें:ls /dev/tty*
/dev/ttyACMO
OTBR डॉकर कंटेनर शुरू करें
नई टर्मिनल विंडो में, आरसीपी के सीरियल पोर्ट का रेफ़रंस देते हुए, OTBR डॉकर शुरू करें.
उदाहरण के लिए, अगर आरसीपी को /dev/ttyACM0
पर माउंट किया जाता है, तो:
docker run --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" -p 8080:80 --dns=127.0.0.1 -it --volume /dev/ttyACM0:/dev/ttyACM0 --privileged openthread/otbr --radio-url spinel+hdlc+uart:///dev/ttyACM0
काम करने पर, आपका आउटपुट इससे मिलता-जुलता होगा:
WARNING: Localhost DNS setting (--dns=127.0.0.1) may fail in containers. RADIO_URL: spinel+hdlc+uart:///dev/ttyACM0 TUN_INTERFACE_NAME: wpan0 NAT64_PREFIX: 64:ff9b::/96 AUTO_PREFIX_ROUTE: true AUTO_PREFIX_SLAAC: true Current platform is ubuntu * Applying /etc/sysctl.d/10-console-messages.conf ... kernel.printk = 4 4 1 7 * Applying /etc/sysctl.d/10-ipv6-privacy.conf ... net.ipv6.conf.all.use_tempaddr = 2 net.ipv6.conf.default.use_tempaddr = 2 * Applying /etc/sysctl.d/10-kernel-hardening.conf ... kernel.kptr_restrict = 1 * Applying /etc/sysctl.d/10-link-restrictions.conf ... fs.protected_hardlinks = 1 fs.protected_symlinks = 1 * Applying /etc/sysctl.d/10-magic-sysrq.conf ... kernel.sysrq = 176 * Applying /etc/sysctl.d/10-network-security.conf ... net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.all.rp_filter = 1 net.ipv4.tcp_syncookies = 1 * Applying /etc/sysctl.d/10-ptrace.conf ... kernel.yama.ptrace_scope = 1 * Applying /etc/sysctl.d/10-zeropage.conf ... vm.mmap_min_addr = 65536 * Applying /etc/sysctl.d/60-otbr-ip-forward.conf ... net.ipv6.conf.all.forwarding = 1 net.ipv4.ip_forward = 1 * Applying /etc/sysctl.conf ... * Starting userspace NAT64 tayga [ OK ] /usr/sbin/service * Starting domain name service... bind9 [ OK ] /usr/sbin/service * dbus is not running * Starting system message bus dbus [ OK ] ...fail! otWeb[155]: border router web started on wpan0 otbr-agent[224]: Thread interface wpan0 otbr-agent[224]: Thread is down otbr-agent[224]: Check if Thread is up: OK otbr-agent[224]: Stop publishing service otbr-agent[224]: PSKc is not initialized otbr-agent[224]: Check if PSKc is initialized: OK otbr-agent[224]: Initialize OpenThread Border Router Agent: OK otbr-agent[224]: Border router agent started.
OTBR डॉकर अब चल रहा है. इस टर्मिनल विंडो को खोलें और बैकग्राउंड में चलाएं. इस प्रोसेस को बंद करने या विंडो बंद करने पर, OTBR डॉकर बंद हो जाएगा.
OTBR डॉकर सेटअप के साथ जारी रखने के लिए कनेक्टिविटी जांचें पर जाएं.
सिम्युलेट किया गया आरसीपी
सिम्युलेट किए गए आरसीपी के लिए सिम्युलेटेड OpenThread RCP बिल्ड का इस्तेमाल करें. अगर आपको एक ही मशीन पर सिम्युलेटेड थ्रेड नेटवर्क के साथ बॉर्डर रूटिंग की जांच करनी है, तो यह तरीका मददगार होता है.
सिम्युलेट किया गया आरसीपी ऐप्लिकेशन बनाएं
OpenThread डेटा स्टोर करने की जगह की कॉपी बनाएं:
cd ~
git clone https://github.com/openthread/openthread
सिम्युलेट किए गए ऐप्लिकेशन को बूटस्ट्रैप करें और बनाएं:
cd openthread
./bootstrap
./script/cmake-build simulation
दोतरफ़ा डेटा स्ट्रीम सेट अप करें
सिम्युलेटेड आरसीपी और OTBR डॉकर के बीच डेटा ट्रांसफ़र करने के लिए, बाईडायरेक्शनल डेटा स्ट्रीम बनाने के लिए socat
कमांड लाइन यूटिलिटी का इस्तेमाल करें.
इस प्रोसेस को चलाने के लिए, नई टर्मिनल विंडो खोलें, क्योंकि जब तक OTBR डॉकर चल रहा हो, तब तक इसे चलने दें.
socat
इंस्टॉल करें:sudo apt-get install socat
socat
शुरू करें:socat -d -d pty,raw,echo=0 pty,raw,echo=0
2018/09/06 09:58:29 socat[242994] N PTY is /dev/pts/2 2018/09/06 09:58:29 socat[242994] N PTY is /dev/pts/7 2018/09/06 09:58:29 socat[242994] N starting data transfer loop with FDs [5,5] and [7,7]
आउटपुट में बोल्ड किए गए दो सीरियल पोर्ट पर ध्यान दें. सिम्युलेटेड RCP के लिए पहला और OTBR डॉकर के लिए दूसरा. ऊपर दिए गए उदाहरण के आउटपुट में:
/dev/pts/2
= सिम्युलेट किया गया आरसीपी पोर्ट/dev/pts/7
= OTBR डॉकर
इस टर्मिनल विंडो को खोलें और इसे बैकग्राउंड में चलाएं.
सिम्युलेट किया गया आरसीपी शुरू करें
सिम्युलेटेड RCP चलाने के लिए, नई टर्मिनल विंडो खोलें, क्योंकि जब OTBR डॉकर चल रहा हो, तब इसे चलने देना चाहिए.
socat
आउटपुट में पहले सीरियल पोर्ट का इस्तेमाल करके, सिम्युलेट किया गया आरसीपी ऐप्लिकेशन शुरू करें. उदाहरण के लिए,socat
आउटपुट से/dev/pts/2
का इस्तेमाल करने पर:~/openthread/build/simulation/examples/apps/ncp/ot-rcp 1 > /dev/pts/2 < /dev/pts/2
इस निर्देश से कोई आउटपुट नहीं आया. इस टर्मिनल विंडो को खोलें और बैकग्राउंड में चलाएं.
OTBR डॉकर कंटेनर शुरू करें
नई टर्मिनल विंडो में, socat
आउटपुट में दूसरे सीरियल पोर्ट का इस्तेमाल करके, OTBR डॉकर को शुरू करें. उदाहरण के लिए, अगर socat
आउटपुट से /dev/pts/7
का इस्तेमाल किया जा रहा है:
docker run --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" -p 8080:80 --dns=127.0.0.1 -it --volume /dev/pts/7:/dev/ttyUSB0 --privileged openthread/otbr
ध्यान दें कि निर्देश, /dev/ttyUSB0
पोर्ट का इस्तेमाल भी कर रहा है. यह डॉकर कंटेनर
में डिफ़ॉल्ट माउंट पॉइंट होता है.
काम करने पर, आपका आउटपुट इससे मिलता-जुलता होगा:
WARNING: Localhost DNS setting (--dns=127.0.0.1) may fail in containers. RADIO_URL: spinel+hdlc+uart:///dev/ttyUSB0 TUN_INTERFACE_NAME: wpan0 NAT64_PREFIX: 64:ff9b::/96 AUTO_PREFIX_ROUTE: true AUTO_PREFIX_SLAAC: true Current platform is ubuntu * Applying /etc/sysctl.d/10-console-messages.conf ... kernel.printk = 4 4 1 7 * Applying /etc/sysctl.d/10-ipv6-privacy.conf ... net.ipv6.conf.all.use_tempaddr = 2 net.ipv6.conf.default.use_tempaddr = 2 * Applying /etc/sysctl.d/10-kernel-hardening.conf ... kernel.kptr_restrict = 1 * Applying /etc/sysctl.d/10-link-restrictions.conf ... fs.protected_hardlinks = 1 fs.protected_symlinks = 1 * Applying /etc/sysctl.d/10-magic-sysrq.conf ... kernel.sysrq = 176 * Applying /etc/sysctl.d/10-network-security.conf ... net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.all.rp_filter = 1 net.ipv4.tcp_syncookies = 1 * Applying /etc/sysctl.d/10-ptrace.conf ... kernel.yama.ptrace_scope = 1 * Applying /etc/sysctl.d/10-zeropage.conf ... vm.mmap_min_addr = 65536 * Applying /etc/sysctl.d/60-otbr-ip-forward.conf ... net.ipv6.conf.all.forwarding = 1 net.ipv4.ip_forward = 1 * Applying /etc/sysctl.conf ... * Starting userspace NAT64 tayga [ OK ] /usr/sbin/service * Starting domain name service... bind9 [ OK ] /usr/sbin/service * dbus is not running * Starting system message bus dbus [ OK ] ...fail! otWeb[155]: border router web started on wpan0 otbr-agent[224]: Thread interface wpan0 otbr-agent[224]: Thread is down otbr-agent[224]: Check if Thread is up: OK otbr-agent[224]: Stop publishing service otbr-agent[224]: PSKc is not initialized otbr-agent[224]: Check if PSKc is initialized: OK otbr-agent[224]: Initialize OpenThread Border Router Agent: OK otbr-agent[224]: Border router agent started.
OTBR डॉकर अब चल रहा है. इस टर्मिनल विंडो को खोलें और बैकग्राउंड में चलाएं. इस प्रोसेस को बंद करने या विंडो बंद करने पर, OTBR डॉकर बंद हो जाएगा.