IP protocol format, IP address management, routing selection

Table of contents

1. IP protocol format

 16 bit total length

The ip protocol is aimed at the UCP protocol or TCP protocol of the transport layer. When transmitting, whether fragmentation transmission (unpacking transmission) is required

How to shard and combine shards

8-bit time-to-live:

8-bit protocol, 16-bit checksum, 32-bit source port, 32-bit destination port

2. IP address management

network number and host number

​edit

2.1 Early distribution method

Class A: 0 7-bit network number 24-bit host number

Type B: 10 14-bit network number 16-bit host number                                                               

Type C: 110 21-digit network number and 8-digit host number

Special ip address:

2.2 CIDR mode:

 Example one:

  Example 2:

private network ip

3. Routing

background knowledge:

 1. Know the WAN/LAN port 

2. Routing lookup rules

The premise of choosing a road is to know which roads are available.

 2.1 Rules


1. IP protocol format

 16 bit total length

There is a limit to the size of data transmitted at the data link layer: MTU

 Theoretically, a single ip data packet can be up to 65536 bytes, but the data link layer requires the network layer that a single data cannot exceed 1500 bytes, which directly leads to the unpacking of data packets exceeding 1500 bytes

The ip protocol is aimed at the UCP protocol or TCP protocol of the transport layer. When transmitting, whether fragmentation transmission (unpacking transmission) is required

First of all, we need to know: Whether to fragment or not depends on      the size of the data + after the ip protocol header, whether it exceeds the MTU

 The IP protocol is unreliable. If a fragment is lost in the network, the entire data is equivalent to being lost.

Because in order to ensure reliability, TCP guarantees that the data will not be fragmented , so that there is no need to retransmit all the data because a fragment is lost (this is very painful)

How to shard and combine shards

Fragmentation:

Combining shards

8-bit time-to-live:

8-bit protocol, 16-bit checksum, 32-bit source port, 32-bit destination port

 8-bit protocol: identifies what protocol the transport layer uses

                  Purpose: When the receiver parses the IP protocol, it knows which protocol the data should be handed over to the transport layer

16-bit checksum: check whether the IP protocol is distorted during transmission

32 bits:   source IP address

32 bits:   destination IP address

2. IP address management

network number and host number

2.1 Early distribution method

Class A: 0 7-bit network number 24-bit host number

    

Type B: 10 14-bit network number 16-bit host number                                                               

 

Type C: 110 21-digit network number and 8-digit host number

 

Special ip address:

127.0.0.1 : Local loopback address (self), usually used to test the local network protocol stack

0.0.0.0: Represents all network card addresses, when the server bind function is called, 0.0.0.0, binds all network cards of the current machine

2.2 CIDR mode:

1. The subnet mask is introduced, and the subnet mask is used to identify the IP address, the network number range and the host number range

2. The essence of the subnet mask: the integer of uint32_t

        Requirements: All bits from the highest bit to the lower bit must be 1 to be a valid subnet mask

Network number = ip address & subnet mask

 Maximum host number = ~(subnet mask)

 Example one:

The ip address is 42.192.83.143 and the subnet mask is 255.255.255.0
Question 1: What is the network number of this subnet? How many hosts does this subnet have?
Question 2: If the network is to be divided into 4 subnets, how many host numbers does each subnet have, and what is the network number of each subnet?

  Example 2:

private network ip

1. The private network ip does not have the effect of accessing the Internet (the source ip or destination ip in the data packet is a private network ip, then the data packet will not be transmitted in the network), and cannot access the Internet

2. The private network ip is in three segments

 3. The significance of the existence of private network ip

Private network IP can be reused in different subnets , and private network IP can be used to build a private network to alleviate the problem of IP address exhaustion

3. Routing

background knowledge:

1. When network data is transmitted in the network, the transmission path is not determined at the beginning

2. After arriving at a certain router (forwarding device), the router selects a suitable path

3. How big is the forwarding load of the next router?

We call the selection path of each device as routing

 1. Know the WAN/LAN port 

WAN port: connect to the upper-level router

LAN port: used to form the subnet of the middle router

2. Routing lookup rules

Routing lookup is to look up the route to the next host through the destination IP (determining the solution), how to choose a data link layer implementation (specific implementation)

1. To go from one point to another, you need to choose a suitable path, which is called routing (pathfinding)

2. The data link layer is responsible for the transmission between adjacent devices, and the data link layer is responsible for the transmission from host A to router A (on the road)

The premise of choosing a road is to know which roads are available.

The routing table holds multiple routes (multiple routes)

 2.1 Rules

 example:

 The transmission process of the IP data packet is the same as asking for directions .
          When the IP data packet arrives at the router, the router will first check the destination IP; the router
                        divides the obtained data and obtains the destination IP

The router decides whether the data packet can be sent directly to the target host or needs to be sent to the next router: repeat in turn until reaching the target IP address:

Now that we know which route to take, the work of how to go is handed over to the data link layer

Guess you like

Origin blog.csdn.net/flyingcloud6/article/details/128997773