当前位置:网站首页>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 : 
边栏推荐
- Use abp Zero builds a third-party login module (4): wechat applet development
- [unity3d] ugui callback function
- Cout format output common functions and flags summary
- R奇怪语法总结
- Temperature table lookup and calculation formula
- C#读取倍福Beckhoff变量
- Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
- Download and run the C open source control metroframework demo project
- C language -c51 compilation warning "* * * warning l1: unresolved external symbol" and extern
- Design of automatic machine dot drawing script based on C language
猜你喜欢

Brief introduction of acoustic filter Market
![[datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization](/img/4e/aabc603e47977503a4bcc5d07b4c61.png)
[datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization

R奇怪语法总结
![[reprint] pycharm packages.Py program as executable exe](/img/9c/02a967fb08ca54bb742cf69c4578a7.png)
[reprint] pycharm packages.Py program as executable exe

你了解PowerBI中的去年同期吗

Mlx90640 infrared thermal imager temperature measurement module development notes (I)

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

SAP FICO section III BDC and ltmc import S4 financial account
![[sword finger offer] analog implementation ATOI](/img/01/76a3b1fcc6403368a363146d553777.png)
[sword finger offer] analog implementation ATOI

Req.body in node.express is always undefind
随机推荐
[jailhouse article] base architectures for virtual physical computing (2018)
[Luogu p6629] string (runs) (tree array)
Common API of window
健康打卡每日提醒累了?那就让自动化帮你---HiFlow,应用连接自动化助手
Bug notes
Prevention strategy of Chang'an chain Shuanghua transaction
[C language] program environment and preprocessing
Use of golang exec.command
JZ7 rebuild binary tree
[node] the service port is occupied error: listen eaddinuse: address already in use::: 9000- how to close the port started by node
“蔚来杯“2022牛客暑期多校训练营2 Link with Game Glitch (spfa找正负环)
Function template learning record
[datawhale202207] reinforcement learning: the foundation of reinforcement learning
Jstat command summary [easy to understand]
Analysis of the calling principle of Changan chain solid smart contract
Koa2 learning
[QT] solve the problem of Chinese garbled code output from QT console
【C】 Program environment and pretreatment
Shell script realizes the scheduled backup of MySQL database on two computers
Use abp Zero builds a third-party login module (III): web side development