CN117061586A - Service data sending method, receiving method, device, system and equipment - Google Patents

Service data sending method, receiving method, device, system and equipment Download PDF

Info

Publication number
CN117061586A
CN117061586A CN202311061515.8A CN202311061515A CN117061586A CN 117061586 A CN117061586 A CN 117061586A CN 202311061515 A CN202311061515 A CN 202311061515A CN 117061586 A CN117061586 A CN 117061586A
Authority
CN
China
Prior art keywords
data
interface
mlcp
connection
class
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311061515.8A
Other languages
Chinese (zh)
Inventor
王仕友
刘剑华
谈成宝
程黎辉
关亚东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Longcheer Technology Co Ltd
Original Assignee
Shanghai Longcheer Technology Co Ltd
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 Shanghai Longcheer Technology Co Ltd filed Critical Shanghai Longcheer Technology Co Ltd
Priority to CN202311061515.8A priority Critical patent/CN117061586A/en
Publication of CN117061586A publication Critical patent/CN117061586A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/43Assembling or disassembling of packets, e.g. segmentation and reassembly [SAR]
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application provides a service data transmitting method, a receiving method, a device, a system and equipment, wherein the transmitting method comprises the following steps: creating and starting an MLCP connection with a data receiver at a data sender; generating a heartbeat data packet of an MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request; based on the first data length, dividing the heartbeat data packet and each service data packet into a plurality of data segments; and sequentially sending the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket. By the method, MLCP long connection is established between the data receiving and transmitting parties, business data is flexibly split into custom data segments for transmission, flexibility and bandwidth utilization rate of data encapsulation are improved, transmission efficiency is improved, frame layers are few, codes are light, and resource expenses of a CPU, a memory and the like are reduced.

Description

Service data sending method, receiving method, device, system and equipment
Technical Field
The application relates to the technical field of computer data transmission, in particular to a service data transmission technology.
Background
In computer network systems, different business data is typically transmitted, processed in byte streams to implement business functions or to provide business services. In an application scenario where the amount of transmission service data is large or frequent interaction is required between a data sender and a data receiver, a long connection protocol is generally used to establish a transmission channel. The existing common long connection protocols such as WebSocket, HTTP/HTTPS and the like have the defects of excessive frame layers, multiple encapsulation, high cost, high resource occupancy rate, fewer callback entries, low configurability and expandability, and no heartbeat keep-alive function exists in the existing part of the long connection protocols, so that the existing part of the long connection protocols need to be automatically realized in a service application layer.
With the rapid development of the mobile internet, interactive services based on the mobile internet are endless, such as various social apps and chat apps used on mobile devices, and in the process of implementing data interaction, data transmission is often required to be implemented by establishing a long connection.
In application scenarios where mobile devices are numerous and service scenarios are more and more complex, the existing long connection protocol mainly applied to computer network systems is not very suitable.
Disclosure of Invention
The application aims to provide a service data sending method, a service data receiving device, a service data sending system and service data receiving equipment, which are used for at least partially solving the technical problems of high resource occupancy rate, fewer callback entries, low configurability and expandability caused by excessive frame layers, multiple encapsulation and high expenditure of a long connection protocol for byte stream data transmission in the prior art.
According to an embodiment of an aspect of the present application, there is provided a service data transmission method applied to a data transmitter, wherein the method includes:
creating and starting an MLCP connection with a data receiver;
generating a heartbeat data packet of an MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request;
based on the first data length, dividing the heartbeat data packet and each service data packet into a plurality of data segments;
and sequentially sending the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket.
Optionally, the MLCP includes:
the MLCPsocket class corresponds to a Socket operation layer in the hierarchical architecture of the MLCP and is used for realizing Socket connection management, data transmission and data reception;
The MLCPSocket control class is inherited by an MLCP control layer in the hierarchical architecture corresponding to the MLCP and is used for realizing Socket request and MLCP long connection logic control;
an MLCP class, corresponding to an MLCP interface layer in the hierarchical architecture of the MLCP, inherits the MLCPSocketControl class and is used for realizing an external public interface;
the MLCPINterface class is used for providing callback function interfaces;
the MLCPCallBack class is used for callback function management;
MLCPLogUtil class for providing logging tools.
Optionally, the MLCP further includes:
the MLCPNetUtil class is used for providing network management;
the MLCPSysUtil class is used for providing system management;
the MLCPVERIL class is used for providing version management.
Optionally, the MLCPSocket class includes:
the Socket connection creation interface is used for initializing Socket connection, initializing a data buffer area and calling the data receiving interface to start a data receiving process;
the Socket connection closing interface is used for destroying the data buffer area, destroying the data connection thread and destroying Socket connection;
the first data transmission interface is used for splitting the data packet of the MLCP frame structure into a plurality of data segments and sequentially transmitting the data segments corresponding to the data packet of the MLCP frame structure through sockets;
The data receiving interface is used for sequentially receiving a plurality of data segments corresponding to the data packets of the MLCP frame structure through sockets and writing the data segments into the data buffer area;
the data buffer management interface is used for initializing the data buffer, writing the data buffer, reading the data buffer, obtaining the length of the data buffer and emptying the data buffer.
Optionally, the Socket connection creation interface, the Socket connection closing interface, the first data sending interface and the data receiving interface are further configured to:
and (5) capturing and logging the abnormality.
Optionally, the MLCPSocketControl class includes:
the first initialization interface is used for setting a connection name, a context object and a log switch;
the first setting callback interface is used for initializing an MLCPCallBack class and calling the setting callback interface of the MLCPCallBack class;
starting a connection interface, which is used for setting parameters such as connection url, ports, heartbeat keep-alive time interval, disconnection reconnection interval and the like, calling the Socket connection creation interface to create MLCP connection, starting a reading thread to read data from a data buffer zone, calling the heartbeat keep-alive interface to start the heartbeat keep-alive thread, and disconnecting reconnection;
The heartbeat keep-alive interface is used for sending heartbeat keep-alive data packets and reconnecting broken wires;
the reconnection port is used for calling the Socket connection closing interface to close the MLCP connection and calling the starting connection interface to start the MLCP connection;
the second data sending interface is used for calling the callback interface, calling the first data sending interface to send data, and reconnecting when disconnection occurs;
the first closing connection interface is used for calling the data buffer management interface to empty the data buffer, calling the Socket connection closing interface to close the MLCP connection and destroying the data reading thread;
the first acquisition connection state interface is used for returning to the MLCP connection state;
and the first emptying data interface is used for calling the data buffer area management interface to empty the data buffer area.
Optionally, the start connection interface, the heartbeat keep-alive interface, the reconnection port, the second data transmission interface, and the first close connection interface are further configured to:
and (5) capturing and logging the abnormality.
Optionally, the MLCP class includes:
the second initialization interface is used for calling the first initialization interface;
the second setting callback interface is used for calling the first setting callback interface;
The connection interface is used for calling the starting connection interface;
a transmission data interface for calling the second data transmission interface;
the second connection state acquisition interface is used for calling the first connection state acquisition interface;
the second emptying data interface is used for calling the first emptying data interface;
and the second closing connection interface is used for calling the first closing connection interface.
Optionally, the MLCPCallBack class includes:
the third callback interface is used for setting the callback interface to receive the parameters of the MLCPINterface class;
and the callback interface is used for calling callback functions of the MLCPINterface class to enter the service application type, the MLCP instance name, the connection state and the service data or return the parameters to the service application.
Optionally, the MLCPInterface class includes:
and the callback function, wherein parameters of the callback function comprise service application type, MLCP instance name, connection state and context object.
Optionally, the MLCPLogUtil class includes:
the management log switch interface is used for setting a log switch state and acquiring the log switch state;
the record information log interface is used for printing the information type log, and calling the save log to the file interface to save the information type log to the file;
The record debug log interface is used for printing a debug type log, and calling a save log to file interface to save the debug type log to a file;
the warning log recording interface is used for printing a warning type log, and calling a saving log to a file interface to save the warning type log to a file;
the record exception log interface is used for printing an exception type log, and calling a save log to a file interface to save the exception type log to a file;
the log is saved to a file interface and is used for creating a catalog, creating a file and writing the file;
and the deletion log file interface is used for acquiring and deleting the expired log file.
Optionally, wherein the creating and initiating the MLCP connection with the data receiver includes:
using an MLCP class, setting a first core parameter, wherein the first core parameter comprises: context object, MLCP instance name, log switch;
setting a callback function and a second core parameter by using an MLCPSocketControl class and an MLCPICnterface class, wherein the parameters of the callback function comprise a current MLCP instance name, a connection state and a context object, and the second core parameter comprises: connecting party url, port, heartbeat keep-alive sending interval, broken line reconnection interval and data buffer area size;
And establishing and starting the MLCP connection according to the second core parameters.
Optionally, if the MLCP connection with the data receiver fails, the method further includes:
and restarting the MLCP connection with the data receiver based on the disconnection reconnection interval.
Optionally, the MLCPNetUtil class includes:
acquiring a network connection type interface for acquiring a network type;
and the network connection state acquisition interface is used for calling the system bottom layer interface to judge the network state and calling the network connection type acquisition interface to acquire the network type.
Optionally, the mlcpsysys ntil class includes:
acquiring an IP address interface;
acquiring a sim card state interface;
a first data type conversion interface for int conversion into byte arrays;
a second data type conversion interface for converting byte arrays into int;
a third data type conversion interface for converting the input stream into a byte array;
a byte array intercepting interface for byte array intercepting operation;
and the byte array splicing interface is used for byte array splicing operation.
Optionally, the mlcpvaerutil class includes:
and the version number acquisition interface is used for acquiring the version number of the currently used MLCP.
Optionally, the MLCP frame structure includes:
compression mode field, encryption mode field, total frame number field, current frame field, key field, payload length bit width field, payload length field, payload field.
Optionally, when splitting the heartbeat data packet or each service data packet into a plurality of data segments, if the length of the last actual remaining data is smaller than the first data length, the length of the last data segment is the length of the actual remaining data.
According to another embodiment of an aspect of the present application, there is provided a method for receiving service data, applied to a data receiving side, wherein the method includes:
creating and starting an MLCP connection with a data sender;
initializing a data buffer zone, receiving data sequentially sent by a data sender through a Socket, reading the data according to a second data length based on a first data reading interval, obtaining a data segment and writing the data segment into the data buffer zone;
based on a second data reading interval, reading a plurality of data segments from the data buffer area, and assembling the data segments into a data packet with an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet;
And acquiring service data based on the service data packet of the MLCP frame structure.
Optionally, the method further comprises:
and deleting the data segment from the data buffer after the data segment is successfully read from the data buffer.
Optionally, the method further comprises:
when all the data segments in the data buffer are successfully read and no new data segments are written, the data buffer is emptied.
According to an embodiment of another aspect of the present application, there is provided a service data transmitting apparatus deployed at a data transmitting side, wherein the apparatus includes:
a first module for creating and starting an MLCP connection with a data receiver;
the second module is used for generating a heartbeat data packet of the MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on the service data transmission request;
the third module is used for dividing the heartbeat data packet and each service data packet into a plurality of data segment packets based on the first data length;
and a fourth module, configured to sequentially send, to the data receiver through Socket, a heartbeat packet and a plurality of data segments corresponding to each service packet.
According to another embodiment of another aspect of the present application, there is provided a service data receiving apparatus deployed on a data receiving side, wherein the apparatus includes:
a fifth module for creating and starting an MLCP connection with the data sender;
a sixth module, configured to initialize a data buffer, receive data sequentially sent by the data sender through Socket, read data according to a second data length based on a first data reading interval, obtain a data segment, and write the data segment into the data buffer;
a seventh module, configured to read a plurality of data segments from the data buffer based on a second data reading interval, and assemble a data packet with an MLCP frame structure, where the data packet is a heartbeat keep-alive data packet or a service data packet;
and a ninth module, configured to obtain service data based on the service data packet of the MLCP frame structure.
According to an embodiment of still another aspect of the present application, there is provided a service data transmission system, wherein the system includes:
the data transmission side is used for creating and starting MLCP connection with the data receiver, generating a heartbeat data packet of an MLCP frame structure based on a heartbeat keep-alive transmission interval, packaging service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request, respectively splitting the heartbeat data packet and each service data packet into a plurality of data segment packets based on a first data length, and sequentially transmitting the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket;
The data receiving party is used for creating and starting MLCP connection with the data sending party, initializing a data buffer zone, receiving data sequentially sent by the data sending party through a Socket, reading the data according to a second data length based on a first data reading interval to obtain data segments and writing the data segments into the data buffer zone, reading a plurality of data segments from the data buffer zone based on the second data reading interval, and assembling the data segments into a data packet of an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet, and acquiring service data based on the service data packet of the MLCP frame structure.
Compared with the prior art, the application provides a service data sending method, a receiving method, a device, a system and equipment, wherein the method comprises the following steps: creating and starting an MLCP connection with a data receiver at a data sender; generating a heartbeat data packet of an MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request; based on the first data length, dividing the heartbeat data packet and each service data packet into a plurality of data segments; and sequentially sending the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket. Creating and starting MLCP connection with a data sender at a data receiver, initializing a data buffer zone, receiving data sequentially sent by the data sender through a Socket, reading data according to a second data length based on a first data reading interval to obtain data segments and writing the data segments into the data buffer zone, reading a plurality of data segments from the data buffer zone based on the second data reading interval, and assembling the data segments into a data packet of an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet, and acquiring service data based on the service data packet of the MLCP frame structure. By the method, MLCP long connection is established between the data receiving and transmitting parties, business data is flexibly split into custom data segments for transmission, flexibility and bandwidth utilization rate of data encapsulation are improved, transmission efficiency is improved, frame layers are few, codes are light, and resource expenses of a CPU, a memory and the like are reduced.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the accompanying drawings in which:
fig. 1 shows a flow diagram of a method for sending service data applied to a data sender according to an embodiment of an aspect of the present application;
fig. 2 is a flow chart of a service data receiving method applied to a data receiving party according to another embodiment of an aspect of the present application;
FIG. 3 is a schematic diagram of a service data transmitting device deployed on a data sender according to one embodiment of another aspect of the present application;
fig. 4 is a schematic diagram of a service data receiving apparatus deployed on a data receiving side according to another embodiment of another aspect of the present application;
fig. 5 shows a schematic diagram of a service data transmission system according to an embodiment of a further aspect of the present application;
the same or similar reference numbers in the drawings refer to the same or similar parts.
Detailed Description
The application is described in further detail below with reference to the accompanying drawings.
In a typical configuration of embodiments of the application, the modules of the apparatus, system trusted parties and/or devices may each include one or more processors (CPUs), input/output interfaces, network interfaces and memory, as well as associated software to ensure that the associated functions are implemented.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer readable media, as defined herein, does not include non-transitory computer readable media (transmission media), such as modulated data signals and carrier waves.
The existing long-connection communication protocols applied to byte stream data communication, such as WebSocket and HTTP, or have excessive frame layers and multiple encapsulation, inflexible packet header formats, high occupied bandwidth, high expenditure and high resource occupancy rate; or the provided callback entrance is less, the personalized customization of the connection process cannot be realized, for example, the provided connection callback cannot distinguish the starting connection, the connection and the completion of the connection node; or parameters related to sending, receiving and heartbeat keep-alive cannot be set in a self-defined mode, and the configurability and the expandability are low. Some have no heartbeat keep-alive function yet, and the heartbeat keep-alive function needs to be realized at the service application level; the method can not record the relevant logs of the necessary nodes in the connection process, can not effectively and thoroughly track and analyze offline, and only records the abnormality when the abnormality occurs, but does not record the relevant specific logic node names, so that the source of the abnormality problem can not be judged. In addition, although the android system is mostly adopted for mobile devices, versions are numerous, and compatibility needs to be considered.
In order to solve the above problems, the present application provides a technical solution for byte stream data transmission based on MLCP (Multi frame (Micro) Long Connect Protocol), multi-frame long connection transmission protocol/Micro long connection transmission protocol), which can be written based on Java, and a long connection protocol and encapsulation method are newly designed, which can achieve high utilization of bandwidth resources and light weight of codes, without limiting data sender and data receiver, as long as data transmission service can be provided and MLCP protocol supported devices are provided), specifically,
The method can realize the light weight of codes, encapsulate necessary core function classes and auxiliary tool classes, provide a heartbeat keep-alive mechanism according to heartbeat keep-alive data packets customized by different network types, customize the size of an MLCP frame, split the MLCP frame according to the size of a custom data segment, transmit the MLCP frame through a Socket, reduce the occupancy rate of resources, reduce the packing volume and the memory occupancy, and improve the transmission efficiency, so as to be applied to equipment sensitive to the size of a binary file and precious in running memory resources, such as smart phones, wearable equipment or Internet of things equipment, or virtual machines of computers.
And providing an atomization log record, so that the granularity of the log in the connection process is refined, the coverage of key nodes is enlarged, and the debugging, anomaly tracking and offline log analysis are facilitated.
The extensibility and parameter configurability of the callback interface are improved, so that core variables and parameters can be configured pertinently when facing different system versions, devices and network environments.
The frame format of the MLCP data packet is customized, so that the flexibility can be improved, the bandwidth can be fully utilized for transmitting data with different orders, the cost is reduced, and the occupancy rate of CPU, memory and bandwidth can be reduced during mass data transmission.
The system version dependence is reduced, portability is improved, and the system and the method are applicable to any version of android system or android virtual machine supporting Socket communication, wherein the android system or the android virtual machine at least comprises the following core dependence: java.io.IOException, java.io.InputStream, java.io.OutputStream, java.io.ByteArrayOutputStream, java.io.BufferedWriter, java, io, file, java.io.FileWriter, java.io.IOException, java.io.InputStream, java, uteil, energy, java, uteil, vector, java, net, socket, java.net.SocketException, java.net.InetAddress, java.net.NetworkInterface, java.net.SocketException, android, content, android, uteil, log, android.net.ConnectivityManager, android.net.NetworkInfo, android.telephony.TelephonyManager.
The MLCP is in the application layer on the network structure as the same as WebSocket, HTTP/HTTPS equal-length connection protocol, and on the Socket interface of the transmission layer, the MLCP connection is based on Socket connection plus MLCP protocol encapsulation and connection of a series of protocol control logic, and the MLCP connection is communicated with the transmission layer through Socket. Different from other long connection protocols, the MLCP adopts a new encapsulation format to encapsulate application data and then communicates with a Socket.
In the application, the data sender and the data receiver are computer equipment supporting Socket and MLCP communication and/or intelligent terminal equipment supporting network communication based on JVM, wherein the computer equipment comprises, but is not limited to, a personal computer, a notebook computer, an industrial computer, a network host, a single network server and a plurality of network server sets; the intelligent terminal equipment comprises, but is not limited to, a smart phone, a PAD, a wearable intelligent device and an Internet of things device. The computer device and/or the intelligent terminal device are only examples, and other devices and/or resources that may be present in the present application or may appear in the future are also included in the scope of the present application as applicable, and are incorporated herein by reference.
In order to further illustrate the technical means and the effects adopted by the present application, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings and preferred embodiments.
Fig. 1 shows a flow chart of a data transmission method applied to a data sender according to an embodiment of an aspect of the present application, wherein the method includes:
s101, establishing and starting MLCP connection with a data receiver;
S102, generating a heartbeat data packet of an MLCP frame structure based on a heartbeat keep-alive transmission interval, and packaging service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request;
s103, respectively splitting a heartbeat data packet and each service data packet into a plurality of data segments based on the first data length;
and S104, sequentially transmitting the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket.
The method is applied to the data sender 100. In this embodiment, when the relevant service application in the data sender 100 needs to transmit service data, an MLCP connection with the data receiver 200 is created and started in step S101.
In the MLCP, a lightweight framework and a simplified hierarchical structure are adopted, and related functions are realized by defining and packaging related classes.
Optionally, the MLCP includes:
the MLCPsocket class corresponds to a Socket operation layer in the hierarchical architecture of the MLCP and is used for realizing the management of Socket connection, data transmission and data reception through a Socket interface of a transmission layer;
the MLCPSocket control class is inherited by an MLCP control layer in the hierarchical architecture of the corresponding MLCP and is used for realizing Socket requests between Socket interfaces of the transmission layer and the MLCP long connection logic control;
An MLCP class, corresponding to an MLCP interface layer in the hierarchical architecture of the MLCP, inherits the MLCPSocketControl class and is used for realizing an external public interface;
the MLCPINterface class is used for providing callback function interfaces;
the MLCPCallBack class is used for callback function management;
MLCPLogUtil class for providing logging tools.
The hierarchical architecture of the MLCP is divided into 3 layers, namely an MLCP interface layer for butting a service layer, an intermediate MLCP control layer and a Socket operation layer for butting a Socket interface of a transmission layer. The MLCP includes MLCPSocket class, MLCPSocket control class, MLCP class, MLCPICINTERFACE class, MLCPCallBack class, and MLCPLOGI Util class that can provide an atomization operation log function for realizing core functions.
In MLCP, the following classes are defined to implement core functions:
and the MLCPsocket class corresponds to a Socket operation layer in the hierarchical architecture of the MLCP and is used for realizing Socket connection management, data transmission and data reception between a data interaction party (a data receiving party or a data transmitting party) through a Socket interface of the transmission layer. The Socket operation layer mainly comprises the following modules:
and the connection management module is used for realizing the creation and closing of Socket connection.
And the data transmission module is used for realizing segmentation and transmission of the data packet of the MLCP frame structure.
And the data receiving module is used for receiving data and managing a receiving buffer zone, and comprises creating, writing, emptying, destroying and the like.
And the MLCPSocket control class is inherited by an MLCP control layer in the hierarchical architecture corresponding to the MLCP and is used for realizing Socket request and MLCP long connection logic control.
Wherein, the MLCP control layer mainly comprises the following modules:
the configuration item management module, MLCP defines a series of constant, configurable items, defaults to optimal values, and provides configuration portal for custom settings.
The connection management module is used for managing the life cycle, state and callback of the MLCP connection, and comprises the steps of creating, closing and reconnecting Socket connection between a data interaction party through a Socket interface of a transmission layer; and managing the life cycle, state and callback of the heartbeat keep-alive thread, and realizing the MLCP long connection function.
And the data transmission management module is used for managing the life cycle, the data transmission state and the callback of the data transmission thread.
And the data receiving management module is used for managing the life cycle, the data receiving state and the callback of the data receiving thread.
And the MLCP class, corresponding to an MLCP interface layer in the hierarchical architecture of the MLCP, inherits the MLCPSocketControl class and is used for realizing an external public interface. Wherein common methods, callbacks, and configuration portals are provided that are easy to understand and use.
The MLCPINterface class is used for providing callback function interfaces.
And the MLCPCallBack class is used for callback function management.
MLCPLogUtil class for providing logging tools.
Optionally, the MLCPSocket class includes:
the Socket connection creation interface is used for initializing Socket connection, initializing a data buffer area and calling the data receiving interface to start a data receiving process;
the Socket connection closing interface is used for destroying the data buffer area, destroying the data connection thread and destroying Socket connection;
the first data transmission interface is used for splitting the data packet of the MLCP frame structure into a plurality of data segments and sequentially transmitting the data segments corresponding to the data packet of the MLCP frame structure through sockets;
the data receiving interface is used for sequentially receiving a plurality of data segments corresponding to the data packets of the MLCP frame structure through sockets and writing the data segments into the data buffer area;
the data buffer management interface is used for initializing the data buffer, writing the data buffer, reading the data buffer, obtaining the length of the data buffer and emptying the data buffer.
The MLCPSocket class is used in the MLCP to implement management Socket connection, and may provide the following interfaces:
1.1Socket connection creation interface, the following functions can be realized: and initializing Socket connection, initializing a data buffer area, and calling a data receiving interface to start a data receiving process.
1.2Socket connection closing interface, can realize following function: destroying the data buffer area, destroying the data connection thread and destroying the Socket connection.
1.3 the first data transmission interface can realize the following functions: splitting the data packet of the MLCP frame structure into a plurality of data segments, and sequentially transmitting the plurality of data segments corresponding to the data packet of the MLCP frame structure through a system Socket.
1.4 data receiving interface, can realize the following functions: and sequentially receiving a plurality of data segments corresponding to the data packets of the MLCP frame structure through a system Socket, and writing the data segments into a data buffer area.
1.5 data buffer management interface, can realize the following functions: initializing a data buffer area, writing the data buffer area, reading the data buffer area, obtaining the length of the data buffer area, and emptying the data buffer area.
Optionally, the Socket connection creation interface, the Socket connection closing interface, the first data sending interface and the data receiving interface are further configured to:
and (5) capturing and logging the abnormality.
The MLCPSocket class comprises interfaces such as a Socket connection creation interface, a Socket connection closing interface, a first data sending interface, a data receiving interface and the like, and can also capture and record anomalies in atomic operations such as interface call and the like in a log, or record changes of key nodes such as a network or a data transmission state and the like, so as to realize finer-granularity record of an operation log for tracing and offline analysis.
Optionally, the MLCPSocketControl class includes:
the first initialization interface is used for setting a connection name, a context object and a log switch;
the first setting callback interface is used for initializing an MLCPCallBack class and calling the setting callback interface of the MLCPCallBack class;
starting a connection interface, which is used for setting parameters such as connection url, ports, heartbeat keep-alive time interval, disconnection reconnection interval and the like, calling the Socket connection creation interface to create MLCP connection, starting a reading thread to read data from a data buffer zone, calling the heartbeat keep-alive interface to start the heartbeat keep-alive thread, and disconnecting reconnection;
the heartbeat keep-alive interface is used for sending heartbeat keep-alive data packets and reconnecting broken wires;
the reconnection port is used for calling the Socket connection closing interface to close the MLCP connection and calling the starting connection interface to start the MLCP connection;
the second data sending interface is used for calling the callback interface, calling the first data sending interface to send data, and reconnecting when disconnection occurs;
the first closing connection interface is used for calling the data buffer management interface to empty the data buffer, calling the Socket connection closing interface to close the MLCP connection and destroying the data reading thread;
The first acquisition connection state interface is used for returning to the MLCP connection state;
and the first emptying data interface is used for calling the data buffer area management interface to empty the data buffer area.
The MLCPSocket control class is used for realizing Socket connection establishment and MLCP long connection logic control in the MLCP, inherits the MLCPSocket class and is a subclass of the MLCPSocket class, and a method or an interface included in the MLCPSocket class can be directly referred to without redefinition or rewriting so as to realize a new function. The MLCPSocketControl class may provide the following interfaces:
2.1Socket connection creation interface, the following functions can be implemented: setting a connection name, a context object and a log switch.
2.2 the first set callback interface may implement the following functions: and initializing an MLCPCallBack class, and calling a setting callback interface of the MLCPCallBack class.
2.3 starting the connection interface, the following functions can be realized: setting parameters such as connection url, ports, heartbeat keep-alive time intervals, disconnection reconnection intervals and the like, calling a Socket connection creation interface of an MLCPsocket class to create MLCP connection, starting a reading thread to read data from a data buffer area, calling a callback interface to return the data, calling a heartbeat keep-alive interface to start the heartbeat keep-alive thread, and disconnection reconnection.
2.4 heartbeat keep-alive interfaces, the following functions can be realized: and sending the heartbeat keep-alive data packet, and reconnecting the broken wire. The heartbeat keep-alive function of the MLCP allows heartbeat keep-alive data packets of a self-defined MLCP frame structure, and allows heartbeat keep-alive data packets to be sent at self-defined time intervals, and the heartbeat keep-alive data packets are processed by calling a callback processing interface of an MLCPINTERFACE class.
2.5 re-connection ports, the following functions can be realized: and calling a Socket connection closing interface of the MLCPsocket class to close the MLCP connection, and calling the starting connection interface to start the MLCP connection.
2.6 a second data transmission interface, the following functions can be implemented: and calling a first data sending interface of the MLCPsocket class to send data, and reconnecting the broken line by the callback interface.
2.7 the first closed connection interface can implement the following functions: and calling a data buffer management interface of the MLCPsocket class to empty the data buffer, calling a Socket connection closing interface of the MLCPsocket class to close the MLCP connection, and destroying the data reading thread.
2.8 the first get connection status interface may implement the following functions: returning to the MLCP connection state.
2.9 a first flush data interface, which can implement the following functions: and calling a data buffer management interface of the MLCPsocket class to empty the data buffer.
Optionally, the start connection interface, the heartbeat keep-alive interface, the reconnection port, the second data transmission interface, and the first close connection interface are further configured to:
and (5) capturing and logging the abnormality.
The MLCPSocketControl class comprises a starting connection interface, a heartbeat keep-alive interface, a reconnection interface, a second data transmission interface and a first closing connection interface, and can also capture and record the abnormality in the atomic operations such as interface call and the like into a log so as to realize the record of finer granularity of an operation log for tracing and offline analysis.
Optionally, the MLCP class includes:
the second initialization interface is used for calling the first initialization interface;
the second setting callback interface is used for calling the first setting callback interface;
the connection interface is used for calling the starting connection interface;
a transmission data interface for calling the second data transmission interface;
the second connection state acquisition interface is used for calling the first connection state acquisition interface;
the second emptying data interface is used for calling the first emptying data interface;
and the second closing connection interface is used for calling the first closing connection interface.
The MLCP class is used for providing a public interface in the MLCP, inherits the MLCPSocketControl class, is a subclass of the MLCPSocketControl class, and can directly refer to a method or an interface included in the MLCPSocketControl class without redefinition or rewrite so as to realize a new function. The MLCP class may provide the following interfaces:
3.1 a second initialization interface, which can realize the following functions: and calling a first initialization interface of the MLCPSocketControl class.
3.2 a callback interface is set for realizing the following functions: and calling a first setting callback interface of the MLCPSocketControl class.
3.3 connection interfaces, which can realize the following functions: and calling a starting connection interface of the MLCPSocketControl class.
3.4 data transmission interface, the following functions can be realized: and calling a second data transmission interface of the MLCPSocketControl class.
3.5 a second acquisition connection status interface, the following functions can be implemented: and calling a first acquisition connection state interface of the MLCPSocketControl class.
3.6 a second emptying data interface, the following functions can be realized: and calling a first emptying data interface of the MLCPSocketControl class.
3.7 a second closing connection interface, the following functions can be realized: and calling a first closed connection interface of the MLCPSocketControl class.
In the application, the MLCPSocket class and the MLCP class have inheritance relationship with each other, wherein the MLCPSocket class inherits the MLCPSocket class and is a subclass of the MLCPSocket class, and correspondingly, the MLCPSocket class is a father class of the MLCPSocket class; the MLCP class inherits the MLCPSocketControl class, which is a subclass of the MLCPSocketControl class, and correspondingly, is a parent class of the MLCP class. The subclass can rewrite the method of the parent class, for example, some environment parameters or variable parameters can be set according to the requirement, and when the method of the subclass is called, the atomic operation of the parent class can be called in a layer-by-layer recursion mode finally. For example, the function of emptying the data buffer area by using the data buffer area management interface of the MLCPSocket class is an actual atomic operation of emptying the data buffer area, when the data buffer area is to be emptied by using the first closed connection interface or the first emptying data interface of the MLCPSocket class, the data buffer area management interface of the MLCPSocket class is called, and the sub-class MLCP class of the MLCPSocket control class can overwrite the first emptying data interface of the MLCPSocket control class as the second emptying data interface of the MLCP class, so as to provide the service application for use. Therefore, in the present application, when the service application needs to empty the data buffer, the second empty data interface of the MLCP class needs to be called first, the first empty data interface of the MLCPSocketControl class is called through the second empty data interface of the MLCP class, and then the data buffer management interface of the MLCPSocketControl class is called through the first empty data interface of the MLCPSocketControl class.
Optionally, the MLCPCallBack class includes:
the third callback interface is used for setting the callback interface to receive the parameters of the MLCPINterface class;
and the callback interface is used for calling callback functions of the MLCPINterface class to enter the service application type, the MLCP instance name, the connection state and the service data or return the parameters to the service application.
Wherein the MLCPCallBack class is used for callback function management in the MLCP. The MLCPCallBack class may provide the following interfaces:
4.1 a callback interface is set up in the third mode, and the following functions can be achieved: the callback interface is set to receive parameters of the MLCPInterface class.
4.2 callback interface, can realize the following functions: and calling a callback function of the MLCPINterface class to transmit parameters such as service application type, MLCP instance name, connection state, service data and the like from the service application or transmit the parameters back to the service application.
Optionally, the MLCPInterface class includes:
and the callback function, wherein parameters of the callback function comprise service application type, MLCP instance name, connection state and context object.
Wherein the MLCPINterface class is used in the MLCP to provide a callback function interface to call the callback function. The MLCPInterface class may provide the following function declarations:
5.1 callback functions, such as a SocketNotify function, the parameters of which may include the service application type, MLCP instance name, connection state, and context object.
The context object may be service data encapsulated in an MLCP, where the service data may be binary data such as a character string or a picture, and the type of the service data is not limited.
The MLCP encapsulated MLCPCallBack class and MLCPICINTERFACE class improve the expansibility of callback interfaces and the configurability of related parameters, and can configure corresponding variables and/or parameters for different android system versions, devices and network environments. In the MLCP long connection life cycle, each key node, such as a key node related to a network state, a data transmission state and the like, such as connection establishment, heartbeat keep-alive, data transmission, data reception, connection abnormality, connection closing and the like, calls a unified callback interface to callback, transmits an MLCP long connection instance name, a connection state and a context object in the interface, and can be used for service expansion in the callback by service application. The configuration items may be set by default for most device optima, and may provide configuration entries for user self-tuning based on application environments, capabilities of devices and/or business applications, network environments, etc. For example, the business application can copy the callback function method, read the related parameters from the callback function method, and execute the extended business logic according to the obtained different parameters.
Optionally, the MLCPLogUtil class includes:
the management log switch interface is used for setting a log switch state and acquiring the log switch state;
the record information log interface is used for printing the information type log, and calling the save log to the file interface to save the information type log to the file;
the record debug log interface is used for printing a debug type log, and calling a save log to file interface to save the debug type log to a file;
the warning log recording interface is used for printing a warning type log, and calling a saving log to a file interface to save the warning type log to a file;
the record exception log interface is used for printing an exception type log, and calling a save log to a file interface to save the exception type log to a file;
the log is saved to a file interface and is used for creating a catalog, creating a file and writing the file;
and the deletion log file interface is used for acquiring and deleting the expired log file.
Wherein the MLCPLogUtil class is used in the MLCP to provide a logging tool. The MLCPLogUtil class may provide the following interfaces:
6.1 managing log switch interface, can realize the following functions: setting a log switch state and obtaining the log switch state.
6.2 record information log interface, can realize the following functions: printing the information type log, and calling a save log to file interface to save the information type log to a file.
6.3, recording a debug log interface, and realizing the following functions: printing the debug type log, and calling a save log to file interface to save the debug type log to a file.
6.4, recording a warning log interface, and realizing the following functions: the alert type log is printed and the save log to file interface is invoked to save the alert type log to the file.
6.5 recording an abnormal log interface, which can realize the following functions: printing an exception type log, and calling a save log to file interface to save the exception type log to a file.
6.6, storing log to file interface, which can realize the following functions: creating a log directory, creating a log file, and writing the related type log into the corresponding log file.
6.7 deleting log file interface, can realize the following functions: and acquiring and deleting the expiration log file.
The existing long connection protocol lacks tracking of abnormal operation or state change of some key nodes in the long connection communication process, and lacks related logs, so that offline analysis of related nodes is not possible. The MLCP classifies the frames into classes, interfaces/methods and atomic operations/functions, and provides log records at the level of atomic operations/functions, for example, the log records can be normalized as "MLCP instance name_time_function_ [ custom information ]", the log records can be recorded to the file according to the log normalized, for example, the log file name format can be "MLCP instance name_date_sequence number", the log file capacity can be set, the capacity of the log file exceeds the capacity, the files can be stored in a split manner, and the sequence number identification can be added in the file name. Therefore, the MLCP supports log granularity atomization in a long connection process, enlarges the coverage of key nodes of the log, sets log records in each key atomic operation, realizes fine traceability of operation logs, and can support offline log analysis.
Optionally, in step S101, the creating and starting an MLCP connection with the data receiver includes:
using an MLCP class, setting a first core parameter, wherein the first core parameter comprises: context object, MLCP instance name, log switch;
setting a callback function and a second core parameter by using an MLCPSocketControl class and an MLCPICnterface class, wherein the parameters of the callback function comprise a current MLCP instance name, a connection state and a context object, and the second core parameter comprises: connecting party url, port, heartbeat keep-alive sending interval, broken line reconnection interval and data buffer area size;
and establishing and starting the MLCP connection according to the second core parameters.
During the initialization process of the MLCP, a callback interface of the MLCP class is used for setting a first core parameter related to a callback function, wherein the first core parameter comprises: context object (mlcpContext), MLCP instance name (mlcpSocketName), log switch (logFlag); setting a callback function and a second core parameter by using an MLCPSocketControl class and an MLCPICnterface class, wherein the parameters of the callback function comprise a current MLCP instance name, a connection state and a context object, and the second core parameter comprises: the connection party url (mlcport), port (mlcport), heartbeat keep-alive transmission interval (heartbeat), disconnection reconnection interval (reConnectGap), data buffer size (socks_bus_max_len), and then creates and starts the MLCP connection according to the second core parameter.
In the MLCP, each operation of each sub-process can timely call back the MLCP instance name, the connection state and the context object to the self-defined operation class through the callback function, and the service application adopting the MLCP long-connection communication can timely monitor the callback function and complete service data transmission according to the actual requirement of the service application.
When the MLCP connection is created, a connection interface of the MLCP class is used, parameters such as a connecting party url, a port and the like in the second core parameters are set, and parameters such as a heartbeat keep-alive sending interval, a broken line reconnection interval, a data buffer area size and the like in the second core parameters are set according to available resources of equipment. For one example, default values for the relevant parameters may be set in connection with the general device available resource situation. After the MLCP connection with the data receiver is completed according to parameters such as url, port and the like of the connecting party, the allocated data buffer is initialized according to the size parameters of the data buffer, a data receiving sub-process and a data reading sub-process are started, and a heartbeat keep-alive sub-process is started.
The common interfaces of the MLCP class in the application can call the interfaces of the MLCPSocket control class and/or the MLCPSocket class finally. For one example, an initialization interface definition written in Java may be as follows in table 1,
TABLE 1
The set callback interface definition may be as follows in table 2.
TABLE 2
The startup connection interface definition may be as follows in table 3.
TABLE 3 Table 3
/>
The data transmission interface definition may be as follows in table 4.
TABLE 4 Table 4
The flush data interface definition may be as follows in table 5.
TABLE 5
Use of the same Emptying data
Interface definition void cleanReceiveData()
Use of the same Clearing received data
Return value type Return value description
void
The get connection status interface definition may be as follows in table 6.
TABLE 6
Interface name Acquiring connection status
Interface definition int getMLCPSocketStatus()
Use of the same Acquiring a current connection state
Return value type Return value description
int Connection status, correspondence table 8
One exemplary callback processing interface definition including a callback processing function that sends an MLCP Socket notification may be as follows in table 7.
TABLE 7
One exemplary connection state may include the states as in table 8, among others.
TABLE 8
Optionally, if the MLCP connection with the data receiver fails, the data sending method further includes:
and restarting the MLCP connection with the data receiver based on the disconnection reconnection interval.
After the MLCP connection is established, network anomalies may occur in the process over time, resulting in disconnection of the established MLCP connection. Therefore, before the service data is transmitted through the MLCP connection, it needs to determine whether the network connection or the MLCP connection is normal, for example, whether the network connection is abnormal can be determined through the related interfaces of the MLCPNetUtil class, and whether the MLCP connection is normal can be determined through the heartbeat keep-alive mechanism of the MLCP. If the network connection or the MLCP connection is abnormal, the data transmission fails.
And if the MLCP connection is started for reasons, calling a callback function to acquire related parameters, and establishing the MLCP connection with the data receiver according to the related parameters again after the time of the disconnection reconnection interval is met.
Optionally, the MLCP further includes:
the MLCPNetUtil class is used for providing network management;
the MLCPSysUtil class is used for providing system management;
the MLCPVERIL class is used for providing version management.
The MLCP also comprises an MLCPNetUtil class, an MLCPSysUtil class and an MLCPVErUtil class which provide auxiliary tools.
Optionally, the MLCPNetUtil class includes:
acquiring a network connection type interface for acquiring a network type;
and the network connection state acquisition interface is used for calling the system bottom layer interface to judge the network state and calling the network connection type acquisition interface to acquire the network type.
Wherein the MLCPNetUtil class is used in the MLCP to provide network management functions. The MLCPNetUtil class may provide the following interfaces:
7.1 obtaining network connection type interface, the following functions can be realized: according to the network information provided by the system bottom layer interface, the network connection type is obtained, for example, the MLCP connection of the two connected parties is based on which type of network, and the network type is 2G/3G/4G/WIFI/other network types.
7.2 obtaining network connection state interface, the following functions can be realized: and judging whether the network connection is normal or not according to the network information provided by the system bottom layer interface.
The network connection status acquiring interface is generally called first to judge whether the network connection is normal, and if the network connection is normal, the network connection type acquiring interface is called again to acquire the network type.
Optionally, the mlcpsysys ntil class includes:
acquiring an IP address interface;
acquiring a sim card state interface;
a first data type conversion interface for int conversion into byte arrays;
a second data type conversion interface for converting byte arrays into int;
a third data type conversion interface for converting the input stream into a byte array;
a byte array intercepting interface for byte array intercepting operation;
and the byte array splicing interface is used for byte array splicing operation.
Among them, the mlcpsys ntil class is used in the MLCP to provide a system management function. The mlcpsysys ntil class may provide the following interfaces:
8.1 obtaining IP address interface, the following functions can be realized: the IP address of the data sender is obtained.
8.2 acquiring sim card status interface, the following functions can be realized: if the data sender device establishes MLCP connection with the data receiver through the mobile network to transmit service data, the sim card state in the data sender device can be obtained by obtaining the sim card state interface.
8.3 the first data type conversion interface can realize the following functions: the int type data is converted into byte arrays.
8.4 a second data type conversion interface, the following functions can be implemented: the byte array is converted into int type data.
8.5 a third data type conversion interface, which can implement the following functions: the input stream is converted into a byte array.
8.6byte array intercept interface, can realize the following functions: byte array intercept operations.
8.7byte array splicing interfaces, which can realize the following functions: byte array concatenation operation.
Optionally, the mlcpvaerutil class includes:
and the version number acquisition interface is used for acquiring the version number of the currently used MLCP.
Wherein the MLCPVERIL class is used in the MLCP to provide version management functions of the MLCP. The mlcpvaritil class may provide the following interfaces:
9.1 version number acquisition interface, can realize following function: the version number of the MLCP currently used by the connection party is acquired.
In this embodiment, in step S102, the data sender 100 generates a heartbeat packet of an MLCP frame structure according to a preset heartbeat keep-alive transmission interval, and encapsulates the service data to be transmitted into service data packets of a plurality of MLCP frame structures according to a service data transmission request of a service application.
Optionally, the MLCP frame structure includes:
compression mode field, encryption mode field, total frame number field, current frame field, key field, payload length bit width field, payload length field, payload field.
Wherein the MLCP frame structure includes the following fields: compression mode, encryption mode, total frame number, current frame, key, payload length bit width, payload length, payload. The user can define the fields by combining the application scene and the service requirement.
An exemplary MLCP frame structure is shown in table 9 below,
TABLE 9
The fields are described as follows:
1. a compression mode field occupying 4 bits (bits), wherein,
0: representation uncompressed
Non-0: the representation is in a corresponding compression format (e.g., 1 for gzip compression, 2 for deflate compression, 3 for brotli compression, 4 for zlib compression, 5-15 for reservation).
2. Encryption, occupies 4 bits, wherein,
0: representation is not encrypted
Non-0: indicating that the corresponding compression format is adopted (e.g., 1: indicating that the SHA256 mode is adopted; 2-15: reserved).
3. The total frame number occupies 4 bits, is unsigned, and represents the total frame number of the MLCP frame of the service data encapsulation, and is 15 (the value of each bit is 1) at the maximum and 1 (0) at the minimum.
4. The current frame number occupies 4 bits, is unsigned, and indicates what frame the current MLCP frame is, and the maximum is 15 and the minimum is 1.
5. The number of bits occupied by the key should correspond to the maximum number of bits occupied in the supported encryption scheme, e.g., if the maximum number of bits occupied in the supported encryption scheme is SHA256, then the field occupies 256 bits, where,
when the value of the encryption mode field is 0: the field is empty
When the value of the encryption mode field is not 0, the key is transmitted in the first frame MLCP corresponding to the field, and transmission in the corresponding field may not be required in the subsequent MLCP frame. For example, if the value of the total frame number field is 8 (i.e. the service data is transmitted in an 8-frame MLCP frame), and encrypted transmission is adopted, in the 1 st frame MLCP frame, the value of the encryption mode field is 0001, the key is transmitted in the key field, the encryption mode field and the key field can be null in the following 2-8 frames MLCP frames, and in the data receiving party, the encryption mode field and the key field in the 2-8 frames MLCP frame are ignored.
6. The payload length is bit wide, occupies 2 bits, and represents the payload data width which can be transmitted at one time, the default unit is byte (byte), and can be identified by N, the minimum value is 0, and the maximum value is 3.
7. The payload length is set according to the payload length bit width, and the unit is byte, the minimum is 0 (when the payload length bit width is 0), the maximum is (2) 24 -1)。
8. The payload, the service data actually transmitted in each MLCP frame, is determined by the payload length.
In this example, the maximum supportable length of the payload of one frame MLCP frame is (2 24 -1) bytes, about 16MB, the maximum supportable by the service application for a payload transmittable per request is 240MB (16 MB x 15 = 240 MB). The data sender 100 and the data receiver 200 can set a data compression mode according to the conventions of both sides in a compression mode field, can set a data encryption mode according to the conventions of both sides in an encryption mode field, can also combine the total frame number in an MLCP frame with a current frame field to judge whether the MLCP frame needs retransmission and whether the transmission is finished, and can select a proper bit width according to the actual application scene and the service requirement and the transmission data amount through a payload length bit width field.
In the existing WebSocket protocol, the WebSocket frame structure also comprises a payload length field, but also comprises an extended payload length field, wherein the payload length occupies 7 bits, and when the value of the payload length takes 0-125, the value represents the maximum length of the transmissible payload, namely the maximum length is 125 bytes; when the value is 126, the unsigned integer value (the most significant bit must be 0) of the field, which is followed by 2 bytes (16 bits), is the length of the transmissible payload, which is at most (2 15 -1) bytes, which are actually used to represent that the payload length needs to occupy (7+16) bits; when the value is 127, the unsigned shaping value of the next 8 bytes (64 bits) of this field is the length of the transmissible payload, which is at most (2 63 -1) bytes, which are actually used to represent that the payload length needs to occupy (7+64) bits.
In the above-mentioned exemplary MLCP frame structure, if the payload is transmitted with no more than 256 bytes, the payload length field occupies 8 bits, and the payload length bit width field occupies 2 bits, which is actually used to indicate that the payload length needs to occupy (8+2) bits; if the transmission exceeds 256 bytes but does not exceed (2 16 -1) a byte payload, actually representing the payload length to occupy (16+2) bits; if the transmission exceeds (2 16 -1) bytes but not more than (2) 24 -1) byte hasThe payload, in effect, is used to represent the (24+2) bits that the payload length needs to occupy.
Therefore, when the transmission data amount is large, the use of MLCP is more efficient in terms of bandwidth utilization than the use of WebSocket. The service applications running on mobile devices and the like based on the mobile internet generally transmit large data volume in the interaction process, so that the MLCP is more suitable than the existing long connection protocol.
The MLCP provided by the application can customize the MLCP frame structure according to the application scene and the data volume of the service data to be transmitted, improves the flexibility and bandwidth utilization rate of data encapsulation, improves the transmission efficiency, has fewer frame layers, lightens codes, and reduces the resource cost of a CPU, a memory and the like.
Continuing with this embodiment, in step S103, the data sender 100 further splits the heartbeat packet and the service packet encapsulated into the MLCP frame into a number of data segments according to the preset first data length.
The data sender application layer can combine with the Socket state to split the data packet of the MLCP frame structure into a plurality of data segments according to the preset first data length, namely, each frame of MLCP frame of the heartbeat data packet and the service data packet can be split into a plurality of data segments by itself.
Optionally, in step S103, when splitting the heartbeat packet or each service packet into a plurality of data segments, if the length of the last actual remaining data is smaller than the first data length, the length of the last data segment is the length of the actual remaining data.
When each frame of the heartbeat data packet and the service data packet is split into a plurality of data segments, if the length of the last actual remaining data is smaller than the first data length, the length of the last data segment may be the length of the actual remaining data.
Continuing in this embodiment, in step S104, the data sender 100 sequentially sends, to the data receiver, the heartbeat packet and a number of data segments corresponding to each service packet through a Socket.
When the heartbeat data packet or the service data packet of the MLCP frame structure is split into a plurality of data segments and transmitted to the Socket, the heartbeat data packet and the plurality of data segments corresponding to each service data packet are sequentially transmitted to the data receiver through the Socket channel between the data sender 100 and the data receiver 200.
When the service data packet is completely sent, if the service application does not send a disconnection signal, the heartbeat data packet is continuously sent. If the service application does not send data later, the MLCP connection can be closed to release the resources.
Fig. 2 shows a flow diagram of a service data receiving method applied to a data receiver according to another embodiment of an aspect of the present application, wherein the method includes:
s201, establishing and starting MLCP connection with a data sender;
s202, initializing a data buffer area, receiving data sequentially sent by a data sender through a Socket, reading the data according to a second data length based on a first data reading interval, obtaining a data segment and writing the data segment into the data buffer area;
S203, based on a second data reading interval, reading a plurality of data segments from the data buffer area, and assembling the data segments into a data packet with an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet;
s205, based on the service data packet of the MLCP frame structure, the service data is obtained.
The method is applied to the data receiver 200. In this embodiment, when the data receiving side 200 receives the MLCP connection request of the data transmitting side 100, in step S201, an MLCP connection with the data transmitting side 100 is created and started. The MLCP connection creation and activation procedure of the data receiver 200 is the same as or similar to that of the data sender, and will not be described here again.
Continuing in this embodiment, after the MLCP connection with the data sender 100 is created and started, in step S202, the data receiver 200 initializes a data buffer, receives data sequentially sent by the data sender 100 through a Socket, reads data according to the second data length based on the first data reading interval, obtains a data segment, and writes the data segment into the data buffer.
The data receiving side 200 firstly initializes a data buffer to allocate the data buffer for Socket data segment reception, sets a data receiving queue, then creates a data receiving sub-process, receives data sequentially sent by the data sending side 100 through Socket, reads the sequentially received data at regular time according to a preset first data reading interval, puts the sequentially received data into the queue, and stores the sequentially received data into the data buffer, wherein each time the data is sequentially read according to a preset second data length, the data segment is obtained and written into the data buffer. The preset first data length and the preset second data length can be different so as to meet different data read-write control granularities.
In this embodiment, in step S203, the data receiving party creates a data reading sub-process, sequentially reads a plurality of data segments from the data buffer according to a preset second data reading interval and a first-in first-out principle, and assembles the data segments into a data packet with an MLCP frame structure, where the data packet is a heartbeat keep-alive data packet or a service data packet.
In an exemplary embodiment, at the data sender 100, assuming that one MLCP frame includes a 5MB payload according to the amount of data transmitted by service data, and the preset first data length is 512KB, one MLCP frame is split into 10 data segments and transmitted in sequence through sockets. And the data receiving party sequentially receives data through Socket timing and reads 20 data segments according to a preset first data reading interval, and stores the data segments into a data buffer area, then sequentially reads the 20 data segments from the data buffer area, and the payload of the assembled MLCP frame is 5MB, namely, the transmission and the reception of the 5MB data are completed through MLCP connection.
If the payload of each MLCP frame of the data packet is empty, the data packet is a heartbeat keep-alive data packet; and if the payload of at least one MLCP frame in the MLCP frames corresponding to the data packet is not null, the data packet is a service data packet.
In this embodiment, in step S205, the data receiving party transmits the valid data in the service data packet of the MLCP frame structure back to the service application, so that the service application obtains the service data, and completes receiving the service data.
Optionally, the data receiving method further includes:
s204, deleting the data segment from the data buffer after the data segment is successfully read from the data buffer.
In order to avoid repeated reading of the read data and save storage resources and improve the use efficiency of the data buffer, in step S203, after the data segment is successfully read from the data buffer, the data segment may be deleted from the data buffer.
Optionally, the data receiving method further includes:
s206, when all the data segments in the data buffer are successfully read and no new data segments are written, the data buffer is emptied.
Wherein, no new data segment is written in the data buffer, and all the data segments in the data buffer are successfully read, the data receiver can use the above-mentioned data clearing interface to clear the data buffer, and release the storage space.
If the service application does not send data later, after the data is emptied, the MLCP connection can be further closed, and the data receiving sub-process is destroyed.
Fig. 3 shows an embodiment according to another aspect of the present application, and provides an apparatus schematic diagram of a service data transmitting apparatus deployed at a data transmitting side, where the apparatus includes:
a first module 310 for creating and starting an MLCP connection with a data receiver;
a second module 320, configured to generate a heartbeat data packet of an MLCP frame structure based on the heartbeat keep-alive transmission interval, and encapsulate, based on the service data transmission request, service data to be transmitted into service data packets of a plurality of MLCP frame structures;
a third module 330, configured to split the heartbeat packet and each service packet into a plurality of data segment packets based on the first data length;
and a fourth module 340, configured to sequentially send, to the data receiving party through Socket, a heartbeat packet and a plurality of data segments corresponding to each service packet.
In this embodiment, the apparatus is integrated in the data sender device. The software and hardware environment of the data sender device is the same as the software and hardware environment of the device of the data sender 100 in the foregoing method embodiment and/or the optional embodiment.
In this embodiment, when related service application needs to send service data in the data sender 100, a first module 310 of the device creates and starts MLCP connection with a data receiver, then a second module 320 of the device generates a heartbeat data packet of an MLCP frame structure according to a preset heartbeat keep-alive sending interval, encapsulates service data to be sent into service data packets of a plurality of MLCP frame structures according to a service data sending request of the service application, then a third module 330 of the device splits the heartbeat data packet and the service data packet encapsulated into an MLCP frame into a plurality of data segments according to a preset first data length, finally, a fourth module 340 of the device sends the data segments to a Socket, and sequentially sends the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through the Socket.
In the embodiments and/or optional embodiments of the foregoing apparatus, the method steps performed by each module of the apparatus are not mentioned in the same parts as those in the foregoing related method embodiments, and are not described herein again.
Fig. 4 shows another embodiment according to another aspect of the present application, providing an apparatus schematic diagram of a service data receiving apparatus deployed on a data receiving side, wherein the apparatus includes:
A fifth module 410 for creating and starting an MLCP connection with a data sender;
a sixth module 420, configured to initialize a data buffer, receive data sequentially sent by the data sender through Socket, read data according to a second data length based on a first data reading interval, obtain a data segment, and write the data segment into the data buffer;
a seventh module 430, configured to read a plurality of data segments from the data buffer based on a second data reading interval, and assemble a data packet with an MLCP frame structure, where the data packet is a heartbeat keep-alive data packet or a service data packet;
and a ninth module 450, configured to obtain service data based on the service data packet of the MLCP frame structure.
In this embodiment, the apparatus is integrated in the data receiving device. The software and hardware environment of the data receiving device is the same as that of the data receiving device in the foregoing method embodiment and/or the optional embodiment.
In this embodiment, when the data receiving side 200 receives the MLCP connection request of the data sending side 100, the fifth module 410 of the device creates and starts the MLCP connection with the data sending side 100, then the sixth module 420 of the device initializes a data buffer, receives data sequentially sent by the data sending side 100 through a Socket, reads data according to a second data length based on a first data reading interval, obtains a data segment and writes the data buffer, then the seventh module 430 of the device creates a data reading sub-process, sequentially reads a plurality of data segments from the data buffer according to a first-in first-out principle according to a preset second data reading interval, and assembles the data packets into a data packet of a MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet, and finally, the ninth module 450 of the device returns valid data in the service data packet of the MLCP frame structure to the service application, so that the service application obtains the service data, and completes the reception of the service data.
In order to save storage resources and improve the use efficiency of the data buffer, the apparatus may further include an eighth module 440, and after the seventh module 330 successfully reads the data segment from the data buffer, the data segment may be deleted from the data buffer by the eighth module 440.
The apparatus may further include a tenth module 460, by which the data buffer is emptied when all of the data segments in the data buffer have been successfully read and no new data segments have been written.
In the embodiments and/or optional embodiments of the foregoing apparatus, the method steps performed by each module of the apparatus are not mentioned in the same parts as those in the foregoing related method embodiments, and are not described herein again.
Fig. 5 shows a schematic diagram of a service data transmission system according to an embodiment of a further aspect of the present application, wherein the system 10 comprises:
the data sender 100 is configured to create and start an MLCP connection with a data receiver, generate a heartbeat data packet of an MLCP frame structure based on a heartbeat keep-alive transmission interval, encapsulate service data to be sent into service data packets of a plurality of MLCP frame structures based on a service data transmission request, split the heartbeat data packet and each service data packet into a plurality of data segment packets based on a first data length, and sequentially send the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket;
The data receiving party 200 is configured to create and start an MLCP connection with a data sending party, initialize a data buffer, receive data sequentially sent by the data sending party through a Socket, read the data according to a second data length based on a first data reading interval, obtain a data segment and write the data segment into the data buffer, and read a plurality of data segments from the data buffer based on the second data reading interval, and assemble a data packet with an MLCP frame structure, where the data packet is a heartbeat keep-alive data packet or a service data packet, and obtain service data based on the service data packet with the MLCP frame structure.
In this embodiment, the system includes the data sender 100 and the data receiver 200, and the device software and hardware environments thereof are the same as those of the data receiver 100 and the data receiver 200 in the foregoing method embodiment and/or the optional embodiment. The data sender 100 and the data receiver 200 perform data transmission through a network.
When related service application in the data sender 100 needs to send service data, an MLCP connection with a data receiver is created and started, then a heartbeat data packet of an MLCP frame structure is generated based on a heartbeat keep-alive sending interval, service data to be sent is packaged into service data packets of a plurality of MLCP frame structures based on a service data sending request, then the heartbeat data packet and each service data packet are respectively split into a plurality of data segment packets based on a first data length, and then the heartbeat data packet and a plurality of data segments corresponding to each service data packet are sequentially sent to the data receiver through a Socket so as to complete sending of the service data.
On the data receiving side 200, when receiving an MLCP connection request of the data transmitting side 100, an MLCP connection with the data transmitting side is created and started, then a data buffer is initialized, data sequentially transmitted by the data transmitting side is received through a Socket, data is read according to a second data length based on a first data reading interval, a data segment is obtained and written into the data buffer, then a plurality of data segments are read from the data buffer based on a second data reading interval, and a data packet of an MLCP frame structure is assembled, wherein the data packet is a heartbeat keep-alive data packet or a service data packet, and service data is acquired based on a service data packet of the MLCP frame structure, so that the reception of the service data is completed.
According to yet another aspect of the present application, there is also provided a computer readable medium storing computer readable instructions executable by a processor to implement the foregoing method embodiments.
It should be noted that, the method embodiments and/or the optional embodiments in the present application do not strictly limit the order of execution of the steps, so long as the method embodiments can solve the defects existing in the prior art, and achieve the purposes of the present application and obtain beneficial effects. The method embodiments of the present application may be implemented in software and/or a combination of software and hardware. The software program involved in the present application can be executed by a processor to realize the steps or functions of the above-described embodiments. Likewise, the software program of the present application (including the related data structures) may be stored in a computer-readable recording medium.
Furthermore, some or all of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or solutions in accordance with the present application by way of operation of the computer. Program instructions for invoking the inventive methods may be stored in fixed or removable recording media and/or transmitted via a data stream in a broadcast or other signal bearing medium and/or stored within a working memory of a computer device operating according to the program instructions.
According to an embodiment of a further aspect of the present application, there is provided an apparatus for traffic data transmission, the apparatus comprising: a memory storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to run the methods and/or aspects of the foregoing embodiments.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. The units or means recited in the apparatus claims may also be implemented by means of software and/or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.

Claims (26)

1. A service data transmitting method applied to a data transmitting party, the method comprising:
creating and starting an MLCP connection with a data receiver;
generating a heartbeat data packet of an MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request;
based on the first data length, dividing the heartbeat data packet and each service data packet into a plurality of data segments;
and sequentially sending the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket.
2. The method of claim 1, wherein the MLCP comprises:
the MLCPsocket class corresponds to a Socket operation layer in the hierarchical architecture of the MLCP and is used for realizing Socket connection management, data transmission and data reception;
the MLCPSocket control class is inherited by an MLCP control layer in the hierarchical architecture corresponding to the MLCP and is used for realizing Socket request and MLCP long connection logic control;
an MLCP class, corresponding to an MLCP interface layer in the hierarchical architecture of the MLCP, inherits the MLCPSocketControl class and is used for realizing an external public interface;
The MLCPINterface class is used for providing callback function interfaces;
the MLCPCallBack class is used for callback function management;
MLCPLogUtil class for providing logging tools.
3. The method of claim 1, wherein the MLCP further comprises:
the MLCPNetUtil class is used for providing network management;
the MLCPSysUtil class is used for providing system management;
the MLCPVERIL class is used for providing version management.
4. The method of claim 2, wherein the MLCPSocket class comprises:
the Socket connection creation interface is used for initializing Socket connection, initializing a data buffer area and calling the data receiving interface to start a data receiving process;
the Socket connection closing interface is used for destroying the data buffer area, destroying the data connection thread and destroying Socket connection;
the first data transmission interface is used for splitting the data packet of the MLCP frame structure into a plurality of data segments and sequentially transmitting the data segments corresponding to the data packet of the MLCP frame structure through sockets;
the data receiving interface is used for sequentially receiving a plurality of data segments corresponding to the data packets of the MLCP frame structure through sockets and writing the data segments into the data buffer area;
the data buffer management interface is used for initializing the data buffer, writing the data buffer, reading the data buffer, obtaining the length of the data buffer and emptying the data buffer.
5. The method of claim 4, wherein the Socket connection creation interface, the Socket connection closing interface, the first data transmission interface, and the data reception interface are further configured to:
and (5) capturing and logging the abnormality.
6. The method of claim 4, wherein the MLCPSocketControl class comprises:
the first initialization interface is used for setting a connection name, a context object and a log switch;
the first setting callback interface is used for initializing an MLCPCallBack class and calling the setting callback interface of the MLCPCallBack class;
starting a connection interface, which is used for setting parameters such as connection url, ports, heartbeat keep-alive time interval, disconnection reconnection interval and the like, calling the Socket connection creation interface to create MLCP connection, starting a reading thread to read data from a data buffer zone, calling the heartbeat keep-alive interface to start the heartbeat keep-alive thread, and disconnecting reconnection;
the heartbeat keep-alive interface is used for sending heartbeat keep-alive data packets and reconnecting broken wires;
the reconnection port is used for calling the Socket connection closing interface to close the MLCP connection and calling the starting connection interface to start the MLCP connection;
The second data sending interface is used for calling the callback interface, calling the first data sending interface to send data, and reconnecting when disconnection occurs;
the first closing connection interface is used for calling the data buffer management interface to empty the data buffer, calling the Socket connection closing interface to close the MLCP connection and destroying the data reading thread;
the first acquisition connection state interface is used for returning to the MLCP connection state;
and the first emptying data interface is used for calling the data buffer area management interface to empty the data buffer area.
7. The method of claim 6, wherein the initiate connection interface, the heartbeat keep-alive interface, the re-connection interface, the second data transmission interface, and the first close connection interface are further configured to:
and (5) capturing and logging the abnormality.
8. The method of claim 6, wherein the MLCP class comprises:
the second initialization interface is used for calling the first initialization interface;
the second setting callback interface is used for calling the first setting callback interface;
the connection interface is used for calling the starting connection interface;
a transmission data interface for calling the second data transmission interface;
The second connection state acquisition interface is used for calling the first connection state acquisition interface;
the second emptying data interface is used for calling the first emptying data interface;
and the second closing connection interface is used for calling the first closing connection interface.
9. The method of claim 8, wherein the MLCPCallBack class comprises:
the third callback interface is used for setting the callback interface to receive the parameters of the MLCPINterface class;
and the callback interface is used for calling callback functions of the MLCPINterface class to enter the service application type, the MLCP instance name, the connection state and the service data or return the parameters to the service application.
10. The method of claim 9, wherein the MLCPInterface class comprises:
and the callback function, wherein parameters of the callback function comprise service application type, MLCP instance name, connection state and context object.
11. The method of claim 10, wherein the MLCPLogUtil class comprises:
the management log switch interface is used for setting a log switch state and acquiring the log switch state;
the record information log interface is used for printing the information type log, and calling the save log to the file interface to save the information type log to the file;
The record debug log interface is used for printing a debug type log, and calling a save log to file interface to save the debug type log to a file;
the warning log recording interface is used for printing a warning type log, and calling a saving log to a file interface to save the warning type log to a file;
the record exception log interface is used for printing an exception type log, and calling a save log to a file interface to save the exception type log to a file;
the log is saved to a file interface and is used for creating a catalog, creating a file and writing the file;
and the deletion log file interface is used for acquiring and deleting the expired log file.
12. The method of claim 11, wherein the creating and initiating an MLCP connection with a data receiver comprises:
using an MLCP class, setting a first core parameter, wherein the first core parameter comprises: context object, MLCP instance name, log switch;
setting a callback function and a second core parameter by using an MLCPSocketControl class and an MLCPICnterface class, wherein the parameters of the callback function comprise a current MLCP instance name, a connection state and a context object, and the second core parameter comprises: connecting party url, port, heartbeat keep-alive sending interval, broken line reconnection interval and data buffer area size;
And establishing and starting the MLCP connection according to the second core parameters.
13. The method of claim 12, wherein if the MLCP connection with the data receiver fails, the method further comprises:
and restarting the MLCP connection with the data receiver based on the disconnection reconnection interval.
14. A method according to claim 3, wherein the MLCPNetUtil class comprises:
acquiring a network connection type interface for acquiring a network type;
and the network connection state acquisition interface is used for calling the system bottom layer interface to judge the network state and calling the network connection type acquisition interface to acquire the network type.
15. A method according to claim 3, wherein the mlcpsysys uli class comprises:
acquiring an IP address interface;
acquiring a sim card state interface;
a first data type conversion interface for int conversion into byte arrays;
a second data type conversion interface for converting byte arrays into int;
a third data type conversion interface for converting the input stream into a byte array;
a byte array intercepting interface for byte array intercepting operation;
and the byte array splicing interface is used for byte array splicing operation.
16. A method according to claim 3, wherein the mlcpvaerutil class comprises:
and the version number acquisition interface is used for acquiring the version number of the currently used MLCP.
17. The method of claim 1, wherein the MLCP frame structure comprises:
compression mode field, encryption mode field, total frame number field, current frame field, key field, payload length bit width field, payload length field, payload field.
18. A method according to claim 1, wherein in step C, when splitting the heartbeat packet or each traffic packet into a number of data segments, if the last actual remaining data length is smaller than the first data length, the last data segment length is the actual remaining data length.
19. A method for receiving service data, applied to a data receiving party, the method comprising:
creating and starting an MLCP connection with a data sender;
initializing a data buffer zone, receiving data sequentially sent by a data sender through a Socket, reading the data according to a second data length based on a first data reading interval, obtaining a data segment and writing the data segment into the data buffer zone;
Based on a second data reading interval, reading a plurality of data segments from the data buffer area, and assembling the data segments into a data packet with an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet;
and acquiring service data based on the service data packet of the MLCP frame structure.
20. The method of claim 19, wherein the method further comprises:
and deleting the data segment from the data buffer after the data segment is successfully read from the data buffer.
21. The method of claim 20, wherein the method further comprises:
when all the data segments in the data buffer are successfully read and no new data segments are written, the data buffer is emptied.
22. A service data transmitting apparatus deployed at a data transmitting side, the apparatus comprising:
a first module for creating and starting an MLCP connection with a data receiver;
the second module is used for generating a heartbeat data packet of the MLCP frame structure based on the heartbeat keep-alive transmission interval, and packaging the service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on the service data transmission request;
The third module is used for dividing the heartbeat data packet and each service data packet into a plurality of data segment packets based on the first data length;
and a fourth module, configured to sequentially send, to the data receiver through Socket, a heartbeat packet and a plurality of data segments corresponding to each service packet.
23. A service data receiving apparatus deployed on a data receiving side, the apparatus comprising:
a fifth module for creating and starting an MLCP connection with the data sender;
a sixth module, configured to initialize a data buffer, receive data sequentially sent by the data sender through Socket, read data according to a second data length based on a first data reading interval, obtain a data segment, and write the data segment into the data buffer;
a seventh module, configured to read a plurality of data segments from the data buffer based on a second data reading interval, and assemble a data packet with an MLCP frame structure, where the data packet is a heartbeat keep-alive data packet or a service data packet;
and a ninth module, configured to obtain service data based on the service data packet of the MLCP frame structure.
24. A traffic data transmission system, the system comprising:
The data transmission side is used for creating and starting MLCP connection with the data receiver, generating a heartbeat data packet of an MLCP frame structure based on a heartbeat keep-alive transmission interval, packaging service data to be transmitted into a plurality of service data packets of the MLCP frame structure based on a service data transmission request, respectively splitting the heartbeat data packet and each service data packet into a plurality of data segment packets based on a first data length, and sequentially transmitting the heartbeat data packet and a plurality of data segments corresponding to each service data packet to the data receiver through a Socket;
the data receiving party is used for creating and starting MLCP connection with the data sending party, initializing a data buffer zone, receiving data sequentially sent by the data sending party through a Socket, reading the data according to a second data length based on a first data reading interval to obtain data segments and writing the data segments into the data buffer zone, reading a plurality of data segments from the data buffer zone based on the second data reading interval, and assembling the data segments into a data packet of an MLCP frame structure, wherein the data packet is a heartbeat keep-alive data packet or a service data packet, and acquiring service data based on the service data packet of the MLCP frame structure.
25. A computer-readable medium comprising,
having stored thereon computer readable instructions to be executed by a processor to implement the method of any of claims 1 to 21.
26. An apparatus for traffic data transmission, the apparatus comprising:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method of any one of claims 1 to 21.
CN202311061515.8A 2023-08-22 2023-08-22 Service data sending method, receiving method, device, system and equipment Pending CN117061586A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311061515.8A CN117061586A (en) 2023-08-22 2023-08-22 Service data sending method, receiving method, device, system and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311061515.8A CN117061586A (en) 2023-08-22 2023-08-22 Service data sending method, receiving method, device, system and equipment

Publications (1)

Publication Number Publication Date
CN117061586A true CN117061586A (en) 2023-11-14

Family

ID=88665930

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311061515.8A Pending CN117061586A (en) 2023-08-22 2023-08-22 Service data sending method, receiving method, device, system and equipment

Country Status (1)

Country Link
CN (1) CN117061586A (en)

Similar Documents

Publication Publication Date Title
CN108494817B (en) Data transmission method, related device and system
RU2496278C2 (en) Method for communication between platforms
CN111158779B (en) Data processing method and related equipment
CN115396528A (en) Quic data transmission method and device based on protocol family
CN110187986A (en) A kind of command management method, system, device and computer readable storage medium
CN111147340A (en) Method, equipment and medium for carrying out networked access on CAN bus interface
CN110071839B (en) CORBA communication device supporting digital signal processor
CN111723115A (en) Data statistics method, device, terminal and storage medium based on multi-level cache
CN110209344B (en) Method, device and computer readable storage medium for migrating object storage
CN109982315A (en) Log method for uploading and relevant device
CN113296987A (en) Interface calling method and device for calling module, computer equipment and storage medium
CN117061586A (en) Service data sending method, receiving method, device, system and equipment
CN114244758B (en) Network diagnosis method, storage medium, electronic equipment and system of android platform
CN115037671B (en) Multi-path aggregation scheduling method and electronic equipment
CN114780353A (en) File log monitoring method and system and computing device
CN115426375A (en) Data processing method and data processing system
CN114615355A (en) Message processing method and message analysis module
CN111538660B (en) Method and device for counting coverage rate of program codes in cloud container
CN111585807A (en) Log management method and related equipment
CN118227343B (en) Data processing method, system, device, equipment, medium and product
CN115174552B (en) Local area network communication and file transmission method and system based on WEB operating system
CN112769638B (en) Method for improving JAIN SIP server performance based on DPDK technology
CN116800605B (en) Network implementation method, system, equipment and medium for running virtual machine in container
WO2024145862A1 (en) Data transmission method and related apparatus
JP5463325B2 (en) Wireless access module, data card, and method of communication between wireless access module and host

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination