O OpenThread Border Router (OTBR) requer um nó Thread RCP para se juntar a uma rede Thread. OTBR Docker fornece suporte para um RCP físico (dongle OpenThread) ou um RCP simulado.
Se você deseja conectar o OTBR Docker a outros dispositivos físicos Thread, use um RCP físico. Se você deseja testar o roteamento de borda com uma rede Thread simulada, use um RCP simulado.
RCP Físico
Use qualquer plataforma OpenThread com suporte para o RCP físico. Consulte a etapa Build and flash RCP do guia de construção e configuração do OpenThread Border Router para obter mais informações.
Anexe o RCP
- Depois de construir e atualizar, conecte o dispositivo RCP à máquina que executa o OTBR Docker via USB.
- Determine o nome da porta serial para o dispositivo RCP verificando
/dev
:ls /dev/tty*
/dev/ttyACMO
Inicie o contêiner OTBR Docker
Em uma nova janela de terminal, inicie o OTBR Docker, fazendo referência à porta serial do RCP. Por exemplo, se o RCP estiver montado em /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
Após o sucesso, você deve ter uma saída semelhante a esta:
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 agora está em execução. Deixe esta janela do terminal aberta e em execução em segundo plano. Se você sair do processo ou fechar a janela, o OTBR Docker será desativado.
Vá para Testar Conectividade para continuar com a configuração do OTBR Docker.
RCP simulado
Use uma construção OpenThread RCP simulada para o RCP simulado. Isso é útil se você deseja testar o roteamento de borda com uma rede Thread simulada em uma única máquina.
Construir o aplicativo RCP simulado
- Clone o repositório OpenThread:
cd ~
git clone https://github.com/openthread/openthread
- Inicialize e crie o aplicativo simulado:
cd openthread
./bootstrap
make -f examples/Makefile-simulation
Configure um fluxo de dados bidirecional
Use o utilitário de linha de comando socat
para estabelecer um fluxo de dados bidirecional para transferir dados entre o RCP simulado e o OTBR Docker.
- Abra uma nova janela de terminal para executar este processo, pois ele deve permanecer em execução enquanto o OTBR Docker estiver em execução.
- Instale
socat
:sudo apt-get install socat
- Iniciar
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]
Anote as duas portas seriais em negrito na saída. Use o primeiro para o RCP simulado e o segundo para o OTBR Docker. No exemplo de saída acima:
-
/dev/pts/2
= Porta RCP simulada -
/dev/pts/7
= Docker OTBR
Deixe esta janela do terminal aberta e em execução em segundo plano.
Inicie o RCP simulado
- Abra uma nova janela de terminal para executar o RCP simulado, pois ele deve ser deixado em execução enquanto o OTBR Docker estiver em execução.
- Usando a primeira porta serial na saída do
socat
, inicie o aplicativo RCP simulado. Por exemplo, se estiver usando/dev/pts/2
da saída dosocat
:~/openthread/output/simulation/bin/ot-rcp 1 \ > /dev/pts/2 < /dev/pts/2
Não há saída deste comando. Deixe esta janela do terminal aberta e em execução em segundo plano.
Inicie o contêiner OTBR Docker
Em uma nova janela de terminal, inicie o OTBR Docker, usando a segunda porta serial na saída do socat
. Por exemplo, se estiver usando /dev/pts/7
da saída do socat
:
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
Observe que o comando também está usando a porta /dev/ttyUSB0
. Este é o ponto de montagem padrão dentro do contêiner do Docker.
Após o sucesso, você deve ter uma saída semelhante a esta:
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 Docker está em execução agora. Deixe esta janela do terminal aberta e em execução em segundo plano. Se você sair do processo ou fechar a janela, o OTBR Docker será desativado.