Protocol switching methods, devices, storage media, and software products
By negotiating and establishing a new session with the peer device during the transport layer protocol switching process, and adopting a dual-transmission strategy to repeatedly send data in the old and new protocol sessions, the problem of complex session management and reduced data delivery reliability during protocol switching in the prior art is solved, and a smooth transition and stable data delivery are achieved.
Patent Information
- Application Number
- CN202510635463.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2026-11-17
AI Technical Summary
During the current transport layer protocol switching process, the differences between connection-oriented and connectionless protocols are not effectively distinguished, resulting in complex session management and reduced data delivery reliability.
By receiving the protocol switching signal, negotiating with the peer device and establishing a new protocol session, adopting a dual-transmission strategy to repeatedly send data in the old and new protocol sessions, and delivering data when conditions are met, gradually reducing the amount of data in the old protocol session, and finally closing the old protocol session.
It achieves a smooth transition between the old and new protocols, improves the reliability of protocol switching and the stability of data delivery, and avoids communication interruptions and out-of-order packet loss.
Smart Images

Figure CN123123459A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communications, and more particularly to a protocol switching method, device, storage medium, and program product. Background Technology
[0002] The transport layer, located at layer four of the TCP (Transmission Control Protocol) / IP (Internet Protocol) five-layer architecture, is primarily responsible for end-to-end communication. Transport layer protocols are end-to-end oriented protocols, providing communication services between two host processes by establishing, managing, and terminating transport layer sessions. Existing transport layer protocols can be divided into connection-oriented and connectionless protocols. Connection-oriented transport layer protocols require both sender and receiver to establish a connection, synchronize, and maintain the session connection state, while connectionless transport layer protocols do not establish a connection. Current technologies fail to effectively distinguish between these two types of protocols during the switching process, resulting in a lack of effective session initialization strategies when switching to connection-oriented protocols, and difficulty in handling out-of-order data delivery when switching to connectionless protocols. Therefore, session management during existing protocol switching is complex, leading to reduced data delivery reliability. Summary of the Invention
[0003] The purpose of this invention is to provide a protocol switching method, device, storage medium, and program product that can effectively improve the reliability of protocol switching and the stability of data delivery.
[0004] To achieve the above objectives, embodiments of the present invention provide a protocol switching method, comprising:
[0005] Upon receiving a protocol switching signal, negotiate with the peer device and establish a new protocol session;
[0006] According to the preset dual-transmission strategy, the first data is repeatedly transmitted in the new protocol session and the old protocol session;
[0007] Intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions;
[0008] When the data transmission and reception process is completely transferred to the new protocol session, the old protocol session is closed.
[0009] As an improvement to the above scheme, the dual-transmission strategy is to gradually reduce the amount of data transmitted on the old protocol session.
[0010] As an improvement to the above scheme, the step of repeatedly sending the first data in the new protocol session and the old protocol session includes:
[0011] Divide and number the first data block to obtain at least two data blocks;
[0012] According to the encapsulation requirements of the new protocol session and the old protocol session, each data block is encapsulated to obtain a first data block corresponding to the new protocol session and a second data block corresponding to the old protocol session.
[0013] The first data block is sent to the new protocol session, and the second data block is sent to the old protocol session.
[0014] As an improvement to the above solution, the data delivery conditions include at least one of the following:
[0015] The second data is a data block that does not contain identifiable head and tail padding;
[0016] The second data consists of data blocks containing identifiable head and tail fillers, and no data blocks with the same number have been delivered, and a data block with the previous number has been delivered.
[0017] As an improvement to the above scheme, after intercepting the second data sent by the new protocol session and the old protocol session, the method further includes:
[0018] When the second data meets the data caching conditions, the second data is cached; wherein the data caching conditions are: the second data is a data block containing identifiable header and tail padding, and no data block with the same number has been delivered, and the previous data block with the same number has not been delivered.
[0019] As an improvement to the above solution, after closing the old protocol session, the method further includes:
[0020] When the new protocol is a connection-oriented protocol, if a data block that does not contain identifiable header and footer padding is received, the interception of data blocks transmitted in the new protocol session will be stopped.
[0021] When the new protocol is a connectionless protocol, if a data block without identifiable header and footer padding is received, the interception of data blocks transmitted by the new protocol session will stop after a preset time period.
[0022] As an improvement to the above solution, the negotiation with the peer device and the establishment of a new session includes:
[0023] Send a handover request message to the peer device; wherein the handover request message carries the protocol type and dual-transmission strategy;
[0024] Receive handover response messages sent by the peer device;
[0025] When the information carried in the handover response message and the handover request message matches, a new session is established with the peer device.
[0026] To achieve the above objectives, embodiments of the present invention also provide a protocol switching device, comprising:
[0027] The switching negotiation module is used to negotiate with the peer device when a protocol switching signal is received;
[0028] The session management module is used to establish new protocol sessions;
[0029] The session synchronization module is used to repeatedly send the first data in the new protocol session and the old protocol session according to a preset dual-send strategy; intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions;
[0030] The session management module is also used to close the old protocol session when the data transmission and reception process is completely transferred to the new protocol session.
[0031] To achieve the above objectives, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the protocol switching method as described in any of the above embodiments.
[0032] To achieve the above objectives, embodiments of the present invention also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the protocol switching method as described in any of the above embodiments.
[0033] Compared to existing technologies, the protocol switching method, device, storage medium, and program product disclosed in this invention, through a negotiation process, allow both parties to determine the parameters and transmission strategies of the new protocol, ensuring the normal operation of the new protocol session. This negotiation mechanism avoids communication interruptions caused by protocol incompatibility, achieving a smooth transition between the old and new protocols. Furthermore, the repeated transmission of data allows the system sufficient time to verify the stability and reliability of the new protocol. The new protocol session can gradually take on more data transmission tasks, while the old protocol session serves as a backup, ensuring communication can still be maintained even if problems arise with the new protocol, thus achieving a smooth switch from the old to the new protocol. In addition, a software-implemented intermediate module built into the terminal service application and the transport layer session is used to handle the dual transmission and reception of data between the old and new protocol sessions, eliminating the need for an additional relay terminal for deduplication and forwarding of dual data streams, thus simplifying the complexity of related processes. Attached Figure Description
[0034] Figure 1 This is a flowchart of a protocol switching method provided in an embodiment of the present invention;
[0035] Figure 2 This is a flowchart of the negotiation and establishment of a new session between the local device and the peer device provided in an embodiment of the present invention;
[0036] Figure 3 This is a flowchart illustrating the repeated transmission of data between old and new protocol sessions, provided by an embodiment of the present invention.
[0037] Figure 4 This is a structural block diagram of a protocol switching device provided in an embodiment of the present invention;
[0038] Figure 5 This is another structural block diagram of a protocol switching device provided in an embodiment of the present invention;
[0039] Figure 6 This is a schematic diagram of information interaction between the local device and the remote device provided in an embodiment of the present invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] TCP and UDP (User Datagram Protocol) are the two most traditional and widely used transport layer protocols. TCP is a connection-oriented, stream-based transport layer protocol. Its sequence numbers, acknowledgments, and retransmission mechanisms ensure reliable data transmission. TCP also dynamically adjusts the host's packet sending behavior through flow control and congestion control mechanisms, thereby minimizing network congestion, reducing packet loss, and improving data transmission efficiency. UDP, on the other hand, does not provide retransmission, flow control, or congestion control reliability mechanisms. It only provides basic connectionless, best-effort end-to-end data transmission services. While UDP does not provide the same level of reliable data transmission as TCP, it saves the overhead of complex reliability mechanisms and avoids the high latency issues caused by retransmission and congestion control mechanisms in case of packet loss. Generally, TCP is suitable for applications with high reliability requirements; UDP is suitable for applications with high real-time requirements but lower reliability requirements.
[0042] To further improve the quality of transport layer services, existing technologies have proposed new transport layer protocols such as SCTP (Stream Control Transmission Protocol) and QUIC (Quick UDP Internet Connection, a low-latency Internet transport layer protocol based on UDP) on the basis of TCP and UDP. SCTP combines the characteristics of TCP and UDP, possessing both the message-oriented nature of UDP and the connection-oriented reliable transmission service with in-order delivery and congestion control as its core, similar to TCP. It also provides multi-streaming and multi-homing features. Generally, SCTP is used for signaling transmission. QUIC, on the other hand, is a new transport layer protocol based on UDP, implemented in user space, making it easy to deploy and update. QUIC has all the reliable transmission capabilities of TCP, while optimizing for problems such as long connection establishment time, head-of-line blocking, retransmission ambiguity, and inability to migrate connections, making it a promising application.
[0043] For transport layer protocols, "connection" does not refer to a physical connection, but rather a logical concept. In connectionless protocols, each data packet is independently addressed, and the data packets transmitted between two peer entities are independent. Connectionless protocols only have a best-effort transmission capability; they cannot guarantee that data packets will not be lost or arrive in the correct order. Connection-oriented protocols, on the other hand, maintain the state between packets (such as packet sequence numbers). Based on this state, the protocol can provide reliable transmission services. Transport layer protocols are end-to-end protocols, responsible for providing communication services between two host processes by establishing, managing, and terminating transport layer sessions. A transport layer session is identified using a 5-tuple: <source IP address, source port, destination IP address, destination IP port, transport layer protocol number>. The source / destination IP addresses identify the corresponding hosts, the source / destination ports identify the corresponding communication processes, and the transport layer protocol number indicates the transport layer protocol used.
[0044] To address the issue of complex session management during existing transport layer protocol switching, which leads to reduced data delivery reliability, this invention provides a protocol switching method. By finely differentiating between connection-oriented and connectionless protocol switching strategies, this method optimizes session establishment, data synchronization, and transition period management, thereby improving the reliability of protocol switching and the stability of data delivery.
[0045] See Figure 1 , Figure 1 This is a flowchart of a protocol switching method provided in an embodiment of the present invention. The protocol switching method includes:
[0046] S1. Upon receiving a protocol switching signal, negotiate with the peer device and establish a new protocol session;
[0047] S2. According to the preset dual-transmission strategy, the first data is repeatedly transmitted in the new protocol session and the old protocol session;
[0048] S3. Intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions;
[0049] S4. When the data transmission and reception process is completely transferred to the new protocol session, close the old protocol session.
[0050] For example, upon receiving a protocol switching signal, the system first synchronizes the protocol to be switched with the peer switching device and negotiates the ports required for the new transport layer protocol session and the dual-transmission strategy during repeated transmission. After reaching an agreement, the new protocol session is established and necessary initialization operations are performed. After the new session is established, the repeated transmission phase begins. Both parties repeatedly transmit and deduplicate data in the old and new sessions according to the agreed-upon dual-transmission strategy, gradually transferring the transmission and reception of upper-layer application data from the old protocol session to the new protocol session. When the application data transmission has been completely transferred to the new transport layer session, the old transport layer session is closed, and the switchover is complete.
[0051] In this embodiment of the invention, during the transport layer protocol switching process, application data is transferred from the old transport layer session to the new transport layer session in a way that is imperceptible to the user, while avoiding problems such as out-of-order delivery and packet loss that may occur during the switch. Through the negotiation process, both parties can determine the parameters and transmission strategies of the new protocol, ensuring that the new protocol session can work normally. This negotiation mechanism can avoid communication interruptions caused by protocol incompatibility and achieve a smooth transition between the old and new protocols. Furthermore, the repeated transmission of data allows the system sufficient time to verify the stability and reliability of the new protocol. The new protocol session can gradually take on more data transmission tasks, while the old protocol session serves as a backup, ensuring that communication can still be maintained even if problems occur with the new protocol, thus achieving a smooth switch from the old protocol to the new protocol. In addition, an intermediate module implemented in software and built into the terminal service application and the transport layer session is used to handle the dual transmission and reception of data between the old and new protocol sessions, without the need for an additional relay terminal to deduplicatize and forward the dual data streams, which simplifies the complexity of related processes.
[0052] Specifically, in step S1, see Figure 2 , Figure 2 This is a flowchart illustrating the negotiation and establishment of a new session between a local device and a peer device, as provided in an embodiment of the present invention. The negotiation and establishment of the new session with the peer device specifically includes:
[0053] S11. Send a handover request message to the peer device; wherein, the handover request message carries the protocol type and dual-transmission strategy;
[0054] S12, Receive the handover response message sent by the peer device;
[0055] S13. When the information carried in the handover response message and the handover request message matches, a new session is established with the peer device.
[0056] For example, when the local device receives a handover signal, it enters a handover negotiation period. The local device sends a handover request message to the peer device, informing the peer device of the protocol to be switched to (i.e., the protocol type), and negotiating the dual-transmission strategy during repeated transmissions and the port number to be used for the corresponding new protocol session. If the peer device receives the handover request message, it replies with a handover response message. If the peer device has no objection to the port and dual-transmission strategy in the handover request message, the port information and dual-transmission strategy in the handover response message are consistent with those in the handover request message; otherwise, the available port and dual-transmission strategy are written into the handover response message. After receiving the handover response message, if the local device finds that the port and / or dual-transmission strategy are not agreed upon, it continues to negotiate; if they are agreed upon, the negotiation process ends, and the establishment process of a new session is initiated.
[0057] It should be noted that, considering the potential instability of the existing transport layer protocol session (old protocol session) during the handover, the synchronization or negotiation process can be based on an independent, reliable transport layer session instead of the old protocol session. When the new protocol to be switched to is a connection-oriented reliable protocol, port negotiation communication can be based on this new protocol; when the new protocol to be switched to is a connectionless unreliable protocol, port negotiation can be based on one of the following protocols: ① the reliable transport layer protocol configured by default in the system; ② the reliable transport layer protocol with the best performance under the current network conditions; ③ the connection-oriented reliable protocol most recently used on the end side.
[0058] In this embodiment of the invention, the sent handover request message carries the protocol type and dual-transmission strategy, allowing the peer device to clearly understand the protocol type the initiator expects to switch to and the subsequent data transmission method. Upon receiving the peer device's handover response message, the information carried in it is matched with the handover request message. Only when the two match is a new session established with the peer device. This verification mechanism ensures that both parties agree on the specific content of the protocol switch, preventing communication problems caused by inconsistencies and thus guaranteeing collaborative work during the protocol switch process. Furthermore, before establishing a new session, negotiation through request and response messages allows both parties to evaluate and prepare for the new protocol and dual-transmission strategy in advance. For example, the peer device can check whether it supports the protocol and strategy and whether corresponding configuration adjustments are needed based on the protocol type and dual-transmission strategy in the request message. If not, the peer device can propose modification suggestions in the response message, allowing the initiator to renegotiate based on these suggestions. This avoids discovering incompatibility issues only after establishing a new session, thereby reducing communication interruptions and errors and improving communication reliability and stability. This negotiation-before-session approach avoids the risks associated with blindly switching protocols.
[0059] Specifically, after the negotiation process is completed, the local device and the peer device initiate the process of establishing a new session; during the establishment of the new session, if the new protocol is a connection-oriented protocol, the local device and the peer device also need to initialize the new protocol session based on the historical configuration values of the protocol-related parameters.
[0060] For example, the purpose of initialization is to establish a set of shared operational parameters for the connection (such as TCP's MSS and window scaling factor). Connectionless protocols do not have a "handshake" or "parameter negotiation" process, therefore there is no connection state that needs to be initialized. In other words, connectionless protocols do not need this set of parameters because packet transmission control (such as reliability and ordering) is usually handled by upper-layer applications or additional mechanisms (such as QUIC's connection management implemented on UDP), rather than being mandated by the protocol itself. Therefore, even if optimization is needed, such as setting a default MTU (Maximum Transmission Unit), it can be achieved through system default configuration or static parameters without negotiating "historical configuration values" with the peer device. In contrast, connection-oriented protocols (such as TCP and SCTP) need to negotiate a set of connection-level parameters through an initialization process when establishing a new session to ensure reliable and efficient data transmission.
[0061] For example, parameters negotiated with the peer device, such as RTT estimates, cwnd (Congestion Window), and sstresh (Slow Start Threshold), can be recorded in old sessions (or historical connections). When initializing a new protocol session, if the previously recorded RTT estimate can be used, there's no need for lengthy re-measurement and estimation. For instance, in the TCP protocol, the RTT estimate is used to calculate the Retransmission Timeout (RTO). Using the recorded RTT estimate directly allows for quick setting of an appropriate RTO, avoiding unnecessary retransmissions and delays caused by an unreasonable initial RTO setting. This reduces initial latency in new session establishment and data transmission, improving the initialization efficiency of the new protocol session. The congestion window and slow start threshold determine the amount of data the sender can transmit. Using previously recorded cwnd and ssthresh values during new session initialization allows the sender to enter a suitable sending state more quickly. Without these records, the sender typically needs to gradually increase cwnd from a small initial value, resulting in a lower data transmission rate in the initial phase. Using the recorded values, cwnd and ssthresh can be set to a reasonable level close to the previous runtime, thus speeding up data transmission.
[0062] In this embodiment of the invention, the connection-oriented protocol reduces the RTT (Round-Trip Time) consumption of the "negotiation-response-acknowledgment" process by reusing historical parameters, which is particularly effective during multiple handovers or frequent connection rebuilds, thus reducing the startup time of related algorithms. Furthermore, historical configurations are typically optimal parameters verified through actual operation (such as window sizes adjusted according to network path characteristics). Direct reuse avoids "trial and error" adjustments during the algorithm startup phase, allowing for a rapid transition to an efficient transmission state.
[0063] Specifically, the dual-transmission strategy is to gradually reduce the amount of data transmitted on the old protocol session, and the specific negotiation objects include, but are not limited to, the gradual reduction method or the gradual reduction speed.
[0064] For example, "gradually reducing the amount of data transmitted on old protocol sessions" is an optimization mechanism developed by the dual-send strategy during the protocol switching transition period. Its core is to gradually reduce the frequency of using old protocol sessions while ensuring reliability, rather than always sending the exact same data blocks to both the old and new sessions at the same rate. In the initial stage of protocol switching, to ensure that the peer device can receive data simultaneously through both sessions (avoiding data loss due to packet loss in the new session caused by network problems), the local device will send the same data blocks to both sessions with a high probability (even 100%). However, as the switching process progresses, the "auxiliary transmission" role of the old session gradually weakens. At this point, it is necessary to gradually reduce the sending frequency or data volume of the old session, eventually completely stopping the old session and transmitting data only through the new session. Gradual reduction methods include, but are not limited to, any of the following two approaches:
[0065] 1) The strategy for reducing the amount of data transmitted in old sessions can be determined based on time;
[0066] Specifically, the probability of generating old session data blocks can be gradually reduced over a certain time interval. For example, the probability of sending old session data blocks is 100% in the first 10 seconds, then drops to 50% in the next 10 seconds, then to 20% in the following 10 seconds, until it drops to 0%.
[0067] 2) The strategy for reducing the amount of data transmitted in old sessions can be determined based on the amount of data already transmitted;
[0068] Specifically, the probability of generating old session data blocks is gradually reduced based on the amount of data already transmitted. For example, when the cumulative amount of data transmitted by the old session reaches 80% of the total data, the old session only sends 2 out of every 10 data blocks transmitted, gradually reducing it to 0.
[0069] In this embodiment of the invention, the compatibility and stability of the old and new protocols require time to adapt and be verified during the protocol switching process. Suddenly stopping data transmission from the old protocol session could lead to data transmission interruptions or loss before the new protocol session is fully stable. Gradually reducing the data volume of the old protocol session allows for a smooth transition between the old and new protocols. For example, as the new protocol session gradually assumes the data transmission task, the old protocol session acts as a backup, continuously providing some data transmission support. This ensures that even if the new protocol session experiences a brief failure, data transmission will not be completely interrupted, thus guaranteeing the continuity and stability of communication.
[0070] Specifically, in step S2, see Figure 3 , Figure 3 This is a flowchart illustrating the repeated transmission of data between new and old protocol sessions provided in this embodiment of the invention. The repeated transmission of first data between the new and old protocol sessions includes:
[0071] S21. Divide and number the first data into blocks to obtain at least two data blocks;
[0072] S22. According to the encapsulation requirements of the new protocol session and the old protocol session, each data block is encapsulated to obtain a first data block corresponding to the new protocol session and a second data block corresponding to the old protocol session.
[0073] S23. Send the first data block to the new protocol session and send the second data block to the old protocol session.
[0074] For example, when the first data is received from the upper-layer application, the sending submodule first segments and numbers the first data. The segment length should not exceed the smaller of the maximum data length (excluding the header) that the new and old session connections can actually handle, and the length required for the header should be reserved. Segmentation and numbering are global processing of the raw application data, generating "raw data blocks (application data content only + basic number)" without any protocol-related headers or footers added. After segmentation and numbering, the sending submodule adds an identifiable header containing the number (at least the sender's number, used for identification and synchronization of data blocks transmitted between the new and old sessions) to the header of each data block, and adds padding of the necessary length to the tail (to align the actual data volume contained in the data block pair transmitted between the new and old sessions), generating a first data block (identifiable header + application data block + identifiable footer padding) for the new session transmission and a second data block (identifiable header + application data block + identifiable footer padding) for the old session transmission. The lengths of the first and second data blocks should be equal to the maximum data length that a single packet of the new and old sessions can handle, respectively. The generated first data block and second data block are written into the send buffers of the new and old sessions respectively, thereby sending the first data block to the new protocol session and the second data block to the old protocol session.
[0075] It's important to note that data segmentation and numbering are logical processing based on data content and are independent of the specific protocol. Once a "raw data block + number" is generated, it can be reused for encapsulating new and old sessions without physically copying the original data. The headers of new and old sessions may be exactly the same (because the sender's numbering needs to be synchronously identified), but the tail padding length may differ (because the new and old MTUs may be different). The final total length of the data block is equal to its respective MTU. For example, if the original data blocks are [data block 1, data block 2,...] and numbered 1, 2,..., both new and old sessions generate headers based on these numbers (e.g., the header contains number 1), with only the tail padding differing due to MTU differences.
[0076] In this embodiment of the invention, after the new session is established, the local device and the peer device will repeatedly send data over the old and new session connections. This allows for a smooth transition of upper-layer application data transmission from the old protocol session to the new protocol session, avoiding potential out-of-order and packet loss issues during the handover process. Furthermore, by numbering the data blocks, the receiving end can determine whether the data is complete and arrived in order based on the number. Additionally, the new and old protocols may have different data packet size limits, format requirements, and transmission mechanisms. By segmenting the data, each data block can be encapsulated into a format suitable for the respective protocol's transmission requirements. For example, the new protocol may support larger data packets, while the old protocol has smaller data packet size limits; segmentation ensures successful data transmission in both protocols.
[0077] Specifically, in step S3, the second data sent by the new protocol session and the old protocol session is intercepted, and the second data is delivered when the second data meets the data delivery conditions; wherein, the data delivery conditions include at least one of the following: the second data is a data block that does not contain identifiable header and tail padding; the second data is a data block that contains identifiable header and tail padding, and no data block with the same number has been delivered, and the data block with the previous number has been delivered.
[0078] It should be noted that the second data may contain or not contain data blocks with identifiable headers and trailing padding. Data blocks containing identifiable headers and trailing padding are generated during the handover synchronization period (i.e., step S2). To ensure that data blocks transmitted between the old and new sessions can be correctly identified and synchronized by the receiver, these data blocks only exist during the transition period and are a special format used for the dual-transmission strategy in the handover mechanism. Data blocks without identifiable headers and trailing padding come from two sources: the first is legacy data from the old session (i.e., data packets sent before the transition period arrive later than data packets sent during the transition period). The old session may still have untransmitted data in the network, and this data is in the original format of the old protocol (without additional headers and padding); the second is normal data from the new session (i.e., data packets sent after the transition period arrive earlier than data packets sent during the transition period). When the handover transition period ends, the new session enters normal operation, and identifiable headers and padding are no longer added (no dual-transmission strategy required), and the data blocks revert to the original format of the new protocol.
[0079] For example, both the local device and the remote device's receiving submodules need to intercept the second data sent by the new protocol session and the old protocol session, analyze the second data, and deliver the second data to the upper-layer application when the second data meets the data delivery conditions. The two data delivery conditions are explained in detail below:
[0080] 1) The second data is a data block that does not contain identifiable head and tail padding;
[0081] Data blocks that do not contain identifiable headers and footers may be normal data sent after a new session has been running stably, or residual data from an old session. In this case, the receiving submodule cannot accurately determine the sending time and order through the header identifier. In this case, the data is directly delivered to the application, allowing the application layer to handle the order and integrity of the data according to its own logic.
[0082] 2) The second data is a data block containing identifiable head and tail filler, and no data block with the same number has been delivered, and the data block with the previous number has been delivered.
[0083] Transport layer protocols require data to be delivered in order. The receiving submodule needs to maintain the numbering order of data blocks. When a current number has been delivered, it means that the data block with the current number is the next block to be processed. If the data block with the current number has not been delivered before, it means that this is the first time the data block has been received. At this time, the header and padding (these are additional information during the transition period) are removed, and the original application data is delivered to the upper layer.
[0084] Furthermore, regarding scenario 2), since the second data block contains identifiable headers and footers, the receiving submodule needs to remove these headers and footers before delivery to the upper-layer application. The identifiable headers and footers are a temporary mechanism used during the transition to distinguish data blocks between new and old sessions and align the MTU; they are not part of the application data. Once the data block is confirmed to have arrived in order and needs delivery, this additional information is no longer required and must be removed to restore the original data. Additionally, after delivering the second data block with headers and footers removed, the receiving submodule marks its corresponding number as delivered and checks if there are subsequent numbered data blocks in the cache. If so, it delivers the data to the upper layer and removes the corresponding data block from the cache.
[0085] In this embodiment of the invention, for data blocks that do not contain identifiable headers and footers, such data blocks may be data sent according to a new simplified format after the new protocol has stabilized. Directly delivering these data to the application ensures that the application receives the latest data without excessive processing steps, reducing the risk of data loss or corruption caused by data processing and ensuring the original integrity of the data. For data blocks containing identifiable headers and footers, it is required that no data block with the same number has been delivered before, and that the previous data block with the same number has already been delivered. This ensures that the data is delivered to the application in order and completely. If a data block with a certain number is not received completely or is received in the wrong order, it will not be delivered to the application, avoiding the application receiving incomplete or out-of-order data and ensuring the logical integrity of the data.
[0086] Furthermore, in step S3, the method further includes: caching the second data when the second data meets the data caching conditions; wherein the data caching conditions are: the second data is a data block containing identifiable header and tail padding, and no data block with the same number has been delivered, and the previous data block with the same number has not been delivered.
[0087] For example, if a previously numbered data block has not been delivered, it means the data blocks arrived out of order. For instance, if data block number 2 is received but data block number 1 has not yet been delivered, even if data block number 2 is being received for the first time and is not cached, it cannot be delivered directly. Otherwise, the upper-layer application will receive out-of-order data. The correct approach is to temporarily store it in the cache, wait for data block number 1 to arrive and be delivered, and then process subsequent data blocks in order.
[0088] In this embodiment of the invention, temporarily storing out-of-order data blocks and waiting for the arrival of preceding data blocks ensures that the application layer receives a continuous and ordered data stream, avoiding business logic errors caused by out-of-order delivery. During the dual-transmission phase of protocol switching, the old and new sessions may send the same data blocks (with identifiable headers). The temporary storage mechanism can filter duplicate data blocks (by numbering), ensuring that data blocks with the same number from the old and new sessions are delivered only once (regardless of which session arrives first). This mechanism, combined with the dual-transmission strategy, can utilize the reliability of the old session as a backup while avoiding duplication or out-of-order issues caused by dual-transmission. If out-of-order data blocks are delivered directly, the upper-layer application may discard them due to inability to process them, causing subsequent correctly arriving preceding data blocks to also need to be retransmitted, increasing network and computing resource consumption. The temporary storage mechanism, through "caching-waiting-batch delivery," ensures that each data block is processed only once, reducing the overhead of retransmission and repeated parsing.
[0089] Furthermore, in step S3, the method further includes: discarding the second data when the second data does not meet the data delivery conditions and data caching conditions; wherein, the scenarios that trigger "discarding" are as follows (only as examples, and not limited to):
[0090] 1) Duplicate reception; the data block number has been marked as "delivered" (i.e., it has been processed before and may arrive repeatedly due to network retransmission);
[0091] 2) Out-of-order and cannot be cached; the previous number has not been delivered, and the current data block has already been cached (to avoid caching the same data block repeatedly);
[0092] 3) Format error; data block header parsing failed (e.g., missing number, incorrect sender identifier), and it could not be confirmed that it belonged to either the old or new session.
[0093] In this embodiment of the invention, by discarding data blocks that do not meet the data delivery conditions and data caching conditions, there is no need to process invalid, duplicate, or out-of-order and unrecoverable data, ensuring that only valid, ordered, and non-duplicate application data is delivered to the upper layer, thus maintaining communication reliability during the handover process.
[0094] Specifically, in step S4, when the data transmission and reception process is completely transferred to the new protocol session, the old protocol session is closed.
[0095] For example, when the old session's send buffer is empty, meaning there is no new data to be sent and all historical data from the dual-send period has been sent, it indicates that the data transmission and reception process has been completely transferred to the new protocol session; or, upper-layer data is no longer written to the old session and is entirely handled by the new session, indicating that the data transmission and reception process has been completely transferred to the new protocol session. After the data transmission has been completely transferred from the old protocol session to the new protocol session, the old session's closing process is initiated. The sender no longer performs dual-send behavior, the sending submodule stops working, and upper-layer application data will no longer be intercepted but will be directly written to the new session's send buffer.
[0096] In this embodiment of the invention, by tracking the state of the old and new protocol sessions and strictly controlling the dual-transmission strategy, the continuity and reliability of data during protocol switching are ensured, and transmission interruptions caused by differences in the characteristics of the old and new protocols are avoided.
[0097] Furthermore, after executing step S4, unlike the sending submodule which actively terminates the dual-sending behavior, the receiving submodule needs to determine the timing of ending the handover transition period based on the two different scenarios of switching to a connection-oriented or connectionless protocol, and take the following two different actions:
[0098] 1) When the new protocol is a connection-oriented protocol, if a data block without identifiable header and trailer padding is received, stop intercepting the data block transmitted by the new protocol session;
[0099] For example, when switching to a connection-oriented protocol, considering the in-order delivery characteristic of connection-oriented transport layer protocols, when the receiving submodule begins to receive data blocks without identifiable headers and trailer padding (i.e., all data sent during the transition period in the new session has been delivered to the upper layer), it stops working, the transition period ends, and the switchover is complete. After the switchover is complete, application data delivered by the new session will no longer be intercepted but will be directly written to the application; at the same time, if data still being delivered upwards in the old session is received, it will be ignored.
[0100] 2) When the new protocol is a connectionless protocol, if a data block without identifiable header and footer padding is received, the interception of data blocks transmitted by the new protocol session will stop after a preset time period.
[0101] For example, connectionless protocols (such as UDP) do not guarantee in-order delivery of data and may even lose data. During the handover transition (dual transmission phase), data blocks sent by the old and new sessions may be transmitted via different paths, causing data blocks with identifiable headers sent during the transition to arrive at the receiving end later than the normal data blocks (without headers) sent by the new session after the handover is complete. For instance, data block number 10 sent during the dual transmission phase may arrive only after the handover is complete (when the new session has already sent normal data block number 20) due to network delays. If the receiving submodule immediately stops working (as in connection-oriented protocols), these late-arriving header-laden data blocks will be directly ignored (because connectionless protocols do not handle state), resulting in data loss during the transition. Therefore, when switching to a connectionless protocol, considering the potential out-of-order delivery of connectionless transport layer protocols, when the receiving module begins to receive data blocks without identifiable headers and footers, it indicates that the new session has successfully sent data. Instead of immediately stopping, it immediately starts a countdown (a preset waiting time, which can be negotiated through the dual transmission strategy) and waits for a period of time. During the waiting period, if a data block with a identifiable header (out-of-order transitional data) is detected, the header and footer of the data block are removed before delivery to the upper layer; for other data streams without a identifiable header, they are delivered directly to the upper layer. After the waiting time expires, the handover transition period ends, and the handover is complete. After the handover is complete, application data delivered by the new session will no longer be intercepted by the receiving submodule, but will be written directly to the application; at the same time, if data from the old session is still being delivered upwards, it will be ignored.
[0102] In this embodiment of the invention, for connection-oriented protocols, due to their in-order delivery characteristic, when the receiving submodule begins to receive data blocks without identifiable headers and footers, it means that all data during the transition period in the new session has been delivered. At this point, stopping the interception of data blocks transmitted by the new protocol session can quickly end the handover transition period, reducing unnecessary interception and processing operations. This allows the data of the new protocol session to be directly and efficiently written to the application, improving the overall data processing efficiency of the system. For connectionless protocols, during the handover transition period, data from the old and new sessions may arrive out of order. Waiting for a preset time period allows sufficient time for header-containing data blocks that may arrive late due to network latency to reach the receiving end. During the waiting period, these late-arriving data blocks are processed and delivered to the upper layer, avoiding data loss during the transition period due to immediately stopping interception, thus ensuring data integrity. Furthermore, once the transition is determined to be complete, the receiving submodule stops working, and the application data delivered by the new session is directly written to the application, avoiding continuous interception and complex judgment processes. Simultaneously, directly ignoring the data delivered upwards from the old session reduces the processing burden on old session data, making the system processing logic simpler and clearer, and reducing system complexity and error probability.
[0103] Furthermore, during operation, it is also necessary to record the configuration of the current transport layer protocol operating parameters, including but not limited to RTT estimates, cwnd, sstresh, etc. These operating parameters are used for the initialization process of connection-oriented protocols when establishing a new session.
[0104] In this embodiment of the invention, the connection-oriented protocol can improve the initialization efficiency of new protocol sessions by reusing historical parameters.
[0105] See Figure 4 , Figure 4 This is a structural block diagram of a protocol switching device 100 provided in an embodiment of the present invention. The protocol switching device 100 includes:
[0106] The switching negotiation module 11 is used to negotiate with the peer device when a protocol switching signal is received;
[0107] Session management module 12 is used to establish new protocol sessions;
[0108] The session synchronization module 13 is used to repeatedly send the first data in the new protocol session and the old protocol session according to a preset dual-send strategy; intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions;
[0109] The session management module 12 is also used to close the old protocol session when the data transmission and reception process is completely transferred to the new protocol session.
[0110] Specifically, see Figure 5 , Figure 5 This is another structural block diagram of a protocol switching device 100 provided in an embodiment of the present invention. The detailed working process of each module is as follows:
[0111] The handover negotiation module 11 provides both parties with synchronization services for the proposed new transport layer session protocol type, a dual-transmission strategy during retransmission, and port negotiation services. It then feeds back the port number and the negotiation results of the dual-transmission strategy to the session management module 12 and the session synchronization module 13, respectively. The specific synchronization and handover process can be initiated by the handover initiator by sending a handover request message, and both parties subsequently synchronize and negotiate through handover response messages. The handover request message and handover response message must include the dual-transmission strategy during retransmission supported by the end-side and the five-tuple identifier corresponding to the new session. Communication between the handover negotiation module 11 of both parties should be based on a reliable transport layer protocol. One possible method for selecting the specific protocol is: when the proposed new protocol is a connection-oriented reliable protocol, the communication of the handover negotiation module 11 can be based on this new protocol; when the proposed new protocol is a connectionless unreliable protocol, the communication of the handover negotiation module 11 can be based on the system's default configured reliable transport layer protocol, the best-performing reliable transport layer protocol under the current network conditions, or the connection-oriented reliable protocol most recently used by the end-side.
[0112] The session management module 12 includes a session establishment submodule 121 and a session initialization submodule 122. After the handover negotiation is completed, the session establishment submodule 121 on the handover initiating end immediately initiates the establishment of a new session, and the session establishment submodule 121 on the handover responding end responds. When the new session is connection-oriented, the session initialization submodule 122 initializes the new session at the beginning of its establishment based on historical values recorded by the session record module 14, including but not limited to the setting of RTO values and congestion control parameter values, to reduce the startup time of the congestion control algorithm.
[0113] The session synchronization module 13 acts as an intermediary between the application and the transport layer session. It includes a sending submodule 131 and a receiving submodule 132. The session synchronization module 13 is activated after a new session is established. During the operation of the session synchronization module 13, the sending submodule 131 intercepts application data transmitted from the upper-layer application to the transport layer session. According to the dual-transmission strategy agreed upon by both parties during the retransmission period, the application data is divided into blocks and marked to generate new session transport blocks and old session transport blocks. These blocks are then written into the new and old sessions respectively for transmission, thus smoothly completing the switch between the new and old sessions. The receiving submodule 132 is responsible for intercepting the data delivered to the upper-layer application by the new and old sessions, performing deduplication, and delivering the data to the upper-layer application in sequence.
[0114] The session recording module 14 is responsible for recording the configuration of the transport layer protocol operating parameters used during application operation, including but not limited to RTT estimates, cwnd, and sstresh.
[0115] Furthermore, the session synchronization module 13 is also used for:
[0116] The first data is divided into blocks and numbered to obtain at least two data blocks; each data block is encapsulated according to the encapsulation requirements of the new protocol session and the old protocol session to obtain a first data block corresponding to the new protocol session and a second data block corresponding to the old protocol session; the first data block is sent to the new protocol session and the second data block is sent to the old protocol session.
[0117] When the second data meets the data caching conditions, the second data is cached; wherein the data caching conditions are: the second data is a data block containing identifiable header and tail padding, and no data block with the same number has been delivered, and the previous data block with the same number has not been delivered;
[0118] When the new protocol is a connection-oriented protocol, if a data block without identifiable header and footer padding is received, the interception of data blocks transmitted by the new protocol session will stop. When the new protocol is a connectionless protocol, if a data block without identifiable header and footer padding is received, the interception of data blocks transmitted by the new protocol session will stop after a preset time period.
[0119] Further, see Figure 6 , Figure 6 This is a schematic diagram of information interaction between the local device and the peer device provided in an embodiment of the present invention. Except for the information interaction process during the negotiation phase (the local device sends a handover request message to the peer device, and the peer device returns a handover response message to the local device), the local device (the handover initiator) and the peer device (the handover responder) have the same process for sending (segmenting, numbering) and receiving (deduplicating) application data.
[0120] It is worth noting that the working process of each module in the protocol switching device 100 described in the embodiments of the present invention can refer to the working process of the protocol switching method described in the above embodiments, and will not be repeated here.
[0121] Furthermore, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the protocol switching method described in the above embodiments. The computer program can be divided into one or more modules / units, which are stored in a memory and executed by a processor to complete the present invention. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0122] Furthermore, embodiments of the present invention also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the protocol switching method as described in the above embodiments.
[0123] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A protocol switching method, characterized by, include: Upon receiving a protocol switching signal, negotiate with the peer device and establish a new protocol session; According to the preset dual-transmission strategy, the first data is repeatedly transmitted in the new protocol session and the old protocol session; Intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions; When the data transmission and reception process is completely transferred to the new protocol session, the old protocol session is closed.
2. The protocol handover method of claim 1, wherein, The dual-transmission strategy is to gradually reduce the amount of data transmitted on the old protocol session.
3. The protocol switching method as described in claim 1, characterized in that, The step of repeatedly sending the first data in the new protocol session and the old protocol session includes: Divide and number the first data block to obtain at least two data blocks; According to the encapsulation requirements of the new protocol session and the old protocol session, each data block is encapsulated to obtain a first data block corresponding to the new protocol session and a second data block corresponding to the old protocol session. The first data block is sent to the new protocol session, and the second data block is sent to the old protocol session.
4. The protocol switching method as described in claim 1, characterized in that, The data delivery conditions include at least one of the following: The second data is a data block that does not contain identifiable head and tail padding; The second data consists of data blocks containing identifiable head and tail fillers, and no data blocks with the same number have been delivered, and a data block with the previous number has been delivered.
5. The protocol switching method as described in claim 1, characterized in that, After intercepting the second data sent by the new protocol session and the old protocol session, the method further includes: When the second data meets the data caching conditions, the second data is cached; wherein the data caching conditions are: the second data is a data block containing identifiable header and tail padding, and no data block with the same number has been delivered, and the previous data block with the same number has not been delivered.
6. The protocol switching method as described in claim 1, characterized in that, After closing the old protocol session, the method further includes: When the new protocol is a connection-oriented protocol, if a data block that does not contain identifiable header and footer padding is received, the interception of data blocks transmitted in the new protocol session will be stopped. When the new protocol is a connectionless protocol, if a data block without identifiable header and footer padding is received, the interception of data blocks transmitted by the new protocol session will stop after a preset time period.
7. The protocol switching method as described in claim 1, characterized in that, The process of negotiating with the peer device and establishing a new session includes: Send a handover request message to the peer device; wherein the handover request message carries the protocol type and dual-transmission strategy; Receive handover response messages sent by the peer device; When the information carried in the handover response message and the handover request message matches, a new session is established with the peer device.
8. A protocol switching device, characterized in that, include: The switching negotiation module is used to negotiate with the peer device when a protocol switching signal is received; The session management module is used to establish new protocol sessions; The session synchronization module is used to repeatedly send the first data in the new protocol session and the old protocol session according to a preset dual-send strategy; intercept the second data sent by the new protocol session and the old protocol session, and deliver the second data when the second data meets the data delivery conditions; The session management module is also used to close the old protocol session when the data transmission and reception process is completely transferred to the new protocol session.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the protocol switching method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, implements the protocol switching method as described in any one of claims 1 to 7.
