9.3.3 Network principle (network layer IP)

1. Message:

1.4-digit version number: IPv4 and IPv6 (others may be lab versions).

2.4-bit header length: Same as TCP, variable length, with options, the unit is 4 bytes. 

3.8 bit service type 

4.16-bit total length: IP header + IP payload

The transport layer does not know the length of the payload, it needs to be calculated by the network layer.

IP packet - IP header = IP payload = TCP packet

TCP payload = IP payload (TCP packet) - TCP header

5. The 16-bit flag, the 3-bit flag and the 13-bit offset together indicate the process of unpacking and grouping the IP datagram.

16-bit identifier: The 16-bit identifier is the same for multiple packages that have been disassembled.

13-bit offset: to distinguish the sequence, the previous packet slice offset is small, and the latter one is large.

3 flag bits: one is not used, one indicates whether unpacking is allowed, and the last one indicates the end mark (0 indicates the last package).

6.8-bit time-to-live (TTL)

The unit is times,

There are initial values ​​(32/64/128),

Every time a route is forwarded, the TTL is reduced by 1,

Decrease to 0 (indicating that the target address does not exist) and discard

7.8-bit protocol: Which protocol is used by the transport layer (TCP/UDP/KCP...)

8. 16-bit header checksum: only need to check the IP header, and the payload part has its own checksum of the transport layer.

2. IP address

1. IP address: a 32-bit integer (4 bytes), using dotted decimal, using three dots to divide into four segments, each segment represents the size of a byte (8 bits) (0~255) (none symbol).

2. Three ways to deal with insufficient IP addresses:

a. Dynamic allocation of IP address (DHCP): IP is allocated if it needs to go online, otherwise it will not be allocated.

b. NAT mechanism (network address translation): IP addresses are divided into two categories: internal network IP and external network IP.

1) Intranet IP: cannot be repeated within a LAN.

10.*

172.16.* ~ 172.31.*

192.168.*

2) External network IP: cannot be repeated.

3) If you want to carry out network communication, you must have a device with an external network IP for transit. At this time, the NAT mechanism is involved. When the datagram reaches the router, the router will replace the original IP with its external network IP (intranet IP), the server does not know which host is communicating with itself, but only knows the external network IP of the router that sends the datagram (only the approximate range, not the specific device). For NAT devices (routers), trigger A mapping table is maintained during NAT.

4) Disadvantages of NAT:

a) Not very efficient.

b) very tedious.

c) It is inconvenient to access the devices in the LAN by yourself.

5) The advantages of NAT: pure software implementation.

c.IPv6:

1) IPv4: 4 bytes, 2^32 (4.19 billion).

2) IPv6: 16 bytes, 2^128.

3. Other knowledge points about IP address:

a. The composition of the IP address:

1) Network number:

2) Host number:

Regulations: In the same LAN, the network numbers must be the same, and the host numbers must be different. In different LANs, the network numbers must be different.

b. The distinction between the network number and the host number in the IP address:

Use the subnet mask to distinguish.

 

c. Special IP address:

1) Set all the host addresses in the IP address to 0, which becomes the network number, representing this local area network.

2) Set all host addresses in the IP address to 1, which becomes a broadcast address, which is used to send datagrams to all hosts connected to each other in the same link (only UDP can be used, TCP cannot be used).

3) The IP address of 127.* is used for the local loop back (loop back) test, usually 127.0.0.1.

4) The local machine return is mainly used for the network communication from the local machine to the local machine (the future performance of the system will not be transmitted through the network). For the development of network communication programs, the common development method is from the local machine to the local machine. Local network communication.

4. Routing selection:

Each router has a data structure inside, which is called a routing table. When the datagram arrives at the router, it needs to query the routing table (ask for directions). If it is found, it can continue forwarding directly in this direction. Give a default direction (next hop address), along the default direction, often go to the superior router.

 

Guess you like

Origin blog.csdn.net/m0_73345579/article/details/132273357