当前位置:网站首页>In container multicast
In container multicast
2022-07-25 06:29:00 【Fiona_ q】
I was also stunned when I first heard about multicast , As a non computer major , Become a monk halfway to study containers and k8s Little white of , Multicast is strange to me , Therefore, it is also a variety of reference materials , Experience first understand and then try , Whether responsibly or irresponsibly , To a large extent, this blog is also the operation of porters , But I still want to commemorate some of my only learning achievements .
First, explain the reason for studying multicast , The function of multicast in LAN should be realized on the container cluster management software , This time I learned the concept of multicast , Knowledge of LAN , Yes macvlan A preliminary understanding of , There is only a simple understanding about routing and gateway , At present, I am not familiar with how to configure LAN , Probably the process is like this , So let's study together next ~
Catalog
1. IP The way of network data transmission
4. Implementation of multicast communication
1. IP The way of network data transmission
unicast (unicast)
Unicast is the communication between a single sender and a receiver through the network .
shortcoming : Bandwidth resources will be wasted due to repeated packets , The load of the source host will increase due to multiple data replication .
radio broadcast (broadcast)
Between the host “ A pair of all ” Of Communication mode , The network copies and forwards the signals sent by each host unconditionally , All hosts can receive all information ( Whether you need it or not ).
shortcoming : The information will be sent to the host that does not need the information, thus wasting bandwidth resources , Even caused a broadcast storm .
Multicast / multicast (multicast)
Between the host “ One on one ” Communication mode , That is, hosts that join the same group can accept all data in this group , Switches and routers in the network only copy and forward their required data to those who need it .
advantage : Improve the efficiency of data transmission , Reduce the possibility of congestion in the backbone network .
For a more vivid understanding, see the following figure :


The picture is from IP Multicast of three transmission modes - Tencent cloud developer community - Tencent cloud .
2. Multicast address
First, let's learn about five categories IP Division of address :
A Class address : First byte 0 start , rest 7 Bit is the network address , after 3 Bytes for host address .A The class address is from :1~126, The effective network number is 126, The number of valid hosts contained in each network number is 16,777,214.1.0.0.1~126.225.255.254,A Class is reserved for government agencies . A Private address and reserved address in class address : |
B Class address : First byte 10 start , front 2 Bytes are network addresses , after 2 Bytes for host address ,B The starting address of the class address is :128~191, The number of effective networks is 16,382 individual , The number of valid hosts contained in each network number is 65,531.128.0.0.1~191.255.255.254,B Class to medium-sized companies . B Private address and reserved address of class address : |
C Class address : First byte 110 start , front 3 Bytes are network addresses , after 1 Bytes for host address ,C The starting address of the class address is 192~223, The number of effective networks is 2,097,150 individual , The number of valid hosts contained in each network number is 254.192.0.0.1~223.255.255.254,C Class to anyone who needs it . C Private address in class address : |
D Class address : First byte 1110 start , Usually used for multicast or group addressing .224.0.0.0~239.255.255.255,D Class for multicast . D Class address is not divided into network address and host address |
| E Class address : First byte 11110 start , Experimental address , Reserved for future use .240.0.0.0~247.255.255.255,E Class for experiments , The number of addresses that can be accommodated by each type is different .E Class address is not divided into network address and host address |
IP The information of the address comes from Tell me about the five categories ip? What is the scope ?_zxa1334 The blog of -CSDN Blog _ The starting range of the first byte of various addresses
What we want to achieve is the function of in container multicast , So we need to use D Class address , About D The description of class address is as follows :

PS: You know, not all D Class address , Can be used as multicast address .
3. macvlan
macvlan Itself is linux Modules in the kernel , In essence, it is a network card virtualization technology , Its function is to allow virtual multiple network cards on the same physical network card , Through different MAC Address in the data link layer for network data forwarding .
One network card is configured with multiple MAC Address , That is, multiple interfaces , Each interface can configure its own IP Address .Docker Of macvlan The Internet is actually using Linux Provided macvlan Drive function .
Because of multiple MAC The network data packets of the address are transmitted from the same network card , Therefore, you need to turn on the hybrid mode of the network card .
( The above information comes from the link :https://www.jianshu.com/p/cc481870236b)
macvlan There are four modes , The classification is as follows :
bridge: Each sub device can communicate .
vepa: Each sub device cannot communicate directly ( You can communicate through switches that support port aggregation ), Can communicate with the outside .
private: and vepa Similar model , There is no communication between the sub devices , Even switches that support port aggregation cannot .
passthru: Will take over the parent device ( so ), The parent device cannot receive packets , And only one parent device is allowed macvlan equipment .
Subsequent tests docker-macvlan It uses bridge Pattern .
4. Implementation of multicast communication
data source : The physical machine where the multicast program is located is used as the data source , Send the data information to the multicast group address .
Multicast group : Set up multicast group ip, And forward the information sent by the data source to the multicast members .
Multicast group host : Generally speaking, the host in the multicast group and the data source host are in the same LAN , Multicast routers are needed in different networks .
Multicast classification :
Internet multicast : Multicast between routers ; involves IGMP agreement and Multicast routing protocol .
Hardware multicast : Multicast in subnet .
Concrete realization :
First, turn on the hybrid mode of the network card :
ip link set enp4s0 promisc on 
There are docker The driver created on the host of the environment is macvlan Network of :
docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.2 -o parent=enp4s0 macvlan190 -d : Drive type
--subnet: Subnet segment
--gateway: gateway
-o parent: Network card used
macvlan190: Created macvlan Name , You can set it yourself

Check the network :
docker network ls 
Run the required container in this macvlan On :
docker run -it -d --name mactest1 --net macvlan190 --ip 192.168.0.207 test1:v1--name: mactest1 Name of the container to start
--net: macvlan190 For the network used
--ip: 192.168.0.207 Container ip
test1:v1 Is the name of the local image package

Check out the Internet ping Communication ,macvlan Of ip unable ping Local ip, Sure ping Others of the same network segment ip: 
View multicast test results , Can receive multicast messages : 
边栏推荐
- Multithreading programming under Win32 API
- Use abp Zero builds a third-party login module (III): web side development
- Mysql database backup and recovery
- [datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization
- C # read Beckhoff variable
- R奇怪语法总结
- Brief tutorial of vbs script syntax (1)
- Scientific computing library numpy Foundation & Improvement (Understanding + explanation of important functions)
- 深度解析:2022年最火的商业模式链动2+1,是合法模式吗?
- C#读取倍福Beckhoff变量
猜你喜欢

Netease game Flink SQL platform practice
This is how the permission system is designed, yyds

The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market
![[reprint] pycharm packages.Py program as executable exe](/img/9c/02a967fb08ca54bb742cf69c4578a7.png)
[reprint] pycharm packages.Py program as executable exe

Bubble sort code implementation

Special episode of Goddess Festival | exclusive interview with Chinese AI goddess Zhang Qingqing's transformation from a female learning tyrant to a female entrepreneur

HTX00001_ Keil51 bug encountered in serial port parsing

NFT: how to improve rentable NFT (erc-4907)

百度希壤首场元宇宙拍卖落槌,陈丹青六幅版画作品全部成交!

labelme标注不同物体显示不同颜色以及批量转换
随机推荐
机器学习 Keras拟合正弦函数
DOM events
Openzeppelin scalable template library contract initialization details
【C语言】指针和数组的深入理解(第一期)
This is how the permission system is designed, yyds
VBS common built-in functions (2)
[jailhouse article] base architectures for virtual physical computing (2018)
Learning notes: detailed use of 12864 LCD module
【datawhale202207】强化学习:策略梯度和近端策略优化
Daily question brushing record (XXVIII)
C#开源控件MetroFramework Demo项目下载和运行
Typedef usage and template
Bubble sort code implementation
target_ compile_ features specified unknown feature “cxx_std_14“ for target
Easy to use code statistics tool
How to play a data mining game entry Edition
容器内组播
What determines the "personality" of AI robots?
Date (day 76)
函数模板学习记录