A method and server for processing a packet

By identifying and updating UDP entries in the NAT mapping flow table on the server side, the problem of UDP session drop caused by NAT device aging is solved. By receiving UDP service packets, determining whether there are matching session entries in the NAT mapping flow table, and updating the NAT mapping flow table, the problem of abnormal communication between the terminal and the server is solved, and the stability and effectiveness of communication are achieved.

CN115499481BActive Publication Date: 2025-12-05NEW H3C TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211050029.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-30
Publication Date
2025-12-05
Estimated Expiration
2042-08-30

AI Technical Summary

Technical Problem

Due to the problem of abnormal communication between the terminal and the server caused by the aging of NAT devices in handling UDP sessions, existing technologies cannot effectively identify and update the NAT mapping flow table, resulting in the dropping of UDP sessions.

Method used

The server receives UDP service packets through the NAT device, determines whether there is a matching session entry in the NAT mapping flow table, and if not, sends a session identification request to the target terminal, updates the session entry of the target terminal in the NAT mapping flow table, carries attribute information for differentiation, and establishes a UDP session if necessary.

Benefits of technology

Effectively identify target terminals, prevent UDP session drop, ensure normal communication, and optimize communication stability by adjusting keep-alive time parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115499481B_ABST
    Figure CN115499481B_ABST
Patent Text Reader

Abstract

The specification provides a method and a server for processing a packet, the method comprising: receiving, by a server, a target UDP service packet through a NAT device; judging whether a session item matching the target UDP service packet exists in a NAT mapping flow table; if not, sending a session identification request to a target terminal sending the target UDP service packet; and updating a session item corresponding to the target terminal in the NAT mapping flow table according to feedback information sent by the target terminal in response to the session identification request. Through the method, the problem of abnormal communication between a terminal and a server caused by aging of a NAT device in processing a UDP session can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the field of communication technology, and in particular, to a method for processing a packet and a server. BACKGROUND

[0002] UDP: User Datagram Protocol, a connectionless transport protocol supported by the Internet protocol set.

[0003] NAT, Network Address Translation.

[0004] NAPT, Network Address Port Translation.

[0005] NAPT technology is a widely used technology in the world today. NAPT is a type of NAT technology. When a local area network has only one or two public network exit IPs, and internal clients or devices need to access external devices or services, NAPT technology needs to be used. For example, as shown in the following table, when a NAT device receives a UDP session packet from Client1 IP1: PortA to Server IP4: PortE, it will detect the NAT mapping flow table. If there is no session table item in the flow table, it is considered to be the first packet. The NAT device adds an IP1: PortA→IP4: PortE UDP mapping to IP3: PortC→IP4: PortE UDP in the NAT mapping table. If there is already a session table item in the flow table, it will be directly forwarded according to the existing table item. Figure 1

[0006] The Server continuously monitors the service port IP4: PortE. When a new session of IP3: PortC→IP4: PortE UDP is received, a new session table item is added in the session table of the Server. SUMMARY

[0007] The embodiments of the present disclosure provide a method for processing a packet and a server. The method can solve the problem of abnormal communication between a terminal and a server caused by the aging processing of a NAT device for a UDP session.

[0008] The embodiments of the present disclosure provide a method for processing a packet, which comprises the following steps.

[0009] The Server receives a target UDP service packet through a NAT device.

[0010] It is judged whether there is a session item matching the target UDP service packet in a NAT mapping flow table. ​

[0011] If not, a session identification request is sent to the target terminal sending the target UDP service message;

[0012] According to feedback information sent by the target terminal for the session identification request, a session item corresponding to the target terminal in the NAT mapping flow table is updated.

[0013] The session identification request carries attribute information for distinguishing terminals.

[0014] Optionally, if there is no session item matching the target UDP service message in the NAT mapping flow table, the method further comprises:

[0015] It is judged whether the target UDP message is a newly established session establishment request;

[0016] If so, a UDP session is established according to the newly established session establishment request.

[0017] The session identification request includes one or more combinations of the following: MAC, SN number, identifier, IP:Port information of the terminal in the request, and session token information.

[0018] According to the feedback information sent by the target terminal for the session identification request, the session item corresponding to the target terminal in the NAT mapping flow table is updated.

[0019] Attribute information of the target terminal carried in the feedback information is obtained.

[0020] It is judged whether there is a target session item matching the attribute information in the NAT mapping flow table.

[0021] If so, the session item corresponding to the target terminal in the NAT mapping flow table is updated.

[0022] Optionally, after updating the session item corresponding to the target terminal in the NAT mapping flow table, the method further comprises:

[0023] After updating the NAT mapping flow table, NAT traversal change information is sent to the target terminal to inform the target terminal that the session item from the NAT to the server has changed.

[0024] Optionally, after updating the session item corresponding to the target terminal in the NAT mapping flow table, the method further comprises:

[0025] The time interval for sending keep-alive messages between the target terminal and the server is shortened.

[0026] Through the above embodiments, after the server identifies the unknown UDP service message, the server can identify whether the target terminal is a legal terminal (whether the target terminal matches the terminal in the NAT mapping flow table) by sending a session identification request to the target terminal sending the UDP service message, and if so, the unknown UDP service message can be processed to prevent the problem of abnormal communication between the terminal and the server due to the aging processing of the NAT device on the UDP session.

[0027] The present disclosure also provides a server, which comprises:

[0028] a receiving module configured to receive a target UDP service message through a NAT device;

[0029] a judging module configured to judge whether there is a session item matching the target UDP service message in a NAT mapping flow table;

[0030] a sending module configured to send a session identification request to a target terminal sending the target UDP service message when the judging module judges that there is no matching session item;

[0031] a processing module configured to update a session item corresponding to the target terminal in the NAT mapping flow table according to feedback information sent by the target terminal in response to the session identification request;

[0032] The session identification request carries attribute information used to distinguish between terminals.

[0033] The processing module is specifically configured to acquire attribute information of the target terminal carried in the feedback information, judge whether there is a target session item matching the attribute information in the NAT mapping flow table, and update the session item corresponding to the target terminal in the NAT mapping flow table if there is.

[0034] Optionally, the sending module is further configured to send NAT traversal change information to the target terminal after updating the NAT mapping flow table, to inform the target terminal that the session item from the NAT to the server has changed.

[0035] Optionally, the processing module is further configured to shorten the time interval for sending keep-alive messages between the target terminal and the server after updating the session item corresponding to the target terminal in the NAT mapping flow table. BRIEF DESCRIPTION OF DRAWINGS

[0036] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present specification and, together with the description, further serve to explain the principles of the present specification.

[0037] Figure 1 A network architecture diagram is provided for the embodiments of the present disclosure.

[0038] Figure 2 A method for processing a packet is provided in the embodiments of the present disclosure. DETAILED DESCRIPTION

[0039] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The description of the exemplary embodiments is intended to apply to various alternative embodiments as well. The following description is not limited to the exemplary embodiments, but rather, is applicable to any apparatus and method consistent with the present disclosure. The following description is presented for purposes of clarity and explanation only and is not intended to limit the scope of the exemplary embodiments as broader examples can be devised that fall within the scope of the exemplary embodiments.

[0040] The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting thereof. As used in the description of the embodiments and the appended claims, the singular forms "a", "an" and "the" are intended to include plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0041] It will be understood that, although the terms first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used only as distinguishable identifiers, for example, to identify different types of information. For example, a first information can also be termed a second information, and similarly, a second information can also be termed a first information, without departing from the scope of the present disclosure. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining" or "in response to a determination".

[0042] Currently, due to the limited resources of the NAT device, each session record will not be permanently saved, and the session will be subjected to a timing aging process, resulting in session invalidation.

[0043] As Figure 1As shown, when the NAT entry IP1:PortA→IP4:PortE UDP on the NAT device is aged and deleted, and the message of the IP1:portA→IP4:PortE UDP session of Client1 to Server is received again, a new NAT entry IP1:PortA→IP4:PortE UDP is established, which is mapped to IP5:PortH→IP4:PortE UDP. When the Server receives the message of IP5:PortH→IP4:PortE UDP, it is found that the message is not a new session message, nor a known session, and thus the Server may discard the message, resulting in abnormal session of the Client to the Server.

[0044] To solve the above technical problems, the embodiment of the disclosure provides a method for processing a message, as shown in the following formula: Figure 2 The method comprises the following steps:

[0045] S201, a server receives a target UDP service message through a NAT device;

[0046] S202, it is judged whether a session item matched with the target UDP service message exists in a NAT mapping flow table;

[0047] S203, if not, a session identification request is sent to a target terminal sending the target UDP service message;

[0048] S204, according to feedback information sent by the target terminal to the session identification request, a session item corresponding to the target terminal in the NAT mapping flow table is updated;

[0049] In the session identification request, attribute information for distinguishing terminals is carried.

[0050] In the embodiment, the terminal can be a Client, and the server can be a Server.

[0051] When the UDP session on the NAT device is aged and timed out, the target Client cannot directly perceive that the UDP session on the NAT device has been aged, and thus a new session process is not initiated. At this time, when the target Client sends a target UDP service message to the Server through the NAT device, the target UDP service message is processed according to the session process established with the Server before.

[0052] When the Server receives the target UDP service packet sent by the target Client, the Server identifies the UDP session. Since the session corresponding to the target Client in the NAT has changed (not the original session recorded in the Server), the Server identifies the target UDP service packet as an unknown UDP session.

[0053] Therefore, when the Server performs step S202, the Server finds no matching session item when matching the target UDP service packet with the NAT mapping flow table. The NAT mapping flow table is used for conversion between public and private network addresses, and stores public and private network address information, as well as attribute information (such as MAC, SN number, identifier, IP:Port information, and session token information) of the corresponding Client.

[0054] At this time, the Server can send a session identification request to the target Client through the NAT device. The session identification request can carry one or more combinations of the request instructions for the MAC, SN number, identifier, IP:Port information, and session token information of the terminal in the request.

[0055] After receiving the session identification request, the target Client sends feedback information to the Server according to the information obtained in the session identification request. The feedback information carries the terminal attribute information required by the Server.

[0056] The Server obtains the attribute information of the target terminal from the feedback information, and determines whether there is a target session item in the NAT mapping flow table that matches the attribute information. For example, the Server determines whether there is one or more combinations of the MAC, SN number, identifier, IP:Port information, and session token information of the target terminal carried by the target Client in the feedback information in the NAT mapping flow table.

[0057] If there is, the Server can confirm that the target terminal is legitimate (there is a session for the target terminal, but the session of the target terminal in the NAT device has aged), at which time the Server can identify the target terminal, update the session item corresponding to the target terminal in the NAT mapping flow table, and process the target UDP service packet.

[0058] In another case, when the Server identifies the unknown UDP service packet, the Server can further determine whether it is a newly established UDP session. If so, the Server can establish the UDP session according to the establishment process of the UDP session.

[0059] In the embodiment, when the Server updates the session item corresponding to the target terminal in the NAT mapping flow table, the Server can also send a notification to the target terminal, which is used to inform the target terminal of the NAT traversal change information, i.e., to inform the target terminal that the session to the Server through the NAT device has changed.

[0060] In the embodiment, the Client receives the NAT traversal change information informed by the Server, which indicates that the keep-alive time configured by the Client can be too large, resulting in aging of the session in the NAT, and the keep-alive time needs to be reasonably set to solve the problem of aging of the UDP session table in the NAT device. Therefore, the Client can intelligently adjust the UDP session keep-alive time according to the received NAT traversal change information, or trigger an alarm mechanism, for example, shorten the time interval for sending the keep-alive packet between the target terminal and the Server.

[0061] The embodiment provides a mechanism for adjusting and implementing, which is specifically as follows.

[0062] 1) To exclude interference and jitter, the Client only records, without modifying the UDP session keep-alive time parameter t1, when the Client receives the NAT traversal change information informed by the Server for the first three times within △T (△T = 3*t1, t1 is the current time keep-alive parameter of the Client).

[0063] 2) When the Client receives the NAT traversal change information informed by the Server for the fourth time, the Client considers that the current keep-alive time parameter is indeed too large, and adjusts the current UDP session keep-alive time by halving the current UDP session keep-alive time.

[0064] 3) When the Client receives the NAT traversal change information informed by the Server again, the Client continues to adjust the current UDP session keep-alive time by halving the current UDP session keep-alive time.

[0065] 4) If the Client does not receive the NAT traversal change information informed by the Server, the Client increases the keep-alive time by 1 s, until the Client receives the NAT traversal change information informed by the Server again, and then stops and reverts by 5 s, and then keeps the keep-alive time parameter unchanged.

[0066] To further illustrate the scheme in the disclosure, an example is further provided in the embodiment of the disclosure, which is specifically as follows.

[0067] In the initial state, the Client 1 accesses the UDP service of the Server through the NAT device for NAT processing, and the Server has saved the UDP service flow IP3:PortC→IP4:PortE of the Client 1 in the session table of the Server.

[0068] The session IP1:PortA→IP4:PortE of Client1 accessing Server on the NAT device is deleted from the NAT table item due to aging timeout or other abnormal reasons. The session IP1:PortA→IP4:PortE of Client1 accessing Server is remapped IP5:PortH→IP4:PortE by the NAT device again.

[0069] When the Server receives the new UDP service session IP5:PortH→IP4:PortE, it judges whether IP5:PortH is a newly established session establishment request, if yes, the service new flow process is entered; if not, the Server initiates a session identification request to IP5:PortH, and the session identification information includes but is not limited to: MAC, SN number, identifier, IP:Port information, session token information, etc. of the Client. After receiving the request of the Server, Client1 informs the Server of the session information. The Server compares and judges, and finds that IP5:PortH is the original IP3:PortC, so it migrates the complete session information of IP3:PortC in the service session table to IP5:PortH, and deletes the session record of IP3:PortC. At the same time, it informs Client1 that the UDP NAT traversal session on the NAT device has changed, and the informing information includes but is not limited to: NAT device identity information, session information before NAT traversal change, and session information after NAT traversal change. If the reply information received by the Server is not the known session information in the service session flow table, it is discarded.

[0070] As can be seen from the above embodiments, when the NAT traversal is caused by session aging in the NAT device, the Server can identify whether the Client is a legal (service-providing) terminal by sending a session identification request to the Client, if yes, the unknown session sent by the terminal can be processed, and the situation of discarding the UDP packet sent by the Client due to the aging of the session in the NAT device is avoided.

[0071] Based on the above method embodiments, the present embodiment also provides a server, which comprises:

[0072] A receiving module is configured to receive a target UDP service packet through a NAT device;

[0073] A judging module is configured to judge whether there is a session item matching the target UDP service packet in a NAT mapping flow table;

[0074] The sending module sends a session identification request to the target terminal sending the target UDP service message when the judging module judges that there is no matched session item.

[0075] The processing module is configured to update a session item corresponding to the target terminal in the NAT mapping flow table according to feedback information sent by the target terminal in response to the session identification request.

[0076] The session identification request carries attribute information used to distinguish terminals.

[0077] The processing module is specifically configured to acquire attribute information of the target terminal carried in the feedback information, judge whether there is a target session item matching the attribute information in the NAT mapping flow table, and update the session item corresponding to the target terminal in the NAT mapping flow table if there is the target session item.

[0078] Optionally, the sending module is further configured to send NAT traversal change information to the target terminal after updating the NAT mapping flow table, so as to inform the target terminal that a session item from the NAT to the server has changed.

[0079] Optionally, the processing module is further configured to shorten a time interval for sending a keep-alive message between the target terminal and the server after updating the session item corresponding to the target terminal in the NAT mapping flow table.

[0080] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different than the order in the embodiments and still achieve the desired result. In addition, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous or possible.

[0081] Other embodiments of the present specification will be apparent to those skilled in the art after consideration of the specification and practice of the application disclosed herein. The specification is intended to cover any variations, uses or adaptations of the present specification following, in general, the principles of the present specification and including such departures from the present specification as come within the known and customary practice of the art to which the present specification pertains or the like. The specification is to be regarded as illustrative rather than restrictive, and the true scope and spirit of the present specification are indicated by the following claims.

[0082] It should be understood that the present specification is not limited to the precise construction that has been described above and shown in the accompanying drawings and that various modifications and changes can be effected therein by those skilled in the art without departing from the scope of the application. The scope of the application should be limited only by the appended claims.

[0083] The above description is only the preferred embodiment of the present specification, and is not intended to limit the present specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of protection of the present specification.

Claims

1. A method of processing a packet, the method comprising: The method comprises: The server receives a target UDP service message through a NAT device; It is judged whether there is a session item matching the target UDP service message in a NAT mapping flow table; If not, a session identification request is sent to a target terminal sending the target UDP service message; According to the feedback information sent by the target terminal in response to the session identification request, the session item corresponding to the target terminal in the NAT mapping flow table is updated; The session identification request carries attribute information for distinguishing each terminal.

2. The method of claim 1, wherein, If there is no session item matching the target UDP service message in the NAT mapping flow table, the method further comprises: It is judged whether the target UDP message is a newly established session establishment request; If so, a UDP session is established according to the newly established session establishment request.

3. The method of claim 1, wherein, The session identification request includes one or more combinations of the MAC, SN number, identifier, IP:Port information of the terminal in the request, and session token information.

4. The method of claim 1, wherein, According to the feedback information sent by the target terminal in response to the session identification request, the session item corresponding to the target terminal in the NAT mapping flow table is updated, which comprises: The attribute information of the target terminal carried in the feedback information is obtained; It is judged whether there is a target session item matching the attribute information in the NAT mapping flow table; If so, the session item corresponding to the target terminal in the NAT mapping flow table is updated.

5. The method of claim 1, wherein, After updating the session item corresponding to the target terminal in the NAT mapping flow table, the method further comprises: After updating the NAT mapping flow table, NAT traversal change information is sent to the target terminal to inform the target terminal that the session item from the NAT to the server has changed.

6. The method of claim 1, wherein, After updating the session item corresponding to the target terminal in the NAT mapping flow table, the method further comprises: The time interval for sending keep-alive messages between the target terminal and the server is shortened.

7. A server, characterized by The server comprises: A receiving module for receiving a target UDP service message through a NAT device; A judging module for judging whether there is a session item matching the target UDP service message in a NAT mapping flow table; A sending module for sending a session identification request to a target terminal sending the target UDP service message when the judging module judges that there is no matching session item; A processing module for updating the session item corresponding to the target terminal in the NAT mapping flow table according to the feedback information sent by the target terminal in response to the session identification request; The session identification request carries attribute information for distinguishing each terminal.

8. The server of claim 7, wherein The processing module is specifically configured to obtain the attribute information of the target terminal carried in the feedback information, judge whether there is a target session item matching the attribute information in the NAT mapping flow table, and update the session item corresponding to the target terminal in the NAT mapping flow table if there is.

9. The server of claim 7, wherein The sending module is further configured to send, after updating the NAT mapping flow table, NAT traversal change information to the target terminal, so as to inform the target terminal that the session item from the NAT to the server has changed.

10. The server of claim 7, wherein, The processing module is further configured to shorten a time interval for sending a keep-alive packet between the target terminal and the server after updating the session item corresponding to the target terminal in the NAT mapping flow table.

Citation Information

Patent Citations

  • Methods for managing a centralized network address translation session

    KR1020140146521A