当前位置: 首页 > article >正文

bridge-multicast-igmpsnooping

 # 1.topo


 # 2.创建命名空间
 ip netns add ns0
 ip netns add ns1
 ip netns add ns2
 ip netns add ns3

 # 3.创建veth设备
 ip link add ns0-veth0 type veth peer name hn0-veth0
 ip link add ns1-veth0 type veth peer name hn1-veth0
 ip link add ns2-veth0 type veth peer name hn2-veth0
 ip link add ns3-veth0 type veth peer name hn3-veth0

 # 4.veth设备放入命名空间,启动接口
 ip link set ns0-veth0 netns ns0
 ip link set ns1-veth0 netns ns1
 ip link set ns2-veth0 netns ns2
 ip link set ns3-veth0 netns ns3
 ip -netns ns0 link set ns0-veth0 up
 ip -netns ns1 link set ns1-veth0 up
 ip -netns ns2 link set ns2-veth0 up
 ip -netns ns3 link set ns3-veth0 up

 # 5.创建br0,添加接口到br0
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 hn0-veth0
 brctl addif br0 hn1-veth0
 brctl addif br0 hn2-veth0
 brctl addif br0 hn3-veth0

 ip link set dev hn0-veth0 up
 ip link set dev hn1-veth0 up
 ip link set dev hn2-veth0 up
 ip link set dev hn3-veth0 up

 # 7.配置地址
 ip -netns ns0 addr add 1.1.1.10/24 dev ns0-veth0
 ip -netns ns1 addr add 1.1.1.11/24 dev ns1-veth0
 ip -netns ns2 addr add 1.1.1.12/24 dev ns2-veth0
 ip -netns ns3 addr add 1.1.1.13/24 dev ns3-veth0

 # 8.测试
 # 8.1测试iperf
 ip netns exec ns0 iperf -s -u -B 239.1.1.1 -p 5001   //server
 ip netns exec ns1 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.11
 ip netns exec ns2 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.12
 ip netns exec ns3 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.13
 tcpdump -i br0 -e


 # 8.2测试 igmp snooping

 ## bridge开启igmp snooping
 echo 1 > /sys/devices/virtual/net/br0/bridge/multicast_querier //启用 IGMP 查询器功能
 echo 1 > /sys/devices/virtual/net/br0/bridge/multicast_snooping // IGMP Snooping 功能^S
 echo 100 > /sys/devices/virtual/net/br0/bridge/multicast_query_interval //IGMP 查询消息的发送间隔
 echo 4 > /sys/devices/virtual/net/br0/bridge/multicast_query_response_interval

 echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 //关闭ipv6协议栈

 ## 添加组播组
 smcroute -d
 ip netns exec ns1 smcroute -d
 ip netns exec ns1 smcroutectl join ns1-veth0 239.0.0.99  //加入组播组
 ip netns exec ns2 smcroute -d
 ip netns exec ns2 smcroutectl join ns2-veth0 239.0.0.99  //加入组播组

 bridge mdb show br0

 ## 发送组播报文
 //发送组播
 ip netns exec ns0 ip route add 239.0.0.0/8 dev ns0-veth0  添加路由,sendip才发送处理组播报文
 ip netns exec ns0  sendip -p ipv4 -is 1.1.1.10  -id 239.0.0.99 -p udp -us 5000 -ud 5001 -d "Hello, Multicast!" 239.0.0.99

 ## 抓包
 ip netns exec ns1 tcpdump -i ns1-veth0 -e
 ip netns exec ns2 tcpdump -i ns2-veth0 -e
 ip netns exec ns3 tcpdump -i ns3-veth0 -e

 ns1、ns2能收到,ns3收不到。

 # 9.删除
 ip netns del ns0
 ip netns del ns1
 ip netns del ns2
 ip netns del ns3
 ip link set br0 down
 brctl delbr br0

ip link del hn0-veth0
ip link del hn1-veth0
ip link del hn2-veth0
ip link del hn3-veth0


 # 组播
 cat /sys/devices/virtual/net/br0/bridge/multicast_snooping
 cat /proc/net/igmp
 ip maddr show dev br0

 # smcroute
 ip netns exec ns0 smcroute -d  //命名空间开启进程
 smcroute -d  //开启进程
 smcroutectl join br0 224.0.0.99  //加入组播组
 smcroutectl leave br0 224.0.0.99  //离开组播组

 cat /proc/net/igmp
 cat /proc/sys/net/ipv4/conf/all/mc_forwarding

 发送单播报文
 ip netns exec ns0  sendip -p ipv4 -is 1.1.1.10  -id 1.1.12 -p udp -us 5000 -ud 5001 -d "Hello, Multicast!" 1.1.1.12

 # 11.参考
Ubuntu Manpage: smcroute — SMCRoute, a static multicast router


http://www.kler.cn/a/410835.html

相关文章:

  • 第二十八章 TCP 客户端 服务器通信 - JOB命令示例
  • Python和R荧光分光光度法
  • 基于YOLOv8深度学习的农作物番茄成熟度检测系统研究与实现(PyQt5界面+数据集+训练代码)
  • jmeter基础06_(练习)常见的http请求
  • Reactor 模式的理论与实践
  • 即时通讯平台-音视频即时通讯平台就选WorkPlus
  • 虚拟苹果系统MacOS中新建自定义C++Dylib并用C++测试程序测试
  • QT 跨平台实现 SSDP通信 支持多网卡
  • 【ArcGISPro】使用AI提取要素-土地分类(sentinel2)
  • 用树莓派Pico控制8×8 LED点阵屏:深入解析C++核心知识与动态显示实现
  • 深度学习——3种常见的Transformer位置编码【sin/cos、基于频率的二维位置编码(2D Frequency Embeddings)、RoPE】
  • 突破内存限制:Mac Mini M2 服务器化实践指南
  • 提升软件测试报告的质量:Allure2中添加用例失败截图、日志、HTML块和视频的方法
  • 鸿蒙进阶篇-正则
  • 【linux】服务器加装硬盘后如何将其设置为独立硬盘使用
  • Mamba/PyTorch WSL环境配置
  • SQL进阶:如何跳过多个NULL值取第一个非NULL值?
  • Postgresql 获取字段里的字段内容的长度
  • linux实战-黑链——玄机靶场
  • Linux—进程概念学习-03