当前位置:   article > 正文

用socat验证multicase(组播)和broadcast(广播) with k8s容器环境

用socat验证multicase(组播)和broadcast(广播) with k8s容器环境

安装socat

网络允许的话,可以使用yum install -y socat进行安装。

如果是在容器里面运行,建议使用静态链接的socat:

可以从此处下载: Release socat-v1.7.4.4 · ernw/static-toolbox · GitHub

确定网络接口地址和组播地址

  1. #kubectl exec -it pod-node2 -- ifconfig eth0
  2. eth0 Link encap:Ethernet HWaddr 00:00:00:F6:DE:E2
  3. inet addr:101.16.0.118 Bcast:101.16.255.255 Mask:255.255.0.0
  4. inet6 addr: fe80::200:ff:fef6:dee2/64 Scope:Link
  5. UP BROADCAST RUNNING MULTICAST MTU:1400 Metric:1
  6. RX packets:117 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:0
  9. RX bytes:8063 (7.8 KiB) TX bytes:4308 (4.2 KiB)
  10. #kubectl exec -it pod-node3 -- ifconfig eth0
  11. eth0 Link encap:Ethernet HWaddr 00:00:00:60:52:4B
  12. inet addr:101.16.0.119 Bcast:101.16.255.255 Mask:255.255.0.0
  13. inet6 addr: fe80::200:ff:fe60:524b/64 Scope:Link
  14. UP BROADCAST RUNNING MULTICAST MTU:1400 Metric:1
  15. RX packets:118 errors:0 dropped:0 overruns:0 frame:0
  16. TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
  17. collisions:0 txqueuelen:0
  18. RX bytes:8090 (7.9 KiB) TX bytes:2925 (2.8 KiB)

验证组播multicast

server侧运行命令行:

kubectl exec -it pod-node2 -- /usr/bin/socat-1.7.4.4-x86_64 -d UDP4-RECVFROM:6666,ip-add-membership=224.1.0.1:101.16.0.118,fork EXEC:hostname

client侧运行命令行:

kubectl exec -it pod-node3 -- /usr/bin/socat-1.7.4.4-x86_64 STDIO UDP4-DATAGRAM:224.1.0.1:6666,range=101.16.0.119/24

ip地址和rang需要从ifconfig命令中获取

实机运行效果

验证广播broadcast

server侧运行命令行:

kubectl exec -it pod-node2 -- /usr/bin/socat-1.7.4.4-x86_64 -dd UDP4-RECVFROM:6666,broadcast,fork EXEC:hostname

client侧运行命令行:

kubectl exec -it pod-node3 -- /usr/bin/socat-1.7.4.4-x86_64 -dd STDIO UDP4-DATAGRAM:101.16.255.255:6666,broadcast,range=101.16.0.119/16

ip地址和rang需要从ifconfig命令中获取

实机运行效果

server

client

官方操作文档

IP Multicasting with Socat

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/507217
推荐阅读
相关标签
  

闽ICP备14008679号