当前位置:网站首页>Ping principle
Ping principle
2022-07-29 06:49:00 【Flytiger1220】
I've read a lot of interview questions recently , Among them, I was also asked about ping And some principled things , So I read many people's blogs , Finally, it suddenly became clear , Decided to sum up , Also to prevent forgetting .
To understand ping Principle , Let's take a look first ARP The message format of 
among op:
1: Express arp request
2: Express arp The reply
3: Express rarp request
4: Express rarp The reply
Next , Let's take a look at the same broadcast domain ping message :
our host2 Want to go ping host1, So the mainframe 1 It is necessary to encapsulate the layer-2 message , First host2 Will check your MAC Address table , See if there is host1 The address of , without ,host2 It will send out ARP Broadcast packet
ARP The format of frame message is as follows :( omitted arp Hardware type of message , Upper protocol type ,MAC Address length ,IP Address length )
| Purpose MAC | Source MAC | The frame type | op | sender MAC | sender IP | The goal is MAC | The goal is IP |
|---|---|---|---|---|---|---|---|
| FF-FF-FF-FF-FF-FF | 52-54-00-00-11-22 | 0806 | 1 | 52-54-00-00-11-22 | 192.168.1.2 | 00-00-00-00-00-00 | 192.168.1.1 |
First , After our switch receives the message , Will inquire about the switch MAC Address table ( With learning function ), If there is host1 Of MAC Address , Direct return to host2; without , The switch will send to all ports ARP radio broadcast , After the host on other ports is found , If the goal is not yourself , Will discard the message ; until host1 After the host receives the message , Will respond host1 Of MAC What's the address , At the same time, learn the host host2 Of MAC Address , And follow the same format ARP The message is returned to host2.
host1 Back to ARP Frame message :
| Purpose MAC | Source MAC | The frame type | op | sender MAC | sender IP | The goal is MAC | The goal is IP |
|---|---|---|---|---|---|---|---|
| 52-54-00-00-11-22 | 52-54-00-00-11-11 | 0806 | 2 | 52-54-00-00-11-11 | 192.168.1.1 | 52-54-00-00-11-22 | 192.168.1.2 |
This is the time , host host2 I've learned that host1 Of MAC Address , So send icmp message
| Destination address | source address | … | Source IP | The goal is IP | … | ICMP message |
|---|---|---|---|---|---|---|
| 52-54-00-00-11-11 | 52-54-00-00-11-22 | 192.168.1.2 | 192.168.1.1 | Echo Request |
host1 After receiving the message , Hui Fu
| Destination address | source address | … | Source IP | The goal is IP | … | ICMP message |
|---|---|---|---|---|---|---|
| 52-54-00-00-11-22 | 52-54-00-00-11-11 | 192.168.1.1 | 192.168.1.2 | Echo Answer |
Next , Let's take a look at the differences between different broadcast domains ping
First of all, ensure that the whole network can reach !!!
If our host2 Still want to ping host ,host2 You have to go to the gateway to forward , But if you say , What if it doesn't know the gateway ? It will look like ping host1 like that , Send... First ARP message , Determine the gateway mac And then send icmp Send the message to the router .
We omit arp message
host2 send out ICMP Message to gateway
| Destination address | source address | … | Source IP | The goal is IP | … | ICMP message |
|---|---|---|---|---|---|---|
| 52-54-00-00-11-33 | 52-54-00-00-11-22 | 192.168.1.2 | 192.168.2.1 | Echo Request |
When the router receives a message from host2 Of icmp After the message , Find the destination address IP by 192.168.2.1, Query route discovery , We have to find an interface to go out , So get rid of the original mac Address header , Add your own mac Address header and to host3 forward ,( If there is no gateway host3 Of mac, Also have to send ARP Message inquiry , And the port of the router can also learn from the host mac Address , host host3 Can also learn router MAC Address ), The specific message is as follows :
| Destination address | source address | … | Source IP | The goal is IP | … | ICMP message |
|---|---|---|---|---|---|---|
| 52-54-00-00-11-55 | 52-54-00-00-11-44 | 192.168.1.2 | 192.168.2.1 | Echo Request |
host host3 I have learned about routers mac, This will return icmp message
| Destination address | source address | … | Source IP | The goal is IP | … | ICMP message |
|---|---|---|---|---|---|---|
| 52-54-00-00-11-44 | 52-54-00-00-11-55 | 192.168.2.1 | 192.168.1.2 | Echo Answer |
边栏推荐
- Tcp/ip 五层参考模型以及对应的典型设备以及ipv6
- Hongke automation SoftPLC | Hongke kPa modk operation environment and construction steps (3) -- modk routine test
- Using STP spanning tree protocol to solve the problem of two-layer loop in network
- CNN-卷积神经网络
- IPv6 representation and configuration cases
- Solve the error that the simulation output is STX under the frequency division module Modelsim
- Instant 新日期类的使用 API
- Understand the great changes of network security in five years
- Use of callable
- Instruction rearrangement under multithreading concurrency
猜你喜欢

day02_ Basic grammar

【冷冻电镜|论文阅读】A feature-guided, focused 3D signal permutation method for subtomogram averaging

MySQL 事物四种隔离级别分析

4、 LAN and man

Hongke solution | a unique solution to realize seamless integration at low cost in Digital Substations

Shallow reading of shared lock source code of abstractqueuedsynchronizer (AQS)

How to use SFTP command to access SFTP server on the development board

Huawei switch ce12808 import and export configuration file

Complex floating point division of vivado IP core floating point

Hongke case | PAC: an integrated control solution integrating SoftPLC control logic, HMI and other service functions
随机推荐
Use of callable
TCP based online dictionary
How to pre circumvent the vulnerabilities of unsafe third-party components?
Multithreaded server programming
Is it OK to directly compare the size of two numbers in FPGA?
失效的访问控制
Instruction rearrangement under multithreading concurrency
Ansible(自动化软件)
矩阵分解与梯度下降
【干货备忘】50种Matplotlib科研论文绘图合集,含代码实现
apisix健康检查测试
Those vulnerability attacks on app
The difference between DDoS attack and CC attack
Hongke will share the EtherCAT demo for you and teach you how to quickly transition from other protocols to EtherCAT industrial bus
Floating point addition and subtraction method of vivado IP core floating point
【笔记】The art of research - (讲好故事和论点)
Understanding of access, hybrid and trunk modes
ss命令详解
案例补充、ATM
etcd原理