Datagram Forwarding (Multi-network routing)

Source: Internet
Author: User

 

Let's talk about Data encapsulation:
Data is transmitted down from the application layer. When it is transmitted to the network layer, an IP datagram is added, which indicates the source address and destination address of the data.
The source address and destination address are the data source address from the beginning to the final destination address.
The Network Layer encapsulates the IP datagram, and then the link encapsulates the above data layer into a frame, which indicates SRC and desc. Note: SRC and desc
It is also an address, but it refers to the Mac physical address. Data is sent in frame format, so the SRC and desc encapsulated in the frame
Is the real path of data transmission, but this path is not necessarily from the source IP to the final destination IP, because it is related to multiple networks
Data forwarding.
So in general, the source IP address and destination IP address encapsulated in the IP datagram are the starting point and destination of data transmission, and they may not necessarily arrive,
The SRC and desc encapsulated in the frame are the current routes to reach the destination IP address, and the DESC may not necessarily reach the destination.
It can only be reached after numerous forwarding

 

The following describes how to forward data in multiple networks.

Case:
Lan1
PC1 IP: 192.168.1.2 Mac: 000b. be06.4ac1

Router1
Interface 1: IP: 192.168.1.1 Mac: 000b. be36.8d86 (connect LAN lan1)
Interface 2: IP Address: 192.168.12.1 (connect to lan2)

Lan2
PC2 IP: 192.168.3.2 MACOs: 0001. c934.e830

Router2
Interface 1: IP: 192.168.3.1 Mac: 00e0. 8fd1. 1957 (connect LAN lan2)
Interface 2: IP: 192.168.12.2 (connect to lan1)

The above two local networks are connected through two routers, router1 and router2. Let's take a look at the process in which pC1 in lan1 sends data to pc2.

1. pC1 forms an IP datagram at the network layer, which encapsulates the starting address: 192.168.1.2 and the ending address: 192.168.3.1.
2. IP data is encapsulated into data frames at the link layer, which indicates SRC: 000b. be06.4ac1 (pC1 Mac) Desc: 000b. be36.8d86 (router1 interface 1mac)
Because the source address and destination address in the IP datagram are not in the same network, the destination address cannot be directly encapsulated into the frame, and must be converted
The corresponding network, so we need to send the data to the router first, because the data is sent according to the address line in the data frame, so DESC is connected to the router
MAC address of the LAN
3. When the router receives data, It queries the route table of the Router Based on the destination IP address in the IP datagram. If the destination network in the same network as the destination IP address, the data
Send to the next hop Network, go to the vro of the next hop Network, find the path table, and then continue forwarding
...........

4. Finally, find the last IP address, 192.168.3.0, and the network where the destination address is located. Then modify the data frame, because the data is sent from the router of router2.
So the SRC of the data frame is: 00e0. 8fd1. 1957. Who is the destination address ????
Let's think about it. Now it is in a LAN. Next, you need to find the host whose IP address is 192.168.3.2 in this lan, and then set the data
In the past, because frame-based data transmission is used, we need to know the MAC address of the target host, and how can we know its MAC address? Hey .. Remember.
This is not the ARP (Address Resolution Protocol) we learned. In router2, we first send ARP, find the Mac, encapsulate the Mac into frames, and then send data.
5. If data is received successfully, a message is returned.

This is a simple model with developed data in multiple networks,
The IP datagram only records the source IP address and destination IP address in the header, and does not have the IP address of the intermediate route. When the router receives a group to be forwarded, it finds it in the route table.
The IP address of the next hop router is not entered in the IP datagram, but sent to the lower-layer network interface software.
Replace the IP address of the router with the hardware address (using ARP), place the hardware address in the MAC frame header of the connection layer, and find the next hop route based on the hardware address.

Remember: as long as the source IP address and destination IP address are not in the same network, you must first send the data to the vro, encapsulate the MAC address of the vromac into DESC, and then forward the data according to the route table,
If no record of the same network as the IP address is found in the routing table, the next hop is developed according to the default route. The default route is 0.0.0.0, which masks
The code is 0.0.0.0, And the next hop of the default route can be specified arbitrarily
If the matched network does not have the next hop address, the data will return to the original network.

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.