Full hardware TCP/IP protocol stack study notes (second day: TCP/IP protocol learning 2)

Regarding the "network layer" of yesterday, the last point is that since the IP packet is sent in the Ethernet packet, we must know both addresses, one is the MAC address of the other party, and the other is the other party's. IP address. But under normal circumstances, the other party's IP address is known, but we do not know his MAC address. This is divided into two cases. In the first case, if the two hosts are not in the same subnet, there is actually no way to get the MAC address of the other party, and the packet can only be transmitted to the "gateway" at the two subnet connections. Let the gateway handle it.

In the second case, if the two hosts are on a subnet, then we can use the ARP protocol to get the MAC address of the other party. The ARP protocol also sends out a data packet containing the IP address of the host he wants to query. In the IP field of the other party, the FF:FF:FF:fFF:FF is filled, indicating that this is a "broadcast" address, where he is. Each host of the subnet receives this packet, extracts the IP address from it, and compares it with its own IP address. If the two are the same, respond to it and report your MAC address to the other party, otherwise discard the packet. With the ARP protocol, we can get the host MAC address in the same subnet, and send the packet to any host.

The IP protocol is the core of TCP/IP. All TCP, UDP, IMCP, and IGCP data are in IP data format. But IP is not a reliable protocol, which means that the IP protocol does not provide a mechanism for processing data that is not communicated. This is considered to be the upper layer protocol, so this is the emergence of TCP is a reliable protocol, and UDP is not so reliable.

There is an 8-bit Time to Live (TTL) field that specifies how many routes the packet will pass before being discarded. This proves that the IP protocol is unreliable and he cannot guarantee that the data will be delivered. Whenever an IP packet passes, the TTL value of the packet is reduced by 1. When the TTL of the packet becomes 0, it is discarded. The maximum value of this segment is 255, which means that a protocol packet will be discarded after 255 times in the router. The data is different depending on the system.

If the TTL (lifecycle) of the IP packet arrives, the IP packet is discarded.

Search the routing table to search for matching hosts first. If you can find the target host that is identical to the IP address, send the packet to the target host.

Search the routing table. If the matching host fails, it matches the router in the same subnet. This requires the assistance of "subnet mask (1.3.)". If a router is found, the packet is sent to the router.

Search the routing table. If the router matching the same subnet fails, match the router with the same network number (described in Chapter 1). If the router is found, send the packet to the router.

Search the land tour table, if all of the above fails, search for the default route, if the default route exists, then send the package

If it fails, just drop the package.

Since the IP protocol is not a reliable protocol, he cannot guarantee that the data will be delivered, and the work of ensuring data delivery should be done by other modules. One of the most important modules is the ICMP (Network Control Message) protocol. When an error occurs in the transmission of an IP packet, such as a host unreachable, a route unreachable, etc., ICMP will packet the error message and then pass it back to the host. Give the host a chance to handle the error, which is why the protocol built on the IP layer is safe. The ICMP packet consists of an 8-bit error type and a 16-bit parity bit.

Although in most cases, the wrong packet transmission should give an ICMP message, in special cases, no ICMP error message is generated. as follows

ICMP error packets do not generate ICMP error messages (out of IMCP query messages) (to prevent infinite generation and transmission of IMCP)

The destination address is an IP datagram of a broadcast address or a multicast address.

A datagram broadcast as a link layer.

Not the first piece of IP fragmentation.

The source address is not a single host's datagram. That is to say, the source address cannot be a zero address, a loopback address, a broadcast address, or a multicast address.

Although some of the provisions are not yet fully understood, all of these provisions are defined to prevent the infinite propagation of ICMP messages.

Seven. Transport layer

1. Origin: With the MAC address and IP address, we can already establish communication on any two hosts on the Internet. And when you are in multiple processes, many programs use the network, such as browsing the network while chatting with friends. When a packet is sent from the Internet, how do you know if it is the content of the network or the content of the online chat. Therefore, we also need a parameter to indicate which program the packet is used for. This parameter is called "port". It is actually the number of each NIC program. Each data is sent to the host's designated port, so different programs can get the data they need. "Port" is an integer between 0 and 65535, which is exactly 16 binary bits. The ports from 0 to 1023 are occupied by the system, and the user can only select ports larger than 1023. Whether browsing the web or chatting online, the app randomly selects a port and then contacts the corresponding port on the server.

The function of the "transport layer" is to establish "port-to-port" communication. In contrast, the network layer can only communicate from host to host. As long as we can determine the host and port, we can achieve communication between programs.

Therefore, the Unix system calls the host + port a "socket." With it, you can develop web applications.

2.UDP protocol

We must now add port information to the packet, which requires a new protocol. The simplest implementation is the UDP protocol. Its format is almost just the port number in front of the data.

UDP packets are also composed of two parts: "header" and "data". The header section mainly defines the outgoing port and the receiving port, and the "data" part is the specific content. The entire UDP packet is then placed in the data portion of the IP packet, and the IP packet is in the Ethernet packet, so the entire Ethernet packet now looks like this:

Specific agreement information we will continue tomorrow

Learning sea is boundless...

Enzyme Essence Liquid 4

1. Decomposition: biodegradable excess body fat, flat meat, all kinds of stone decomposition, promote the decomposition of food digestion and absorption.
2. Blood purification: Arrange internal environment, purify the blood and improve physical fitness - decomposition, eliminate waste, the blood becomes acid.
3. activation: the pituitary gland to stimulate cell regeneration, a recession is not easy to remember, can not afford to skin wrinkles, youthful beauty delay human aging.
4. Anti-inflammatory antibacterial effect: enzymes can strengthen the fight against white blood cells and remove invading bacteria and purulent matter, the cells speed recovery and enhance wound healing
5. hangover, hangover prevention.
6. For picky eaters, do not like to eat fruits and vegetables children the best nutritional supplements and energy sources.
It contains nutrients more easily absorbed by the body, containing amino acids, polysaccharides, protein components, vitamins B, C, E, and trace elements needed by the body. Long-term use, long-term preservation.

Enzyme Essence Liquid,Liquid Promote Digestion And Absorption,Orange Enzyme Liquid For Health

Ganzhou Green days Biochemical Technology Shower folder mechanic Co., Ltd. , https://www.tlqcjs.com