CN107276873B - Method and device for accessing service - Google Patents

Method and device for accessing service Download PDF

Info

Publication number
CN107276873B
CN107276873B CN201610217189.9A CN201610217189A CN107276873B CN 107276873 B CN107276873 B CN 107276873B CN 201610217189 A CN201610217189 A CN 201610217189A CN 107276873 B CN107276873 B CN 107276873B
Authority
CN
China
Prior art keywords
terminal
service
tunnel
service access
port
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
CN201610217189.9A
Other languages
Chinese (zh)
Other versions
CN107276873A (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.)
Insta360 Innovation Technology Co Ltd
Original Assignee
Shenzhen Arashi Vision 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 Shenzhen Arashi Vision Co ltd filed Critical Shenzhen Arashi Vision Co ltd
Priority to CN201610217189.9A priority Critical patent/CN107276873B/en
Publication of CN107276873A publication Critical patent/CN107276873A/en
Application granted granted Critical
Publication of CN107276873B publication Critical patent/CN107276873B/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
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4633Interconnection of networks using encapsulation techniques, e.g. tunneling
    • 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]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Abstract

In an embodiment of the present invention, a method for accessing a service is provided: the method comprises the steps that a first terminal establishes a tunnel capable of communicating with a second terminal; the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a TCP and/or UDP protocol; the first terminal receives a service access response sent by the second terminal through the tunnel, and executes related operation according to the service access response, wherein the service access response adopts a TCP (transmission control protocol) and/or UDP (user datagram protocol); in the scheme, the first terminal and the second terminal communicate through the tunnel, the service access request and the service access response transmitted through the tunnel adopt TCP and/or UDP protocols, the TCP and UDP protocols are common in the communication field, and an open source library, a framework and a program based on the protocols are very common without defining a new protocol, so that the defect of low access service efficiency in the prior art can be overcome.

Description

Method and device for accessing service
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for accessing a service.
Background
Currently, there are various connection modes for the terminal and the associated accessory, such as a bluetooth mode, a WiFi (Wireless-Fidelity) mode, or a USB (Universal Serial Bus) mode. The accessory can be a standardized accessory, such as a Bluetooth mouse and a USB flash disk, and the mobile device can directly communicate with the terminal through the driver. The other type of communication-mode-based non-standardized accessories which are developed by each company and provide special purposes are provided, corresponding drivers are not arranged on terminals of the non-standardized accessories, communication data formats need to be defined by the non-standardized accessories, and programs on accessory ends and mobile equipment ends need to be developed by the self-defined communication modes.
For non-standardized accessories, all instructions and data related to the interoperation of devices at two ends need to be defined one by one, the definition of a protocol is very complicated, and the development efficiency is low, so that the access service has the defect of low efficiency aiming at the non-standardized accessories at present.
Disclosure of Invention
The present invention has been made in view of the above problems, and it is an object of the present invention to provide a method and apparatus for accessing services, which overcome or at least partially solve the above problems, and which solve the problems of the prior art, such as the inefficiency of the prior art.
According to a first aspect of the present invention, there is provided a method of accessing a service, comprising:
the method comprises the steps that a first terminal establishes a tunnel capable of communicating with a second terminal;
the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a Transmission Control Protocol (TCP) and/or a User Datagram Protocol (UDP);
and the first terminal receives a service access response sent by the second terminal through the tunnel, and executes related operation according to the service access response, wherein the service access response adopts the TCP and/or UDP protocol.
In an embodiment, according to the method in the above embodiment of the present invention, the sending, by the first terminal, a service access request to the second terminal through the tunnel includes:
the application layer of the first terminal and the tunnel layer of the first terminal establish TCP connection;
a tunnel layer of the first terminal determines a TCP service request port;
the application layer of the first terminal sends the service access request to the tunnel layer of the first terminal through the TCP connection;
and the tunnel layer of the first terminal sends the service access request to the tunnel layer of the second terminal from the TCP service request port.
In some embodiments, according to the method of any one of the above embodiments of the present invention, a protocol used by the TCP service request port is the same as a protocol used by the service providing port in the second terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the port number of the TCP service request port and the port number of the service providing port in the second terminal are the same or different.
In some embodiments, according to the method in any one of the above embodiments of the present invention, after the application layer of the first terminal establishes a TCP connection with the tunnel layer of the first terminal, before the first terminal receives a service access response sent by the second terminal through the tunnel, the method further includes:
and the tunnel layer of the first terminal sends the TCP connection identifier and/or the port number of the TCP service request port to the tunnel layer of the second terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the sending, by the first terminal, a service access request to the second terminal through the tunnel includes:
a tunnel layer of the first terminal determines a UDP service request port;
the application layer of the first terminal sends the service access request to a tunnel layer of the first terminal;
and the tunnel layer of the first terminal sends the service access request to the tunnel layer of the second terminal from the UDP service request port.
In some embodiments, according to the method of any one of the above embodiments of the present invention, a protocol used by the UDP service request port is the same as a protocol used by a service providing port in the second terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, a port number of the UDP service request port and a port number of the service providing port in the second terminal are the same or different.
In some embodiments, according to the method in any one of the above embodiments of the present invention, after the tunnel layer of the first terminal determines the UDP service request port, before the first terminal receives a service access response sent by the second terminal through the tunnel, the method further includes:
and the tunnel layer of the first terminal sends the port number of the UDP service request port to the tunnel layer of the second terminal.
In some embodiments, the method according to any of the above embodiments of the present invention, performing the relevant operation according to the service access response, includes:
receiving data carrying a connection identifier sent by the second terminal according to the service access response;
and sending feedback to the second terminal through the connection corresponding to the connection identifier.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the sending, by the first terminal, a service access request to the second terminal through the tunnel includes:
the first terminal sends a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to a connection mode of the first terminal and the second terminal;
the step of receiving, by the first terminal, a service access response sent by the second terminal through the tunnel includes:
and the first terminal receives the service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
According to a second aspect of the present invention, there is provided a method of accessing a service, comprising:
the second terminal establishes a tunnel capable of communicating with the first terminal;
the second terminal receives a service access request sent by the first terminal through the tunnel, wherein the service access request adopts a Transmission Control Protocol (TCP) and/or a User Datagram Protocol (UDP);
and the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, wherein the service access response adopts the TCP and/or UDP protocol.
In an embodiment, according to the method in the above embodiment of the present invention, after the second terminal receives the service access request sent by the first terminal through the tunnel, the method further includes:
a tunnel layer of the second terminal receives the service access request through the tunnel;
the tunnel layer of the second terminal and the service layer of the second terminal establish TCP connection;
and the tunnel layer of the second terminal sends the service access request to a service providing port of the service layer of the second terminal through the TCP connection.
In some embodiments, according to the method of any one of the above embodiments of the present invention, a protocol used by the service providing port is the same as a protocol used by a TCP service request port in the first terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the port number of the service providing port is the same as or different from the port number of the TCP service request port in the first terminal.
In some embodiments, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method according to any of the above embodiments of the present invention further includes:
and the tunnel layer of the second terminal receives the TCP connection identifier and/or the port number of the TCP service request port sent by the first terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the receiving, by the second terminal, the service access request sent by the first terminal through the tunnel includes:
a tunnel layer of the second terminal receives the service access request through the tunnel;
and the tunnel layer of the second terminal sends the service access request to a service providing port of the service layer of the second terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, a protocol used by the service providing port is the same as a protocol used by a UDP service request port in the first terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the port number of the service providing port is the same as or different from the port number of the UDP service request port in the first terminal.
In some embodiments, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method according to any of the above embodiments of the present invention further includes:
and the tunnel layer of the second terminal receives the port number of the UDP service request port sent by the first terminal.
In some embodiments, according to the method of any one of the above embodiments of the present invention, after the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further includes:
sending data carrying a connection identifier to a first terminal;
and receiving feedback sent by the first terminal through the connection corresponding to the connection identifier.
In some embodiments, according to the method of any one of the above embodiments of the present invention, the receiving, by the second terminal, the service access request sent by the first terminal through the tunnel includes:
the second terminal receives the service access request sent by the first terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, and the service access response comprises the following steps:
and the second terminal sends a service access response to the first terminal through the tunnel according to the service access request by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
According to a third aspect of the present invention, there is provided a first terminal comprising:
the establishing unit is used for establishing a tunnel which can be used for the first terminal to communicate with the second terminal;
a sending unit, configured to send a service access request to the second terminal through the tunnel, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
a receiving unit, configured to receive a service access response sent by the second terminal through the tunnel;
and the processing unit is used for executing relevant operation according to the service access response, and the service access response adopts the TCP and/or UDP protocol.
In an embodiment, according to the apparatus in the foregoing embodiment of the present invention, the establishing unit is further configured to control an application layer of the first terminal to establish a TCP connection with a tunnel layer of the first terminal;
the processing unit is further configured to control a tunnel layer of the first terminal to determine a TCP service request port;
the sending unit is further configured to control an application layer of the first terminal to send the service access request to a tunnel layer of the first terminal through the TCP connection;
the sending unit is further configured to control the tunnel layer of the first terminal to send the service access request from the TCP service request port to the tunnel layer of the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a protocol used by the TCP service request port is the same as a protocol used by the service providing port in the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a port number of the TCP service request port and a port number of the service providing port in the second terminal are the same or different.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, the sending unit is further configured to control the tunnel layer of the first terminal to send the identifier of the TCP connection and/or the port number of the TCP service request port to the tunnel layer of the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, the processing unit is further configured to control a tunnel layer of the first terminal to determine a UDP service request port;
the sending unit is further configured to control an application layer of the first terminal to send the service access request to a tunnel layer of the first terminal;
the sending unit is further configured to control the tunnel layer of the first terminal to send the service access request from the UDP service request port to the tunnel layer of the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a protocol used by the UDP service request port is the same as a protocol used by a service providing port in the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a port number of the UDP service request port and a port number of a service providing port in the second terminal are the same or different.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, the sending unit is further configured to control the tunnel layer of the first terminal to send the port number of the UDP service request port to the tunnel layer of the second terminal.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, the receiving unit is further configured to receive, according to the service access response, data carrying a connection identifier sent by the second terminal; the sending unit is further configured to send feedback to the second terminal through the connection corresponding to the connection identifier.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, when the sending unit sends the service access request to the second terminal through the tunnel, specifically:
sending a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
when the receiving unit receives the service access response sent by the second terminal through the tunnel, the receiving unit specifically includes:
and receiving a service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
According to a third aspect of the present invention, there is provided a second terminal comprising:
the establishing unit is used for establishing a tunnel which can be used for the second terminal to communicate with the first terminal;
a receiving unit, configured to receive, through the tunnel, a service access request sent by the first terminal, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
and the sending unit is used for sending a service access response to the first terminal through the tunnel according to the service access request, wherein the service access response adopts the TCP and/or UDP protocol.
In an embodiment, according to the apparatus of the foregoing embodiment of the present invention, the receiving unit is further configured to control a tunnel layer of the second terminal to receive the service access request through the tunnel;
the establishing unit is further configured to control a tunnel layer of the second terminal and a service layer of the second terminal to establish a TCP connection;
the sending unit is further configured to control the tunnel layer of the second terminal to send the service access request to the service providing port of the service layer of the second terminal through the TCP connection.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a protocol used by the service providing port is the same as a protocol used by a TCP service request port in the first terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a port number of the service providing port is the same as or different from a port number of a TCP service request port in the first terminal.
In some embodiments, according to the apparatus of any preceding embodiment of the present invention, the receiving unit is further configured to control a tunnel layer of the second terminal to receive an identifier of the TCP connection and/or a port number of the TCP service request port sent by the first terminal.
In some embodiments, according to the apparatus of any of the foregoing embodiments of the present invention, the receiving unit is further configured to control a tunnel layer of the second terminal to receive the service access request through the tunnel;
the sending unit is further configured to control the tunnel layer of the second terminal to send the service access request to a service providing port of the service layer of the second terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a protocol used by the service providing port is the same as a protocol used by a UDP service request port in the first terminal.
In some embodiments, according to the apparatus of any one of the above embodiments of the present invention, a port number of the service providing port is the same as or different from a port number of the UDP service request port in the first terminal.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, the receiving unit is further configured to control a tunnel layer of the second terminal to receive a port number of the UDP service request port sent by the first terminal.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, the sending unit is further configured to send data carrying a connection identifier to the first terminal;
the receiving unit is further configured to receive feedback sent by the first terminal through a connection corresponding to the connection identifier.
In some embodiments, according to the apparatus of any one of the foregoing embodiments of the present invention, when the receiving unit receives the service access request sent by the first terminal through the tunnel, specifically:
the receiving unit receives a service access request sent by the first terminal through the tunnel by adopting a communication mode corresponding to a connection mode of the first terminal and the second terminal;
when the sending unit sends a service access response to the first terminal through the tunnel according to the service access request, the sending unit specifically includes:
and the sending unit sends a service access response to the first terminal through the tunnel according to the service access request by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
In an embodiment of the present invention, a method for accessing a service is provided: the method comprises the steps that a first terminal establishes a tunnel capable of communicating with a second terminal; the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a TCP (Transmission Control Protocol) and/or a UDP (user data Protocol) Protocol; the first terminal receives a service access response sent by the second terminal through the tunnel, and executes related operations according to the service access response, wherein the service access response adopts the TCP and/or UDP protocol; in the scheme, a first terminal establishes a tunnel capable of communicating with a second terminal; the communication is carried out through the tunnel, the service access request and the service access response transmitted through the tunnel adopt TCP and/or UDP protocols, the TCP and UDP protocols are common in the communication field, an open source library, a framework and a program based on the protocols are very common, and a new protocol is not required to be defined, so that the defect of low service access efficiency in the prior art can be overcome.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow diagram of a proposed access service according to an embodiment of the invention;
FIG. 2 is another flow diagram of a proposed access service according to an embodiment of the invention;
FIG. 3 is a flow diagram of an embodiment of a proposed access service according to an embodiment of the invention;
fig. 4 is a schematic diagram of a first terminal according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a proposed second terminal according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 schematically shows a flow diagram of a method 10 of accessing a service according to an embodiment of the invention. As shown in fig. 1, the method may include steps 100, 110, and 120.
Step 100: the method comprises the steps that a first terminal establishes a tunnel capable of communicating with a second terminal;
step 110: the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a TCP and/or UDP protocol;
step 120: and the first terminal receives a service access response sent by the second terminal through the tunnel, and executes related operation according to the service access response, wherein the service access response adopts the TCP and/or UDP protocol.
In the embodiment of the invention, the second terminal interacts with the first terminal in an auxiliary mode. The interaction of the second terminal with the first terminal in an assisted manner can be understood as follows: the first terminal is an independent device, has one or more functions, and can be used independently, and the second terminal has an effect of providing an additional function or an auxiliary function for the first terminal, and the function is more single, and generally needs to be connected with the first terminal to be used.
In the embodiment of the present invention, data transmitted by a first terminal and a second terminal through a tunnel is encapsulated in a certain specification, for example, a packet specification in the tunnel is defined, bytes 0 to 3 represent the entire packet length, bytes 4 to 5 represent operation and status identifiers (one bit corresponds to each protocol operation and status, for example, 0x01 represents a request to establish a TCP connection, 0x02 represents to close the TCP connection, 0x04 represents data transmission, 0x08 represents a connection error, etc.), bytes 6 to 9 represent a TCP connection identifier used for distinguishing from other TCP connection data, bytes 10 to 17 represent an ending data offset counted from the reception of the first byte data, that is, a reception sliding window, which can be currently received by a current tunnel layer, and byte 18 represents data sent by a requesting application.
In this embodiment of the present invention, when the first terminal sends the service access request to the second terminal through the tunnel, optionally, the following manner may be adopted:
the application layer of the first terminal and the tunnel layer of the first terminal establish TCP connection;
a tunnel layer of the first terminal determines a TCP service request port;
the application layer of the first terminal sends the service access request to the tunnel layer of the first terminal through the TCP connection;
and the tunnel layer of the first terminal sends the service access request to the tunnel layer of the second terminal from the TCP service request port.
In this embodiment of the present invention, optionally, a protocol used by the TCP service request port is the same as a protocol used by the service providing port in the second terminal.
For example, if the service providing port uses the TCP protocol, the protocol used by the TCP service requesting port is the TCP protocol.
In the embodiment of the present invention, optionally, the port number of the TCP service request port is the same as or different from the port number of the service providing port in the second terminal.
In this embodiment of the present invention, further, after the application layer of the first terminal establishes a TCP connection with the tunnel layer of the first terminal, and before the first terminal receives a service access response sent by the second terminal through the tunnel, the method further includes the following operations:
and the tunnel layer of the first terminal sends the TCP connection identifier and/or the port number of the TCP service request port to the tunnel layer of the second terminal.
In this embodiment of the present invention, when the first terminal sends the service access request to the second terminal through the tunnel, optionally, the following manner may be adopted:
a tunnel layer of the first terminal determines a UDP service request port;
the application layer of the first terminal sends the service access request to a tunnel layer of the first terminal;
and the tunnel layer of the first terminal sends the service access request to the tunnel layer of the second terminal from the UDP service request port.
In this embodiment of the present invention, optionally, a protocol used by the UDP service request port is the same as a protocol used by a service providing port in the second terminal.
In this embodiment of the present invention, optionally, a port number of the UDP service request port is the same as or different from a port number of a service providing port in the second terminal.
In this embodiment of the present invention, further, after the tunnel layer of the first terminal determines the UDP service request port, before the first terminal receives a service access response sent by the second terminal through the tunnel, the method further includes the following operations:
and the tunnel layer of the first terminal sends the port number of the UDP service request port to the tunnel layer of the second terminal.
In the embodiment of the present invention, when the relevant operation is executed according to the service access response, optionally, the following manner may be adopted:
receiving data carrying a connection identifier sent by the second terminal according to the service access response;
and sending feedback to the second terminal through the connection corresponding to the connection identifier.
In this embodiment of the present invention, when the first terminal sends the service access request to the second terminal through the tunnel, optionally, the following manner may be adopted:
the first terminal sends a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to a connection mode of the first terminal and the second terminal;
the step of receiving, by the first terminal, a service access response sent by the second terminal through the tunnel includes:
and the first terminal receives the service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
For example, if the first terminal and the second terminal are connected by USB, the first terminal sends a service access request to the second terminal through a tunnel in a USB communication manner, or receives a service access response sent by the second terminal.
In the embodiment of the invention, the service access response can be operations such as returning data, closing connection, refusing connection and the like.
In the scheme, the first terminal and the second terminal communicate through the tunnel, the service access request and the service access response transmitted through the tunnel both adopt TCP and/or UDP protocols, the TCP and UDP protocols are common in the communication field, and an open source library, a framework and a program based on the protocols are very common without defining a new protocol, so that the defect of low access service efficiency in the prior art can be overcome.
In the embodiment of the invention, the service layer is separated from the physical communication layer between the two terminals, so that a new protocol does not need to be redefined when the communication mode between the first terminal and the second terminal is changed, for example, when the communication mode between the first terminal and the second terminal is converted from a USB mode to a Bluetooth mode, the new protocol does not need to be redefined.
Fig. 2 schematically shows a flow diagram of a method 20 of accessing a service according to an embodiment of the invention. As shown in fig. 2, the method may include steps 200, 210, and 220.
Step 200: the second terminal establishes a tunnel capable of communicating with the first terminal;
step 210: the second terminal receives a service access request sent by the first terminal through the tunnel, wherein the service access request adopts a Transmission Control Protocol (TCP) and/or a User Datagram Protocol (UDP);
step 220: and the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, wherein the service access response adopts the TCP and/or UDP protocol.
In the embodiment of the invention, the second terminal interacts with the first terminal in an auxiliary mode. The interaction of the second terminal with the first terminal in an assisted manner can be understood as follows: the first terminal is an independent device, has one or more functions, and can be used independently, and the second terminal has an effect of providing an additional function or an auxiliary function for the first terminal, and the function is more single, and generally needs to be connected with the first terminal to be used.
In the embodiment of the present invention, data transmitted by a first terminal and a second terminal through a tunnel is encapsulated according to a certain specification, for example, a specification of a data packet in the tunnel is defined, bytes 0 to 3 represent the length of the whole data packet, bytes 4 to 5 represent operation and status identifiers (one bit corresponds to each protocol operation and status, for example, 0x01 represents a request to establish a TCP connection, 0x02 represents a closing of the TCP connection, 0x04 represents data transmission, 0x08 represents a connection error, etc.), bytes 6 to 9 represent a TCP connection identifier for distinguishing from other TCP connection data, bytes 10 to 17 represent an offset of a cutoff data count since the first byte data is received at the current tunnel end, that is, a reception sliding window, and byte 18 represents data sent by a requesting application.
In this embodiment of the present invention, after the second terminal receives the service access request sent by the first terminal through the tunnel, the method further includes the following operations:
a tunnel layer of the second terminal receives the service access request through the tunnel;
the tunnel layer of the second terminal and the service layer of the second terminal establish TCP connection;
and the tunnel layer of the second terminal sends the service access request to a service providing port of the service layer of the second terminal through the TCP connection.
In this embodiment of the present invention, optionally, a protocol used by the service providing port is the same as a protocol used by a TCP service request port in the first terminal.
For example, if the service providing port uses the TCP protocol, the protocol used by the TCP service requesting port is the TCP protocol.
In this embodiment of the present invention, optionally, the port number of the service providing port is the same as or different from the port number of the TCP service request port in the first terminal.
In this embodiment of the present invention, further, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further includes the following operations:
and the tunnel layer of the second terminal receives the TCP connection identifier and/or the port number of the TCP service request port sent by the first terminal.
In this embodiment of the present invention, when the second terminal receives the service access request sent by the first terminal through the tunnel, optionally, the following manner may be adopted:
a tunnel layer of the second terminal receives the service access request through the tunnel;
and the tunnel layer of the second terminal sends the service access request to a service providing port of the service layer of the second terminal.
In this embodiment of the present invention, optionally, a protocol used by the service providing port is the same as a protocol used by a UDP service request port in the first terminal.
In this embodiment of the present invention, optionally, the port number of the service providing port is the same as or different from the port number of the UDP service request port in the first terminal.
In this embodiment of the present invention, further, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further includes the following operations:
and the tunnel layer of the second terminal receives the port number of the UDP service request port sent by the first terminal.
In this embodiment of the present invention, after the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further includes the following operations:
sending data carrying a connection identifier to a first terminal;
and receiving feedback sent by the first terminal through the connection corresponding to the connection identifier.
In this embodiment of the present invention, when the second terminal receives the service access request sent by the first terminal through the tunnel, optionally, the following manner may be adopted:
the second terminal receives the service access request sent by the first terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, and the service access response comprises the following steps:
and the second terminal sends a service access response to the first terminal through the tunnel according to the service access request by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
For example, if the first terminal and the second terminal are connected by USB, the first terminal sends a service access request to the second terminal through a tunnel in a USB communication manner, or receives a service access response sent by the second terminal.
In the embodiment of the invention, the service access response can be operations such as returning data, closing connection, refusing connection and the like.
In the scheme, the first terminal and the second terminal communicate through the tunnel, the service access request and the service access response transmitted through the tunnel adopt TCP and/or UDP protocols, the TCP/UDP protocols are common in the communication field, and an open source library, a framework and a program based on the protocols are very common without defining a new protocol, so that the defect of low access service efficiency in the prior art can be overcome.
In the embodiment of the invention, the service layer is separated from the physical communication layer between the two terminals, so that a new protocol does not need to be redefined when the communication mode between the first terminal and the second terminal is changed, for example, when the communication mode between the first terminal and the second terminal is converted from a USB mode to a Bluetooth mode, the new protocol does not need to be redefined.
An embodiment of the present invention further provides an embodiment of accessing a service, which is shown in fig. 3.
Step 300: the first terminal establishes a tunnel capable of communicating with the second terminal.
The second terminal waits for connection or data at the service providing port to provide service, and the first terminal selects an idle TCP service request port which adopts the same protocol as the protocol adopted by the service providing port to listen to or wait for the data.
Step 310: and the tunnel layer of the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a TCP and/or UDP protocol.
In this step, data transmitted by the first terminal and the second terminal through the tunnel is encapsulated in a certain specification, such as defining a specification of a data packet in the tunnel, bytes 0 to 3 indicate a length of the whole data packet, bytes 4 to 5 are operation and status identifiers (one bit corresponds to each protocol operation and status, such as 0x01 indicating that a TCP connection is requested to be established, 0x02 indicating that the TCP connection is closed, 0x04 indicating data transmission, 0x08 indicating a connection error, etc.), bytes 6 to 9 indicate a TCP connection identifier for distinguishing from other TCP connection data, bytes 10 to 17 indicate an offset of an ending data counted from the data of the first byte received currently receivable by the current tunnel layer, i.e. a reception sliding window, and byte 18 indicates data sent by the requesting application.
Step 320: and after receiving the service access request, the tunnel layer of the second terminal decapsulates according to the agreed encapsulation specification, and initiates operations to the service layer port, such as establishing a TCP connection, transmitting TCP data, and the like.
Step 330: the second terminal sends a service access response to the first terminal through the tunnel.
The service access response may be packets such as return data, close connection, and reject connection.
And the first terminal and the second terminal continuously carry out interactive communication according to the steps.
It should be noted that the above steps are only a specific case of accessing a service, and according to actual needs, the first terminal may provide multiple service providing ports on one service, or the second terminal has multiple service providing ports to provide services, and the first terminal only needs to open as many TCP service requesting ports according to the above steps to establish one-to-one mapping of ports.
Referring to fig. 4, in the embodiment of the present invention, a first terminal 40 is further provided, which includes:
an establishing unit 400, configured to establish a tunnel through which the first terminal can communicate with a second terminal;
a sending unit 410, configured to send a service access request to the second terminal through the tunnel, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
a receiving unit 420, configured to receive a service access response sent by the second terminal through the tunnel;
a processing unit 430, configured to perform relevant operations according to the service access response, where the service access response employs the TCP and/or UDP protocol.
In the embodiment of the invention, the second terminal interacts with the first terminal in an auxiliary mode. The interaction of the second terminal with the first terminal in an assisted manner can be understood as follows: the first terminal is an independent device, has one or more functions, and can be used independently, and the second terminal has an effect of providing an additional function or an auxiliary function for the first terminal, and the function is more single, and generally needs to be connected with the first terminal to be used.
In the embodiment of the present invention, data transmitted by a first terminal and a second terminal through a tunnel is encapsulated according to a certain specification, for example, a packet specification in the tunnel is defined, bytes 0 to 3 represent the length of the entire packet, bytes 4 to 5 represent operation and status identifiers (one bit corresponds to each protocol operation and status, for example, 0x01 represents a request to establish a TCP connection, 0x02 represents a closing TCP connection, 0x04 represents data transmission, 0x08 represents a connection error, etc.), bytes 6 to 9 represent a TCP connection identifier for distinguishing from other TCP connection data, bytes 10 to 17 represent an ending data offset counted from the receipt of the first byte data, that is, a reception sliding window, which can be currently received by a current tunnel layer, and byte 18 represents data sent by a requesting application.
In this embodiment of the present invention, further, the establishing unit 400 is further configured to control an application layer of the first terminal and a tunnel layer of the first terminal to establish a TCP connection;
the processing unit 430 is further configured to control a tunnel layer of the first terminal to determine a TCP service request port;
the sending unit 410 is further configured to control an application layer of the first terminal to send the service access request to a tunnel layer of the first terminal through the TCP connection;
the sending unit 410 is further configured to control the tunnel layer of the first terminal to send the service access request from the TCP service request port to the tunnel layer of the second terminal.
In this embodiment of the present invention, optionally, a protocol used by the TCP service request port is the same as a protocol used by the service providing port in the second terminal.
For example, if the service providing port uses the TCP protocol, the protocol used by the TCP service requesting port is the TCP protocol.
In the embodiment of the present invention, optionally, the port number of the TCP service request port is the same as or different from the port number of the service providing port in the second terminal.
In this embodiment of the present invention, the sending unit 410 is further configured to control the tunnel layer of the first terminal to send the identifier of the TCP connection and/or the port number of the TCP service request port to the tunnel layer of the second terminal.
In this embodiment of the present invention, further, the processing unit 430 is further configured to control a tunnel layer of the first terminal to determine a UDP service request port;
the sending unit 410 is further configured to control an application layer of the first terminal to send the service access request to a tunnel layer of the first terminal;
the sending unit 410 is further configured to control the tunnel layer of the first terminal to send the service access request from the UDP service request port to the tunnel layer of the second terminal.
In this embodiment of the present invention, optionally, a protocol used by the UDP service request port is the same as a protocol used by a service providing port in the second terminal.
In this embodiment of the present invention, optionally, a port number of the UDP service request port is the same as or different from a port number of a service providing port in the second terminal.
In this embodiment of the present invention, the sending unit 410 is further configured to control the tunnel layer of the first terminal to send the port number of the UDP service request port to the tunnel layer of the second terminal.
In this embodiment of the present invention, the receiving unit 420 is further configured to receive, according to the service access response, data carrying a connection identifier sent by the second terminal; the sending unit 410 is further configured to send feedback to the second terminal through the connection corresponding to the connection identifier.
In this embodiment of the present invention, optionally, when the sending unit 410 sends the service access request to the second terminal through the tunnel, specifically, the sending unit is to:
sending a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
when the receiving unit 420 receives the service access response sent by the second terminal through the tunnel, the specific steps are:
and receiving a service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
For example, if the first terminal and the second terminal are connected by USB, the first terminal sends a service access request to the second terminal through a tunnel in a USB communication manner, or receives a service access response sent by the second terminal.
In the embodiment of the invention, the service access response can be operations such as returning data, closing connection, refusing connection and the like.
In the scheme, the first terminal and the second terminal communicate through the tunnel, the service access request and the service access response transmitted through the tunnel adopt TCP and/or UDP protocols, the TCP/UDP protocols are common in the communication field, and an open source library, a framework and a program based on the protocols are very common without defining a new protocol, so that the defect of low access service efficiency in the prior art can be overcome.
In the embodiment of the invention, the service layer is separated from the physical communication layer between the two terminals, so that a new protocol does not need to be redefined when the communication mode between the first terminal and the second terminal is changed, for example, when the communication mode between the first terminal and the second terminal is converted from a USB mode to a Bluetooth mode, the new protocol does not need to be redefined.
Referring to fig. 5, in the embodiment of the present invention, a second terminal 50 is further provided, which includes:
an establishing unit 500, configured to establish a tunnel through which the second terminal can communicate with the first terminal;
a receiving unit 510, configured to receive, through the tunnel, a service access request sent by the first terminal, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
a sending unit 520, configured to send a service access response to the first terminal through the tunnel according to the service access request, where the service access response employs the TCP and/or UDP protocol.
In the embodiment of the invention, the second terminal interacts with the first terminal in an auxiliary mode. The interaction of the second terminal with the first terminal in an assisted manner can be understood as follows: the first terminal is an independent device, has one or more functions, and can be used independently, and the second terminal has an effect of providing an additional function or an auxiliary function for the first terminal, and the function is more single, and generally needs to be connected with the first terminal to be used.
In the embodiment of the present invention, data transmitted by a first terminal and a second terminal through a tunnel is encapsulated according to a certain specification, for example, a packet specification in the tunnel is defined, bytes 0 to 3 represent the length of the entire packet, bytes 4 to 5 represent operation and status identifiers (one bit corresponds to each protocol operation and status, for example, 0x01 represents a request to establish a TCP connection, 0x02 represents a closing TCP connection, 0x04 represents data transmission, 0x08 represents a connection error, etc.), bytes 6 to 9 represent a TCP connection identifier for distinguishing from other TCP connection data, bytes 10 to 17 represent an ending data offset counted from the receipt of the first byte data, that is, a reception sliding window, which can be currently received by a current tunnel layer, and byte 18 represents data sent by a requesting application.
In this embodiment of the present invention, the receiving unit 510 is further configured to control a tunnel layer of the second terminal to receive the service access request through the tunnel;
the establishing unit 500 is further configured to control a tunnel layer of the second terminal to establish a TCP connection with a service layer of the second terminal;
the sending unit 520 is further configured to control the tunnel layer of the second terminal to send the service access request to the service providing port of the service layer of the second terminal through the TCP connection.
In this embodiment of the present invention, optionally, a protocol used by the service providing port is the same as a protocol used by a TCP service request port in the first terminal.
For example, if the service providing port uses the TCP protocol, the protocol used by the TCP service requesting port is the TCP protocol.
In this embodiment of the present invention, optionally, the port number of the service providing port is the same as or different from the port number of the TCP service request port in the first terminal.
In this embodiment of the present invention, the receiving unit 510 is further configured to control a tunnel layer of the second terminal to receive the identifier of the TCP connection and/or the port number of the TCP service request port sent by the first terminal.
In this embodiment of the present invention, the receiving unit 510 is further configured to control a tunnel layer of the second terminal to receive the service access request through the tunnel;
the sending unit 520 is further configured to control the tunnel layer of the second terminal to send the service access request to a service providing port of the service layer of the second terminal.
In this embodiment of the present invention, optionally, a protocol used by the service providing port is the same as a protocol used by a UDP service request port in the first terminal.
In this embodiment of the present invention, optionally, the port number of the service providing port is the same as or different from the port number of the UDP service request port in the first terminal.
In this embodiment of the present invention, the receiving unit 510 is further configured to control a tunnel layer of the second terminal to receive a port number of the UDP service request port sent by the first terminal.
In this embodiment of the present invention, the element 520 is further configured to send data carrying the connection identifier to the first terminal;
the receiving unit 510 is further configured to receive feedback sent by the first terminal through a connection corresponding to the connection identifier.
In this embodiment of the present invention, optionally, when the receiving unit 510 receives the service access request sent by the first terminal through the tunnel, specifically, the receiving unit is to:
the receiving unit 510 receives a service access request sent by the first terminal through the tunnel by using a communication mode corresponding to a connection mode of the first terminal and the second terminal;
when the sending unit 520 sends the service access response to the first terminal through the tunnel according to the service access request, specifically:
the sending unit 520 sends a service access response to the first terminal through the tunnel according to the service access request by using a communication mode corresponding to a connection mode of the first terminal and the second terminal.
For example, if the first terminal and the second terminal are connected by USB, the first terminal sends a service access request to the second terminal through a tunnel in a USB communication manner, or receives a service access response sent by the second terminal.
In the embodiment of the invention, the service access response can be operations such as returning data, closing connection, refusing connection and the like.
In the scheme, the first terminal and the second terminal communicate through the tunnel, the service access request and the service access response transmitted through the tunnel adopt TCP and/or UDP protocols, the TCP/UDP protocols are common in the communication field, and an open source library, a framework and a program based on the protocols are very common without defining a new protocol, so that the defect of low access service efficiency in the prior art can be overcome.
In the embodiment of the invention, the service layer is separated from the physical communication layer between the two terminals, so that a new protocol does not need to be redefined when the communication mode between the first terminal and the second terminal is changed, for example, when the communication mode between the first terminal and the second terminal is converted from a USB mode to a Bluetooth mode, the new protocol does not need to be redefined.
The methods and apparatus provided herein are not inherently related to any particular computer, virtual machine system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the apparatus of an embodiment may be adaptively changed and disposed in one or more apparatuses other than the embodiment. Several modules of embodiments may be combined into one module or unit or assembly and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-assemblies. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or modules are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
Various apparatus embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the modules in an apparatus according to embodiments of the present invention. The present invention may also be embodied as apparatus programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (36)

1. A method of accessing a service, comprising:
the method comprises the steps that a first terminal establishes a tunnel capable of communicating with a second terminal;
the first terminal sends a service access request to the second terminal through the tunnel, wherein the service access request adopts a Transmission Control Protocol (TCP) and/or a User Datagram Protocol (UDP);
the first terminal receives a service access response sent by the second terminal through the tunnel, and executes related operations according to the service access response, wherein the service access response adopts the TCP and/or UDP protocol;
the first terminal sends a service access request to the second terminal through the tunnel, and the service access request comprises the following steps: the application layer of the first terminal and the tunnel layer of the first terminal establish TCP connection; a tunnel layer of the first terminal determines a TCP service request port; the application layer of the first terminal sends the service access request to the tunnel layer of the first terminal through the TCP connection; the tunnel layer of the first terminal sends the service access request from the TCP service request port to the tunnel layer of the second terminal; or the tunnel layer of the first terminal determines a UDP service request port; the application layer of the first terminal sends the service access request to a tunnel layer of the first terminal; the tunnel layer of the first terminal sends the service access request from the UDP service request port to the tunnel layer of the second terminal;
the second terminal interacts with the first terminal in an auxiliary mode, and the service access response comprises returned data, connection closing or connection refusing;
the physical communication layers of the first terminal and the second terminal are separated from the service layer of the second terminal, so that a new protocol does not need to be redefined when the communication modes of the first terminal and the second terminal are changed.
2. The method of claim 1, wherein a protocol used by the TCP service request port is the same as a protocol used by a service providing port in the second terminal.
3. The method of claim 1, wherein the port number of the TCP service request port and the port number of the service providing port in the second terminal are the same or different.
4. The method according to claim 1, before the first terminal receives the service access response sent by the second terminal through the tunnel after the application layer of the first terminal establishes the TCP connection with the tunnel layer of the first terminal, the method further comprising:
and the tunnel layer of the first terminal sends the TCP connection identifier and/or the port number of the TCP service request port to the tunnel layer of the second terminal.
5. The method of claim 1, wherein a protocol used by the UDP service request port is the same as a protocol used by a service provision port in the second terminal.
6. The method of claim 1, wherein the port number of the UDP service request port and the port number of the service providing port in the second terminal are the same or different.
7. The method according to claim 1, 5 or 6, wherein after the tunnel layer of the first terminal determines the UDP service request port and before the first terminal receives the service access response sent by the second terminal through the tunnel, the method further comprises:
and the tunnel layer of the first terminal sends the port number of the UDP service request port to the tunnel layer of the second terminal.
8. The method of claim 1, performing a related operation in accordance with the service access response, comprising:
receiving data carrying a connection identifier sent by the second terminal according to the service access response;
and sending feedback to the second terminal through the connection corresponding to the connection identifier.
9. The method of claim 1, the first terminal sending a service access request to the second terminal through the tunnel, comprising:
the first terminal sends a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to a connection mode of the first terminal and the second terminal;
the step of receiving, by the first terminal, a service access response sent by the second terminal through the tunnel includes:
and the first terminal receives the service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
10. A method of accessing a service, comprising:
the second terminal establishes a tunnel capable of communicating with the first terminal;
the second terminal receives a service access request sent by the first terminal through the tunnel, wherein the service access request adopts a Transmission Control Protocol (TCP) and/or a User Datagram Protocol (UDP);
the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, wherein the service access response adopts the TCP and/or UDP protocol;
after the second terminal receives the service access request sent by the first terminal through the tunnel, the method further includes: a tunnel layer of the second terminal receives the service access request through the tunnel; the tunnel layer of the second terminal and the service layer of the second terminal establish TCP connection; the tunnel layer of the second terminal sends the service access request to a service providing port of the service layer of the second terminal through the TCP connection; or the tunnel layer of the second terminal receives the service access request through the tunnel; the tunnel layer of the second terminal sends the service access request to a service providing port of a service layer of the second terminal;
the second terminal interacts with the first terminal in an auxiliary mode, and the service access response comprises returned data, connection closing or connection refusing;
the physical communication layers of the first terminal and the second terminal are separated from the service layer of the second terminal, so that a new protocol does not need to be redefined when the communication modes of the first terminal and the second terminal are changed.
11. The method of claim 10, wherein the protocol used by the service providing port is the same as the protocol used by the TCP service request port in the first terminal.
12. The method of claim 10, wherein the port number of the service providing port is the same as or different from the port number of the TCP service request port in the first terminal.
13. The method according to claim 10 or 11 or 12, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further comprising:
and the tunnel layer of the second terminal receives the TCP connection identifier and/or the port number of the TCP service request port sent by the first terminal.
14. The method of claim 10, wherein the protocol used by the service providing port is the same as the protocol used by the UDP service request port in the first terminal.
15. The method of claim 10, wherein the port number of the service providing port is the same as or different from the port number of the UDP service request port in the first terminal.
16. The method according to claim 10 or 14 or 15, before the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, the method further comprising:
and the tunnel layer of the second terminal receives the port number of the UDP service request port sent by the first terminal.
17. The method of claim 10 or 14 or 15, after the second terminal sending a service access response to the first terminal through the tunnel according to the service access request, the method further comprising:
sending data carrying a connection identifier to a first terminal;
and receiving feedback sent by the first terminal through the connection corresponding to the connection identifier.
18. The method according to any one of claims 10, 14 or 15, wherein the second terminal receives the service access request sent by the first terminal through the tunnel, and the method comprises:
the second terminal receives the service access request sent by the first terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
the second terminal sends a service access response to the first terminal through the tunnel according to the service access request, and the service access response comprises the following steps:
and the second terminal sends a service access response to the first terminal through the tunnel according to the service access request by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
19. A first terminal, comprising:
the establishing unit is used for establishing a tunnel which can be used for the first terminal to communicate with the second terminal;
a sending unit, configured to send a service access request to the second terminal through the tunnel, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
a receiving unit, configured to receive a service access response sent by the second terminal through the tunnel;
the processing unit is used for executing relevant operations according to the service access response, and the service access response adopts the TCP and/or UDP protocol;
the sending unit sends the service access request to the second terminal through the tunnel, and the service access request includes: an application layer of a sending unit of the first terminal establishes TCP connection with a tunnel layer of the first terminal; a tunnel layer of a sending unit of the first terminal determines a TCP service request port; the application layer of the sending unit of the first terminal sends the service access request to the tunnel layer of the first terminal through the TCP connection; the tunnel layer of the sending unit of the first terminal sends the service access request from the TCP service request port to the tunnel layer of the second terminal; or the tunnel layer of the sending unit of the first terminal determines a UDP service request port; the application layer of the sending unit of the first terminal sends the service access request to the tunnel layer of the first terminal; the tunnel layer of the sending unit of the first terminal sends the service access request from the UDP service request port to the tunnel layer of the second terminal;
the second terminal interacts with the first terminal in an auxiliary mode, and the service access response comprises returned data, connection closing or connection refusing;
the physical communication layers of the first terminal and the second terminal are separated from the service layer of the second terminal, so that a new protocol does not need to be redefined when the communication modes of the first terminal and the second terminal are changed.
20. The terminal of claim 19, wherein a protocol used by the TCP service request port is the same as a protocol used by the service providing port in the second terminal.
21. The terminal of claim 19, wherein a port number of the TCP service request port and a port number of the service providing port in the second terminal are the same or different.
22. The terminal according to claim 19, wherein the sending unit is further configured to send an identification of the TCP connection and/or a port number of the TCP service request port to a tunnel layer of the second terminal.
23. The terminal of claim 19, wherein a protocol used by the UDP service request port is the same as a protocol used by a service provision port in the second terminal.
24. The terminal of claim 19, wherein the port number of the UDP service request port and the port number of the service providing port in the second terminal are the same or different.
25. The terminal according to claim 19 or 23 or 24, wherein the sending unit is further configured to send the port number of the UDP service request port to the tunnel layer of the second terminal.
26. The terminal of claim 19, wherein the processing unit performs related operations according to the service access response, comprising:
receiving data carrying a connection identifier sent by the second terminal according to the service access response;
and sending feedback to the second terminal through the connection corresponding to the connection identifier.
27. The terminal of claim 19, wherein the sending unit sends the service access request to the second terminal through the tunnel, comprising:
sending a service access request to the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal;
the receiving unit receives a service access response sent by the second terminal through the tunnel, and includes:
and receiving a service access response sent by the second terminal through the tunnel by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
28. A second terminal, comprising:
the establishing unit is used for establishing a tunnel which can be used for the second terminal to communicate with the first terminal;
a receiving unit, configured to receive, through the tunnel, a service access request sent by the first terminal, where the service access request employs a transmission control protocol TCP and/or a user datagram UDP protocol;
a sending unit, configured to send a service access response to the first terminal through the tunnel according to the service access request, where the service access response employs the TCP and/or UDP protocol;
the receiving unit is further configured to receive the service access request through the tunnel; establishing a TCP connection with a service layer of the second terminal; the sending unit is further configured to send the service access request to a service providing port of a service layer of the second terminal through the TCP connection; or receiving the service access request through the tunnel; sending the service access request to a service providing port of a service layer of the second terminal;
the second terminal interacts with the first terminal in an auxiliary mode, and the service access response comprises returned data, connection closing or connection refusing;
the physical communication layers of the first terminal and the second terminal are separated from the service layer of the second terminal, so that a new protocol does not need to be redefined when the communication modes of the first terminal and the second terminal are changed.
29. The terminal of claim 28, wherein the protocol used by the service providing port is the same as the protocol used by the TCP service request port in the first terminal.
30. The terminal of claim 28, wherein the port number of the service providing port is the same as or different from the port number of the TCP service request port in the first terminal.
31. The terminal according to claim 28, 29 or 30, wherein the receiving unit is further configured to receive an identifier of the TCP connection and/or a port number of the TCP service request port sent by the first terminal.
32. The terminal of claim 28, wherein the protocol used by the service providing port is the same as the protocol used by the UDP service request port in the first terminal.
33. The terminal of claim 28, wherein the port number of the service providing port is the same as or different from the port number of the UDP service request port in the first terminal.
34. The terminal according to claim 28, 32 or 33, wherein the receiving unit is further configured to receive a port number of the UDP service request port sent by the first terminal.
35. The terminal according to claim 28, 32 or 33, wherein the sending unit is further configured to send data carrying the connection identifier to the first terminal;
the receiving unit is further configured to receive feedback sent by the first terminal through a connection corresponding to the connection identifier.
36. The terminal according to claim 28, 32 or 33, wherein the receiving unit receives the service access request sent by the first terminal through the tunnel, and includes:
receiving a service access request sent by the first terminal through the tunnel by adopting a communication mode corresponding to a connection mode of the first terminal and the second terminal;
the sending unit sends a service access response to the first terminal through the tunnel according to the service access request, and the sending unit includes:
and sending a service access response to the first terminal through the tunnel according to the service access request by adopting a communication mode corresponding to the connection mode of the first terminal and the second terminal.
CN201610217189.9A 2016-04-08 2016-04-08 Method and device for accessing service Active CN107276873B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610217189.9A CN107276873B (en) 2016-04-08 2016-04-08 Method and device for accessing service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610217189.9A CN107276873B (en) 2016-04-08 2016-04-08 Method and device for accessing service

Publications (2)

Publication Number Publication Date
CN107276873A CN107276873A (en) 2017-10-20
CN107276873B true CN107276873B (en) 2020-03-24

Family

ID=60052857

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610217189.9A Active CN107276873B (en) 2016-04-08 2016-04-08 Method and device for accessing service

Country Status (1)

Country Link
CN (1) CN107276873B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1870568A (en) * 2005-05-23 2006-11-29 华为技术有限公司 Method for implementing network address conversion anti-virus transition
CN101626337A (en) * 2009-06-18 2010-01-13 南京联创科技股份有限公司 Multiple tunnel concurrent model implementation method based on virtual network card technology
CN103392316A (en) * 2013-01-11 2013-11-13 华为技术有限公司 Method of traversing firewall, client, and media traversing server

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1870568A (en) * 2005-05-23 2006-11-29 华为技术有限公司 Method for implementing network address conversion anti-virus transition
CN101626337A (en) * 2009-06-18 2010-01-13 南京联创科技股份有限公司 Multiple tunnel concurrent model implementation method based on virtual network card technology
CN103392316A (en) * 2013-01-11 2013-11-13 华为技术有限公司 Method of traversing firewall, client, and media traversing server

Also Published As

Publication number Publication date
CN107276873A (en) 2017-10-20

Similar Documents

Publication Publication Date Title
US9762429B2 (en) Control protocol encapsulation
EP2597842B1 (en) Providing network capability over a converged interconnect fabric
JP6269999B2 (en) Packet processing method and apparatus
US9240899B2 (en) Method for implementing virtual network port and embedded device for implementing virtual network port
CN102904959B (en) Network accelerating method and gateway
CN110266713A (en) Intranet and extranet communication means, device, system and proxy server and storage medium
CN108377671A (en) Handle the method and computer equipment of message
JP2022033791A (en) Bras system-based packet encapsulation method and device
CN109412922B (en) Method, forwarding device, controller and system for transmitting message
CN112769794B (en) Data conversion method and device
CN108228366B (en) Data stream processing method and device
EP2939473A1 (en) Discovery mechanisms for universal serial bus (usb) protocol adaptation layer
CN110912836A (en) Method, control device, storage medium, and system for forwarding data by forwarding device
CN102821082A (en) Data transmission method, device and system
CN105389120A (en) Supporting RMA API over active message
CN103905510A (en) Processing method and background server for data package
WO2006121247A1 (en) High speed data processing communication method and apparatus for embedded system
JP2019525566A (en) Multi-network convergence method and apparatus
CN103823721B (en) A kind of method and apparatus of interprocess communication
US20120069855A1 (en) Control method, apparatus and system
CN112910725B (en) Network flow detection method and device and computer readable storage medium
CN110247926A (en) A kind of exchange method and system
CN105245365A (en) Parameter configuration method, equipment and system for virtual network
CN107276873B (en) Method and device for accessing service
CN106331051A (en) File transmission method and system, file receiving device and file transmission device

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

Effective date of registration: 20180605

Address after: 518000 601/603/605, 6 floor, A tower, Dragon Street Century Towers, 23 Xin'an street, Baoan District, Shenzhen, Guangdong

Applicant after: Arashi Vision Co., Ltd.

Address before: Room A231, two Xiangshan Road, Haidian District, Beijing, Beijing

Applicant before: Beijing LAN Feng Chong View Network Technology Co., Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 518000 601/603/605, 6 floor, A tower, Dragon Street Century Towers, 23 Xin'an street, Baoan District, Shenzhen, Guangdong

Patentee after: Yingshi Innovation Technology Co., Ltd

Address before: 518000 601/603/605, 6 floor, A tower, Dragon Street Century Towers, 23 Xin'an street, Baoan District, Shenzhen, Guangdong

Patentee before: SHENZHEN ARASHI VISION Co.,Ltd.

CP01 Change in the name or title of a patent holder