LVS-depth understanding of articles: network communication theory (a) the forwarding to route traffic between LANs

The purpose of writing this blog

LVSNetwork 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
  • LVSThe three operating modesNAT DR TUN
  • Build your own server LVS
  • Keepalived+ LVSImplemented HA
    wherein, 网络通讯the principle will be from the OSI7层模型start, the whole process introduces packet sent from the client to the server, including but not limited halfway TCP\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 Linuxopen-source software, but because of superior performance, after being Linuxadded to the kernel which has become a Linuxbuilt-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:

OSI seven-layer model
TCP / IP four-layer model
Corresponding network protocol
Application layer (Application)
Application layer
HTTP、TFTP, FTP, NFS, WAIS、SMTP
The presentation layer (the Presentation)
Telnet, Rlogin, SNMP, Gopher
Session layer (Session)
SMTP, DNS
Transport Layer (Transport)
Transport Layer
TCP, UDP
Network layer (Network)
Network layer
IP, ICMP, ARP, RARP, AKP, UUCP
Data Link Layer (Data Link)
data link layer
FDDI, Ethernet, Arpanet, PDN, SLIP, PPP
The physical layer (the Physical)
IEEE 802.1A, IEEE 802.2到IEEE 802.11

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, 目标IPand other information , hop in the routing data link layer encapsulation MACaddress information.
Packet format

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 Insert Picture Description
Here are a few terms:

  • Destination Network_IP_address
  • Gateway Gateway
  • GenmaskSubnet mask, *on behalf of a local area network, without having to jump.
    For example, if I want to access the IP 192.168.174.11of the machine, the router will take receipt of the request 192.168.174.11and the subnet mask to do 逻辑与arithmetic, the results and Destinationfor comparison, if the match was on, will be based on Gatewayongoing 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个路由器:
Network topology model
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.2machine 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:
Here Insert Picture Description
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 ARPthe agreement, I intend to tell it in detail in the next article.

Released five original articles · won praise 0 · Views 492

Guess you like

Origin blog.csdn.net/TheRainManFSA/article/details/105347252