Two or three-layer forwarding principle (ping process)

Source: Internet
Author: User

1. Overview

1, the switch Router,SW1,SW2 All the table entries are empty,Host 1 to Ping Host 2, that is, host 1 To send an ICMP echo request to host 2 ,when host 2 receives the request, it discovers that it is requesting its own IP address and will reply to the ICMP echo response messages.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/92/wKiom1XmvyayH__sAAB6l_Oiga4610.jpg "title=" 1.jpg " alt= "Wkiom1xmvyayh__saab6l_oiga4610.jpg"/>

Figure 1 network topology diagram

the IP address of Host 1 is 1.1.1.1/24, the default gateway is 1.1.1.254, andthe MAC address is ca02.1a14.0000;

the IP address for Host 2 is 2.2.2.2/24, the default gateway is 2.2.2.254, andthe MAC address is ca03.1a14.0000 ;

The IP address of the Router fa0/0 Port is 1.1.1.254/24, andthe MAC address is ca06.1b2c.0008;

The IP address of the Router FA0/1 Port is 2.2.2.254/24, andthe MAC address is ca06.1b2c.0006.

2. three-layer forwarding

2.1 ARP Request for Host 1

Host 1 will ICMP echo request packet, encapsulated to source ip< Span style= "font-family: ' The song Body '; The address is 1.1.1.1 Ip address is 2.2.2.1 Ip host1 route table, send the message ready to the Host 1 default gateway 1.1.1.254 Host 1 there is no default gateway for mac address, so Host 1 arp request.

Host 1 will source hardware address is ca02.1a14.0000, the source protocol address is 1.1.1.1, the destination hardware addresses populated 00:00:00:00:00:00, the destination protocol address is 1.1.1.254 ARP request, encapsulated at source mac address ca02.1a14.0000, destination mac address is FFFF.FFFF.FFFF Ethernet frame is emitted,as shown in 2.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/8F/wKioL1XmwL-y3r1-AANE7G6p4fI201.jpg "title=" 2.jpg " Width= "height=" 299 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:299PX; "alt=" Wkiol1xmwl-y3r1-aane7g6p4fi201.jpg "/>

Figure 2 ARP request

2.2 SW1 Learning MAC address

SW1 receives the frame broadcast and associates the ca02.1a14.0000 with the 1 port, adding to the MAC Address table.

ARP response of 2.3 Router

Router after receiving this frame, remove the two-layer package and view the arp The destination protocol address in the request is fa0/0 port address, which will send the response physical address as Ca06.1b2c.0008 Mac address ca02.1a14.0000 Ip address 1.1.1.1 Arp answer, encapsulated in source Mac Mac address is ca02.1a14.0000 3 as shown.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/92/wKiom1Xmvu3zqKvUAANaoPBd3pI906.jpg "title=" 3.jpg " Width= "height=" 277 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:277PX; "alt=" Wkiom1xmvu3zqkvuaanaopbd3pi906.jpg "/>

Figure 3 ARP response

also Router also deposits the physical address ca02.1a14.0000 with the IP address 1.1.1.1 into its own ARP table,as shown in 4 .

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/8F/wKioL1XmwVywnYA-AABwbbC-g18049.jpg "title=" 4.jpg " alt= "Wkiol1xmwvywnya-aabwbbc-g18049.jpg"/>


Figure 4 ARP table for Router

2.4 SW1 Learning MAC address

SW1 after receiving the frame, query the MAC Address table, send the frame from 1 ports, and associate the ca06.1b2c.0008 address with 2 port, add to mac The Address table.

2.5 ICMP echo request

After Host 1 receives an ARP reply sent by Router , the physical address is ca06.1b2c.0008 with the IP address 1.1.1.254 Deposit into your own ARP table, as shown in5 .

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/92/wKiom1Xmv2ChUxx-AABwDzSdKBU230.jpg "title=" 5.jpg " alt= "Wkiom1xmv2chuxx-aabwdzsdkbu230.jpg"/>

Figure 5 ARP table for Host 1

Host 1 will bring up the ICMP echo request, encapsulating the source mac address as ca02.1a14.0000, with the destination mac address ca06.1b2c.0008 data frame, sent to Router,shown in 6 .

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/92/wKiom1Xmv3miBWZGAANviGDtYfM386.jpg "title=" 6.jpg " Width= "height=" 277 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:277PX; "alt=" Wkiom1xmv3mibwzgaanvigdtyfm386.jpg "/>

Figure 6 ICMP echo request

Router 's fa0/0 receives the message, queries the routing table, andRouter sends the message to Host 2 from FA0/1. Since the FA0/1 port of Router does not have a 2.2.2.2 MAC address, the ARP request can only be made first .

ARP request for 2.6 Router

Router will be the source physical address of ca06.1b2c.0006, the source protocol address is 2.2.2.254, the purpose of thePhysical address to fill the full 0, the destination IP address is 2.2.2.2 ARP request, encapsulated at source mac address ca06.1b2c.0006, destination mac address is FFFF.FFFF.FFFF Ethernet frames are broadcast from the FA0/1 port.

2.7 SW2 Learning MAC address

SW2 receives the frame and then broadcasts the frame, associating the ca06.1b2c.0006 with the 1 port, adding to the MAC Address table.

2.8 Host 2 Arp reply

Host 2 received Arp After the request, the response will be Mac ip address 2.2.2.2 Mac address ca06.1b2c.0006< Span style= "font-family: ' The song Body '; The purpose Ip address 2.2.2.254 arp< Span style= "font-family: ' The song Body '; > answer, encapsulated in source mac address is Ca03.1a14.0000 mac address is Ca06.1b2c.0006 The Ethernet frame is emitted. The physical address is also ca06.1b2c.0006 and ip address 2.2.2.254 arp

2.9 SW2 Learning MAC address

after SW2 receives the frame, queries the Mac Address table, emits the frame from 2 , and associates the ca03.1a14.0000 address with the 1 port, adding to the Mac Address table.

After Router receives the ARP response from Host 2 , the physical address is ca06.1b2c.0006 with the IP address 2.2.2.254 Association, and join to the ARP table. At this point,Router forwarded the ICMP echo message just now to Host 2.

2.10 ICMP echo response

After host 2 receives the ICMP echo request sent by Host 1 , the Icmpecho reply is encapsulated in the source IP to 2.2.2.1, for thepurpose the IP address is 1.1.1.1 in the IP message, sent to Host 1.

Host 1 receives the ICMP echo response sent by Host 2 , and the ping process ends with7 .

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/8F/wKioL1XmwcSgxeZwAAO3E4XEsUg245.jpg "title=" 7.jpg " Width= "height=" 295 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:295px; "alt=" Wkiol1xmwcsgxezwaao3e4xesug245.jpg "/>

Figure 7 ICMP echo response

3. Related Message Formats

3.1 ARP Messages

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/8F/wKioL1XmwoCjd_q5AADQQHgs48c929.jpg "title=" Arpqq20150902172400.jpg "alt=" Wkiol1xmwocjd_q5aadqqhgs48c929.jpg "/>

which

Hardware type: Describes the hardware type information, as shown in the following table, length 2 bytes;

Type number

Hardware type

1

Ethernet

6

IEEE 802 Network

12

Local network

15

Frame Relay

16

Atm

17

Hdld

19

Asynchronous Transfer Mode

20

Serial Line

21st

Synchronous transfer Mode

protocol type: Describes the type of protocol to be mapped,0x0800 is the IP protocol, length 2 bytes;

Hardware Address Length:1 bytes;

protocol Address length:1 bytes;

Action: Description The ARP operation type,1 is the ARP request,2 is the arp reply, the length is 2 bytes;

3.2 ICMP echo message

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/92/wKiom1XmwJSBnUGfAAA4X4lN4Rs057.jpg "title=" Icmpqq20150902172421.jpg "alt=" Wkiom1xmwjsbnugfaaa4x4ln4rs057.jpg "/>

type:0x00 for echo response,0x08 for Echo request, 1 bytes in length ;

code:0x00, length 1 bytes;

Checksum:2 bytes;

identification number: randomly generated in the ping request,2 bytes;

Serial Number: Describes the request and the answer sequence, based on the previous +1,1 bytes.

This article from the "8133053" blog, reproduced please contact the author!

Two or three-layer forwarding principle (ping process)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.