OTBR डॉकर चलाएं

GitHub पर सोर्स देखें

किसी Thread नेटवर्क. ओटीबीआर Docker, फ़िज़िकल आरसीपी (OpenThread की मदद से काम करता है) दोनों के लिए सहायता देता है डोंगल) या एक सिम्युलेटेड आरसीपी.

अगर आपको OTBR Docker को अन्य फ़िज़िकल Thread डिवाइसों से कनेक्ट करना है, तो फ़िज़िकल आरसीपी. अगर आपको सिम्युलेट किए गए थ्रेड के साथ बॉर्डर रूटिंग की जांच करनी है इस नेटवर्क के लिए, सिम्युलेटेड आरसीपी का इस्तेमाल करें.

फ़िज़िकल आरसीपी

इस एपीआई के साथ काम करने वाले किसी भी OpenThread प्लैटफ़ॉर्म का इस्तेमाल करें फ़िज़िकल आरसीपी. बिल्ड और फ़्लैश आरसीपी देखें ज़्यादा जानकारी के लिए, OpenThread Border राऊटर बनाने और कॉन्फ़िगरेशन गाइड करने का चरण जानकारी.

आरसीपी अटैच करें

  1. बनाने और फ़्लैश करने के बाद, आरसीपी डिवाइस को चल रही मशीन से जोड़ें यूएसबी से शुरू हुआ ओटीबीआर डॉकर.
  2. /dev की जांच करके, आरसीपी डिवाइस के सीरियल पोर्ट का नाम पता करें:
    ls /dev/tty*
    /dev/ttyACMO
    

OTBR Docker कंटेनर शुरू करें

नई टर्मिनल विंडो में, आरसीपी के सीरियल पोर्ट का रेफ़रंस देते हुए ओटीबीआर Docker शुरू करें. उदाहरण के लिए, अगर आरसीपी /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 Docker सेटअप के साथ जारी रखें.

सिम्युलेट किया गया आरसीपी

सिम्युलेट किए गए आरसीपी के लिए, सिम्युलेटेड OpenThread आरसीपी बिल्ड का इस्तेमाल करें. यह तब फ़ायदेमंद होता है, जब आपको किसी सिंगल Thread नेटवर्क पर, सिम्युलेटेड Thread नेटवर्क के साथ बॉर्डर रूटिंग की जांच करनी हो मशीन.

सिम्युलेट किया गया आरसीपी ऐप्लिकेशन बनाएं

  1. OpenThread डेटा स्टोर करने की जगह का क्लोन बनाएं:

    cd ~
    git clone https://github.com/openthread/openthread
    
    अभी तक किसी भी व्यक्ति ने चेक इन नहीं किया है

  2. सिम्युलेट किया गया ऐप्लिकेशन बूटस्ट्रैप करें और बनाएं:

    cd openthread
    ./script/bootstrap
    ./script/cmake-build simulation
    
    अभी तक किसी भी व्यक्ति ने चेक इन नहीं किया है

दोतरफ़ा डेटा स्ट्रीम सेट अप करना

दोनों तरफ़ की डेटा स्ट्रीम बनाने के लिए, socat कमांड लाइन सुविधा का इस्तेमाल करें का इस्तेमाल, सिम्युलेटेड आरसीपी और ओटीबीआर डॉकर के बीच डेटा ट्रांसफ़र करने के लिए किया.

  1. इस प्रोसेस को चलाने के लिए, एक नई टर्मिनल विंडो खोलें, क्योंकि इसे चालू रखना ज़रूरी है जब OTBR Docker चल रहा है.

  2. socat इंस्टॉल करें:

    sudo apt-get install socat
    

  3. शुरू 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]
    

आउटपुट में मौजूद दो सीरियल पोर्ट का नाम बना लें. पहला विकल्प इसके लिए इस्तेमाल करें सिम्युलेट किया गया आरसीपी और दूसरा OTBR Docker के लिए. उदाहरण के तौर पर दिए गए आउटपुट में ऊपर:

  • /dev/pts/2 = सिम्युलेट किया गया आरसीपी पोर्ट
  • /dev/pts/7 = ओटीबीआर डॉकर

इस टर्मिनल विंडो को खुला रहने दें और बैकग्राउंड में चलाएं.

सिम्युलेट किया गया आरसीपी शुरू करें

  1. सिम्युलेट किए गए आरसीपी को चलाने के लिए नई टर्मिनल विंडो खोलें, क्योंकि इसे बाईं ओर ही चलाना होगा OTBR Docker के चलने के दौरान चल रहा है.

  2. socat आउटपुट में पहले सीरियल पोर्ट का इस्तेमाल करके, सिम्युलेट किया गया आरसीपी शुरू करें का इस्तेमाल करें. उदाहरण के लिए, अगर socat आउटपुट से /dev/pts/2 का इस्तेमाल किया जा रहा है, तो:

    ~/openthread/build/simulation/examples/apps/ncp/ot-rcp 1 > /dev/pts/2 < /dev/pts/2
    

इस निर्देश से कोई आउटपुट नहीं मिलता. इस टर्मिनल विंडो को खुला छोड़ दें और बैकग्राउंड में चल रहा है.

OTBR Docker कंटेनर शुरू करें

नई टर्मिनल विंडो में, OTBR Docker को चालू करें. इसके लिए, socat आउटपुट. उदाहरण के लिए, अगर 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 पोर्ट का भी इस्तेमाल कर रहा है. यह डिफ़ॉल्ट है माउंट पॉइंट की मदद से, Docker कंटेनर में मौजूद माउंट पॉइंट का इस्तेमाल करना.

सफलता के बाद, आपके पास इस तरह का आउटपुट होना चाहिए:

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.

ओटीबीआर डॉकर अब काम कर रहा है. इस टर्मिनल विंडो को खुला छोड़ दें और इसमें बैकग्राउंड शामिल करें. अगर प्रोसेस को बंद किया जाता है या विंडो बंद की जाती है, तो ओटीबीआर डॉकर काम करना बंद कर देगा नीचे.