我正在 QEMU 上的虚拟 QNX 来宾内运行 Wiki 页面“https://github.com/COVESA/vsomeip/wiki/vsomeip-in-10-minutes#devices”中的 vsomeip 服务示例。使用 TAP 接口启用桥接网络。使用的ifup脚本如下。
modprobe dummy
ip link add eth1 type dummy
ifconfig eth1 hw ether A7:C7:3A:3E:37:4A #fudged address
ip addr add 192.168.1.100/24 brd + dev eth1
ip link set dev eth1 up
ETH1_IP=192.168.0.3
ETH1_MASK=255.255.255.0
ETH1_BCAST=192.168.0.255
ifconfig eth1 down
ifconfig eth1 0.0.0.0 promisc up
tunctl -t tap0 -u `whoami`
ifconfig tap0 0.0.0.0 promisc up
brctl addbr br0
brctl addif br0 eth1
brctl addif br0 tap0
ifconfig eth1 up
ifconfig tap0 up
ifconfig br0 up
brctl stp br0 off
ifconfig br0 $ETH1_IP netmask $ETH1_MASK broadcast $ETH1_BCAST
我想从 Ubuntu 主机连接 vsomeip 客户端。 除了单播和组播 IP 之外,配置与示例中的相同。
我在主机和访客上添加了相同的多播 IP 来进行路由。 嘉宾
# route add -net 239.255.255.254 192.168.0.1 -ifp vt0
主持人
$ sudo route add -nv 239.255.255.254 dev br0
客户端无法检测到该服务。日志如下。
# ./service_example
2023-07-01 02:52:31.513250 [info] Parsed vsomeip configuration in 222ms
2023-07-01 02:52:31.513420 [info] Using configuration folder: "/etc/vsomeip".
2023-07-01 02:52:31.513460 [info] Configuration module loaded.
2023-07-01 02:52:31.513480 [info] Initializing vsomeip application "World".
2023-07-01 02:52:31.513530 [info] Instantiating routing manager [Host].
2023-07-01 02:52:31.513750 [info] create_local_server Routing endpoint at /tmp/vsomeip-0
2023-07-01 02:52:31.513890 [info] Service Discovery enabled. Trying to load module.
2023-07-01 02:52:31.514290 [info] Service Discovery module loaded.
2023-07-01 02:52:31.514440 [info] Application(World, 1212) is initialized (11, 100).
2023-07-01 02:52:31.514540 [info] OFFER(1212): [1234.5678:0.0] (true)
2023-07-01 02:52:31.514810 [info] Listening at /tmp/vsomeip-1212
2023-07-01 02:52:31.514950 [info] Starting vsomeip application "World" (1212) using 2 threads I/O nice 255
2023-07-01 02:52:31.515030 [info] main dispatch thread id from application: 1212 (World) is: 3
2023-07-01 02:52:31.515040 [info] shutdown thread id from application: 1212 (World) is: 4
2023-07-01 02:52:31.515230 [warning] udp_server_endpoint_impl:: couldn't set SO_RCVBUF: No buffer space available to: 1703936 local port: 30491
2023-07-01 02:52:31.515330 [debug] Joining to multicast group 239.255.255.254 from 192.168.0.11
2023-07-01 02:52:31.515370 [warning] udp_server_endpoint_impl:: couldn't set SO_RCVBUF: No buffer space available to: 1703936 local port: 30491
2023-07-01 02:52:31.515570 [warning] udp_server_endpoint_impl:: couldn't set SO_RCVBUF: No buffer space available to: 1703936 local port: 30509
2023-07-01 02:52:31.515610 [info] SOME/IP routing ready.
2023-07-01 02:52:31.515670 [info] Watchdog is disabled!
2023-07-01 02:52:31.515750 [info] io thread id from application: 1212 (World) is: 1
2023-07-01 02:52:31.515780 [info] io thread id from application: 1212 (World) is: 6
2023-07-01 02:52:31.515850 [info] vSomeIP 3.1.20.3 | (default)
2023-07-01 02:52:41.615890 [info] vSomeIP 3.1.20.3 | (default)
2023-07-01 02:52:45.655580 [warning] Didn't receive a multicast SD message for 2200ms.
2023-07-01 02:52:45.655640 [debug] Leaving the multicast group 239.255.255.254 from 192.168.0.11
2023-07-01 02:52:45.655730 [debug] Joining to multicast group 239.255.255.254 from 192.168.0.11
2023-07-01 02:52:45.655790 [warning] udp_server_endpoint_impl:: couldn't set SO_RCVBUF: No buffer space available to: 1703936 local port: 30491
~$ client_example
2023-08-01 06:52:42.158375 [info] Using configuration file: "config_client.json".
2023-08-01 06:52:42.158831 [info] Parsed vsomeip configuration in 0ms
2023-08-01 06:52:42.158939 [info] Configuration module loaded.
2023-08-01 06:52:42.159036 [info] Initializing vsomeip (3.3.8) application "Hello".
2023-08-01 06:52:42.159270 [info] Instantiating routing manager [Host].
2023-08-01 06:52:42.160274 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2023-08-01 06:52:42.160785 [info] Service Discovery enabled. Trying to load module.
2023-08-01 06:52:42.163340 [info] Service Discovery module loaded.
2023-08-01 06:52:42.163776 [info] Application(Hello, 1313) is initialized (11, 100).
2023-08-01 06:52:42.163955 [info] REQUEST(1313): [1234.5678:255.4294967295]
2023-08-01 06:52:42.164641 [info] create_local_server: Listening @ /tmp/vsomeip-1313
2023-08-01 06:52:42.165461 [info] Starting vsomeip application "Hello" (1313) using 2 threads I/O nice 255
2023-08-01 06:52:42.166503 [info] Client [1313] routes unicast:192.168.0.3, netmask:255.255.255.0
2023-08-01 06:52:42.166331 [info] main dispatch thread id from application: 1313 (Hello) is: 7fd893ffd640 TID: 10052
2023-08-01 06:52:42.166595 [info] shutdown thread id from application: 1313 (Hello) is: 7fd8937fc640 TID: 10053
2023-08-01 06:52:42.168030 [info] Watchdog is disabled!
**CLIENT: Service [1234.5678] is NOT available.
**2023-08-01 06:52:42.168978 [info] io thread id from application: 1313 (Hello) is: 7fd8957fed80 TID: 10049
2023-08-01 06:52:42.169019 [info] io thread id from application: 1313 (Hello) is: 7fd8927fa640 TID: 10055
2023-08-01 06:52:42.170197 [info] vSomeIP 3.3.8 | (default)
2023-08-01 06:52:42.170620 [info] Network interface "br0" state changed: up
2023-08-01 06:52:42.171615 [info] Route "239.255.255.254/32 if: br0 gw: n/a" state changed: up
2023-08-01 06:52:42.172148 [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 (1703936) local port:30491
2023-08-01 06:52:42.172345 [debug] Joining to multicast group 239.255.255.254 from 192.168.0.3
2023-08-01 06:52:42.172558 [info] SOME/IP routing ready.
2023-08-01 06:52:42.173415 [info] udp_server_endpoint_impl<multicast>: SO_RCVBUF is: 212992 (1703936) local port:30491
2023-08-01 06:52:52.170617 [info] vSomeIP 3.3.8 | (default)
2023-08-01 06:53:02.171167 [info] vSomeIP 3.3.8 | (default)
我希望发现该服务,但我收到“服务不可用”消息,如上面的日志所示。请问有什么指点吗?
该设置可疑地在使用 OpenVPN TAP 适配器的 Windows QEMU 上运行良好。这使得 Ubuntu TAP 适配器成为潜在罪魁祸首。因此在问题中添加了原始脚本。
事实上,问题在于网桥 ifup.sh 脚本中给出的子网错误。它与 br0/vt0 子网不匹配。可能有人把它留在那里作为盲目复制粘贴。使用正确的子网更新后,它就可以工作了。下面是差异。
- ip addr add 192.168.1.100/24 brd + dev eth1
+ ip addr add 192.168.0.1/24 brd + dev eth1
希望这可以帮助解决类似问题的人。