WO2023045313A1 - Session establishment method and apparatus, and client device and computer storage medium - Google Patents

Session establishment method and apparatus, and client device and computer storage medium Download PDF

Info

Publication number
WO2023045313A1
WO2023045313A1 PCT/CN2022/087867 CN2022087867W WO2023045313A1 WO 2023045313 A1 WO2023045313 A1 WO 2023045313A1 CN 2022087867 W CN2022087867 W CN 2022087867W WO 2023045313 A1 WO2023045313 A1 WO 2023045313A1
Authority
WO
WIPO (PCT)
Prior art keywords
session
address information
target
server
target address
Prior art date
Application number
PCT/CN2022/087867
Other languages
French (fr)
Chinese (zh)
Inventor
金勇�
Original Assignee
深圳市广和通无线通信软件有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市广和通无线通信软件有限公司 filed Critical 深圳市广和通无线通信软件有限公司
Publication of WO2023045313A1 publication Critical patent/WO2023045313A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/11Allocation or use of connection identifiers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/19Connection re-establishment
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Definitions

  • the present application relates to the technical field of communications, and in particular to a method and device for establishing a session, a client device and a computer storage medium.
  • the LWM2M Lightweight Machine to Machine, lightweight M2M
  • the client device configured with the LWM2M client has the problem of excessive power consumption.
  • a method and device for establishing a session, a client device and a computer storage medium are provided, so as to reduce power consumption of the client device.
  • a method for establishing a session comprising:
  • the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
  • the session mapping information further includes a session establishment time, and the session establishment time is the last time when the server corresponding to the server address information successfully establishes a session;
  • the method also includes:
  • the judging whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the target address information at the current moment includes:
  • the time interval is less than or equal to the effective duration, confirm the session identifier corresponding to the target address information as the target session identifier.
  • the determining whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the target address information at the current moment further includes:
  • an initial handshake message is sent to the server, so that the server creates a new session.
  • the method further includes: when the server successfully restores the session corresponding to the target session identifier, acquiring the session establishment time of the current session;
  • the method further includes: when the session corresponding to the target session identifier fails to resume, deleting the session mapping information corresponding to the target session identifier.
  • the method further includes: when there is no session mapping information corresponding to the target address information in the stored session mapping information, sending an initial handshake message to the server, so that the server creates a new session;
  • corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
  • a device for establishing a session comprising:
  • a target address information acquisition module configured to acquire target address information of the server
  • a target session identification acquisition module configured to search stored session mapping information based on the target address information, and confirm the session identification corresponding to the target address information as the target session identification;
  • the session mapping information includes server address information and a session identifier corresponding to the server address information;
  • the session restoration module is configured to generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
  • the session mapping information also includes a session establishment time, and the session establishment time is the last time when a server corresponding to the server address information successfully establishes a session; the device further includes:
  • the time determination module is used to search in the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information;
  • the identification judging module is used to obtain the current time, and judge whether to confirm the session identification corresponding to the target address information as the target session identification according to the session establishment time corresponding to the current time and the target address information.
  • the identification judgment module includes:
  • the identification obtaining unit is used to obtain the time interval between the current moment and the session establishment time corresponding to the target address information; when the time interval is less than or equal to the effective duration, confirm the session identification corresponding to the target address information as the target session identification.
  • the identification judgment module also includes:
  • the initial handshake message sending unit is configured to send an initial handshake message to the server so that the server creates a new session when the time interval is greater than the effective duration.
  • the device also includes:
  • the session establishment time obtaining module is used to obtain the session establishment time of the current session when the server successfully restores the session corresponding to the target session identifier;
  • An update module configured to update the session establishment time corresponding to the target address information to the session establishment time of the current session.
  • the device also includes:
  • the deletion module is configured to delete the session mapping information corresponding to the target session ID when the session corresponding to the target session ID fails to recover.
  • the device also includes:
  • the session new module is used to send an initial handshake message to the server when there is no session mapping information corresponding to the target address information in the stored session mapping information, so that the server can create a new session;
  • the session mapping information establishing module is used for establishing and storing corresponding session mapping information according to the target address information and the session identifier of the newly created session when the session is successfully created.
  • a client device comprising a memory and a processor
  • the memory stores a computer program
  • the processor implements the following steps when executing the computer program:
  • the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
  • Fig. 1 is an application environment diagram of a session establishment method in an embodiment
  • Fig. 2 is one of the schematic flow diagrams of the method for establishing a session in an embodiment
  • Fig. 3 is a schematic flow chart of the target session identification acquisition step in one embodiment
  • FIG. 4 is a schematic flow chart of a session identifier judgment step in an embodiment
  • FIG. 5 is a second schematic flow diagram of a method for establishing a session in an embodiment
  • Fig. 6 is the third schematic flow chart of the method for establishing a session in an embodiment
  • FIG. 7 is a fourth schematic flow diagram of a method for establishing a session in an embodiment
  • Fig. 8 is a structural block diagram of a device for establishing a session in an embodiment.
  • the power consumption of a client device configured with an LWM2M client is too high during communication.
  • the inventor found that the reason for this problem is that in the process of establishing a session between the LWM2M client and the server each time, a complete handshake process is required between the LWM2M client and the server before it can be established, resulting in the configuration of the LWM2M client
  • the client device at the end needs to spend more data traffic and time during the session establishment process, thereby increasing the power consumption of the client device.
  • the client device may be a device having a communication function and configured with a communication protocol client.
  • the client device communicates with the server through the communication protocol, and then realizes data interaction.
  • any communication protocol can be configured on the client device, which is not limited in the present application, as long as the communication protocol can be used to realize the communication between the client device and the server.
  • the client device is configured with a client of the LWM2M protocol, and the client device communicates with the server through the LWM2M protocol.
  • the client device can obtain the target address information of the server; the client device searches the stored session mapping information based on the target address information, and confirms the session identifier corresponding to the target address information as the target session identifier; wherein, the session mapping information includes the server The address information and the session ID corresponding to the address information of the server; the client generates a handshake message according to the target session ID, and sends the handshake message to the server, so that the server restores the session corresponding to the target session ID.
  • the client device can be any form of communication device, such as a module, chip or circuit with communication functions, or a terminal device equipped with the aforementioned communication device, such as various types of narrowband Internet of Things devices, mobile phones, tablet computers, Notebook computers, smart cars, smart homes, etc., are not specifically limited in this application.
  • the client device is a 5G communication module.
  • the server can be implemented by an independent server or a server cluster composed of multiple servers.
  • a method for establishing a session is provided.
  • the method is applied to the client device in FIG. 1 as an example for illustration, including the following steps:
  • Step 200 acquiring target address information of the server.
  • the target address information refers to address information of a server used for exchanging application layer data with the client device.
  • the server corresponding to the target address information may be the server currently connected to the client device. It should be noted that the connection status between the client device and the server is not necessarily related to whether a session has been established. In other words, while the client device is connected to the server, there is a possibility that the session between the client device and the server has not yet been established.
  • the client device communicates with the server by obtaining destination address information.
  • the target address information may include one or more types of information used to indicate the server address, which is not specifically limited in this application.
  • the target address information may include the IP address and port of the server.
  • Step 300 Search the stored session mapping information based on the target address information, and confirm the session ID corresponding to the target address information as the target session ID; the session mapping information includes the server address information and the session ID corresponding to the server address information.
  • each set of session mapping information includes server address information and a session identifier corresponding to the server address information, and the session identifier can be based on the client device and the corresponding
  • the server address information is determined by the historical session establishment process between servers.
  • the session mapping information reflects the session corresponding to the session identifier once established between the client device and the server corresponding to the server address information.
  • the session mapping relationship stored by the client device may be dynamically adjusted according to the establishment of the session between the client device and the server, so as to improve the accuracy of the session mapping information.
  • the client device when the client device stores multiple sets of session mapping information, the content included in any two sets of session mapping information may be different, partially identical, or completely overlapped.
  • This application does not specifically limit this, as long as the session It only needs that the mapping information can reflect the mapping relationship between the server address information and the session identifier.
  • the server address information of any two sets of session mapping information can be the same or different; for multiple sets of session mapping information with the same server address information, the target session included in it The IDs can be the same or different.
  • the client device may search the stored session mapping information to determine whether there is a session identifier corresponding to the target address information, that is, the target session identifier. If the target session ID corresponding to the target address information is found, it indicates that a session has been established between the client device and the server, and the found session ID can be confirmed as the target session ID.
  • Step 400 Generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
  • the client device and the server need to perform a handshake process, so that the server can establish a session according to the handshake result.
  • the client device and the server may attempt to restore the session corresponding to the session identifier through a simplified handshake process.
  • a complete handshake process needs to be performed between the client device and the server, so as to realize the allocation, delivery and session establishment of the session ID.
  • the client device and the server may perform a handshake process based on any handshake protocol, which is not specifically limited in this application.
  • the client device and the server perform a handshake through a DTLS (Datagram Transport Layer Security, Datagram Transport Layer Security) protocol.
  • DTLS Datagram Transport Layer Security, Datagram Transport Layer Security
  • the client device After obtaining the target session ID, the client device generates a handshake message according to the target session ID, so that the handshake message includes the target session ID. After the client sends the handshake message, a brief handshake process is performed between the client and the server, so that the server restores the session corresponding to the target session representation and completes the session establishment process. After the session is established, data exchange at the application layer can be performed between the client device and the server.
  • the client device stores server address information and a session identifier corresponding to the server address information, that is, session mapping information.
  • the client device obtains the target address information of the server, it searches the stored session mapping information for the session ID corresponding to the target address information, and confirms the found session ID as the target session ID.
  • the client device can enable the server to restore the session corresponding to the target session identifier through a short handshake process, and complete the session establishment without having to perform a complete handshake process in each session establishment process, thereby reducing the verification during the session establishment process process, shorten the time consumption of the session establishment process, and reduce the data traffic consumption of the client device in this process, thereby reducing the power consumption of the client device.
  • the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session.
  • the session establishment method of the present application also includes:
  • Step 310 searching the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information;
  • Step 320 obtain the current time, and judge whether to confirm the session ID corresponding to the target address information as the target session ID according to the session establishment time corresponding to the current time and the target address information.
  • each set of session mapping information also includes a session establishment time, which is the last time when the client device successfully establishes a session with the server corresponding to the session mapping information.
  • the client device may query the stored session mapping information according to the target address information to determine whether there is session mapping information corresponding to the target address information. If it exists, the session establishment time corresponding to the target address information (hereinafter referred to as the target session establishment time) may be determined, that is, the last time when the client device successfully establishes a session with the server corresponding to the target address information.
  • the client device may determine whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the current time and the target session establishment time. If yes, confirm the session ID corresponding to the target address information as the target session ID, and execute step 400 . If not, a complete handshake process can be performed between the client device and the server to confirm a new session identifier and establish a session.
  • the present application may confirm the session ID corresponding to the target address information as the target session ID if the target session establishment time is earlier than the current time, otherwise, perform a complete handshake process. In this way, it is possible to prevent wrong session mapping information from interfering with the session establishment process, thereby improving the success rate of session establishment.
  • the application can determine the valid period of the session identifier according to the establishment time of the target session. If the current moment is within the valid period of the session identifier, then confirm the session identifier corresponding to the target address information as the target session identifier, otherwise perform a complete handshake process .
  • the session establishment time corresponding to the target address information at the current moment it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier, including:
  • Step 322 obtaining the time interval between the current moment and the session establishment moment corresponding to the target address information
  • step 324 if the time interval is less than or equal to the effective duration, confirm the session identifier corresponding to the target address information as the target session identifier.
  • the client device obtains the time interval between the current time and the target session establishment time, which is the time when the client device and the server corresponding to the target address information successfully established a session last time The difference from the current moment. If the time interval is less than or equal to the valid duration, it indicates that the session identifier corresponding to the target address information has a higher probability of remaining valid, and the server has a higher probability of being able to restore the session corresponding to the session identifier, so as to simplify the session establishment process. Therefore, the client device may confirm the session ID corresponding to the target address information as the target session ID, and execute step 400, so that the server restores the session corresponding to the target session ID.
  • the specific time length of the effective duration can be set according to factors such as the device type of the client device, the communication frequency between it and the server, and/or the update frequency of the session ID by the server, which is not specifically limited in this application.
  • the effective period may be 24 hours.
  • the client device when the time interval between the current moment and the target session establishment time is less than or equal to the effective duration, the client device confirms the session identifier corresponding to the target address information as the target session identifier, thereby avoiding the The resulting session recovery failure further improves the session recovery success rate and minimizes the time consumption, data flow consumption and power consumption of the session establishment process.
  • the session establishment time corresponding to the target address information at the current moment it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier, which also includes:
  • Step 326 when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
  • the client device when the time interval between the current time and the target session establishment time is greater than the effective duration, session recovery based on the session identifier corresponding to the target address information has a higher probability of failure, that is, the session corresponding to the session identifier cannot be restored. Therefore, when the time interval is greater than the effective duration, the client device generates an initial handshake message and sends the initial handshake message to the server, so that the server creates a new session. In this way, the client device performs a complete handshake process with the server, so that the server can re-determine the session ID and establish the session.
  • the length of the session identifier in the initial handshake message is zero, that is, the session identifier in the initial handshake message is empty.
  • a new session ID is determined through a complete handshake process instead of generating a handshake message based on the session ID corresponding to the target address information to perform a simplified handshake process.
  • the session restoration process with high failure rate can be avoided, and the success rate of session establishment can be further improved.
  • it can also reduce the average duration of the session establishment process, and further reduce the time consumption, data traffic consumption and power consumption of the client device.
  • the session establishment method also includes:
  • Step 500 when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session;
  • Step 600 Update the session establishment time corresponding to the target address information to the session establishment time of the current session.
  • the client device when the server successfully restores the session corresponding to the target session identifier, the client device obtains the session establishment time of the session (ie, the current session), and updates the session establishment time in the target mapping relationship.
  • the session establishment time can be determined according to the session recovery process corresponding to the target session identifier, which is not specifically limited in this application.
  • the session establishment time is the handshake completion time, that is, the time when the client device and the server complete the handshake process, so as to improve the accuracy of the session establishment time.
  • the same server address information corresponds to at most one set of session mapping information, in other words, no two sets of session mapping information with the same server address information are stored.
  • Each set of session mapping information will be dynamically updated along with the establishment of the session between the client device and the server, such as updating the session establishment time and/or session identifier.
  • the amount of stored data can be reduced, thereby reducing the hardware requirements of the client device and broadening the applicability.
  • the accuracy and validity of the session mapping information can also be improved, so as to improve the query efficiency and session recovery success rate, and further reduce the power consumption of the client device.
  • the session establishment time of the current session is updated to the session establishment time, thereby improving the validity and accuracy of the session mapping information and further reducing the client device's time in the session establishment process. power consumption.
  • the method for establishing a session further includes: if the session corresponding to the target session identifier fails to resume, the client device deletes the session mapping information corresponding to the target session identifier. Specifically, the client device generates a handshake message based on the target session ID, and sends the handshake message to the server, so that the server attempts to restore the session corresponding to the target session ID. If the session recovery fails, the client device deletes the session mapping information corresponding to the target session identifier stored therein. Further, after the session recovery fails, the client device can also perform a complete handshake process with the server to determine a new session identifier and establish a session.
  • the client device when the session recovery corresponding to the target session ID fails, deletes the session mapping information corresponding to the target session ID, which can not only reduce the amount of stored data, but also avoid the interference of invalid information on the session establishment process. Further improve the efficiency of session establishment.
  • the session establishment method also includes:
  • Step 700 when there is no session mapping information corresponding to the target address information in the stored session mapping information, an initial handshake message is sent to the server, so that the server creates a new session;
  • Step 800 when a new session is successfully created, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
  • the client device sends initial handshake information to the server. In this way, the client device performs a complete handshake process with the server to determine the session ID and establish a new session.
  • the client device When the session is successfully established, the client device generates corresponding session mapping information according to the target address information and the session identifier of the newly created session, and stores the session mapping information for use in the next session establishment process. In this way, the corresponding session can be restored in the subsequent session establishment process, reducing the time consumption, data flow consumption and power consumption in the session establishment process.
  • a method for establishing a session is provided, the method is applied to a client device, and specifically includes:
  • step 902 the client device initiates a connection to the server, and obtains target address information of the server. It should be noted that, during multiple connections, the client device may connect to the same or different servers, which is not specifically limited in this application.
  • Step 904 the client device searches the stored session mapping information to determine whether there is target session mapping information corresponding to the target address information, if not, go to step 906 , if yes, go to step 914 .
  • Step 906 the client device sends an initial CLINET HELLO message to the server, and performs a complete DTLS handshake process with the server.
  • the session identification length of the initial CLINET HELLO message is zero, and the session identification is empty.
  • Step 908 judge whether the DTLS handshake is successful, if not, go to step 906, if yes, go to step 910.
  • Step 910 Obtain the session ID of the new session and the handshake completion time, generate target address information, the session ID of the new session, and the session mapping information of the handshake completion time, and store them.
  • Step 912 the client device exchanges application layer data with the server.
  • Step 914 judging whether the distance from the current time to the session establishment time of the target session mapping information exceeds the effective duration, if yes, go to step 906 , if not, go to step 916 .
  • Step 916 the client device generates a target CLIENT HELLO message based on the session identifier of the target session mapping information, and sends the target CLIENT HELLO message to the server.
  • the target CLIENT HELLO message includes the session identifier of the target session mapping information.
  • the client device and the server perform a short handshake process, so that the server attempts to restore the session corresponding to the session identifier of the target session mapping information.
  • Step 918 judge whether the DTLS handshake is successful, if not, go to step 920, if yes, go to step 922.
  • Step 920 the client device deletes the target session mapping information, and enters step 904 to re-initiate the handshake process.
  • Step 922 the client device obtains the session establishment time of the current session, and updates the session establishment time in the target session mapping information to the session establishment time of the current session.
  • the LWMM client is started and connected to the server.
  • the client device After connecting, the client device initiates the CLIENT HELLO message packaging and sending process in the DTLS handshake process. Specifically, the client device queries the cached session mapping information according to the server address information and port of the server, and judges whether to establish the session through the session recovery process or the session creation process according to the query result.
  • the client device and the server perform a complete DTLS handshake process, and store the session ID of the new session, the handshake completion time of the new session, server IP address and port after the handshake is successful. If there is target session mapping information in the client device, it is judged whether the time interval between the current moment and the session establishment time of the target session mapping information is greater than the effective duration (eg, 24 hours). If yes, perform a complete DTLS handshake process; if not, pack the session identifier in the target session mapping information into the CLIENT HELLO message, and the client device and the server perform session recovery verification and execute the session recovery process.
  • the effective duration eg, 24 hours
  • the client device updates the session establishment time in the target session mapping information; in the case of session recovery failure, it re-shakes through the complete DTLS handshake process. In this way, the conversation process between the LWM2M client and the server can be simplified, and the power consumption of the client device can be reduced.
  • a session establishment device including: a target address information acquisition module, a target session identifier acquisition module, and a session recovery module, wherein:
  • a target address information acquisition module configured to acquire target address information of the server
  • the target session identification acquisition module is used to search the stored session mapping information based on the target address information, and confirm the session identification corresponding to the target address information as the target session identification; the session mapping information includes server address information and information corresponding to the server address information. the session ID of the
  • the session restoration module is configured to generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
  • the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session.
  • the session establishment device includes a time determination module and an identification judgment module, wherein the time determination module is used to search the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information.
  • the identification judging module is used to obtain the current time, and judge whether to confirm the session identification corresponding to the target address information as the target session identification according to the session establishment time corresponding to the current time and the target address information.
  • the identification judging module includes an identification obtaining unit, which is used to obtain the time interval between the current moment and the session establishment time corresponding to the target address information; when the time interval is less than or equal to the effective duration, the target The session ID corresponding to the address information is confirmed as the target session ID.
  • the identity judging module includes an initial handshake message sending unit configured to send an initial handshake message to the server when the time interval is greater than the effective duration, so that the server creates a new session.
  • the session establishment device further includes a session establishment time acquisition module and an update module, wherein the session establishment time acquisition module is used to obtain the session establishment time of the current session when the server successfully restores the session corresponding to the target session identifier .
  • the update module is used to update the session establishment time corresponding to the target address information to the session establishment time of the current session.
  • the device for establishing a session further includes a deletion module, configured to delete the session mapping information corresponding to the target session ID when the session corresponding to the target session ID fails to resume.
  • the session establishment device further includes a session establishment module and a session mapping information establishment module, wherein the session establishment module is used to send a message to the server when there is no session mapping information corresponding to the target address information in the stored session mapping information Send an initial handshake message to cause the server to create a new session.
  • the session mapping information establishment module is used to establish and store corresponding session mapping information according to the target address information and the session identifier of the newly created session when the session is successfully created.
  • Each module in the above-mentioned session establishment device can be fully or partially realized by software, hardware and a combination thereof.
  • the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.
  • a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and or a computer.
  • a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and or a computer.
  • an application running on a server and a server can be a component.
  • One or more components can reside within a process and or thread of execution, and a component can be localized on one computer and or distributed between two or more computers.
  • a client device is provided.
  • the client device may be any device with a communication function, which is not specifically limited in this application.
  • client devices can be mobile phones, tablet computers, laptops, smart cars, smart homes, etc., as well as modules with communication functions.
  • the client device is a communication module, and in one example, the communication module is a Qualcomm 5G communication module.
  • the client device includes a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
  • the session mapping information includes the server address information and the session identification corresponding to the server address information;
  • the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session.
  • session establishment time is the last time when the server corresponding to the server address information successfully establishes a session.
  • the processor executes the computer program, the following steps are also implemented: obtaining the time interval between the current moment and the session establishment time corresponding to the target address information; The session ID of is confirmed as the target session ID.
  • the processor executes the computer program, the following steps are further implemented: when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
  • the processor executes the computer program, the following steps are also implemented: when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session; update the session establishment time corresponding to the target address information to The session establishment time of the current session.
  • the processor executes the computer program, the following steps are further implemented: when the session corresponding to the target session identifier fails to resume, delete the session mapping information corresponding to the target session identifier.
  • the following steps are also implemented when the processor executes the computer program: when there is no session mapping information corresponding to the target address information in the session mapping information, an initial handshake message is sent to the server so that the server creates a new session; In the case of creating a new session, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the session mapping information includes the server address information and the session identification corresponding to the server address information;
  • the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session.
  • session establishment time is the last time when the server corresponding to the server address information successfully establishes a session.
  • the following steps are also implemented: obtaining the time interval between the current moment and the session establishment time corresponding to the target address information; The corresponding session ID is confirmed as the target session ID.
  • the following steps are further implemented: when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
  • the following steps are also implemented: when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session; update the session establishment time corresponding to the target address information The session establishment moment for the current session.
  • the following steps are further implemented: when the session corresponding to the target session identifier fails to resume, delete the session mapping information corresponding to the target session identifier.
  • the following steps are also implemented: when there is no session mapping information corresponding to the target address information in the stored session mapping information, an initial handshake message is sent to the server, so that the server creates a new session ; In the case of successfully creating a new session, establish and store corresponding session mapping information according to the target address information and the session identifier of the newly created session.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory or optical memory, etc.
  • Volatile memory can include Random Access Memory (RAM) or external cache memory.
  • RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

Abstract

The present application relates to a session establishment method and apparatus, and a client device and a computer storage medium. The method comprises: acquiring target address information of a server (200); performing, on the basis of the target address information, a search in stored session mapping information, and confirming a session identifier corresponding to the target address information as a target session identifier, wherein the session mapping information comprises server address information and a session identifier that corresponds to the server address information (300); and generating a handshake message according to the target session identifier, and sending the handshake message to the server, so that the server recovers a session corresponding to the target session identifier (400).

Description

会话建立方法、装置、客户端设备和计算机存储介质Session establishment method, device, client device and computer storage medium
相关申请的交叉引用Cross References to Related Applications
本申请要求于2021年9月26日提交中国专利局、申请号为202111128425.7、发明名称为“会话建立方法、装置、客户端设备和计算机存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202111128425.7 and the title of the invention "session establishment method, device, client device and computer storage medium" submitted to the China Patent Office on September 26, 2021, the entire content of which is passed References are incorporated in this application.
技术领域technical field
本申请涉及通信技术领域,特别是涉及一种会话建立方法、装置、客户端设备和计算机存储介质。The present application relates to the technical field of communications, and in particular to a method and device for establishing a session, a client device and a computer storage medium.
背景技术Background technique
随着无线通信技术的发展,目前不仅可以实现人与人之间的通信,还可以实现物与物之间的通信和物与人之间的通信。考虑到通信设备的多样化,为满足特定通信设备的应用需求(如低功耗和存储空间小等),制定了LWM2M(Lightweight Machine to Machine,轻量型M2M)协议,用以满足前述需求。然而,在采用LWM2M协议通信的情况下,配置有LWM2M客户端的客户端设备存在功耗过大的问题。With the development of wireless communication technology, not only communication between people can be realized, but also communication between things and communication between things and people can be realized. Considering the diversification of communication equipment, in order to meet the application requirements of specific communication equipment (such as low power consumption and small storage space, etc.), the LWM2M (Lightweight Machine to Machine, lightweight M2M) protocol has been formulated to meet the aforementioned requirements. However, in the case of using the LWM2M protocol for communication, the client device configured with the LWM2M client has the problem of excessive power consumption.
发明内容Contents of the invention
根据本申请的各种实施例,提供一种会话建立方法、装置、客户端设备和计算机存储介质,用以降低客户端设备的功耗。According to various embodiments of the present application, a method and device for establishing a session, a client device and a computer storage medium are provided, so as to reduce power consumption of the client device.
一种会话建立方法,所述方法包括:A method for establishing a session, the method comprising:
获取服务器的目标地址信息;Obtain the target address information of the server;
基于所述目标地址信息在存储的会话映射信息中进行查找,并将所述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;Search the stored session mapping information based on the target address information, and confirm the session identifier corresponding to the target address information as the target session identifier; the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。Generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
在其中一个实施例中,所述会话映射信息还包括会话建立时刻,所述会话建立时刻为最近一次与所述服务器地址信息对应的服务器成功建立会话的时刻;In one of the embodiments, the session mapping information further includes a session establishment time, and the session establishment time is the last time when the server corresponding to the server address information successfully establishes a session;
所述方法还包括:The method also includes:
基于所述目标地址信息在存储的所述会话映射信息中进行查找,得到所述目标地址信息对应的会话建立时刻;Searching the stored session mapping information based on the target address information to obtain a session establishment time corresponding to the target address information;
获取当前时刻,并根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识。Obtaining the current time, and judging whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the current time and the target address information.
在其中一个实施例中,所述根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识,包括:In one of the embodiments, the judging whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the target address information at the current moment includes:
获取所述当前时刻距离所述目标地址信息对应的会话建立时刻的时间间隔;Obtain the time interval between the current moment and the session establishment moment corresponding to the target address information;
在所述时间间隔小于或等于有效时长的情况下,将所述目标地址信息对应的会话标识确认为所述目标会话标识。If the time interval is less than or equal to the effective duration, confirm the session identifier corresponding to the target address information as the target session identifier.
在其中一个实施例中,所述根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识,还包括:In one of the embodiments, the determining whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the target address information at the current moment further includes:
在所述时间间隔大于所述有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。If the time interval is greater than the effective duration, an initial handshake message is sent to the server, so that the server creates a new session.
在其中一个实施例中,所述方法还包括:在服务器成功恢复所述目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;In one of the embodiments, the method further includes: when the server successfully restores the session corresponding to the target session identifier, acquiring the session establishment time of the current session;
将所述目标地址信息对应的会话建立时刻更新为所述当前会话的会话建立时刻。Updating the session establishment time corresponding to the target address information to the session establishment time of the current session.
在其中一个实施例中,所述方法还包括:当所述目标会话标识对应的会话恢复失败,则删除所述目标会话标识对应的会话映射信息。In one of the embodiments, the method further includes: when the session corresponding to the target session identifier fails to resume, deleting the session mapping information corresponding to the target session identifier.
在其中一个实施例中,所述方法还包括:当存储的所述会话映射信息中不存在与所述目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;In one of the embodiments, the method further includes: when there is no session mapping information corresponding to the target address information in the stored session mapping information, sending an initial handshake message to the server, so that the server creates a new session;
在成功新建会话的情况下,根据所述目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。In the case of successfully establishing a new session, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
一种会话建立装置,所述装置包括:A device for establishing a session, the device comprising:
目标地址信息获取模块,用于获取服务器的目标地址信息;A target address information acquisition module, configured to acquire target address information of the server;
目标会话标识获取模块,用于基于所述目标地址信息在存储的会话映射信息中进行查找,并将所 述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;A target session identification acquisition module, configured to search stored session mapping information based on the target address information, and confirm the session identification corresponding to the target address information as the target session identification; the session mapping information includes server address information and a session identifier corresponding to the server address information;
会话恢复模块,用于根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。The session restoration module is configured to generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
在其中一个实施例中,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻;所装置还包括:In one of the embodiments, the session mapping information also includes a session establishment time, and the session establishment time is the last time when a server corresponding to the server address information successfully establishes a session; the device further includes:
时刻确定模块,用于基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻;The time determination module is used to search in the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information;
标识判断模块,用于获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。The identification judging module is used to obtain the current time, and judge whether to confirm the session identification corresponding to the target address information as the target session identification according to the session establishment time corresponding to the current time and the target address information.
在其中一个实施例中,所述标识判断模块包括:In one of the embodiments, the identification judgment module includes:
标识获取单元,用于获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔;在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为目标会话标识。The identification obtaining unit is used to obtain the time interval between the current moment and the session establishment time corresponding to the target address information; when the time interval is less than or equal to the effective duration, confirm the session identification corresponding to the target address information as the target session identification.
在其中一个实施例中,所述标识判断模块还包括:In one of the embodiments, the identification judgment module also includes:
初始握手消息发送单元,用于在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。The initial handshake message sending unit is configured to send an initial handshake message to the server so that the server creates a new session when the time interval is greater than the effective duration.
在其中一个实施例中,所述装置还包括:In one of the embodiments, the device also includes:
会话建立时刻获取模块,用于在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;The session establishment time obtaining module is used to obtain the session establishment time of the current session when the server successfully restores the session corresponding to the target session identifier;
更新模块,用于将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。An update module, configured to update the session establishment time corresponding to the target address information to the session establishment time of the current session.
在其中一个实施例中,所述装置还包括:In one of the embodiments, the device also includes:
删除模块,用于当目标会话标识对应的会话恢复失败,则删除目标会话标识对应的会话映射信息。The deletion module is configured to delete the session mapping information corresponding to the target session ID when the session corresponding to the target session ID fails to recover.
在其中一个实施例中,所述装置还包括:In one of the embodiments, the device also includes:
会话新建模块,用于当存储的会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;The session new module is used to send an initial handshake message to the server when there is no session mapping information corresponding to the target address information in the stored session mapping information, so that the server can create a new session;
会话映射信息建立模块,用于在成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。The session mapping information establishing module is used for establishing and storing corresponding session mapping information according to the target address information and the session identifier of the newly created session when the session is successfully created.
一种客户端设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现以下步骤:A client device, comprising a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
获取服务器的目标地址信息;Obtain the target address information of the server;
基于所述目标地址信息在存储的会话映射信息中进行查找,并将所述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;Search the stored session mapping information based on the target address information, and confirm the session identifier corresponding to the target address information as the target session identifier; the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。Generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
获取服务器的目标地址信息;Obtain the target address information of the server;
基于所述目标地址信息在存储的会话映射信息中进行查找,并将所述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;Search the stored session mapping information based on the target address information, and confirm the session identifier corresponding to the target address information as the target session identifier; the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。Generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
本发明的一个或多个实施例的细节在下面的附图和描述中提出。本发明的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。The details of one or more embodiments of the invention are set forth in the accompanying drawings and the description below. Other features, objects and advantages of the invention will be apparent from the description, drawings and claims.
附图说明Description of drawings
为了更好地描述和说明这里公开的那些发明的实施例和或示例,可以参考一幅或多幅附图。用于描述附图的附加细书或示例不应当被认为是对所公开的发明、目前描述的实施例和或示例以及目前理解的这些发明的最佳模式中的任何一者的范围的限制。In order to better describe and illustrate embodiments and or examples of the inventions disclosed herein, reference may be made to one or more of the accompanying drawings. The accompanying specification or examples used to describe the drawings should not be considered limiting of the scope of any of the disclosed inventions, the presently described embodiments and or examples, and the best mode of these inventions currently understood.
图1为一个实施例中会话建立方法的应用环境图;Fig. 1 is an application environment diagram of a session establishment method in an embodiment;
图2为一个实施例中会话建立方法的流程示意图之一;Fig. 2 is one of the schematic flow diagrams of the method for establishing a session in an embodiment;
图3为一个实施例中目标会话标识获取步骤的流程示意图;Fig. 3 is a schematic flow chart of the target session identification acquisition step in one embodiment;
图4为一个实施例中会话标识判断步骤的流程示意图;FIG. 4 is a schematic flow chart of a session identifier judgment step in an embodiment;
图5为一个实施例中会话建立方法的流程示意图之二;FIG. 5 is a second schematic flow diagram of a method for establishing a session in an embodiment;
图6为一个实施例中会话建立方法的流程示意图之三;Fig. 6 is the third schematic flow chart of the method for establishing a session in an embodiment;
图7为一个实施例中会话建立方法的流程示意图之四;FIG. 7 is a fourth schematic flow diagram of a method for establishing a session in an embodiment;
图8为一个实施例中会话建立装置的结构框图。Fig. 8 is a structural block diagram of a device for establishing a session in an embodiment.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not intended to limit the present application.
正如背景技术所述,配置有LWM2M客户端的客户端设备在通信过程中的功耗过大。经发明人研究发现,导致该问题的原因在于,在每次建立LWM2M客户端与服务器的会话的过程中,LWM2M客户端与服务器之间需要进行完整的握手流程方可建立,导致配置有LWM2M客户端的客户端设备在会话建立过程中需要花费较多的数据流量和时间,进而增加了该客户端设备的功耗。As mentioned in the background, the power consumption of a client device configured with an LWM2M client is too high during communication. The inventor found that the reason for this problem is that in the process of establishing a session between the LWM2M client and the server each time, a complete handshake process is required between the LWM2M client and the server before it can be established, resulting in the configuration of the LWM2M client The client device at the end needs to spend more data traffic and time during the session establishment process, thereby increasing the power consumption of the client device.
基于此,有必要提供一种会话建立方法、装置、客户端设备和计算机存储介质,通过对服务器地址信息和对应于服务器地址信息的会话标识进行存储,从而可基于存储的会话映射信息发起会话恢复流程,无需通过完整会话流程建立每一次会话,进而可缩短会话建立过程花费的时间,并降低客户端设备在该过程中消耗的数据流量,以降低客户端设备的功耗。Based on this, it is necessary to provide a session establishment method, device, client device and computer storage medium, by storing the server address information and the session identifier corresponding to the server address information, thereby initiating session recovery based on the stored session mapping information The process does not need to establish each session through a complete session process, which can shorten the time spent in the session establishment process, and reduce the data traffic consumed by the client device during the process, so as to reduce the power consumption of the client device.
本申请提供的会话建立方法、装置、客户端设备和计算机存储介质,可以应用于图1所示的应用环境中。其中,客户端设备可以是具备通信功能,且配置有通信协议客户端的设备。客户端设备通过通信协议实现与服务器的通信,进而实现数据交互。可以理解,客户端设备上可配置有任意通信协议,本申请对此不作限定,只需该通信协议能够用于实现客户端设备与服务器之间的通信即可。在其中一个实施例中,客户端设备配置有LWM2M协议的客户端,客户端设备与服务器通过LWM2M协议通信。The session establishment method, device, client device and computer storage medium provided in this application can be applied to the application environment shown in FIG. 1 . Wherein, the client device may be a device having a communication function and configured with a communication protocol client. The client device communicates with the server through the communication protocol, and then realizes data interaction. It can be understood that any communication protocol can be configured on the client device, which is not limited in the present application, as long as the communication protocol can be used to realize the communication between the client device and the server. In one embodiment, the client device is configured with a client of the LWM2M protocol, and the client device communicates with the server through the LWM2M protocol.
客户端设备可以获取服务器的目标地址信息;客户端设备基于目标地址信息在存储的会话映射信息中进行查找,并将目标地址信息对应的会话标识确认为目标会话标识;其中,会话映射信息包括服务器地址信息和对应于服务器地址信息的会话标识;客户端根据目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器恢复目标会话标识对应的会话。The client device can obtain the target address information of the server; the client device searches the stored session mapping information based on the target address information, and confirms the session identifier corresponding to the target address information as the target session identifier; wherein, the session mapping information includes the server The address information and the session ID corresponding to the address information of the server; the client generates a handshake message according to the target session ID, and sends the handshake message to the server, so that the server restores the session corresponding to the target session ID.
客户端设备可以为任意形式的通信设备,如具有通信功能的模组、芯片或电路等,或者是设有前述通信设备的终端设备,如各种类型的窄带物联网设备、手机、平板电脑、笔记本电脑、智能汽车、 智能家居等,本申请对此不作具体限定。在其中一个实施例中,客户端设备为5G通信模块。服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。The client device can be any form of communication device, such as a module, chip or circuit with communication functions, or a terminal device equipped with the aforementioned communication device, such as various types of narrowband Internet of Things devices, mobile phones, tablet computers, Notebook computers, smart cars, smart homes, etc., are not specifically limited in this application. In one of the embodiments, the client device is a 5G communication module. The server can be implemented by an independent server or a server cluster composed of multiple servers.
在一个实施例中,如图2所示,提供了一种会话建立方法,以该方法应用于图1中的客户端设备为例进行说明,包括以下步骤:In one embodiment, as shown in FIG. 2, a method for establishing a session is provided. The method is applied to the client device in FIG. 1 as an example for illustration, including the following steps:
步骤200,获取服务器的目标地址信息。 Step 200, acquiring target address information of the server.
其中,目标地址信息是指用于与客户端设备进行应用层数据交互的服务器的地址信息。在其中一个实施例中,目标地址信息对应的服务器可以是客户端设备当前连接的服务器。需要说明的是,客户端设备与该服务器的连接状态,与是否已建立会话并无必然联系。换言之,在客户端设备与该服务器连接的情况下,客户端设备与服务器之间的会话有可能仍未建立。Wherein, the target address information refers to address information of a server used for exchanging application layer data with the client device. In one embodiment, the server corresponding to the target address information may be the server currently connected to the client device. It should be noted that the connection status between the client device and the server is not necessarily related to whether a session has been established. In other words, while the client device is connected to the server, there is a possibility that the session between the client device and the server has not yet been established.
客户端设备通过获取目标地址信息以便于与服务器进行通信。可以理解,目标地址信息可以包括一种或多种用于指示服务器地址的信息,本申请对此不作具体限定。在其中一个实施例中,目标地址信息可以包括服务器的IP地址和端口。The client device communicates with the server by obtaining destination address information. It can be understood that the target address information may include one or more types of information used to indicate the server address, which is not specifically limited in this application. In one embodiment, the target address information may include the IP address and port of the server.
步骤300,基于目标地址信息在存储的会话映射信息中进行查找,并将目标地址信息对应的会话标识确认为目标会话标识;会话映射信息包括服务器地址信息和对应于服务器地址信息的会话标识。Step 300: Search the stored session mapping information based on the target address information, and confirm the session ID corresponding to the target address information as the target session ID; the session mapping information includes the server address information and the session ID corresponding to the server address information.
具体而言,客户端设备中存储有一组或多组会话映射信息,每一组会话映射信息包括服务器地址信息和对应于该服务器地址信息的会话标识,该会话标识可以依据客户端设备和对应于服务器地址信息的服务器之间的历史会话建立过程来确定。会话映射信息反映了客户端设备与对应于服务器地址信息的服务器之间曾经建立会话标识对应的会话。在其中一个实施例中,客户端设备存储的会话映射关系可以是随客户端设备与服务器之间的会话建立情况动态调整,以提高会话映射信息的准确性。Specifically, one or more sets of session mapping information are stored in the client device, each set of session mapping information includes server address information and a session identifier corresponding to the server address information, and the session identifier can be based on the client device and the corresponding The server address information is determined by the historical session establishment process between servers. The session mapping information reflects the session corresponding to the session identifier once established between the client device and the server corresponding to the server address information. In one embodiment, the session mapping relationship stored by the client device may be dynamically adjusted according to the establishment of the session between the client device and the server, so as to improve the accuracy of the session mapping information.
可以理解,在客户端设备存储有多组会话映射信息的情况下,任意两组会话映射信息所包括的内容可以均不相同、部分相同或完全重合,本申请对此不作具体限制,只需会话映射信息能够反映服务器地址信息与会话标识之间的映射关系即可。例如,在客户端设备存储有多组会话映射信息的情况下,任意两组会话映射信息的服务器地址信息可以相同或不同;对于服务器地址信息相同的多组会话映射信息,其内包括的目标会话标识可以相同或不同。It can be understood that when the client device stores multiple sets of session mapping information, the content included in any two sets of session mapping information may be different, partially identical, or completely overlapped. This application does not specifically limit this, as long as the session It only needs that the mapping information can reflect the mapping relationship between the server address information and the session identifier. For example, when the client device stores multiple sets of session mapping information, the server address information of any two sets of session mapping information can be the same or different; for multiple sets of session mapping information with the same server address information, the target session included in it The IDs can be the same or different.
在得到目标地址信息后,客户端设备可在存储的会话映射信息中进行查找,以确定是否存在与目标地址信息对应的会话标识,即目标会话标识。若查找得到与目标地址信息对应的目标会话标识,则表明客户端设备与服务器之间曾经建立会话,并可将该查找得到的会话标识确认为目标会话标识。After obtaining the target address information, the client device may search the stored session mapping information to determine whether there is a session identifier corresponding to the target address information, that is, the target session identifier. If the target session ID corresponding to the target address information is found, it indicates that a session has been established between the client device and the server, and the found session ID can be confirmed as the target session ID.
步骤400,根据目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器恢复目标会话标识对应的会话。Step 400: Generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
具体而言,在会话建立过程中,客户端设备与服务器需要进行握手流程,以使服务器根据握手结果建立会话。在客户端设备发送的握手消息中包括会话标识的情况下,客户端设备与服务器之间可以通过简化的握手流程尝试恢复该会话标识对应的会话。在客户端设备发送的握手消息中未包括会话标识的情况下,客户端设备与服务器之间需要进行完整的握手流程,以实现会话标识的分配、下发以及会话建立。Specifically, during the session establishment process, the client device and the server need to perform a handshake process, so that the server can establish a session according to the handshake result. In the case that the session identifier is included in the handshake message sent by the client device, the client device and the server may attempt to restore the session corresponding to the session identifier through a simplified handshake process. In the case that the session ID is not included in the handshake message sent by the client device, a complete handshake process needs to be performed between the client device and the server, so as to realize the allocation, delivery and session establishment of the session ID.
可以理解,客户端设备与服务器可以基于任意握手协议进行握手流程,本申请对此不作具体限制。在其中一个实施例中,客户端设备与服务器通过DTLS(Datagram Transport Layer Security,数据包传输层安全性)协议进行握手。It can be understood that the client device and the server may perform a handshake process based on any handshake protocol, which is not specifically limited in this application. In one of the embodiments, the client device and the server perform a handshake through a DTLS (Datagram Transport Layer Security, Datagram Transport Layer Security) protocol.
客户端设备在得到目标会话标识后,根据目标会话标识生成握手消息,以使该握手消息中包括目标会话标识。在客户端发送握手消息后,客户端与服务器之间进行简短的握手流程,以使服务器恢复目标会话表示对应的会话,完成会话建立过程。在会话建立后,客户端设备与服务器之间可以进行应用层的数据交互。After obtaining the target session ID, the client device generates a handshake message according to the target session ID, so that the handshake message includes the target session ID. After the client sends the handshake message, a brief handshake process is performed between the client and the server, so that the server restores the session corresponding to the target session representation and completes the session establishment process. After the session is established, data exchange at the application layer can be performed between the client device and the server.
上述会话建立方法中,客户端设备存储有服务器地址信息和对应于该服务器地址信息的会话标识,即会话映射信息。客户端设备在获取到服务器的目标地址信息的情况下,从存储的会话映射信息中查找该目标地址信息对应的会话标识,并将查找得到的会话标识确认为目标会话标识。根据目标会话标识生成握手信息,且将该握手信息发送至服务器。如此,客户端设备通过简短的握手流程即可使得服务器恢复目标会话标识对应的会话,完成会话建立,而无需在每一次会话建立过程中都进行完整的握手流程,从而减少会话建立过程中的验证过程,缩短会话建立过程的时间消耗,并降低客户端设备在该过程中数据流量消耗,进而降低客户端设备的功耗。In the above method for establishing a session, the client device stores server address information and a session identifier corresponding to the server address information, that is, session mapping information. When the client device obtains the target address information of the server, it searches the stored session mapping information for the session ID corresponding to the target address information, and confirms the found session ID as the target session ID. Generate handshake information according to the target session identifier, and send the handshake information to the server. In this way, the client device can enable the server to restore the session corresponding to the target session identifier through a short handshake process, and complete the session establishment without having to perform a complete handshake process in each session establishment process, thereby reducing the verification during the session establishment process process, shorten the time consumption of the session establishment process, and reduce the data traffic consumption of the client device in this process, thereby reducing the power consumption of the client device.
在一个实施例中,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻。In one embodiment, the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session.
如图3所示,本申请的会话建立方法还包括:As shown in Figure 3, the session establishment method of the present application also includes:
步骤310,基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻; Step 310, searching the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information;
步骤320,获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标 地址信息对应的会话标识确认为目标会话标识。 Step 320, obtain the current time, and judge whether to confirm the session ID corresponding to the target address information as the target session ID according to the session establishment time corresponding to the current time and the target address information.
具体而言,每组会话映射信息还包括会话建立时刻,该会话建立时刻为客户端设备最近一次与会话映射信息对应的服务器成功建立会话的时刻。客户端设备可以根据目标地址信息对存储的会话映射信息进行查询,以确定是否存在目标地址信息所对应的会话映射信息。若存在,则可确定目标地址信息对应的会话建立时刻(以下简称目标会话建立时刻),即客户端设备最近一次与目标地址信息对应的服务器成功建立会话的时刻。在确定目标会话建立时刻的情况下,客户端设备可根据当前时刻与目标会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。若是,则将目标地址信息对应的会话标识确认为目标会话标识,并执行步骤400。若否,则客户端设备与服务器之间可以进行完整的握手流程,以确认新的会话标识并建立会话。Specifically, each set of session mapping information also includes a session establishment time, which is the last time when the client device successfully establishes a session with the server corresponding to the session mapping information. The client device may query the stored session mapping information according to the target address information to determine whether there is session mapping information corresponding to the target address information. If it exists, the session establishment time corresponding to the target address information (hereinafter referred to as the target session establishment time) may be determined, that is, the last time when the client device successfully establishes a session with the server corresponding to the target address information. In the case of determining the target session establishment time, the client device may determine whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the current time and the target session establishment time. If yes, confirm the session ID corresponding to the target address information as the target session ID, and execute step 400 . If not, a complete handshake process can be performed between the client device and the server to confirm a new session identifier and establish a session.
进一步地,本申请可在目标会话建立时刻早于当前时刻的情况下,将目标地址信息对应的会话标识确认为目标会话标识,否则执行完整的握手流程。如此,可避免错误的会话映射信息对会话建立过程造成干扰,进而可提高会话建立的成功率。或者,本申请可根据目标会话建立时刻确定会话标识有效时段,在当前时刻处于会话标识有效时段内的情况下,则将目标地址信息对应的会话标识确认为目标会话标识,否则执行完整的握手流程。Further, the present application may confirm the session ID corresponding to the target address information as the target session ID if the target session establishment time is earlier than the current time, otherwise, perform a complete handshake process. In this way, it is possible to prevent wrong session mapping information from interfering with the session establishment process, thereby improving the success rate of session establishment. Alternatively, the application can determine the valid period of the session identifier according to the establishment time of the target session. If the current moment is within the valid period of the session identifier, then confirm the session identifier corresponding to the target address information as the target session identifier, otherwise perform a complete handshake process .
本实施例中,通过获取客户端设备最近一次与服务器地址信息对应的服务器成功建立会话的时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识,从而可确保目标地址信息对应的会话标识的有效性,进而提高会话恢复成功率,并降低会话建立的平均时长。In this embodiment, by obtaining the last time when the client device successfully established a session with the server corresponding to the server address information, and according to the session establishment time corresponding to the current time and the target address information, it is judged whether to confirm the session identifier corresponding to the target address information It is the target session identifier, so as to ensure the validity of the session identifier corresponding to the target address information, thereby improving the success rate of session recovery and reducing the average duration of session establishment.
在一个实施例中,如图4所示,根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识,包括:In one embodiment, as shown in FIG. 4, according to the session establishment time corresponding to the target address information at the current moment, it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier, including:
步骤322,获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔; Step 322, obtaining the time interval between the current moment and the session establishment moment corresponding to the target address information;
步骤324,在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为所述目标会话标识。In step 324, if the time interval is less than or equal to the effective duration, confirm the session identifier corresponding to the target address information as the target session identifier.
具体而言,在得到目标会话建立时刻的情况下,客户端设备获取当前时刻与目标会话建立时刻的时间间隔,该时间间隔为客户端设备与目标地址信息对应的服务器前次成功建立会话的时刻与当前时刻的差值。若该时间间隔小于或等于有效时长,则表明目标地址信息对应的会话标识有较大几率保持有效,服务器有较大几率能够恢复该会话标识对应的会话,以简化会话建立过程。因此,客户端设备 可将目标地址信息对应的会话标识确认为目标会话标识,并执行步骤400,以使服务器恢复目标会话标识对应的会话。Specifically, in the case of obtaining the target session establishment time, the client device obtains the time interval between the current time and the target session establishment time, which is the time when the client device and the server corresponding to the target address information successfully established a session last time The difference from the current moment. If the time interval is less than or equal to the valid duration, it indicates that the session identifier corresponding to the target address information has a higher probability of remaining valid, and the server has a higher probability of being able to restore the session corresponding to the session identifier, so as to simplify the session establishment process. Therefore, the client device may confirm the session ID corresponding to the target address information as the target session ID, and execute step 400, so that the server restores the session corresponding to the target session ID.
可以理解,有效时长的具体时间长度可以根据客户端设备的设备类型、其与服务器之间的通信频率和/或服务器对于会话标识的更新频率等因素设定,本申请对此不作具体限制。在一个实例中,有效时长可以为24小时。It can be understood that the specific time length of the effective duration can be set according to factors such as the device type of the client device, the communication frequency between it and the server, and/or the update frequency of the session ID by the server, which is not specifically limited in this application. In one example, the effective period may be 24 hours.
本实施例中,在当前时刻距离目标会话建立时刻的时间间隔小于或等于有效时长的情况下,客户端设备将目标地址信息对应的会话标识确认为目标会话标识,从而可避免因时间间隔过长而导致的会话恢复失败,进一步提高会话恢复成功率,最大地降低会话建立过程的时间消耗、数据流量消耗和功耗。In this embodiment, when the time interval between the current moment and the target session establishment time is less than or equal to the effective duration, the client device confirms the session identifier corresponding to the target address information as the target session identifier, thereby avoiding the The resulting session recovery failure further improves the session recovery success rate and minimizes the time consumption, data flow consumption and power consumption of the session establishment process.
在一个实施例中,请继续参阅图4,根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识,还包括:In one embodiment, please continue to refer to FIG. 4 , according to the session establishment time corresponding to the target address information at the current moment, it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier, which also includes:
步骤326,在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。 Step 326, when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
具体而言,在当前时刻与目标会话建立时刻的时间间隔大于有效时长的情况下,基于目标地址信息对应的会话标识进行会话恢复有较大几率失效,即通过无法恢复该会话标识对应的会话。因此,当时间间隔大于有效时长时,客户端设备生成初始握手消息,并向服务器发送该初始握手消息,以使服务器新建会话。如此,客户端设备与服务器进行完整的握手流程,以使服务器重新确定会话标识并建立会话。在其中一个实施例中,初始握手消息中会话标识长度为零,即初始握手消息中会话标识为空。Specifically, when the time interval between the current time and the target session establishment time is greater than the effective duration, session recovery based on the session identifier corresponding to the target address information has a higher probability of failure, that is, the session corresponding to the session identifier cannot be restored. Therefore, when the time interval is greater than the effective duration, the client device generates an initial handshake message and sends the initial handshake message to the server, so that the server creates a new session. In this way, the client device performs a complete handshake process with the server, so that the server can re-determine the session ID and establish the session. In one embodiment, the length of the session identifier in the initial handshake message is zero, that is, the session identifier in the initial handshake message is empty.
本实施例中,在时间间隔大于有效时长的情况下,通过完整的握手流程确定新的会话标识,而非基于目标地址信息对应的会话标识生成握手消息以进行简化的握手流程。如此,可避免发起失败率较高的会话恢复流程,进一步提高会话建立的成功率。同时,还可降低会话建立过程的平均时长,进一步降低客户端设备的时间消耗、数据流量消耗和功耗。In this embodiment, when the time interval is greater than the effective duration, a new session ID is determined through a complete handshake process instead of generating a handshake message based on the session ID corresponding to the target address information to perform a simplified handshake process. In this way, the session restoration process with high failure rate can be avoided, and the success rate of session establishment can be further improved. At the same time, it can also reduce the average duration of the session establishment process, and further reduce the time consumption, data traffic consumption and power consumption of the client device.
在一个实施例中,如图5所示,会话建立方法还包括:In one embodiment, as shown in Figure 5, the session establishment method also includes:
步骤500,在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻; Step 500, when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session;
步骤600,将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。Step 600: Update the session establishment time corresponding to the target address information to the session establishment time of the current session.
具体而言,在服务器成功恢复目标会话标识对应的会话时,客户端设备获取该会话(即当前会话)的会话建立时刻,并对目标映射关系中的会话建立时刻进行更新。可以理解,会话建立时刻可以根据目标会话标识对应的会话恢复过程确定,本申请对此不作具体限制。在其中一个实施例中,会话建立 时刻为握手完成时刻,即客户端设备与服务器完成握手流程的时间,以提高会话建立时刻的准确性。Specifically, when the server successfully restores the session corresponding to the target session identifier, the client device obtains the session establishment time of the session (ie, the current session), and updates the session establishment time in the target mapping relationship. It can be understood that the session establishment time can be determined according to the session recovery process corresponding to the target session identifier, which is not specifically limited in this application. In one embodiment, the session establishment time is the handshake completion time, that is, the time when the client device and the server complete the handshake process, so as to improve the accuracy of the session establishment time.
在其中一个实施例中,在客户端设备存储的会话映射信息中,同一服务器地址信息最多对应一组会话映射信息,换言之,不存储两组服务器地址信息相同的会话映射信息。各组会话映射信息会随着客户端设备与服务器之间的会话建立情况而进行动态更新,例如更新会话建立时刻和/或会话标识等。如此,一方面可以减低存储的数据量,进而降低客户端设备的硬件要求,拓宽适用性。另一方面,还可提高会话映射信息的准确性和有效性,以便于提高查询效率和会话恢复成功率,进一步降低客户端设备的功耗。In one embodiment, in the session mapping information stored by the client device, the same server address information corresponds to at most one set of session mapping information, in other words, no two sets of session mapping information with the same server address information are stored. Each set of session mapping information will be dynamically updated along with the establishment of the session between the client device and the server, such as updating the session establishment time and/or session identifier. In this way, on the one hand, the amount of stored data can be reduced, thereby reducing the hardware requirements of the client device and broadening the applicability. On the other hand, the accuracy and validity of the session mapping information can also be improved, so as to improve the query efficiency and session recovery success rate, and further reduce the power consumption of the client device.
本实施例中,在成功恢复会话的情况下,将当前会话的会话建立时刻更新为会话建立时刻,从而可提高会话映射信息的有效性和准确性,进一步降低客户端设备在会话建立过程中的功耗。In this embodiment, when the session is successfully restored, the session establishment time of the current session is updated to the session establishment time, thereby improving the validity and accuracy of the session mapping information and further reducing the client device's time in the session establishment process. power consumption.
在一个实施例中,会话建立方法还包括:若目标会话标识对应的会话恢复失败,客户端设备则删除目标会话标识对应的会话映射信息。具体而言,客户端设备基于目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器尝试恢复目标会话标识对应的会话。若该会话恢复失败,则客户端设备删除其内存储的目标会话标识对应的会话映射信息。进一步地,在会话恢复失败后,客户端设备还可与服务器进行完整的握手的流程,以确定新的会话标识并建立会话。In one embodiment, the method for establishing a session further includes: if the session corresponding to the target session identifier fails to resume, the client device deletes the session mapping information corresponding to the target session identifier. Specifically, the client device generates a handshake message based on the target session ID, and sends the handshake message to the server, so that the server attempts to restore the session corresponding to the target session ID. If the session recovery fails, the client device deletes the session mapping information corresponding to the target session identifier stored therein. Further, after the session recovery fails, the client device can also perform a complete handshake process with the server to determine a new session identifier and establish a session.
本实施例中,在目标会话标识对应的会话恢复失败的情况下,客户端设备删除目标会话标识对应的会话映射信息,既可以降低存储数据量,又可以避免无效信息对会话建立过程的干扰,进一步提高会话建立的效率。In this embodiment, when the session recovery corresponding to the target session ID fails, the client device deletes the session mapping information corresponding to the target session ID, which can not only reduce the amount of stored data, but also avoid the interference of invalid information on the session establishment process. Further improve the efficiency of session establishment.
在一个实施例中,如图6所示,会话建立方法还包括:In one embodiment, as shown in Figure 6, the session establishment method also includes:
步骤700,当存储的会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话; Step 700, when there is no session mapping information corresponding to the target address information in the stored session mapping information, an initial handshake message is sent to the server, so that the server creates a new session;
步骤800,当成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。 Step 800, when a new session is successfully created, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
具体而言,若客户端设备存储的会话映射信息中不存在与目标地址信息对应的会话标识,则客户端设备向服务器发送初始握手信息。如此,客户端设备与服务器进行完整的握手流程,以确定会话标识并建立新的会话。在成功建立会话的情况下,客户端设备根据目标地址信息和该新建会话的会话标识生成对应的会话映射信息,并将该会话映射信息进行存储,以便在下一次会话建立过程中使用。如此,可在后续会话建立过程中恢复对应的会话,降低会话建立过程中的时间消耗、数据流量消耗和功 耗。Specifically, if there is no session identifier corresponding to the target address information in the session mapping information stored by the client device, the client device sends initial handshake information to the server. In this way, the client device performs a complete handshake process with the server to determine the session ID and establish a new session. When the session is successfully established, the client device generates corresponding session mapping information according to the target address information and the session identifier of the newly created session, and stores the session mapping information for use in the next session establishment process. In this way, the corresponding session can be restored in the subsequent session establishment process, reducing the time consumption, data flow consumption and power consumption in the session establishment process.
为便于理解本申请,下面通过一个具体的实施例进行说明。如图7所示,提供了一种会话建立方法,该方法应用于客户端设备,具体包括:In order to facilitate the understanding of the present application, a specific embodiment will be described below. As shown in Figure 7, a method for establishing a session is provided, the method is applied to a client device, and specifically includes:
步骤902,客户端设备发起连接服务器,并获取服务器的目标地址信息。需要说明的是,在多次连接过程中,客户端设备可以连接相同或不同的服务器,本申请对此不作具体限制。In step 902, the client device initiates a connection to the server, and obtains target address information of the server. It should be noted that, during multiple connections, the client device may connect to the same or different servers, which is not specifically limited in this application.
步骤904,客户端设备在存储的会话映射信息中进行查询,判断是否存在与目标地址信息对应的目标会话映射信息,若不存在,则进入步骤906,若存在,则进入步骤914。 Step 904 , the client device searches the stored session mapping information to determine whether there is target session mapping information corresponding to the target address information, if not, go to step 906 , if yes, go to step 914 .
步骤906,客户端设备向服务器发送初始CLINET HELLO消息,并与服务器进行完整的DTLS握手流程。其中,初始CLINET HELLO消息的会话标识长度为零,会话标识为空。 Step 906, the client device sends an initial CLINET HELLO message to the server, and performs a complete DTLS handshake process with the server. Wherein, the session identification length of the initial CLINET HELLO message is zero, and the session identification is empty.
步骤908,判断DTLS握手是否成功,若否,则进入步骤906,若是,则进入步骤910。 Step 908, judge whether the DTLS handshake is successful, if not, go to step 906, if yes, go to step 910.
步骤910,获取新建会话的会话标识和握手完成时刻,并生成目标地址信息、新建会话的会话标识和握手完成时刻的会话映射信息,并存储。Step 910: Obtain the session ID of the new session and the handshake completion time, generate target address information, the session ID of the new session, and the session mapping information of the handshake completion time, and store them.
步骤912,客户端设备与服务器进行应用层数据交互。 Step 912, the client device exchanges application layer data with the server.
步骤914,判断当前时刻距离目标会话映射信息的会话建立时刻是否超过有效时长,若是,则进入步骤906,若否,则进入步骤916。 Step 914 , judging whether the distance from the current time to the session establishment time of the target session mapping information exceeds the effective duration, if yes, go to step 906 , if not, go to step 916 .
步骤916,客户端设备基于目标会话映射信息的会话标识生成目标CLIENT HELLO消息,并向服务器发送该目标CLIENT HELLO消息。其中,目标CLIENT HELLO消息包括目标会话映射信息的会话标识。具体而言,客户端设备向服务器发送该目标CLIENT HELLO消息后,客户端设备与服务器进行简短的握手流程,以使服务器尝试恢复目标会话映射信息的会话标识对应的会话。 Step 916, the client device generates a target CLIENT HELLO message based on the session identifier of the target session mapping information, and sends the target CLIENT HELLO message to the server. Wherein, the target CLIENT HELLO message includes the session identifier of the target session mapping information. Specifically, after the client device sends the target CLIENT HELLO message to the server, the client device and the server perform a short handshake process, so that the server attempts to restore the session corresponding to the session identifier of the target session mapping information.
步骤918,判断DTLS握手是否成功,若否,则进入步骤920,若是,则进入步骤922。 Step 918, judge whether the DTLS handshake is successful, if not, go to step 920, if yes, go to step 922.
步骤920,客户端设备删除目标会话映射信息,并进入步骤904,以重新发起握手流程。 Step 920, the client device deletes the target session mapping information, and enters step 904 to re-initiate the handshake process.
步骤922,客户端设备获取当前会话的会话建立时刻,并将目标会话映射信息中的会话建立时刻更新为当前会话的会话建立时刻。 Step 922, the client device obtains the session establishment time of the current session, and updates the session establishment time in the target session mapping information to the session establishment time of the current session.
本申请中,客户端设备开机后启动LWMM客户端,并与服务器连接。连接后,客户端设备发起DTLS握手流程中的CLIENT HELLO消息打包和发送流程。具体而言,客户端设备根据服务器的服务器地址信息和端口在缓存的会话映射信息中进行查询,并根据查询结果判断是通过会话恢复流程建立会话,或是通过会话新建流程建立会话。In this application, after the client device is turned on, the LWMM client is started and connected to the server. After connecting, the client device initiates the CLIENT HELLO message packaging and sending process in the DTLS handshake process. Specifically, the client device queries the cached session mapping information according to the server address information and port of the server, and judges whether to establish the session through the session recovery process or the session creation process according to the query result.
若客户端设备不存在目标会话映射信息,则客户端设备与服务器进行完整的DTLS握手流程,并在握手成功后存储新建会话的会话标识、新建会话的握手完成时刻、服务器IP地址和端口。若客户端设备中存在目标会话映射信息,则判断当前时刻距离目标会话映射信息的会话建立时刻的时间间隔,是否大于有效时长(如24小时)。若是,则进行完整的DTLS握手流程;如否,则将目标会话映射信息中的会话标识打包到CLIENT HELLO消息中,客户端设备与服务器进行会话恢复验证并执行会话恢复流程。在成功恢复会话的情况下,客户端设备更新目标会话映射信息中的会话建立时刻;在会话恢复失败的情况下,则通过完整的DTLS握手流程重新握手。如此,可简化LWM2M客户端与服务器的会话流程,降低客户端设备的功耗。If the client device does not have target session mapping information, the client device and the server perform a complete DTLS handshake process, and store the session ID of the new session, the handshake completion time of the new session, server IP address and port after the handshake is successful. If there is target session mapping information in the client device, it is judged whether the time interval between the current moment and the session establishment time of the target session mapping information is greater than the effective duration (eg, 24 hours). If yes, perform a complete DTLS handshake process; if not, pack the session identifier in the target session mapping information into the CLIENT HELLO message, and the client device and the server perform session recovery verification and execute the session recovery process. In the case of successful session recovery, the client device updates the session establishment time in the target session mapping information; in the case of session recovery failure, it re-shakes through the complete DTLS handshake process. In this way, the conversation process between the LWM2M client and the server can be simplified, and the power consumption of the client device can be reduced.
应该理解的是,虽然图2-7的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-7中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the various steps in the flow charts in FIGS. 2-7 are displayed sequentially as indicated by the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in Figures 2-7 may include multiple steps or stages, these steps or stages are not necessarily executed at the same moment, but may be executed at different moments, the execution of these steps or stages The sequence is not necessarily performed sequentially, but may be performed alternately or alternately with other steps or at least a part of steps or stages in other steps.
在一个实施例中,如图8所示,提供了一种会话建立装置,包括:目标地址信息获取模块、目标会话标识获取模块和会话恢复模块,其中:In one embodiment, as shown in FIG. 8 , a session establishment device is provided, including: a target address information acquisition module, a target session identifier acquisition module, and a session recovery module, wherein:
目标地址信息获取模块,用于获取服务器的目标地址信息;A target address information acquisition module, configured to acquire target address information of the server;
目标会话标识获取模块,用于基于目标地址信息在存储的会话映射信息中进行查找,并将目标地址信息对应的会话标识确认为目标会话标识;会话映射信息包括服务器地址信息和对应于服务器地址信息的会话标识;The target session identification acquisition module is used to search the stored session mapping information based on the target address information, and confirm the session identification corresponding to the target address information as the target session identification; the session mapping information includes server address information and information corresponding to the server address information. the session ID of the
会话恢复模块,用于根据目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器恢复目标会话标识对应的会话。The session restoration module is configured to generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
在一个实施例中,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻。会话建立装置包括时刻确定模块及标识判断模块,其中,时刻确定模块用于基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻。标识判断模块用于获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session. The session establishment device includes a time determination module and an identification judgment module, wherein the time determination module is used to search the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information. The identification judging module is used to obtain the current time, and judge whether to confirm the session identification corresponding to the target address information as the target session identification according to the session establishment time corresponding to the current time and the target address information.
在一个实施例中,标识判断模块包括标识获取单元,该标识获取单元用于获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔;在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, the identification judging module includes an identification obtaining unit, which is used to obtain the time interval between the current moment and the session establishment time corresponding to the target address information; when the time interval is less than or equal to the effective duration, the target The session ID corresponding to the address information is confirmed as the target session ID.
在一个实施例中,标识判断模块包括初始握手消息发送单元,该初始握手消息发送单元用于在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。In one embodiment, the identity judging module includes an initial handshake message sending unit configured to send an initial handshake message to the server when the time interval is greater than the effective duration, so that the server creates a new session.
在一个实施例中,会话建立装置还包括会话建立时刻获取模块和更新模块,其中,会话建立时刻获取模块用于在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻。更新模块用于将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。In one embodiment, the session establishment device further includes a session establishment time acquisition module and an update module, wherein the session establishment time acquisition module is used to obtain the session establishment time of the current session when the server successfully restores the session corresponding to the target session identifier . The update module is used to update the session establishment time corresponding to the target address information to the session establishment time of the current session.
在一个实施例中,会话建立装置还包括删除模块,该删除模块用于当目标会话标识对应的会话恢复失败,则删除目标会话标识对应的会话映射信息。In one embodiment, the device for establishing a session further includes a deletion module, configured to delete the session mapping information corresponding to the target session ID when the session corresponding to the target session ID fails to resume.
在一个实施例中,会话建立装置还包括会话新建模块和会话映射信息建立模块,其中,会话新建模块用于当存储的会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话。会话映射信息建立模块用于在成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。In one embodiment, the session establishment device further includes a session establishment module and a session mapping information establishment module, wherein the session establishment module is used to send a message to the server when there is no session mapping information corresponding to the target address information in the stored session mapping information Send an initial handshake message to cause the server to create a new session. The session mapping information establishment module is used to establish and store corresponding session mapping information according to the target address information and the session identifier of the newly created session when the session is successfully created.
关于会话建立装置的具体限定可以参见上文中对于会话建立方法的限定,在此不再赘述。上述会话建立装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitations of the session establishment device, refer to the above-mentioned definition of the session establishment method, which will not be repeated here. Each module in the above-mentioned session establishment device can be fully or partially realized by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.
如在本申请中所使用的,术语“组件”、“模块”和“系统”等旨在表示计算机相关的实体,它可以是硬件、硬件和软件的组台、软件、或者执行中的软件。例如,组件可以是但不限于是,在处理器上运行的进程、处理器、对象、可执行码、执行的线程、程序和或计算机。作为说明,运行在服务器上的应用程序和服务器都可以是组件。一个或多个组件可以驻留在进程和或执行的线程中,并且组件可以位于一个计算机内和或分布在两个或更多的计算机之间。As used in this application, the terms "component," "module," and "system" and the like are intended to mean a computer-related entity, which may be hardware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and or a computer. As an illustration, both an application running on a server and a server can be a component. One or more components can reside within a process and or thread of execution, and a component can be localized on one computer and or distributed between two or more computers.
在一个实施例中,提供了一种客户端设备。该客户端设备可以为任意具备通信功能的设备,本申请对此不做具体限制。例如,客户端设备可以是手机、平板电脑、笔记本电脑、智能汽车、智能家居等,以及具有通信功能的模组。在其中一个实施例中,客户端设备为通信模块,在一个示例中,通信模块为高通5G通信模块。In one embodiment, a client device is provided. The client device may be any device with a communication function, which is not specifically limited in this application. For example, client devices can be mobile phones, tablet computers, laptops, smart cars, smart homes, etc., as well as modules with communication functions. In one embodiment, the client device is a communication module, and in one example, the communication module is a Qualcomm 5G communication module.
客户端设备包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:The client device includes a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program:
获取服务器的目标地址信息;Obtain the target address information of the server;
基于目标地址信息在存储的会话映射信息中进行查找,并将目标地址信息对应的会话标识确认为目标会话标识;会话映射信息包括服务器地址信息和对应于服务器地址信息的会话标识;Searching in the stored session mapping information based on the target address information, and confirming the session identification corresponding to the target address information as the target session identification; the session mapping information includes the server address information and the session identification corresponding to the server address information;
根据目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器恢复目标会话标识对应的会话。Generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
在一个实施例中,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻。处理器执行计算机程序时还实现以下步骤:基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻;获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session. When the processor executes the computer program, the following steps are also implemented: searching in the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information; At the time of establishment, it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔;在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining the time interval between the current moment and the session establishment time corresponding to the target address information; The session ID of is confirmed as the target session ID.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。In one embodiment, when the processor executes the computer program, the following steps are further implemented: when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。In one embodiment, when the processor executes the computer program, the following steps are also implemented: when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session; update the session establishment time corresponding to the target address information to The session establishment time of the current session.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:当目标会话标识对应的会话恢复失败,则删除目标会话标识对应的会话映射信息。In one embodiment, when the processor executes the computer program, the following steps are further implemented: when the session corresponding to the target session identifier fails to resume, delete the session mapping information corresponding to the target session identifier.
在一个实施例中,处理器执行计算机程序时还实现以下步骤:当会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;在成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。In one embodiment, the following steps are also implemented when the processor executes the computer program: when there is no session mapping information corresponding to the target address information in the session mapping information, an initial handshake message is sent to the server so that the server creates a new session; In the case of creating a new session, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
获取服务器的目标地址信息;Obtain the target address information of the server;
基于目标地址信息在存储的会话映射信息中进行查找,并将目标地址信息对应的会话标识确认为目标会话标识;会话映射信息包括服务器地址信息和对应于服务器地址信息的会话标识;Searching in the stored session mapping information based on the target address information, and confirming the session identification corresponding to the target address information as the target session identification; the session mapping information includes the server address information and the session identification corresponding to the server address information;
根据目标会话标识生成握手消息,并向服务器发送握手消息,以使服务器恢复目标会话标识对应的会话。Generate a handshake message according to the target session ID, and send the handshake message to the server, so that the server restores the session corresponding to the target session ID.
在一个实施例中,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻。计算机程序被处理器执行时还实现以下步骤:基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻;获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, the session mapping information further includes session establishment time, which is the last time when the server corresponding to the server address information successfully establishes a session. When the computer program is executed by the processor, the following steps are also implemented: searching in the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information; When the session is established, it is judged whether to confirm the session identifier corresponding to the target address information as the target session identifier.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔;在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为目标会话标识。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the time interval between the current moment and the session establishment time corresponding to the target address information; The corresponding session ID is confirmed as the target session ID.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: when the time interval is greater than the effective duration, send an initial handshake message to the server, so that the server creates a new session.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when the server successfully restores the session corresponding to the target session identifier, obtain the session establishment time of the current session; update the session establishment time corresponding to the target address information The session establishment moment for the current session.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:当目标会话标识对应的会话恢复失败,则删除目标会话标识对应的会话映射信息。In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: when the session corresponding to the target session identifier fails to resume, delete the session mapping information corresponding to the target session identifier.
在一个实施例中,计算机程序被处理器执行时还实现以下步骤:当存储的会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;在成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when there is no session mapping information corresponding to the target address information in the stored session mapping information, an initial handshake message is sent to the server, so that the server creates a new session ; In the case of successfully creating a new session, establish and store corresponding session mapping information according to the target address information and the session identifier of the newly created session.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。 非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the computer programs can be stored in a non-volatile computer-readable memory In the medium, when the computer program is executed, it may include the processes of the embodiments of the above-mentioned methods. Wherein, any references to memory, storage, database or other media used in the various embodiments provided in the present application may include at least one of non-volatile memory and volatile memory. Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. To make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be It is considered to be within the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several implementation modes of the present application, and the description thereof is relatively specific and detailed, but it should not be construed as limiting the scope of the patent for the invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the scope of protection of the patent application should be based on the appended claims.

Claims (16)

  1. 一种会话建立方法,所述方法包括:A method for establishing a session, the method comprising:
    获取服务器的目标地址信息;Obtain the target address information of the server;
    基于所述目标地址信息在存储的会话映射信息中进行查找,并将所述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;Search the stored session mapping information based on the target address information, and confirm the session identifier corresponding to the target address information as the target session identifier; the session mapping information includes server address information and a session corresponding to the server address information the session ID of the
    根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。Generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
  2. 根据权利要求1所述的会话建立方法,其特征在于,所述会话映射信息还包括会话建立时刻,所述会话建立时刻为最近一次与所述服务器地址信息对应的服务器成功建立会话的时刻;The method for establishing a session according to claim 1, wherein the session mapping information further includes a session establishment time, and the session establishment time is the latest time when a server corresponding to the server address information successfully establishes a session;
    所述方法还包括:The method also includes:
    基于所述目标地址信息在存储的所述会话映射信息中进行查找,得到所述目标地址信息对应的会话建立时刻;Searching the stored session mapping information based on the target address information to obtain a session establishment time corresponding to the target address information;
    获取当前时刻,并根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识。Obtaining the current time, and judging whether to confirm the session identifier corresponding to the target address information as the target session identifier according to the session establishment time corresponding to the current time and the target address information.
  3. 根据权利要求2所述的会话建立方法,其特征在于,所述根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识,包括:The session establishment method according to claim 2, wherein, according to the session establishment time corresponding to the target address information at the current time, it is judged whether to confirm the session identifier corresponding to the target address information as the Target session ID, including:
    获取所述当前时刻距离所述目标地址信息对应的会话建立时刻的时间间隔;Obtain the time interval between the current moment and the session establishment moment corresponding to the target address information;
    在所述时间间隔小于或等于有效时长的情况下,将所述目标地址信息对应的会话标识确认为所述目标会话标识。If the time interval is less than or equal to the effective duration, confirm the session identifier corresponding to the target address information as the target session identifier.
  4. 根据权利要求3所述的会话建立方法,其特征在于,所述根据所述当前时刻与所述目标地址信息对应的会话建立时刻,判断是否将所述目标地址信息对应的会话标识确认为所述目标会话标识,还包括:The session establishment method according to claim 3, wherein, according to the session establishment time corresponding to the target address information at the current time, it is judged whether to confirm the session identifier corresponding to the target address information as the The target session ID, which also includes:
    在所述时间间隔大于所述有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。If the time interval is greater than the effective duration, an initial handshake message is sent to the server, so that the server creates a new session.
  5. 根据权利要求2所述的会话建立方法,其特征在于,所述方法还包括:The method for establishing a session according to claim 2, further comprising:
    在服务器成功恢复所述目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;When the server successfully recovers the session corresponding to the target session identifier, acquire the session establishment time of the current session;
    将所述目标地址信息对应的会话建立时刻更新为所述当前会话的会话建立时刻。Updating the session establishment time corresponding to the target address information to the session establishment time of the current session.
  6. 根据权利要求1至5任一项所述的会话建立方法,其特征在于,所述方法还包括:The session establishment method according to any one of claims 1 to 5, wherein the method further comprises:
    当所述目标会话标识对应的会话恢复失败,则删除所述目标会话标识对应的会话映射信息。When the session recovery corresponding to the target session identifier fails, delete the session mapping information corresponding to the target session identifier.
  7. 根据权利要求1至5任一项所述的会话建立方法,其特征在于,所述方法还包括:The session establishment method according to any one of claims 1 to 5, wherein the method further comprises:
    当所述会话映射信息中不存在与所述目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;When there is no session mapping information corresponding to the target address information in the session mapping information, an initial handshake message is sent to the server, so that the server creates a new session;
    在成功新建会话的情况下,根据所述目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。In the case of successfully establishing a new session, corresponding session mapping information is established and stored according to the target address information and the session identifier of the newly created session.
  8. 一种会话建立装置,所述装置包括:A device for establishing a session, the device comprising:
    目标地址信息获取模块,用于获取服务器的目标地址信息;A target address information acquisition module, configured to acquire target address information of the server;
    目标会话标识获取模块,用于基于所述目标地址信息在存储的会话映射信息中进行查找,并将所述目标地址信息对应的会话标识确认为目标会话标识;所述会话映射信息包括服务器地址信息和对应于所述服务器地址信息的会话标识;A target session identification acquisition module, configured to search stored session mapping information based on the target address information, and confirm the session identification corresponding to the target address information as the target session identification; the session mapping information includes server address information and a session identifier corresponding to the server address information;
    会话恢复模块,用于根据所述目标会话标识生成握手消息,并向服务器发送所述握手消息,以使服务器恢复所述目标会话标识对应的会话。The session restoration module is configured to generate a handshake message according to the target session identifier, and send the handshake message to the server, so that the server restores the session corresponding to the target session identifier.
  9. 根据权利要求8所述的装置,其特征在于,会话映射信息还包括会话建立时刻,会话建立时刻为最近一次与服务器地址信息对应的服务器成功建立会话的时刻;所装置还包括:The device according to claim 8, wherein the session mapping information also includes a session establishment time, and the session establishment time is the last time when a server corresponding to the server address information successfully establishes a session; the device also includes:
    时刻确定模块,用于基于目标地址信息在存储的会话映射信息中进行查找,得到目标地址信息对应的会话建立时刻;The time determination module is used to search in the stored session mapping information based on the target address information to obtain the session establishment time corresponding to the target address information;
    标识判断模块,用于获取当前时刻,并根据当前时刻与目标地址信息对应的会话建立时刻,判断是否将目标地址信息对应的会话标识确认为目标会话标识。The identification judging module is used to obtain the current time, and judge whether to confirm the session identification corresponding to the target address information as the target session identification according to the session establishment time corresponding to the current time and the target address information.
  10. 根据权利要求9所述的装置,其特征在于,所述标识判断模块包括:The device according to claim 9, wherein the identification judging module comprises:
    标识获取单元,用于获取当前时刻距离目标地址信息对应的会话建立时刻的时间间隔;在时间间隔小于或等于有效时长的情况下,将目标地址信息对应的会话标识确认为目标会话标识。The identification obtaining unit is used to obtain the time interval between the current moment and the session establishment time corresponding to the target address information; when the time interval is less than or equal to the effective duration, confirm the session identification corresponding to the target address information as the target session identification.
  11. 根据权利要求10所述的装置,其特征在于,所述标识判断模块还包括:The device according to claim 10, wherein the identification judgment module further comprises:
    初始握手消息发送单元,用于在时间间隔大于有效时长的情况下,向服务器发送初始握手消息,以使服务器新建会话。The initial handshake message sending unit is configured to send an initial handshake message to the server so that the server creates a new session when the time interval is greater than the effective duration.
  12. 根据权利要求9所述的装置,其特征在于,所述装置还包括:The device according to claim 9, wherein the device further comprises:
    会话建立时刻获取模块,用于在服务器成功恢复目标会话标识对应的会话的情况下,获取当前会话的会话建立时刻;The session establishment time obtaining module is used to obtain the session establishment time of the current session when the server successfully restores the session corresponding to the target session identifier;
    更新模块,用于将目标地址信息对应的会话建立时刻更新为当前会话的会话建立时刻。An update module, configured to update the session establishment time corresponding to the target address information to the session establishment time of the current session.
  13. 根据权利要求8至12任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 8 to 12, wherein the device further comprises:
    删除模块,用于若目标会话标识对应的会话恢复失败,则删除目标会话标识对应的会话映射信息。The deletion module is configured to delete the session mapping information corresponding to the target session ID if the session recovery corresponding to the target session ID fails.
  14. 根据权利要求8至12任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 8 to 12, wherein the device further comprises:
    会话新建模块,用于当存储的会话映射信息中不存在与目标地址信息对应的会话映射信息,则向服务器发送初始握手消息,以使服务器新建会话;The session new module is used to send an initial handshake message to the server when there is no session mapping information corresponding to the target address information in the stored session mapping information, so that the server can create a new session;
    会话映射信息建立模块,用于在成功新建会话的情况下,根据目标地址信息和新建会话的会话标识建立对应的会话映射信息并存储。The session mapping information establishing module is used for establishing and storing corresponding session mapping information according to the target address information and the session identifier of the newly created session when the session is successfully created.
  15. 一种客户端设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现权利要求1至7中任一项所述的方法的步骤。A client device, comprising a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
  16. 一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1至7中任一项所述的方法的步骤。A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are realized.
PCT/CN2022/087867 2021-09-26 2022-04-20 Session establishment method and apparatus, and client device and computer storage medium WO2023045313A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111128425.7A CN113923797A (en) 2021-09-26 2021-09-26 Session establishing method, device, client device and computer storage medium
CN202111128425.7 2021-09-26

Publications (1)

Publication Number Publication Date
WO2023045313A1 true WO2023045313A1 (en) 2023-03-30

Family

ID=79236161

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/087867 WO2023045313A1 (en) 2021-09-26 2022-04-20 Session establishment method and apparatus, and client device and computer storage medium

Country Status (2)

Country Link
CN (1) CN113923797A (en)
WO (1) WO2023045313A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113923797A (en) * 2021-09-26 2022-01-11 深圳市广和通无线通信软件有限公司 Session establishing method, device, client device and computer storage medium
CN114866594B (en) * 2022-04-24 2023-08-08 普联技术有限公司 Device connection management method, device, system, server and readable storage medium
CN115296847B (en) * 2022-07-06 2024-02-13 杭州涂鸦信息技术有限公司 Flow control method, flow control device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103795632A (en) * 2012-10-31 2014-05-14 华为技术有限公司 Data message transmission method, related equipment and system
WO2017129992A1 (en) * 2016-01-29 2017-08-03 Tectonic Interactive Limited System and method for managing communication sessions between clients and a server
CN109246172A (en) * 2017-07-11 2019-01-18 华为技术有限公司 A kind of method, apparatus and computer storage medium for restoring session
CN110445826A (en) * 2018-05-04 2019-11-12 阿里巴巴集团控股有限公司 A kind of session information acquisition methods, device and server
CN113923797A (en) * 2021-09-26 2022-01-11 深圳市广和通无线通信软件有限公司 Session establishing method, device, client device and computer storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110213356B (en) * 2019-05-21 2021-11-12 深圳壹账通智能科技有限公司 Login processing method based on data processing and related equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103795632A (en) * 2012-10-31 2014-05-14 华为技术有限公司 Data message transmission method, related equipment and system
WO2017129992A1 (en) * 2016-01-29 2017-08-03 Tectonic Interactive Limited System and method for managing communication sessions between clients and a server
CN109246172A (en) * 2017-07-11 2019-01-18 华为技术有限公司 A kind of method, apparatus and computer storage medium for restoring session
CN110445826A (en) * 2018-05-04 2019-11-12 阿里巴巴集团控股有限公司 A kind of session information acquisition methods, device and server
CN113923797A (en) * 2021-09-26 2022-01-11 深圳市广和通无线通信软件有限公司 Session establishing method, device, client device and computer storage medium

Also Published As

Publication number Publication date
CN113923797A (en) 2022-01-11

Similar Documents

Publication Publication Date Title
WO2023045313A1 (en) Session establishment method and apparatus, and client device and computer storage medium
US20150213134A1 (en) Data query method and system and storage medium
US7111305B2 (en) Facilitating event notification through use of an inverse mapping structure for subset determination
CN103780679B (en) Long delay remote invocation method based on http protocol
TW201709698A (en) Verifying source addresses associated with a terminal
WO2007056954A1 (en) A method for processing data synchronization and client terminal, server and data synchronization system thereof
WO2015062228A1 (en) Method and device for accessing shared memory
US6880013B2 (en) Permanent TCP connections across system reboots
KR20090084091A (en) Device and mehtod for synchronizing data in data communication devices
WO2019205557A1 (en) Resource subscription for internet of things device
WO2009097776A1 (en) System, device and method for achieving service upgrade
TWI716822B (en) Method and device for correcting transaction causality, and electronic equipment
WO2016180168A1 (en) Data copy method and device
CN110909030B (en) Information processing method and server cluster
CN104168140A (en) VTEP abnormal condition processing method and device
WO2009103212A1 (en) Method, system and device of data synchronization
US20210326331A1 (en) Internet of things (iot) device update validation
WO2016107612A1 (en) Method and apparatus for processing virtual card
US8687687B2 (en) Communication system
US20140280668A1 (en) Methods and systems for providing resources for cloud storage
CN110417876A (en) Node server and main control device in session method, distributed system
US7933962B1 (en) Reducing reliance on a central data store while maintaining idempotency in a multi-client, multi-server environment
WO2023123872A1 (en) Data reading method and apparatus and related device
CN106230747B (en) Method, device and system for recovering TCP connection sequence number
JP3088683B2 (en) Data communication system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22871376

Country of ref document: EP

Kind code of ref document: A1