REVIEW
The purpose of writing this blog
LVS
Network knowledge more involved, so the article can not be explained entirely clear. This series of articles will talk in the following modules:
- Network communication theory
LVS
The three operating modesNAT
DR
TUN
- Build your own server LVS
Keepalived
+LVS
ImplementedHA
wherein,网络通讯
the principle will be from theOSI7层模型
start, the whole process introduces packet sent from the client to the server, including but not limited halfwayTCP\UDP
,ARP协议
,交换机
,路由器
and other knowledge. Well, here we go.
What is LVS
LVS(Linux Virtual Server)
It is the great God 章文嵩
an invention-based load balancer 4 network layer protocol, initially just an Linux
open-source software, but because of superior performance, after being Linux
added to the kernel which has become a Linux
built-in load balancing on an artifact.
Network 7-layer model / 4-layer model
The most common model is a seven-layer network model, from the application layer to the physical layer 应用层
are: 表示层
, 会话层
, 传输控制层
, 网络层
, 数据链路层
, 物理层
, . 4-layer model is also more streamlined version of the application layer, presentation layer, and session layer unified 应用层
, the data link layer and the physical layer is uniform 数据链路层
, the structure of each layer and the corresponding protocol as follows:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We know that the communications network is in the form of packets for transmission from the packet 应用层
-> 物理层
process is actually one-pack layer, such as charged in the application layer 请求头
, 请求体
and other information, encapsulated in the network layer 源IP
, 目标IP
and other information , hop in the routing data link layer encapsulation MAC
address information.
When we visited the site, the underlying exactly what has been done?
We first come to know one thing: 路由表
check the routing table command in Linux: route
Here are a few terms:
Destination
Network_IP_addressGateway
GatewayGenmask
Subnet mask,*
on behalf of a local area network, without having to jump.
For example, if I want to access the IP192.168.174.11
of the machine, the router will take receipt of the request192.168.174.11
and the subnet mask to do逻辑与
arithmetic, the results andDestination
for comparison, if the match was on, will be based onGateway
ongoing ip address forwarding.
We have a simple network topology model to show between the computer and the computer how to communicate, assume the following topology model of your home, there are network 2台计算机
and 1个路由器
:
We turn now to simulate 橙色主机
the 绿色主机
communication process, first by 橙色主机
initiating a packet A , data packet arrives at a router will take the destination IP routing table to do with their 逻辑与
operations:
192.168.174.11
255.255.255.0
--------------
192.168.174.0
We will find a very special route entry, its subnet mask 0.0.0.0
, he is our default route, it said, if can not find the target in the IP routing table, we will turn to send packets to IP as a 192.168.174.2
machine for processing.
After the operation, finding the target IP LAN, the router will throw the packet switch, the switch maintains an IP address and MAC address table corresponding to the data packet forwarded by the corresponding relationship between this layer. Specific process is as follows:
Thus, to complete the most simple local area network communication.
Switches are Layer 2 devices in the model, so do not switch IP address to open the packet forwarding do.
It internally maintains a mapping table mapping the LAN segment IP地址
and its corresponding port, which will be involved in ARP
the agreement, I intend to tell it in detail in the next article.