The ID field of the IP header is used to identify different packets (instead of fragments, all parts of a packet have the same ID)
This field only occupies 16 bits, so it will be quickly bypassed on a fast network, which may cause confusion in IP packet recognition by the protocol stack.
The Linux kernel adopts a policy to speed down the loop.
Instead of using the global ID variable, each IP address uses a separate counter to calculate its ID,
However, there are a lot of IP addresses, and the memory will soon be full if you are not clear about it for a long time,
Therefore, set a global timer peer_periodic_timer and call the peer_check_expire function regularly,
It is timed, but it is not so punctual. The first time is generally set to inet_peer_gc_maxtime (2 minutes) and then add or subtract a random value.
Unli says this is to prevent conflict with other timers started at startup.
In the future, the reset time is not a set value. Instead, it is determined that the number of inet_peer changes from 10 seconds to 120 seconds,
The larger the number of inet_peers, the shorter the expiration time, which is easy to understand. The heavier the load, the more frequent the cleaning.
In the peer_check_expire function, a certain number of peers are deleted based on the load.
If the number of peers is greater than inet_peer_threshold, the unused Number of peers that have exceeded inet_peer_minttl (120 s) will be deleted.
Otherwise, delete the peer with a value greater than one of inet_peer_minttl to inet_peer_maxttl (10 min) based on the load.
Generally, not all objects are deleted, but 1Hz is run. How much is deleted,
The delete operation is completed by calling cleanup_once. It accepts a parameter n, which indicates that a peer with an unused time greater than N is deleted, and only one
If not cleared after 1Hz, set the garbage collection timer to the minimum value of 10 seconds and then clean again
Otherwise, it is also set to the value between 10 S and S.
It is possible to add Peer Points:
1. constructor is called when you create an inet_frag_queue in ip_defrag. for IPv4, ip4_frag_init is used,
In this example, inet_getpeer (Arg-> IPH-> saddr, 1) is called ).
2. When ip_select_ident is called to select an ID for the outbound packet, If the destination IP address of the packet is not in the peers,
Rt_bind_peer (RT, 1); call to create a peer and bind it with rtable.
3. functions such as tcp_v4_remember_stamp also call rt_bind_peer or call inet_getpeer directly,
I do not know what these functions are for the moment.