CN110086703B - Message transmission method and device based on TCP (Transmission control protocol) - Google Patents

Message transmission method and device based on TCP (Transmission control protocol) Download PDF

Info

Publication number
CN110086703B
CN110086703B CN201810081327.4A CN201810081327A CN110086703B CN 110086703 B CN110086703 B CN 110086703B CN 201810081327 A CN201810081327 A CN 201810081327A CN 110086703 B CN110086703 B CN 110086703B
Authority
CN
China
Prior art keywords
message
data packet
packet
tcp
characteristic information
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.)
Active
Application number
CN201810081327.4A
Other languages
Chinese (zh)
Other versions
CN110086703A (en
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.)
Zhuomi Private Ltd
Original Assignee
Zhuomi Private 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 Zhuomi Private Ltd filed Critical Zhuomi Private Ltd
Priority to CN201810081327.4A priority Critical patent/CN110086703B/en
Publication of CN110086703A publication Critical patent/CN110086703A/en
Application granted granted Critical
Publication of CN110086703B publication Critical patent/CN110086703B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]

Abstract

The embodiment of the invention discloses a message transmission method and a message transmission device based on a TCP (transmission control protocol), which relate to the technical field of communication and can effectively improve the service performance of TCP messages. The method comprises the following steps: receiving a Transmission Control Protocol (TCP) message sent by opposite-end equipment, wherein the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a packet head part and a packet body part; the packet head part carries corresponding data packet characteristic information; analyzing the packet header part to obtain corresponding data packet characteristic information; and correspondingly processing the TCP message according to the data packet characteristic information. The invention can be used in various TCP-based message transmission.

Description

Message transmission method and device based on TCP (Transmission control protocol)
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a message transmission method and apparatus based on a TCP protocol.
Background
TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte-stream-based transport-layer communication Protocol that defines a source port and a destination port for a byte stream and divides the byte stream into segments for Transmission between the source port and the destination port.
However, with the endless evolution of various applications of a terminal, the types of service data are more and more, and a message transmitted based on a TCP protocol often cannot well meet various service requirements when being processed, so that the TCP message often needs to be processed or adjusted more complicatedly according to a specific service, which greatly affects the service performance of the TCP message.
Disclosure of Invention
In view of this, embodiments of the present invention provide a message transmission method and apparatus based on a TCP protocol, which can effectively improve service performance of a TCP message.
In a first aspect, an embodiment of the present invention provides a message transmission method based on a TCP protocol, including: receiving a Transmission Control Protocol (TCP) message sent by opposite-end equipment, wherein the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a packet head part and a packet body part; the packet head part carries corresponding data packet characteristic information; the data packet characteristic information comprises at least one of the following: packet header length information, packet body length information and message type information; analyzing the packet header part to obtain corresponding data packet characteristic information; and correspondingly processing the TCP message according to the data packet characteristic information.
With reference to the first aspect, in a first implementation manner of the first aspect, the packet characteristic information is the header length information; the corresponding processing of the TCP message according to the data packet characteristic information includes: and identifying the protocol version corresponding to the TCP message according to the header length information so as to correspondingly process the TCP messages with different protocol versions.
With reference to the first aspect, in a second implementation manner of the first aspect, the packet characteristic information is the packet body length information; the corresponding processing of the TCP message according to the data packet characteristic information includes: and determining the packet body length of the corresponding data packet according to the packet body length information so as to identify different data packets under the condition of packet sticking.
With reference to the first aspect, in a third implementation manner of the first aspect, the packet characteristic information is the message type information; the corresponding processing of the TCP message according to the data packet characteristic information includes: and determining the message type of the corresponding data packet according to the message type information so as to carry out different processing on the data packet according to different message types.
With reference to the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the message type includes at least one of: live messages, single chat messages, group chat messages.
With reference to the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect, each of the message types includes at least one of the following: text, voice, video, gift, red envelope.
With reference to the fourth implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the message type is a live message; the data packet characteristic information also comprises a live broadcast room number parameter; after determining the message type of the corresponding data packet according to the message type information, the method further includes: and respectively routing the live broadcast messages according to the live broadcast room number parameters.
With reference to the fourth implementation manner of the first aspect, in a seventh implementation manner of the first aspect, the message type is a live message; the data packet characteristic information also comprises a discarding indication parameter; after determining the message type of the corresponding data packet according to the message type information, the method further includes: and carrying out current limiting processing on the live broadcast message according to the discarding indication parameter.
With reference to any one of the first to seventh embodiments of the first aspect, in an eighth embodiment of the first aspect, the method further comprises: and receiving a heartbeat message sent by the opposite terminal equipment, wherein the length of the heartbeat message is smaller than a preset length threshold value, and the message content of the heartbeat message is a preset value.
In a second aspect, an embodiment of the present invention further provides a message transmission apparatus based on a TCP protocol, including: the device comprises a receiving unit and a sending unit, wherein the receiving unit is used for receiving a Transmission Control Protocol (TCP) message sent by opposite-end equipment, the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a packet head part and a packet body part; the packet head part carries corresponding data packet characteristic information; the data packet characteristic information comprises at least one of the following: packet header length information, packet body length information and message type information; the analyzing unit is used for analyzing the packet head part to obtain corresponding data packet characteristic information; and the processing unit is used for carrying out corresponding processing on the TCP message according to the data packet characteristic information analyzed by the analyzing unit.
With reference to the second aspect, in a first implementation manner of the second aspect, the packet characteristic information is the header length information; and the processing unit is used for identifying the protocol version corresponding to the TCP message according to the header length information so as to perform corresponding processing on the TCP messages with different protocol versions.
With reference to the second aspect, in a second embodiment of the second aspect, the packet characteristic information is the packet body length information; and the processing unit is used for determining the packet body length of the corresponding data packet according to the packet body length information so as to identify different data packets under the condition of packet sticking.
With reference to the second aspect, in a third implementation manner of the second aspect, the packet characteristic information is the message type information; and the processing unit is used for determining the message type of the corresponding data packet according to the message type information so as to carry out different processing on the data packet according to different message types.
With reference to the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect, the message type includes at least one of: live messages, single chat messages, group chat messages.
With reference to the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect, each of the message types includes at least one of the following: text, voice, video, gift, red envelope.
With reference to the fourth implementation manner of the second aspect, in a sixth implementation manner of the second aspect, the message type is a live message; the data packet characteristic information also comprises a live broadcast room number parameter; the device also comprises a routing unit used for respectively routing the live broadcast messages according to the live broadcast number parameters after determining the message types of the corresponding data packets according to the message type information.
With reference to the fourth implementation manner of the second aspect, in a seventh implementation manner of the second aspect, the message type is a live message; the data packet characteristic information also comprises a discarding indication parameter; the device also comprises a current limiting unit which is used for carrying out current limiting processing on the live broadcast message according to the discarding indication parameter after the message type of the corresponding data packet is determined according to the message type information.
With reference to any one of the first to seventh implementation manners of the second aspect, in an eighth implementation manner of the second aspect, the receiving unit is further configured to receive a heartbeat message sent by the peer device, where a length of the heartbeat message is smaller than a preset length threshold, and a message content of the heartbeat message is a preset value.
In a third aspect, an embodiment of the present invention further provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute any message transmission method based on the TCP protocol provided by the embodiment of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing one or more programs, which are executable by one or more processors to implement any one of the TCP protocol-based message transmission methods provided by the embodiments of the present invention.
The message transmission method and device based on the TCP protocol provided by the embodiment of the invention can transmit the TCP message in the form of the data packet and carry the corresponding data packet characteristic information on the packet head part of the data packet, so that the data packet can be processed differently according to different data packet characteristic information under the condition of only analyzing the packet head part, and the service performance of the TCP message is effectively improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a message transmission method based on a TCP protocol according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a transmission effect of TCP messages according to an embodiment of the present invention;
fig. 3 is a detailed flowchart of a message transmission method based on a TCP protocol according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a message transmission apparatus based on a TCP protocol according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In a first aspect, an embodiment of the present invention provides a message transmission method based on a TCP protocol, which can transmit a TCP message in a form of a data packet and carry corresponding data packet characteristic information in a header portion of the data packet, so as to perform different processing on the data packet according to different data packet characteristic information, thereby effectively improving service performance of the TCP message.
TCP provides a connection-oriented, reliable byte-stream service, meaning that two applications using TCP (e.g., where one client and the other is a server) need to establish a TCP connection before exchanging packets with each other. In a TCP connection, two parties communicate with each other. Because one end receiving the TCP message often needs to further process the TCP message according to different service requirements, the message transmission method based on the TCP protocol provided in the embodiment of the present invention is mainly explained based on the receiving end, and the sending end is used as the sender of the TCP message and corresponds to the receiving end in terms of data format and operation. The receiving end or the sending end may be a client or a server, which is not limited in the embodiments of the present invention.
As shown in fig. 1, a message transmission method based on a TCP protocol provided by an embodiment of the present invention may include:
s11, receiving a TCP message sent by an opposite terminal device, wherein the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a header part and a packet part; the packet head part carries corresponding data packet characteristic information;
the peer device may be any device or application that performs TCP communication with the receiving end, for example, when the receiving end is a server, the peer device may be a client. Each TCP message may be sent in one or more packets depending on the length of the TCP message. However, because the packet part has a relatively large data volume and a relatively complex structure, in order to improve the service performance of the TCP message, in the embodiment of the present invention, some data packet characteristic information of each data packet body may be extracted, and the data packet characteristic information is placed in the header part of each data packet. The packet head part has small data quantity and relatively simple structure, and is more favorable for rapidly knowing the service performance of the data packet.
Optionally, the packet characteristic information may include one or more of the following: packet header length information, packet body length information and message type information. The header length information is the length of the header part of the corresponding data packet, for example, the number of bytes included in the header part; the packet body length information is the length of the packet body part of the corresponding data packet, for example, the number of bytes included in the packet body part; the message type information is information describing an attribute type of the TCP message.
S12, analyzing the packet head part to obtain the corresponding data packet characteristic information;
in this step, the received TCP message may be preprocessed to analyze the header portion of each data packet, so as to generally know what characteristics the data packet has, and which service is suitable for.
And S13, performing corresponding processing on the TCP message according to the data packet characteristic information.
In this step, different TCP messages can be processed differently according to the difference of the analyzed header length information, packet length information, and message type information, so as to meet the needs of various services.
The message transmission method based on the TCP protocol provided by the embodiment of the invention can transmit the TCP message in the form of the data packet and carry the corresponding data packet characteristic information on the packet head part of the data packet, so that the data packet can be processed differently according to different data packet characteristic information under the condition of only analyzing the packet head part, and the service performance of the TCP message is effectively improved.
The following respectively describes the influence of the header length information, the body length information, and the message type information on the message processing in a brief manner.
Optionally, when the data packet characteristic information in step S11 includes the header length information, step S12 may obtain the header length information of the data packet by parsing the header portion, and based on this, in step S13, performing corresponding processing on the TCP message according to the data packet characteristic information may specifically include: and identifying the protocol version corresponding to the TCP message according to the header length information so as to correspondingly process the TCP messages with different protocol versions.
Since the body of TCP protocol communications may be various types of devices or applications, the protocol support for each device or application may vary. Even the same device or application may have different TCP protocols supported by different subjects due to different software update schedules. In order to enable the TCP message to be smoothly transmitted among various different main bodies, the TCP message in the embodiment of the invention has certain compatibility and expandability, and can support the use of different applications in various development stages.
Specifically, different applications may support different formats of TCP protocols in different versions, for example, a version 4.1 of an application a may support a TCP protocol with a header length of 12 bytes, and an upgraded version 4.2 may support a TCP protocol with a header length of 15 bytes. In order to enable the two versions of the application a to perform transmission and application of the TCP message, in an embodiment of the present invention, header length information is set in the header portion to specifically indicate how many bytes are in the header portion of one data packet, so as to support reading of the header portions with various byte lengths.
In addition, the parameter of the header length information itself also occupies a certain number of bytes, and the size of the number of bytes occupied by the header length information can be adjusted according to specific needs, for example, when the header portion is short, only one byte is needed to indicate the header length information. Therefore, when the data receiving end receives the data, the content can be obtained only by reading the length of one byte, and the length of the whole packet head part is obtained, so that the content data corresponding to the packet head length can be read according to the length of the packet head part. When the header part is long, two bytes may be needed to indicate the header length information.
Optionally, in addition to the packet header length information, in an embodiment of the present invention, the data packet characteristic information carried by the packet header portion may further include packet body length information; the byte number of the corresponding bag body part can be determined by analyzing the bag body part. Based on this, in step S13, the performing corresponding processing on the TCP message according to the packet feature information may specifically include: and determining the packet body length of the corresponding data packet according to the packet body length information so as to identify different data packets under the condition of packet sticking.
Specifically, as TCP cannot understand upper layer services, when TCP data is transmitted over the network, data organization may be disordered, which affects normal reading of data, i.e., a data packet sticking problem occurs.
As shown in fig. 2, when a Client sends Datal and Data2 Data to a Server, the following situations may occur in the Data arriving at the Server:
in the first case: no sticky packet is shown by Datal and Data2, and the sticky packet normally reaches the Server end.
In the second case: datal sticks with Data2 packets, causing the server side to fail to correctly distinguish the packets.
In order to solve the problem in the second case, in an embodiment of the present invention, the data packet characteristic information carried in the header portion may further include packet length information. The length information of the packet body can be specifically packaged by a data packet before data transmission. For example, the packet length of the data content may be calculated, and the packet length may be written in the packet length field of the header portion. Optionally, since the length of the body is generally greater than the length of the header, the number of bytes occupied by the body length field itself is also greater, and in an embodiment of the present invention, the body length field may be set to be four bytes long, which is slightly greater than one byte length of the header length field. Therefore, when the data receiving end receives data, the length information of the bag body can be obtained only by reading the length of four bytes, so that the content of the bag body with the corresponding length can be read. Of course, in other embodiments of the present invention, the length field may also be set to other lengths, which is not limited in the embodiments of the present invention. Therefore, even if the data is stuck, the boundary lines of different data packets can be accurately found according to the packet body length, so that the failure probability is greatly reduced.
Further, in addition to the packet header length information and the packet body length information, in an embodiment of the present invention, the data packet characteristic information carried by the packet header portion may further include message type information; the message type information of the data packet can be determined by analyzing the packet header part. Based on this, in step S13, the performing corresponding processing on the TCP message according to the packet feature information may specifically include: and determining the message type of the corresponding data packet according to the message type information so as to carry out different processing on the data packet according to different message types.
Optionally, in an embodiment of the present invention, the message type of the data packet may include one or more of the following: live messages, single chat messages, group chat messages. The live broadcast message refers to that data in the data packet is a message in live network broadcast, the single chat message refers to a message in a chat mode from one user to another user in the instant messaging message (for example, a QQ application), and the group chat message refers to a message in a shared chat mode among a plurality of users in the instant messaging message. Since the types of messages to which these packets belong are different, the subsequent further processing may also be different accordingly. For example, a message alert may be sent to a receiving user if a single chat message is received, but not sent to the receiving user if a group chat message is received, unless the message is for the user, e.g. @ the user ".
Further, whether live, single, or group chat messages, each message type may in turn include one or more of the following sub-types: text, voice, video, gift, red envelope, etc. Correspondingly, when a data packet of a received TCP message is processed, different processing modes exist for different message types, and different sub-types under the same message type correspond to different processing modes. For example, the user may not be prompted for textual information, and may be prompted for gift or red envelope information. In the live mode, when the amount of text information is too large, for example, more than 5000 pieces/minute, the anchor is not ready to view the text information one by one in a short time, and thus the text information can be appropriately compressed or limited. In the single chat mode or the group chat mode, the time for the user to view the message is not strictly limited, and the text information may contain important information, so that the text information can be completely reserved without compression and limitation.
Specifically, when the message type of a data packet is a live broadcast message, the data packet feature information carried in the packet header of the data packet may further include a live broadcast room number parameter, where the live broadcast room number parameter is used to indicate to which live broadcast room the data packet is sent, and based on this, after determining the message type of the corresponding data packet according to the message type information, the message transmission method based on the TCP protocol provided in the embodiment of the present invention may further include: and respectively routing the live broadcast messages according to the live broadcast room number parameters. For example, in an embodiment of the present invention, a receiving end receives three data packets within a certain period of time, where a header part of the data packet a indicates that the data packet a is a live broadcast message, a live broadcast room number is 308A, a header part of the data packet B indicates that the data packet B is a single chat message, a header part of the data packet C indicates that the data packet C is a live broadcast message, and a live broadcast room number is 2020, the receiving end performs different processing on the three data packets according to the parsed header parts, routes the data packet a to the live broadcast room with the live broadcast room number being 308A, routes the data packet C to the live broadcast room with the live broadcast room number being 2020, and sends the data packet B to a corresponding single chat object.
Optionally, when the message type of the data packet is a live message, the packet characteristic information may further include a discard indication parameter, where the discard indication parameter is used to indicate whether information in the data packet can be discarded or not, or is used to indicate when data in the data packet satisfies what condition to discard. Based on this, after determining the message type of the corresponding data packet according to the message type information, the TCP protocol-based message transmission method provided in the embodiment of the present invention may further include: and carrying out current limiting processing on the live broadcast message according to the discarding indication parameter.
Because a large amount of messages can possibly be injected in a moment in the live broadcast mode, not only the server is congested, but also the users are easy to find out, cannot catch the key points and miss important information. In order to relieve the server stress and enable the user to see valuable messages in time, in one embodiment of the present invention, the packet information can be selectively discarded according to the discard indication parameter of the packet header part, so as to achieve the purpose of current limiting. Optionally, the discard indication parameter may be, for example, a "yes" or "no" flag bit, which indicates that the packet may be discarded when the flag bit is "yes", and indicates that the packet cannot be discarded when the flag bit is "no". For example, a "gift" in a live message may be set to "no" and a "text" in a live message may be set to "yes". Therefore, when the data volume of a certain live broadcast room is burst in a short time, partial text information can be discarded, all 'gift' messages are reserved, and the host can see the gift messages in time while the pressure of the server is reduced.
Further, in an instant messaging service scenario, besides the messages related to specific services, heartbeat messages are also the most frequent data interactions. In order to save the overhead, in one embodiment of the present invention, the heartbeat messages are not assembled according to the packet header part and the packet body part for each heartbeat message, but are implemented in a special format.
Specifically, the method for transmitting a TCP message provided in the embodiment of the present invention may further include receiving a heartbeat message sent by the peer device, where a length of the heartbeat message is smaller than a preset length threshold, and a message content of the heartbeat message is a preset value. Therefore, the consumption of sending the heartbeat messages can be effectively reduced by limiting the length, and the heartbeat messages can be distinguished from common messages by setting the message content of the heartbeat messages as preset data. For example, in an embodiment of the present invention, the heartbeat message is a packet including only one byte, and does not include the agreed header portion and body portion, and the data content in the heartbeat is-99, so that the data receiving end can determine whether the data packet is a heartbeat message.
The following describes in detail a message transmission method based on the TCP protocol according to an embodiment of the present invention.
As shown in fig. 3, a message transmission method based on a TCP protocol according to an embodiment of the present invention may include the following steps:
s201, receiving a TCP message sent by an opposite terminal device, wherein the TCP message is transmitted by taking a data packet as a unit, and the received TCP message comprises a data packet 001, a data packet 002 and a data packet 003. The data structure of each packet may be as shown in tables 1-3.
S202, respectively analyzing the packet head parts of the data packet 001, the data packet 002 and the data packet 003 to obtain the characteristic information of the data packet;
the packet header length of the data packet 001 is 12 bytes, the packet body length is 40 bytes, the message type is group chat message, and the subtype is voice message;
TABLE 1
Figure BDA0001559931870000111
TABLE 2
Figure BDA0001559931870000112
TABLE 3
Figure BDA0001559931870000113
The header length of the data packet 002 is 12 bytes, the packet body length is 32 bytes, the message type is live broadcast message, the subtype is text message, the number parameter of the live broadcast room is 511, and the discard indication parameter is "yes";
the header length of the data packet 003 is 15 bytes, the packet body length is 60 bytes, the message type is live broadcast message, the subtype is gift message, the live broadcast room number parameter is 516, discard and instruct the parameter to be "no";
s203, distinguishing the three data packets according to the packet head position, the packet head length and the packet body length of the data packets;
s204, forwarding the data packet 001 to the group chat application with the version of 1.0;
s205, forwarding the data packet 002 to the live broadcast application with the version of 1.0 and the live broadcast room number of 511;
s206, forwarding the data packet 003 to the live broadcast application with the version of 1.1 and the live broadcast room number of 516;
and S207, the live broadcast messages of the live broadcast room 511 and the live broadcast room 516 are instantaneously blowout, the data packet 002 is discarded according to the discarding indication parameters in the data packet 002 and the data packet 003, and the data packet 003 is reserved.
In a second aspect, an embodiment of the present invention provides a message transmission apparatus based on a TCP protocol, which is capable of transmitting a TCP message in a form of a data packet and carrying corresponding data packet characteristic information in a header portion of the data packet, so as to perform different processing on the data packet according to different data packet characteristic information, thereby effectively improving service performance of the TCP message.
As shown in fig. 4, a message transmission apparatus based on a TCP protocol provided by an embodiment of the present invention may include:
a receiving unit 31, configured to receive a transmission control protocol TCP message sent by an opposite device, where the TCP message is transmitted in units of data packets, and each data packet includes a header portion and a packet portion; the packet head part carries corresponding data packet characteristic information;
the parsing unit 32 is configured to parse the header portion to obtain corresponding data packet characteristic information;
and the processing unit 33 is configured to perform corresponding processing on the TCP message according to the packet feature information analyzed by the analyzing unit 32.
The message transmission device based on the TCP protocol provided by the embodiment of the invention can transmit the TCP message in the form of the data packet and carry the corresponding data packet characteristic information on the packet head part of the data packet, so that the data packet can be processed differently according to different data packet characteristic information under the condition of only analyzing the packet head part, and the service performance of the TCP message is effectively improved.
Optionally, the packet characteristic information may include at least one of the following: packet header length information, packet body length information and message type information.
Optionally, the data packet characteristic information is the packet header length information; the processing unit 33 is configured to identify a protocol version corresponding to the TCP message according to the header length information, so as to perform corresponding processing on TCP messages of different protocol versions.
Optionally, the data packet characteristic information is the packet body length information; and the processing unit 33 is configured to determine the packet body length of the corresponding data packet according to the packet body length information, so as to identify different data packets under the condition of packet sticking.
Optionally, the data packet characteristic information is the message type information; and the processing unit 33 is configured to determine the message type of the corresponding data packet according to the message type information, so as to perform different processing on the data packet according to different message types.
Optionally, the message type includes at least one of the following: live messages, single chat messages, group chat messages.
Optionally, each of the message types includes at least one of the following: text, voice, video, gift, red envelope.
Optionally, the message type is a live message; the data packet characteristic information also comprises a live broadcast room number parameter; the device also comprises a routing unit used for respectively routing the live broadcast messages according to the live broadcast number parameters after determining the message types of the corresponding data packets according to the message type information.
Optionally, the message type is a live message; the data packet characteristic information also comprises a discarding indication parameter; the device also comprises a current limiting unit which is used for carrying out current limiting processing on the live broadcast message according to the discarding indication parameter after the message type of the corresponding data packet is determined according to the message type information.
Optionally, the receiving unit 33 is further configured to receive a heartbeat message sent by the peer device, where a length of the heartbeat message is smaller than a preset length threshold, and a message content of the heartbeat message is a preset value.
In a third aspect, an embodiment of the present invention provides an electronic device, which is capable of transmitting a TCP message in a data packet form and carrying corresponding data packet characteristic information in a header portion of the data packet, so that different processing is performed on the data packet according to different data packet characteristic information, and service performance of the TCP message is effectively improved.
As shown in fig. 5, an electronic device provided in an embodiment of the present invention may include: the device comprises a shell 51, a processor 52, a memory 53, a circuit board 54 and a power circuit 55, wherein the circuit board 54 is arranged inside a space enclosed by the shell 51, and the processor 52 and the memory 53 are arranged on the circuit board 54; a power supply circuit 55 for supplying power to each circuit or device of the electronic apparatus; the memory 53 is used to store executable program code; the processor 52 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 53, for executing the TCP protocol-based message transmission method provided in any of the foregoing embodiments.
For specific execution processes of the above steps by the processor 52 and further steps executed by the processor 52 by running the executable program code, reference may be made to the description of the foregoing embodiments, and details are not described herein again.
The above electronic devices exist in a variety of forms, including but not limited to:
(1) a mobile communication device: such devices are characterized by mobile communications capabilities and are primarily targeted at providing voice, data communications. Such terminals include: smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer device: the equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include: PDA, MID, and UMPC devices, etc., such as ipads.
(3) A portable entertainment device: such devices can display and play multimedia content. This type of device comprises: audio, video players (e.g., ipods), handheld game consoles, electronic books, and smart toys and portable car navigation devices.
(4) A server: the device for providing the computing service comprises a processor, a hard disk, a memory, a system bus and the like, and the server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic equipment with data interaction function.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs can be executed by one or more processors to implement any one of the TCP protocol-based message transmission methods provided in the foregoing embodiments, so that corresponding technical effects can also be achieved, and the foregoing has been described in detail, and are not described herein again.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. The term "comprising", without further limitation, means that the element so defined is not excluded from the group consisting of additional identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
For convenience of description, the above devices are described separately in terms of functional division into various units/modules. Of course, the functionality of the units/modules may be implemented in one or more software and/or hardware implementations of the invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (18)

1. A message transmission method based on TCP protocol is characterized by comprising the following steps:
receiving a Transmission Control Protocol (TCP) message sent by opposite-end equipment, wherein the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a packet head part and a packet body part; the packet head part carries corresponding data packet characteristic information; the data packet characteristic information comprises packet header length information;
analyzing the packet header part to obtain corresponding data packet characteristic information;
performing corresponding processing on the TCP message according to the data packet characteristic information;
the data packet characteristic information comprises message type information, and the message type comprises a live broadcast message; the data packet characteristic information further comprises a discarding indication parameter, wherein the discarding indication parameter is used for indicating whether the information in the data packet can be discarded or indicating when the data in the data packet meets any condition;
after determining the message type of the corresponding data packet according to the message type information, the method further includes: and carrying out current limiting processing on the live broadcast message according to the discarding indication parameter.
2. The method of claim 1,
the corresponding processing of the TCP message according to the data packet characteristic information includes:
and identifying the protocol version corresponding to the TCP message according to the header length information so as to correspondingly process the TCP messages with different protocol versions.
3. The method of claim 1, wherein the packet characteristic information comprises packet length information;
the corresponding processing of the TCP message according to the data packet characteristic information includes:
and determining the packet body length of the corresponding data packet according to the packet body length information so as to identify different data packets under the condition of packet sticking.
4. The method of claim 1, wherein the packet characteristic information comprises message type information;
the corresponding processing of the TCP message according to the data packet characteristic information includes:
and determining the message type of the corresponding data packet according to the message type information so as to carry out different processing on the data packet according to different message types.
5. The method of claim 4, wherein the message type further comprises: single chat messages and/or group chat messages.
6. The method of claim 5, wherein each of the message types comprises at least one of the following: text, voice, video, gift, red envelope.
7. The method of claim 5, wherein the message type is a live message; the data packet characteristic information also comprises a live broadcast room number parameter;
after determining the message type of the corresponding data packet according to the message type information, the method further includes:
and respectively routing the live broadcast messages according to the live broadcast room number parameters.
8. The method of any one of claims 1 to 7, further comprising:
and receiving a heartbeat message sent by the opposite terminal equipment, wherein the length of the heartbeat message is smaller than a preset length threshold value, and the message content of the heartbeat message is a preset value.
9. A message transmission apparatus based on a TCP protocol, comprising:
the device comprises a receiving unit and a sending unit, wherein the receiving unit is used for receiving a Transmission Control Protocol (TCP) message sent by opposite-end equipment, the TCP message is transmitted by taking a data packet as a unit, and each data packet comprises a packet head part and a packet body part; the packet head part carries corresponding data packet characteristic information; the data packet characteristic information comprises packet header length information;
the analyzing unit is used for analyzing the packet head part to obtain corresponding data packet characteristic information;
the processing unit is used for carrying out corresponding processing on the TCP message according to the data packet characteristic information analyzed by the analyzing unit;
the data packet characteristic information comprises message type information, and the message type comprises a live broadcast message; the data packet characteristic information further comprises a discarding indication parameter, wherein the discarding indication parameter is used for indicating whether the information in the data packet can be discarded or indicating when the data in the data packet meets any condition;
the device also comprises a current limiting unit which is used for carrying out current limiting processing on the live broadcast message according to the discarding indication parameter after the message type of the corresponding data packet is determined according to the message type information.
10. The apparatus of claim 9,
and the processing unit is used for identifying the protocol version corresponding to the TCP message according to the header length information so as to perform corresponding processing on the TCP messages with different protocol versions.
11. The apparatus of claim 9, wherein the packet characteristic information comprises packet length information;
and the processing unit is used for determining the packet body length of the corresponding data packet according to the packet body length information so as to identify different data packets under the condition of packet sticking.
12. The apparatus of claim 9, wherein the packet characteristic information comprises message type information;
and the processing unit is used for determining the message type of the corresponding data packet according to the message type information so as to carry out different processing on the data packet according to different message types.
13. The apparatus of claim 12, wherein the message types further comprise: single chat messages and/or group chat messages.
14. The apparatus of claim 13, wherein each of the message types comprises at least one of the following: text, voice, video, gift, red envelope.
15. The apparatus of claim 13, wherein the message type is a live message; the data packet characteristic information also comprises a live broadcast room number parameter; the device also comprises a routing unit used for respectively routing the live broadcast messages according to the live broadcast number parameters after determining the message types of the corresponding data packets according to the message type information.
16. The apparatus according to any one of claims 9 to 15,
the receiving unit is further configured to receive a heartbeat message sent by the peer device, where a length of the heartbeat message is smaller than a preset length threshold, and a message content of the heartbeat message is a preset value.
17. An electronic device, characterized in that the electronic device comprises: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the TCP protocol-based message transmission method of any one of the preceding claims 1 to 8.
18. A computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more programs which are executable by one or more processors to implement the TCP protocol-based message transmission method of the preceding claims 1 to 8.
CN201810081327.4A 2018-01-26 2018-01-26 Message transmission method and device based on TCP (Transmission control protocol) Active CN110086703B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810081327.4A CN110086703B (en) 2018-01-26 2018-01-26 Message transmission method and device based on TCP (Transmission control protocol)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810081327.4A CN110086703B (en) 2018-01-26 2018-01-26 Message transmission method and device based on TCP (Transmission control protocol)

Publications (2)

Publication Number Publication Date
CN110086703A CN110086703A (en) 2019-08-02
CN110086703B true CN110086703B (en) 2021-10-26

Family

ID=67412770

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810081327.4A Active CN110086703B (en) 2018-01-26 2018-01-26 Message transmission method and device based on TCP (Transmission control protocol)

Country Status (1)

Country Link
CN (1) CN110086703B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190851A (en) * 2019-12-11 2020-05-22 深圳市优必选科技股份有限公司 Analysis method, device, equipment and medium for variable length protocol
CN111343468A (en) * 2020-02-13 2020-06-26 北京字节跳动网络技术有限公司 Message processing method and device and electronic equipment
CN113242245A (en) * 2021-05-12 2021-08-10 上海绚显科技有限公司 TCP message flow limiting method, device, server and storage medium
CN114490459A (en) * 2022-01-27 2022-05-13 重庆物奇微电子有限公司 Data transmission method, device, equipment, receiver and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102377651A (en) * 2010-08-13 2012-03-14 中国移动通信集团公司 TCP (transmission control protocol) message transmission method and TCP message receiving method and device
CN102984253A (en) * 2012-11-27 2013-03-20 山东中创软件工程股份有限公司 Transmission control protocol sticky package processing method and device
CN104410613A (en) * 2014-11-20 2015-03-11 广西大学 A method and device for processing transmitting control protocol data adhering
CN106101018A (en) * 2016-06-07 2016-11-09 北京赛思信安技术股份有限公司 A kind of infallible data sending method of Based on Distributed mass data loading system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102377651A (en) * 2010-08-13 2012-03-14 中国移动通信集团公司 TCP (transmission control protocol) message transmission method and TCP message receiving method and device
CN102984253A (en) * 2012-11-27 2013-03-20 山东中创软件工程股份有限公司 Transmission control protocol sticky package processing method and device
CN104410613A (en) * 2014-11-20 2015-03-11 广西大学 A method and device for processing transmitting control protocol data adhering
CN106101018A (en) * 2016-06-07 2016-11-09 北京赛思信安技术股份有限公司 A kind of infallible data sending method of Based on Distributed mass data loading system

Also Published As

Publication number Publication date
CN110086703A (en) 2019-08-02

Similar Documents

Publication Publication Date Title
CN110086703B (en) Message transmission method and device based on TCP (Transmission control protocol)
CN110798868B (en) Network switching method, electronic equipment and chip subsystem
WO2019228369A1 (en) Message processing method and related product
CN109167750B (en) Data packet transmission method and device, electronic equipment and storage medium
CN107274882B (en) Data transmission method and device
WO2014079382A1 (en) Voice transmission method, terminal, voice server and voice transmission system
CN110167192B (en) Bluetooth connection management method and device, electronic equipment and non-transient storage medium
US11540028B2 (en) Information presenting method, terminal device, server and system
CN109847342B (en) Network detection method and related device
US11023412B2 (en) RDMA data sending and receiving methods, electronic device, and readable storage medium
US20170171255A1 (en) Method and device for establishing a data connection and computer-readable medium
CN112291181B (en) Data transmission method based on multiple network cards and related device
CN110446228B (en) Data transmission method, device, terminal equipment and storage medium
CN108460044B (en) Data processing method and device
CN110248211B (en) Live broadcast room message current limiting method and device, electronic equipment and storage medium
CN114390578A (en) Network performance testing method and device, electronic equipment and medium
CN113115120A (en) Video slicing method and device, electronic equipment and storage medium
TW201836330A (en) Method for uplink data transmission, terminal, network side equipment, and system
CN107733903B (en) Data transmission confirmation method based on UDP (user Datagram protocol) and base station
CN115801927A (en) Message parsing method and device
US10447821B1 (en) Method and apparatus of providing thin client functionality
CN109766347B (en) Data updating method, device, system, computer equipment and storage medium
CN108200604B (en) Data transmission method and device
CN111245702B (en) Data transmission method and device based on 5GS, forwarding equipment and UPF communication equipment
CN111726280A (en) Instant message transmission method and device, electronic equipment and storage medium

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210603

Address after: 25, 5th floor, shuangjingfang office building, 3 frisha street, 189352, Singapore

Applicant after: Zhuomi Private Ltd.

Address before: Room 1101, Santai Commercial Building, 139 Connaught Road, Hong Kong, China

Applicant before: HONG KONG LIVE.ME Corp.,Ltd.

GR01 Patent grant
GR01 Patent grant