我有一个具有以下设置的机器人,并且 [计算机 A] 的以太网接口 (enp4s0) 随机掉线。
当计算机没有太多操作时,接口不会掉线。但是,当 [计算机 B] 开始通过 [计算机 A] 向 [我的电脑] 传输压缩图像流时,以太网接口会掉线。
因此,这似乎是一个配置问题,我可能无意中淹没了网络,导致网络连接中断,我想就此事获得一些建议。
dmesg 的输出没什么帮助
来自计算机 A 的 dmesg
[Mon Apr 12 13:43:33 2021] igb 0000:04:00.0 enp4s0: igb: enp4s0 NIC Link is Down
[Mon Apr 12 13:43:33 2021] br0: port 1(enp4s0) entered disabled state
[Mon Apr 12 13:43:35 2021] igb 0000:04:00.0 enp4s0: igb: enp4s0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX
[Mon Apr 12 13:43:35 2021] br0: port 1(enp4s0) entered blocking state
[Mon Apr 12 13:43:35 2021] br0: port 1(enp4s0) entered listening state
[Mon Apr 12 13:43:39 2021] br0: port 1(enp4s0) entered learning state
[Mon Apr 12 13:43:44 2021] br0: port 1(enp4s0) entered forwarding state
[Mon Apr 12 13:43:44 2021] br0: topology change detected, propagating
[Mon Apr 12 14:05:50 2021] igb 0000:04:00.0 enp4s0: igb: enp4s0 NIC Link is Down
[Mon Apr 12 14:05:50 2021] br0: port 1(enp4s0) entered disabled state
[Mon Apr 12 14:05:52 2021] igb 0000:04:00.0 enp4s0: igb: enp4s0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX
我已经做的事情:
- 检查并更换了所有以太网电缆。
- 用备件更换所有计算机和传感器
- 在网桥上启用 STP,转发延迟为 4
不幸的是,由于机器人内部尺寸的限制,我无法将所有东西都连接到开关。
设置
所有计算机都运行 Ubuntu 18.04,并且ROS 旋律莫雷尼亚。
我已经使用 netplan 设置了网桥,如下所示
# Netplan on Computer A
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
#Computer B
enp1s0:
dhcp4: no
#Sensor
enp2s0:
dhcp4: no
#SBC to switch
enp4s0:
dhcp4: no
#Setup a bridge and link eno1 to it
bridges:
br0:
interfaces: [enp1s0, enp2s0, enp4s0]
addresses: [192.168.1.1/24]
gateway4: 192.168.1.253
nameservers:
addresses: [8.8.8.8]
dhcp4: no
我还尝试过其他方法:
启用端口转发并添加从 [计算机 B] 到 [计算机 A] 的路由,并在不同的子网上设置 NIC /etc/sysctl.conf
:
net.ipv4.ip_forward = 1
计算机B
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
# Netplan on Computer A
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
#Computer B
enp1s0:
addresses:
- 192.168.2.1/24
dhcp4: no
#Sensor
enp2s0:
addresses:
- 192.168.3.1/24
dhcp4: no
#SBC to switch
enp4s0:
addresses:
- 192.168.1.1/24
dhcp4: no
gateway4: 192.168.1.253
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
答案1
我发现 eno1 和 enp4s0 使用的是不同的驱动程序。所以我尝试切换两个接口,现在接口没有掉线。可能是过时的驱动程序导致了掉线。
sudo lspci -v
接口 eno1
Ethernet controller: Intel Corporation Ethernet Connection (6) I219-LM (rev 30)
Subsystem: Intel Corporation Ethernet Connection (6) I219-LM
Flags: bus master, fast devsel, latency 0, IRQ 141
Memory at a1a00000 (32-bit, non-prefetchable) [size=128K]
Capabilities: [c8] Power Management version 3
Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Kernel driver in use: e1000e
Kernel modules: e1000e
接口 enp4s0
Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
Flags: bus master, fast devsel, latency 0, IRQ 17
Memory at a1780000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 3000 [disabled] [size=32]
Memory at a1800000 (32-bit, non-prefetchable) [size=16K]
Expansion ROM at a1700000 [disabled] [size=512K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] MSI-X: Enable+ Count=5 Masked-
Capabilities: [a0] Express Endpoint, MSI 00
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number c4-00-ad-ff-ff-4c-52-bf
Capabilities: [1a0] Transaction Processing Hints
Kernel driver in use: igb
Kernel modules: igb
计算机 A 上的当前 netplan
network:
version: 2
renderer: NetworkManager
ethernets:
enp2s0:
addresses:
- 192.168.3.1/24
dhcp4: no
enp1s0:
mtu: 1500
addresses:
- 192.168.2.1/24
dhcp4: no
eno1:
mtu: 1500
dhcp4: no
addresses: [192.168.1.1/24]
gateway4: 192.168.1.253
nameservers:
addresses: [8.8.4.4,8.8.8.8]
enp4s0:
mtu: 1500
dhcp4: no
addresses: [192.168.1.2/24]
gateway4: 192.168.1.253
nameservers:
addresses: [8.8.4.4,8.8.8.8]